Feature 5 Post Mortem
This feature wasn’t all that difficult to implement. The hardest part was probably figuring out how to use vectors in c++. I ended up writing another function in the ObjUtilities class that reads an obj and turns it into a 2D array of heights. This is admittedly not the best way to do this, because it means I have to read the file twice: once to get the mesh, and once for the height array. These could be merged in some way, but I have yet to decide the best way to do it, so for now, I decided to leave it as is.
The 2D array is then passed back to the camera class and used to set the camera’s height to the terrain after every movement. If the camera goes off the terrain, it is free to fly about as it pleases.
I used bi-linear interpolation to smooth the camera’s movement across the terrain.
Here’s a shot showing how awesomely the bi-linear interpolation can keep us grounded even on the steepest of steep hills:
Here’s a shot of us flying around outside the terrain a bit:
This video probably does a far better job of showcasing this feature, so here it is:
[youtube http://www.youtube.com/watch?v=m8qysNZHvVU?feature=player_detailpage]