Cube Component

Topics: User Forum
Apr 11, 2007 at 9:48 AM

I have followed your tutorial on per bone based collision detection (using the latest release and the Cube Component), and everything works brilliantly until I move the camera then the cube components dont follow the models position and rotation (if I dont move the camera and simply move/rotate the model the cubes follow just perfectly).

What am I doing wrong?

Additionally when I rotate the model it does not seem to be rotating around it's centre point but seems a bit offset, is there any way of rotating the model around it's central bone bBody in my case.

And a big, big thank you for these components they really have made my XNA experiance sooooo much better (and easier!).

Apr 11, 2007 at 12:00 PM
Edited Apr 11, 2007 at 12:03 PM
The collision detection tutorial is one of those un-updated tutorials.

Whenever you move the camera, you need to set cube.View to the view matrix of your camera.

When you rotate a model, it rotates around the model root bone. To rotate around it's center as it appears to you, I'm going to have to fiddle a bit to find out the best solution. You'd probably want to rotate around the mesh root bone. Depending on how your model is set up, this either means applying the rotation to the Mesh's parent bone's DefaultTransform, or doing something like
meshParentBone.DefaultTransform = Matrix.Invert(Matrix.CreateTranslation(meshAbsoluteTransform.Translation)) * rotation * Matrix.CreateTranslation(meshAbsoluteTransform.Translation).