내 질문이있을 수 있습니다처럼 3D 꽤 바보입니다 : WPF AxisAngleRotation3D 대 XNA CreateFromAxisAngle
나는 화면에 물건을 렌더링 WPF에서 "뷰어"프로그램을 만들어,뿐만 아니라 무엇을 회전 할 수있다. 그 조금 더 빠른 것 같다 있기 때문에 그러나 나는 그것을 만들 수 없습니다, WPF 내가 XNA에서이 프로그램을하기로 결정Transform3DGroup tg = new Transform3DGroup();
tg.Children.Add(new ScaleTransform3D(sx, sy, 1));
tg.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), rx)));
tg.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), ry)));
tg.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), rz)));
tg.Children.Add(new TranslateTransform3D(x, y, z));
darabka.Transform = tg;
TeljesModell.Children.Add(darabka);
:
코드 : 내 취향 작동하는 무슨 회전이 사용 작업. 심지어 CreateFromYawPitchRoll이 CreateRotationX (YZ)가 너무하지만, 행운 않고, 물건이 화면은 항상 다르게 회전 한에 drawed 시도
Pozició = Matrix.CreateScale(sx, sy, 1f); //méretezés
Pozició *= Matrix.CreateFromAxisAngle(Vector3.UnitX, rx); //forgatás
Pozició *= Matrix.CreateFromAxisAngle(Vector3.UnitY, ry);
Pozició *= Matrix.CreateFromAxisAngle(Vector3.UnitZ, rz);
Pozició *= Matrix.CreateTranslation(x, y, z); //középpont
:
이 방법 (코드, XNA를) 시도. 그래서 나는 그들이 두뇌 사이에 끼워 넣어야 할 것이 무엇인지 .미리 감사드립니다.
편집 : 자세한 내용을 묻는 다른 포럼에서 시도했습니다. 나도 XNA 코드처럼 여기를 복사/붙여 넣기 :
주요
...
protected override void LoadContent()
{
t3 = new Airplane(); //this is a "zone" object, having zone regions and zone objects in it. all of them together give the zone itself as a static object, where player walks in
Kamera.Példány.Pozició = new Vector3(1362, 627, -757); //starting pozition in the zone - this is camera position so the player's starting pozition. (camera is FPS)
...
}
...
protected override void Update(GameTime gameTime)
{
...
Kameramozgatása(); //kamera mozgatását vezérlő billentyűk
//this moves the FPS camera around
}
...
protected override void Draw(GameTime gameTime)
{
...
ÁltalánosGrafikaiObjektumok.Effect.View = Kamera.Példány.Idenézünk; //camera views this
ÁltalánosGrafikaiObjektumok.Effect.Projection = projectionMatrix; //... and camera views FROM is set in Kameramozgatása()
...
t3.Rajzolj(); //draw zone object
...
}
영역 객체를의
constructor: set the effect and device to the same as main, set the Pozició (a matrix containing the current position and rotations) to origo
...
public virtual Alapmodel Inicializálás(float x, float y, float z, float rx, float ry, float rz, float sx, float sy)
{
//this initializer starts when the coordinates are from a file and not set with Pozició = Matrix....., so we are to convert. this runs only one time. overrides set the vertex positions and textures
VertexDeclaration = new VertexDeclaration(device, VertexPositionTexture.VertexElements);
Pozició = Matrix.CreateScale(sx, sy, 1f); //méretezés
Pozició *= Matrix.CreateFromAxisAngle(Vector3.UnitX, rx); //forgatás
Pozició *= Matrix.CreateFromAxisAngle(Vector3.UnitY, ry);
Pozició *= Matrix.CreateFromAxisAngle(Vector3.UnitZ, rz);
Pozició *= Matrix.CreateTranslation(x, y, z); //középpont
//we set the starting position - nowhere else we do it, from here only the main loop can modify this,... could.. but does not. this is zone, and has only static objects - never moving
}
public void Rajzolj()
{
//this draws the object (what can be a zone or a static object in it)
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
foreach (Elem elem in Elemek)
{
//végigmegyünk az elemeken
effect.Texture = elem.Textúra;
//pozicionálás
effect.World = Pozició; //we take the initialized position
effect.CommitChanges(); //this is needed. if you do not use this, the textures will be screwed up
device.VertexDeclaration = VertexDeclaration;
device.DrawUserIndexedPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, Poziciók, 0, Poziciók.Length, elem.Indexek, 0, elem.Indexek.Length/3);
}
pass.End();
}
}
. 나는 아직도 그것이 드로잉 코드가 아닌 약간의 변환이라고 생각한다. 다른 곳에서는 변경된 위치가 없습니다. 그 행렬은 WPFs 스택 변환과 같습니다. 내 문제는 두 가지 사이에서 변환 할 수학을 모르겠다는 것입니다. WPF 코드가 완벽하게 작동하면 영역의 모델이 잘 보입니다. Inicializálás()가 x, y, z 등에서 잘못된 변환을하기 때문에 XNA 코드가 잘못되었습니다. 그 안에. 이것에서 나는 도움이 필요하다.
미리 감사드립니다.
추가하는 것을 잊었 : XNA 3.1 -하지만이 경우에는 그것은 큰 것 같지 않아 –