Collision detection with spheres.

Started by
4 comments, last by oliii 15 years, 11 months ago
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.
Advertisement
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
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.
Transform the positions using the rotation matrices?
Yes, I figured. But I'm just beginning 3D stuff and basically, well.. I don't know how! Can you please help?
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.

Everything is better with Metal.

This topic is closed to new replies.

Advertisement