Skip to main content
GameDev.net gamedev.net
🔒 Locked

Camera movement over un-even 3ds model loaded terrain...Unsolved, Come on!!!

Started by spencerholmes Feb 16, 2006 at 7:20 AM 3 replies 1.3k views
Original Post
spencerholmes
spencerholmes
Hello. I am creating a game-world and now i am at the stage where i want to put in realistic looking terrain; something which is not flat. The terrain i will use will be a model from which i have made in 3ds max. I am using a loader to get the file in. The question i have is: Does anyone out there know or know where to get information on making the Camera move smoothly across the terrain. I know this problem has something to do with updating the Y() position of the camera according to the terrain but i don't know how to do this. The tutorial i am using is the 3ds loader one from Marrowland.com. Please anyone? S [Edited by - spencerholmes on February 16, 2006 1:27:39 PM]
Rasmadrak
Rasmadrak
This is standard collision detection...
Search google for "ray triangle intersection" or something similar, and you'll find tons of information!

remember to use divided terrain if you go for this approach, or octrees/quadtrees... since collisiondetection on such a vast area is slow!

Using a heightmap is a loooot simpler, and faster too. :)
"Game Maker For Life, probably never professional thou." =)
jpetrie
jpetrie
The basic idea will be to figure out the camera's height above the terrain, using some method (collision detection via rays, heightmap lookup, whatever). If that distance is more or less than the desired height above the terrain, either set the height of the camera to the desired height (easiest, but can look jerky) or start to move towards the desired height over time using some kind of ease curve or interpolation.
haphazardlynamed
haphazardlynamed
To make the camera smooth, don't program it to jerk around or do anything not-smooth.
A good way of doing this is to simulate a camera velocity and acceleration, and only move the camera's position via accelerating forces; never alter the camera position directly.



However, I think you are asking more than just smoothing, but also about camera collisions with terrain, and how to make the camera follow the ground contours instead of going through it.



Ok, you said that your terrain is a 3ds model. Are all the vertices in the terrain in a regular grid? or is this model a totally arbitrary set of polygons all over the place making cliffs and caves and stuff?

If your terrain is grid based (aka a heightmap) then keeping the camera from going through it is a matter of making sure that the camera height never goes below the height of the ground it is over. This is easy, since the terrain is just a big array of height values on a grid, and you can do a weighted average of the nearest points in the grid to your camera. (Bi-Linear Interpolation, look it up)

If your terrain is 'polygon soup'(clifs and caves and random vertices) then you have a much harder problem, and everytime you move the camera you have to be sure that it doesn't pass through a polygon. Checking the camera against every single polygon in the terrain is going to be too slow, so you need to cut down the selection first. You will need to read into Octtrees or Quadtrees or some other culling system. It is highly recommended that if this is your first attempt at this kind of game you go with the Heightmap method instead.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.