Hello, I wonder if anyone has used components of animation with bones and objects of the physical system JigLibX because I am having problems using the component XNAnimation to place a gate to open with physical system objects boxobject of jiglibx … the gate is an animation with bones and use XNAnimation to get it, and in the game I need to position objects "boxobject" when the gate opens … now how to position objects "boxobject" of jiglibx following the bones or animation from xnanimation in xna? Thank you!

using xnanimation with jiglibx

Forum
» General / Help
» using xnanimation with jiglibx

Summary:

how to position objects "boxobject" of jiglibx following the bones from xnanimation???
using xnanimation with jiglibx

xnagames2 23 Jul 2010 21:24

This is how i set the position but haven't find yet a solution for the rotation

In an "Update skin box position method":

```
XNAnimation.SkinnedModel model = skinnedModel;
XNAnimation.Controllers.AnimationController animationController = skinnedAnimationController;
Vector3 position = modelPosition;
Vector3 scale = modelScale;
Vector3 rotation = modelRotation;
Matrix world = Matrix.Invert(model.SkeletonBones[boneIndex].InverseBindPoseTransform)
* animationController.SkinnedBoneTransforms[boneIndex]
* Matrix.CreateScale(scale)
* Matrix.CreateRotationX(rotation.X)
* Matrix.CreateRotationY(rotation.Y)
* Matrix.CreateRotationZ(rotation.Z)
* Matrix.CreateTranslation(position);
Vector3 outScale, outTranslation; Matrix outRotation; Quaternion _rotation;
world.Decompose(out outScale, out _rotation, out outTranslation);
Vector3 pos = outTranslation;
Box tmp = (Box)ret[1];
ret[1] = new Box(pos, Matrix.Identity, new Vector3(tmp.SideLengths.X, tmp.SideLengths.Y, tmp.SideLengths.Z));
```

The code is "pseudo code" in some part (first 5 line) but the other is true code.

Is someone find a solution for the rotation…please post it.

In the SkinnedModel draw method: to make model affect the position of the "PhysicsBody",note that it affect only the model position,

not each limb position

```
//xRot,yRot,zRot,scale,position are skinnedModel Position
Matrix[] temp = animationController.SkinnedBoneTransforms;
for (int i = 0; i < animationController.SkinnedBoneTransforms.Length; i++)
{
temp[i] *= Matrix.CreateRotationX(xRot) * Matrix.CreateRotationY(yRot)
* Matrix.CreateRotationZ(zRot) * Matrix.CreateTranslation(position) * Matrix.CreateScale(scale)
* physicObject.Body.CollisionSkin.GetPrimitiveLocal(i).Transform.Orientation * physicObject.Body.Orientation * Matrix.CreateTranslation(physicObject.Body.Position);
}
// Set the animated bones to the model
effect.Bones = temp;
```

Try to enable the debug drawer to see it bbox are following nodes.

/forum/t-255139/using-xnanimation-with-jiglibx#post-