I can do picking with triangle-accuracy for non-animated models, but I also have animated models in my game. How do I do picking on animated models?

I use code based on this project for animation.

My first idea for doing it is:

Calculate ray
For each model
    If model bounding sphere collides with ray
         For each meshPart
              Make animation transformation
              Calculate transformed triangles in meshPart
         Test collisions of ray with resulting triangles

Have you ever considered how to make something like this?


1 Answer 1


Pardon the brevity as I'm posting from my phone.

  1. Unproject to get your ray.
  2. Transform the ray by the transpose of your view matrix to get its position in world space.

Now, either: A. For each model, transform the world ray by the transpose of the model's world matrix and test the meshes for intersections, or B. Test the ray against the transformed model mesh.

A is easier, but involves more matrix operations.

The idea is to get the ray and mesh into the same coordinate system before testing.

  • \$\begingroup\$ if you could provide a little code later, I'd be glad to upvote your answer :) \$\endgroup\$
    – raine
    Commented Jul 20, 2011 at 15:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .