Jump to content
  • Advertisement
Sign in to follow this  
ramilolz

Terrain collision c++

This topic is 2656 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

Well, I have been Googling this for while but no result. I'm using an .X file to represent my terrain and i have object(.X). I wanna know how i can detect collision. I already saw tomaker tutorial, they used .RAW which won't help me. If you can provide me with sample or something that can help me. thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
In general what you do is calculating the destination point of you movement. That gives you a ray pointing from the current position to the destination position. Then you can intersect this ray using D3DXIntersect with you terrain mesh and determine if it hits the terrain.

Share this post


Link to post
Share on other sites
By inserting a ray from Cam Pos (or ObjectPos) perpendicular to the terrain ,you can get the distance from camera to terrain

the next step is to tell the camera to change the Vertical distance from the terrain

for example if u want to stay 10 units over the terrain and the D3DXintersect func tells u that the current distance is 12 , u should decrease the cam height by 2 .

and check that for any frame,any move;

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!