Jump to content
  • Advertisement
Sign in to follow this  

Following a 3d track

This topic is 2836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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,



Share this post

Link to post
Share on other sites
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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!