モデルの起点ではなく、スキンモデルの骨をどのように回転させるのですか?スキンモデルのボーンを正しく回転させるには? 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);
}