Jump to content
  • Advertisement
Sign in to follow this  
link664

Bounding Boxes with DAGs - URGENT HELP NEEDED

This topic is 4661 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, I'm currently trying to implement a basic hack and slash game, and I have my world made with my hero and bad guys. At the moment I'm trying to implement collision detection but I am really struggling. I thought the easiest way would be to use Bounding Boxes. The only problem is, I have implement a hierarchical structure for the human models. So when I want to get the co-ords of the sword for example, to see if it is inside the area of the torso BB, I only have the local co-ords and not the global co-ords. I'm really stumped on how to solve this problem. If ANYONE has any suggestions, or knows how to implement collision detection with DAGs and can explain it in a bit of detail, that would be greatly appreciated!!!

Share this post


Link to post
Share on other sites
Advertisement
Maybe it's a stupid question, but why don't you simply transform the local coords to their global counterparts using the same matrices you use for displaying them?

Share this post


Link to post
Share on other sites
I've been trying to do that but I'm getting really confused. At the moment, I'm trying to take the modelview matrix of say the torso of one guy and the torso of another, then see if model1 - model2 is > 0.5. If it is then they don't match, if not then they do. But this doesn't seem to be working. If I understood what each value in the modelview matrix stood for, I think it might be a bit easier.
Is there any easier way to convert the local co-ords into global co-ords such as (0.0, 1.0, 2.0) rather than having the 16 float matrix?

Share this post


Link to post
Share on other sites
Quote:
then see if model1 - model2 is > 0.5

i cant see that working

u need to do something to get everything into worldspace
eg models mat44 * sword center vertice (or a mat44*mat44)
best way to see if youre doing it right
-ignore all glMultMatrix etc things
-ie do all the math yourself
-draw the resulting verts/meshs onscreen
-and these should match up exactly with the ones you normally draw with glMultMat glRotate etc

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
It's alright, i got it going. I realised I could just use the root node's translation to test because that was a global value. Then with the sword I just translate a few units in front and now that works too.

Share this post


Link to post
Share on other sites
Do you understand how matrix multiplication and vector-by-matrix transformation work? If not, you should probably read up on that, first. Try googling for "matrix and quaternion FAQ," a copy of which is available right here on gamedev.net.

If you have a local modelview matrix, and want to know the global version of that, all you have to do is multiply the parent's global transform with your local transform; that gives you your global transform. If the parent is a bone as well, then recurse until you get the root transform, which will be global.

Once you have a transform matrix, that matrix will describe the position, orientation, and scaling of your local bone (and things attached to it). The actual bounding box or bounding sphere of that geometry depends on the geometry, as well as the global transform -- just taking the translation part of the matrix is unlikely to give a good fit with the geometry.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!