부모 뼈와 변환 된 오프셋이있는 모델이 있습니다 (부모 뼈의 꼬리에 위치하지 않음). Blender에서는 모델이 만들어진 곳에서 뼈를 회전시키고 첨부 된 메쉬가 올바르게 회전하는지 확인할 수 있습니다. 그러나 코드에서 뼈대를 회전하려고하면 부모의 꼬리 부분을 회전시킵니다. 나는 매트릭스 수학 (내 최악의 적)에서 뭔가를 망칠거야.XNA 오프셋 변환을 사용하여 뼈 회전
업데이트 :이 중요한 경우
protected override void Update(GameTime gameTime)
{
bone.Transform = Matrix.CreateFromYawPitchRoll(0f, 0.5f, 0f);
base.Update(gameTime);
}
예쁜 표준이 있지만, 그리기 :
private void DrawModel(Model model, GraphicsDevice graphics, Matrix viewMatrix, Matrix projectionMatrix)
{
Matrix[] boneTransforms = new Matrix[model.Bones.Count];
model.CopyAbsoluteBoneTransformsTo(boneTransforms);
Matrix worldMatrix = orientation * Matrix.CreateTranslation(position);
foreach (ModelMesh mesh in model.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.World = boneTransforms[mesh.ParentBone.Index] * worldMatrix;
effect.View = viewMatrix;
effect.Projection = projectionMatrix;
effect.EnableDefaultLighting();
effect.PreferPerPixelLighting = true;
// Set the fog to match the black background color
effect.FogEnabled = true;
effect.FogColor = Vector3.Zero;
effect.FogStart = 1000;
effect.FogEnd = 3200;
}
mesh.Draw();
}
}
여기 스크린 샷을 http://s1231.photobucket.com/albums/ee516/Neovivacity/?action=view¤t=boneRotation.png
이 아마도 당신이 worldMatrix이 먼저 있도록 곱셈의 순서를 변경해야합니다
여기 내 솔루션의 코드 단편이다? 확실하지 않지만 시도해 볼 수 있습니다. – annonymously