HW F.5 – Hannah
I completed Feature 5. I have had the ability to move around my scene for a long time, but I haven’t been moving with the contour of the terrain until this submission. I had a hard time conceptualizing how to make that happen, and I give credit to all of those who completed this feature before me, as I looked to their posts for guidance.
When I first tried to implement this functionality, I wanted to try and make it so that the terrain file only had to be read once. I did this by building up a two-dimensional array of heights as I read in the object information in the get mesh method. But then I was passing this array into my camera class and saving it there to use when I moved around my scene. However, something in that design didn’t work properly, and it wasn’t the best design because it doesn’t make all that much sense for the camera to have a heightmap of terrain that may be contained in it’s depiction. Therefore, I ended up practically duplicating my image class and turning it into a terrain class with a float array of heights. I also used bi-linear interpolation when getting the height out of my terrain. Whenever I advance or strafe in my scene, I get my new height from the terrain class and set it in the camera class. I also made my terrain bumpy for the purpose of demonstrating this new functionality. Screenshots and video follow: