PDA

View Full Version : Collision Detection with Senocular's 3D Engine



NotSatoshi
July 13th, 2007, 01:20 AM
I figure this is probably a good time to post this since there's more talk about 3D since last time I tried to ask a question about 3D game making.

A while back, I posted a post about my plans for a Star Fox-style game with Senocular's 3D engine shown in his tutorial. However, I couldn't get the polygon depth sorted out and Senocular (or anyone else with the know-how) never responded to the post with anything helpful. So, I decided to just do something with simpler polygons or wireframe where I don't have to worry about that sort of thing. I'm still up for that game if someone can explain why the "help dots" were in those particular places in the spaceship in Senocular's demo, and how to determine where to put them in other models so that the polygons overlap correctly.

In any case, that's not the main point of this message. The point is that Senocular's tutorial on 3D leaves out something very important if you're going to make a game out of it: collision detection. How you can stop the camera from going through walls, and that sort of thing. Is anyone able to help with that? For the Star Fox-style game, the collision detection works because the camera doesn't change directions, but looks head-on. The only detection involved is if two movie clips collide when they have the same z value. But what should be done when the camera rotates? How do you tell it when it can't go any further into a wall then?

spielereinz
July 16th, 2007, 07:19 AM
In any case, that's not the main point of this message. The point is that Senocular's tutorial on 3D leaves out something very important if you're going to make a game out of it: collision detection. How you can stop the camera from going through walls, and that sort of thing. Is anyone able to help with that? For the Star Fox-style game, the collision detection works because the camera doesn't change directions, but looks head-on. The only detection involved is if two movie clips collide when they have the same z value. But what should be done when the camera rotates? How do you tell it when it can't go any further into a wall then?

The simplest way of doing this would probably be to use some sort of global scene coordinates (for all objects), and testing the camera position against these. This could get very CPU intensive though :hugegrin:
Maybe some sort of bounding box (sort of like the hit boxes from the 3D shooters) could simplify these calculations.
Also - you might want to try out some sort of simple form of clip mapping - like not testing behind the camera. The last one is only valid if you cant move backwards though ;)

Charleh
July 16th, 2007, 07:23 AM
The simplest way of doing this would probably be to use some sort of global scene coordinates (for all objects), and testing the camera position against these. This could get very CPU intensive though :hugegrin:
Maybe some sort of bounding box (sort of like the hit boxes from the 3D shooters) could simplify these calculations.
Also - you might want to try out some sort of simple form of clip mapping - like not testing behind the camera. The last one is only valid if you cant move backwards though ;)

Well you could use a bounding volume and use SAT (seperating axis theorem) for your detection - I'd probably just use a sphere volume for the camera though as it's simpler

spielereinz
July 16th, 2007, 07:35 AM
Well you could use a bounding volume and use SAT (seperating axis theorem) for your detection - I'd probably just use a sphere volume for the camera though as it's simpler

Yup, that doesn't seem to far off that ;)

NotSatoshi - you might want to check this tutorial out - it should give you a basic rundown on the principles involved
http://www.harveycartel.org/metanet/tutorials/tutorialA.html#section6

Aquilonian
July 20th, 2007, 06:17 AM
hitTest 3d you could do like this
give both objects a zRadius property
have pre calculated
zRange = ob1.zRadius + ob2.zRadius;

use any kind of normal hitTest to see if they hit in the 2d plane, i mean, the x/y plane
if they hit, see if they hit in the 3d plane using the zRadius property, i mean,
if( Math.abs(ob1.z - ob2.z) < zRange){
trace("hit!");
}