2
\$\begingroup\$

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?

\$\endgroup\$
2
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ if you could provide a little code later, I'd be glad to upvote your answer :) \$\endgroup\$ – Raine Jul 20 '11 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.