Jump to content
  • Advertisement
Sign in to follow this  
NoobGoneMad

Need help with 3D Collision Detection

This topic is 3492 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, 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]

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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); // rotation
Vector3 vPos=mAux.Translation; //position




Hope it helps!

Synth.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

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!