Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Preventing the camera from going beyond the terrain

Author
Message
Khalt
15
Years of Service
User Offline
Joined: 6th Jan 2009
Location:
Posted: 7th Jan 2009 04:47
I will apologize in advance if this question has been answered. I've searched the forum but have not seen the answer.

I am working through the examples provided with the DarkGDK install. I am on the terrain example that uses the bump map and texture image to create a simple mountain scene. (Game Terrains) So adding code would be redundent here.

I would like to limit the camera movement from going outside the terrain. After leaving the terrain image it floats in mid air inside the skybox. I would like to prevent this.

Thanks,
Khalt
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 7th Jan 2009 23:53
The easiest method would be to grab the camera position before you move, then move, then check to see if the new camera position is out of bounds. If it is, reset the position using the values you saved earlier.

That should all be relatively easy to add, within the function 'userInput'

Sweemoo
15
Years of Service
User Offline
Joined: 8th Jan 2009
Location: 127.0.0.1
Posted: 8th Jan 2009 10:08
what i did is i displayed where the camera was and went to the edges so i knew where to make my boundaries. then in the main loop i checked if it was past them and if so put them back at the boundary.
here is an example
Khalt
15
Years of Service
User Offline
Joined: 6th Jan 2009
Location:
Posted: 10th Jan 2009 17:13
Thanks for the comments. I guess, I am still learning about the terrain rendering and determining the maximum boundries. After posting I realized the dbSetTerrainScale was increasing what I expected was the boundry. (caution newbie learning here However, I am not a nube to C++ )


Thanks again for the help!

Khalt

Thanks,
Khalt

Login to post a reply

Server time is: 2024-09-30 15:34:36
Your offset time is: 2024-09-30 15:34:36