Bounding Boxes with DAGs - URGENT HELP NEEDED

Started by
5 comments, last by hplus0603 18 years, 6 months ago
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!!!
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?
Dubito, Cogito ergo sum.
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?
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
I'm no expert, but have you considered using spheres for collision detection? Incredibly simple and cheap to do..
~Stephen
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.
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.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement