Sign in to follow this  
glopen

Collision detection with spheres.

Recommended Posts

glopen    138
I'm using opengl to make this game but haven't sorted out the collision checking yet. This is the simplest approach I could think of: 1. Make model 2. Designate positions and radii of the spheres. But I don't know how to find out the sphere positions for a moving/rotating object. OpenGL takes care of the positions of the vertices but how can I find out the coords of the centers of the spheres to do a checking? Need help. Thanks.

Share this post


Link to post
Share on other sites
h4tt3n    1974
Your description is a tad unclear, so if you want any help with meat on it, I suggest that you give us something more specific to work with.

One way to find the center of an object is to find its centroid, ie. the average of all vertice positions.

Cheers, h4tt3n

Share this post


Link to post
Share on other sites
glopen    138
What I meant is that I don't know the exact positions of the bounding spheres. If there was just one sphere at the x,y,z coords of the objects I could check the distance between two objects by:

(obj1.r-obj2.r)^2 = (obj1.x-obj2.x)^2+(obj1.y-obj2.y)^2+(obj1.z-obj2.z)^2

But that's not the case. One object has several spheres. How am I going to get the exact positions of these spheres to perform the above check, if I don't know where they'll be when the object rotates around in space? Thanks.

Share this post


Link to post
Share on other sites
oliii    2196
get yourself a book on computer graphics, or some tutorial. I suppose you could start with the openGL red book that is available free, and check out matrix and vector maths.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this