Sign in to follow this  
s3mt3x

Following a 3d track

Recommended Posts

s3mt3x    118
Hi Guys,

I'm creating an app whereby the vehicle goes around a 3d track (represented as triangles). The track can rotate through all directions (like a roller coaster) and I was wondering how to implment the physics of the vehicle (this is not a question about the maths, just the general idea).

I was thinking that at each update I would find the closest triangle on the track to the vehicle's new position, get the normal for that triangle and then position the vehicle at the point within the triangle at a certain distance above it.

Is this a good method to acheive what I want or is there a better one?

So the steps would be:

1. Query Octtree to get all triangles around the vehicles new position.
2. Find the closest point to the vehicle on one of these triangles
3. Set the vehicles position to say 5 units above this point (using the normal of the closest triangle).

How does this sound?

Any comments would be really appreciated,

Cheers,

Chris

Share this post


Link to post
Share on other sites
jyk    2094
I think the method you describe is fairly standard (although it might be a little more common to cast a ray directly downward from the object to find the intersection point and normal).

If you also want to align your object to the surface, this can be done by applying a corrective rotation each update that rotates the object's up vector onto the normal of the surface beneath it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this