Jump to content
  • Advertisement
Sign in to follow this  
musicmany2k

Collison Detection with fractal landscape?

This topic is 4834 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, I need to make a check to see if an object has collided with a randomly-generated fractal landscape. Any ideas how to manage this?

Share this post


Link to post
Share on other sites
Advertisement
So, you have a function that given an (x,z) returns a y value, correct?

You can use the x,z to work out which grid square the point is in, and then which triangle it's in (we're talkng 2.5d here, so think of it more as a vertical line intersecting the x,z).

Once you know which 3 points make up the triangle, feed their x and z into your fractal function to get the heights.

Now you have 3 points you can use with the plane equation to find the ehight at the exact x,z you wanted to test.

This way is simplistic, but will work well with procedural terrain because it's procedural itself.

Share this post


Link to post
Share on other sites
...and if you're doing more than a point check, you can expand the above by basically constructing a temporary mesh out of the triangle directly underneath and its neighbors (for example, 3x3 grid squares). Then you can do a collision test between this mesh and the object hopefully using the same code as regular object-object collisions. A cheap optimization is to save the terrain collision mesh for each moving object and only reconstruct it if you move to a different grid square.

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!