모델의 원점 대신 스킨이있는 모델의 뼈대를 어떻게 회전합니까?스키닝 된 모델의 뼈를 올바르게 회전 하시겠습니까? XNA
SkinningSample
에서 친구의 팔뚝을 회전하면 모델의 원점 인 것처럼 회전합니다. 가능한 경우 뼈를 원래의 위치로 돌리고 싶습니다.
GetSkinTransforms()
에 대한 설명은 말한다 :
는 "현재 뼈가 포즈 스키닝 바인드를 기준으로 행렬을 변환 가져옵니다."
그래서 문제가 될 것으로 생각됩니다. 누구든지이 변환을 어떻게 변환해야하는지 알고 있습니까?
여기는 SkinningSample
의 일부입니다.
float rotation = 0;
protected override void Update(GameTime gameTime)
{
HandleInput();
UpdateCamera(gameTime);
animationPlayer.UpdateWorldTransforms(Matrix.Identity);
animationPlayer.UpdateSkinTransforms();
Matrix RotationTransform = Matrix.CreateFromYawPitchRoll(rotation, 0, 0) ;
animationPlayer.GetSkinTransforms().SetValue(RotationTransform, 34);
rotation = rotation + .1f;
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice device = graphics.GraphicsDevice;
device.Clear(Color.CornflowerBlue);
Matrix[] bones = animationPlayer.GetSkinTransforms();
// Compute camera matrices.
Matrix view = Matrix.CreateTranslation(0, -40, 0) *
Matrix.CreateRotationY(MathHelper.ToRadians(cameraRotation)) *
Matrix.CreateRotationX(MathHelper.ToRadians(cameraArc)) *
Matrix.CreateLookAt(new Vector3(0, 0, -cameraDistance),
new Vector3(0, 0, 0), Vector3.Up);
Matrix projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4,
device.Viewport.AspectRatio,
1,
10000);
// Render the skinned mesh.
foreach (ModelMesh mesh in currentModel.Meshes)
{
foreach (SkinnedEffect effect in mesh.Effects)
{
effect.SetBoneTransforms(bones);
effect.View = view;
effect.Projection = projection;
effect.EnableDefaultLighting();
effect.SpecularColor = new Vector3(0.25f);
effect.SpecularPower = 16;
}
mesh.Draw();
}
base.Draw(gameTime);
}