English 中文(简体)
• 正确确定一个Skinated Model sbons? XNA
原标题:Rotating a Skinned Model s bones correctly? XNA
  • 时间:2012-01-16 05:48:18
  •  标签:
  • c#
  • xna

我如何轮流使用一个kin光模型,而不是模型的起源?

在<条码>Skinning Sample中,当我轮流耳朵时,它围绕模式的起源轮流。 如果有可能,我就希望把骨头放在自己的来源上。

<>GetSkin Transforms()的描述如下:

"Gets the current bone transform matrices, relative to the skinning bind pose."

因此,我怀疑可能是问题。 是否有任何人知道如何将这些转变转化为他们需要做什么?

页: 1

  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);
    }
问题回答

你们必须改变信道,而不是皮肤转变。 我刚刚在AnimationPlayer班子中制造了另一种方法,允许这种操纵:

public void TransformBone(Matrix BoneAlteration, int BoneID)
{
    boneTransform[BoneID] = BoneAlteration * bindPose[BoneID];
    UpdateWorldTransforms(Matrix.Identity);
    UpdateSkinTransforms();
}

因此,如果我想要轮流使用一把一把一只一桶,就采用这种方法来创建正确的皮肤转变矩阵。 这假设其他单一变异的正确立场。 我也认为,如果你希望轮值已经轮值的骨头,你可以更换装饰。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签