Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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