Need help with 3D Collision Detection

Started by
4 comments, last by NoobGoneMad 14 years, 12 months ago
Hi, I'm new to XNA and I have been asked to do a 3D fighting game. I am planning to do sphere to sphere collision checks using BoundingSphere. 1. Is there a way for me to get the positions of a character model's parts to position the spheres? 2.Is there also a proper way to position the spheres or do I just assign the position to the BoundingSphere.Center? Please advise. Thanks in advance. [Edited by - NoobGoneMad on April 16, 2009 10:37:54 PM]
Advertisement
Can anyone help please? My deadline is drawing close and I have been on this problem for weeks already.
Hi Noob,

Well, firstly it depends if those model parts are seprate mesh objecs or if the whole model is one mesh object.

If your different model parts are seperate mesh objects, then it should be quite easy to add a BS to that part. I'm using D3D9 an it has a function where you just give the function the mesh object you want bound, and it returns a BS positioned at the correct place.

I hope I understood you question correctly.

Regards
I am currently manually assigning the bone position to the Sphere.Center.
U have to update it whenever u rotate the bone tree or the model: for example, for the hand, if u rotate the whole model, the hand will orbit around his axis (not around hand axis but model!) So u need to do some matrix multiplications (if u need help with this, ask me; i asked this several days ago in this forum & answered myself with the solution).

Or create a new sphere with the bone position / rotation each time u move, or u transform the sphere coords.

I'm using XNA Animation Component Library, & there u can find the position/rotation with smth like "BonePose[boneName].GetCurrentTransform()" or smth like this (i don't remember).

So (syntax may be wrong):
Matrix mAux=BonePose[boneName].GetCurrentTransform();Quaternion qRot=Quaternion.CreateFromRotationMatrix(mAux);  // rotationVector3 vPos=mAux.Translation; //position




Hope it helps!

Synth.
thanks for your replies.
I am now using XNA Animation Component Library, and I managed to render a sphere at each position. Now i guess i'm left with the figuring of how to actually check for collision detection. any advise would be helpful.
Thank you.
anyone knows what the size of the bounding sphere is?
Because when i use bounding sphere intersect method, it seems to be true no matter what... the code is something like the one below.

if(colSphere.currentModel.Meshes[0].BoundingSphere.Intersects(enemy.bodyCenter.currentModel.Meshes[0].BoundingSphere))
{
do something
}

am I doing it wrong? there are some scaling down to the colSphere and bodyCenter sphere models. hope that's not where the problem is...
please help.
thank you.

This topic is closed to new replies.

Advertisement