# Collision detection with spheres.

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

## Recommended Posts

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 on other sites
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 on other sites
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 on other sites
Transform the positions using the rotation matrices?

##### Share on other sites
Yes, I figured. But I'm just beginning 3D stuff and basically, well.. I don't know how! Can you please help?

##### Share on other sites
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 on other sites

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

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628638
• Total Posts
2983970

• 10
• 18
• 20
• 13
• 9