Trying to move a bone. But in code...

rated by 0 users
This post has 1 Reply | 2 Followers

Top 25 Contributor
Posts 221
SunBurn_Community_Licensee
SunBurn_Pro_Licensee
2.0 Studios Posted: 08-26-2010 2:24 AM

Hey everyone, i'm having trouble moving a bone using code in the game i am making...

I am using sgmotion to animate a charictor and that all works fine.

I can place hit boxes and things at the positions of the bones by just going.

BoneDebug[i].World = Matrix.Invert(skinnedModel.SkeletonBones[i].InverseBindPoseTransform) * animationController.SkinnedBoneTransforms[i];

This makes BoneDebug.World contain a matrix that is the position of the bone and the rotation of the bone in the world.


The thing is however i want to now set the animationController.SkinnedBoneTransforms[i] with something else

In other words i want to go in the other direction, so that i am moving the bone using code, to another position and rotation in the world.


How can i invert the code above so that i can do this?


Anyone have any ideas?

Top 10 Contributor
Posts 4,854
Employee
SunBurn_Studio_Licensee

Hi 2.0,

Tom can probably provide more details, but I believe the transforms in SkinnedBoneTransforms are already flattened / absolute:

That is if bone x is dependent on bone y, then SkinnedBoneTransforms[x] == y * x, not the relative x transform as you might expect.  This is done so the vertex shader (and your C# code) can use SkinnedBoneTransforms[x] directly without having to walk all parent bones to construct the complete transform.

If you look through the controller code it should show where the original relative transforms are stored, you can either interact with these directly or you should be able to inject your own transforms into the controller.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Page 1 of 1 (2 items) | RSS