XNA에서 모델 회전에 관한 질문이 있습니다. 문제는 - 어떻게해야 (이 값을 변경해야하는 방법) 그런 식으로 녹색 모델을 회전하는 (빨간색 화살표) 무엇을 :XNA의 회전
DrawModel(elementD, new Vector3(-1, 0.5f, 0.55f), 0,-90,0);
private void DrawModel(Model model, Vector3 position, float rotXInDeg, float rotYInDeg, float rotZInDeg)
{
float rotX = (float)(rotXInDeg * Math.PI/180);
float rotY = (float)(rotYInDeg * Math.PI/180);
float rotZ = (float)(rotZInDeg * Math.PI/180);
Matrix worldMatrix = Matrix.CreateScale(0.5f, 0.5f, 0.5f) * Matrix.CreateRotationY(rotY) *Matrix.CreateRotationX(rotX)*Matrix.CreateRotationZ(rotZ)* Matrix.CreateTranslation(position);
Matrix[] xwingTransforms = new Matrix[model.Bones.Count];
model.CopyAbsoluteBoneTransformsTo(xwingTransforms);
foreach (ModelMesh mesh in model.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.EnableDefaultLighting();
effect.View = cam.viewMatrix;
effect.Projection = cam.projectionMatrix;
effect.World = (xwingTransforms[mesh.ParentBone.Index] * worldMatrix);
}
mesh.Draw();
}
}
:
http://img843.imageshack.us/i/question1.jpg/이
코드 그리는 데 사용
Matrix worldMatrix = Matrix.CreateScale(0.5f, 0.5f, 0.5f) * Matrix.CreateRotationY(rotY) * Matrix.CreateRotationX(rotX) * Matrix.CreateTranslation(position)
* Matrix.CreateRotationX((float)(45 * Math.PI/180)) * Matrix.CreateRotationZ(rotZ) * Matrix.CreateRotationX((float)(-45 * Math.PI/180));
을 :
그래서 나는 약간 내 코드를 변경하여 솔루션을 적용하려 사실 rotZ 매개 변수를 변경하여 모델을 회전시킬 수있었습니다. 그러나 효과는 내가 달성하고자하는 것이 아니며 http://img225.imageshack.us/i/questionau.jpg/, 그것의 위치를 바 꾸었습니다. 결함이있는 모델이나 다른 실수로 인한 것입니까? 나는 "원통"이 그 위치에 남아 있기를 원한다. 내가 어떻게 이럴 수 있니?
답변을 upvote하거나 허용으로 표시 했습니까? 나는 당신이 여기에서 새로운 것을 본다. 그래서 upvotes가이 사이트를 움직이는 것 인 것을 기억해라. ... – Pedery