have I to store an object (like an space-ship) twice in the memory? First for OpenGL and second for the Collisiondetection??
How can I manage it to find the bounding spheres for an object? Example: I load a space-ship from a file and display it.
How can my program compute where the space-ship was hit from the enemy? - Was the ship destroyed or only damaged?
The answer to your first question is no. I am unsure as to your second question, but the thing about whether the ship was destroyed or not, this would depend upon what you decide to do, for example, it could depend on where the ship was hit…
If you want to use bounding spheres, you only need two fields - a centre point and a radius - probably 4 floats (centre.x, centre.y, centre.z & radius).
If an enemy missile comes into the bounding sphere, then you still don’t know where or if your object was hit. You then have to check your object for hit points. It will depend on how you store your object. If you use something like octrees or BSPs (really only for static objects) you’ll be able to simplify checking. If your object is just a triangle array, you’ll most likely have to check each object in your array for a hit.
Have a look at Paul Bourke’s excellent site for intersections of various objects - http://astronomy.swin.edu.au/pbourke/geometry/ - you’ll typically have to do one of these types of intersections for each subobject that makes up your object and the object that represents your missile.
Hope that helps.
well, I think of loading a spaceship from a file. And then my program has to find out the surfaces who are defined by the vertices.
So my collison-routine has to do the same as OpenGL.
Isn’t it possible to read out the z-buffer to find out wether a collision has happened?
Or do you have an other idea to solve this problem?
thanx, i’ll check it out.