Collision Detection Woes
Hello everyone. I am making an asteroids clone called Space Rocks. It is 3D/2D. The ship, bullets, and rocks only move on 2 axes, but the rocks rotate about three axes, making it have a more 3D feel. However, having the rocks rotate is giving me some collision detection issues. The bullets only hit the rock depending on the way it is rotated. I am only doing brute force collision detection, so I'm very sure that is not very effective. Can someone give me some help on some collision detection calculations that I can do when my objects are rotated?
Thanks in advance for any help.
P.S. I don't think it will help because this is only a logic/math problem, but I am using C++/OpenGL.
if(RotateStatus() == StatusThatDoesntHit()) DontHit();
if(RotateStatus() == StatusThatDoesHit()) Hit();
Simple. Run that check after you check if it's collided in X/Y coordinates. Reading it now, it sounds kinda smart***, but it wasn't meant that way, so don't get mad for the accidental tone.
if(RotateStatus() == StatusThatDoesHit()) Hit();
Simple. Run that check after you check if it's collided in X/Y coordinates. Reading it now, it sounds kinda smart***, but it wasn't meant that way, so don't get mad for the accidental tone.
You can either use a ray-triangle intersection, or else check to see if the point that represents the bullet position is behind each triangle in the asteroid (which would indicate that the bullet has penetrated, but probably "good enough" to detect the moment of collision). In either case, you need to take the bullet point and make it relative to the center of the asteroid, then rotate the point by the inverse of the asteroid's rotation. This will put the bullet point in model coordinates, so you can check the point against the asteroid geometry without having to rotate all of the triangles yourself, etc.
Possumdude, the one you have stated is the one currently in use. It's not good enough to account for the rotations of the objects.
Edit: Well somewhat, it's the math that goes behind the 'RotateStatus' that isnt good enough.
Edit: Well somewhat, it's the math that goes behind the 'RotateStatus' that isnt good enough.
Well, great minds think alike... lesser minds must do the same ;)
I'd just do it in plain 2d, with the asteroids animated to look 3d. Then your RotateStatus would just depend on the animation frame, or you could slip in some math that gave it a Z coordinate (which would have nothing to do with the actual drawing) that would determine if the asteroid was above or below the plane of the bullet.
I'd just do it in plain 2d, with the asteroids animated to look 3d. Then your RotateStatus would just depend on the animation frame, or you could slip in some math that gave it a Z coordinate (which would have nothing to do with the actual drawing) that would determine if the asteroid was above or below the plane of the bullet.
The reason it's semi-3d right now is when I get it working like it is, I hope to change to Complete 3d.
Oh, well if you're going for full 3d then...
1) wouldn't it be easier to start with everything 3d?
and...
2) I will be of absolutely no help to you, because I couldn't tell 3D programming from a hole in the ground.
1) wouldn't it be easier to start with everything 3d?
and...
2) I will be of absolutely no help to you, because I couldn't tell 3D programming from a hole in the ground.
Oh, well if you're going for full 3d then...
1) wouldn't it be easier to start with everything 3d?
and...
2) I will be of absolutely no help to you, because I couldn't tell 3D programming from a hole in the ground.
1) wouldn't it be easier to start with everything 3d?
and...
2) I will be of absolutely no help to you, because I couldn't tell 3D programming from a hole in the ground.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement