# CMSC 435/634: Introduction to Computer Graphics

## Assignment 4 Viewing Due November 11, 2014

### The Assignment

For this assignment, you will use your assignment 3 OpenGL code (or mine, if yours was not working) to load an obj file of a hilly terrain. You will modify your program to interactively walk over the landscape using typical game keyboard and mouse controls. Motion should use four keys: holding 'w' should move you in whatever direction you are currently pointing, 's' should move you backwards, 'a' and 'd' should move you to the left and right. Moving the mouse left, right, up and down should rotate your view and motion direction around your current position. All motions should be computed in terms of rates (per second or per millisecond), then scaled by the elapsed time between frames. This is the typical first-person keyboard and mouse motion control scheme.

During any motion, the view should remain a constant height above the landscape. To figure out the height of your viewpoint, consider just your horizontal (x,y) position. From that position, you can find your triangle and your 2D x/y barycentric position within that triangle. Use barycentric interpolation of the vertex elevations to compute the surface height at your position, then add a constant offset to place your viewpoint above the surface.

You should stop the motion if you reach the edge of the terrain, and would no longer be above any terrain triangle

### 634 only

Also align the view with a barycentric interpolation of the surface normal.

### Extra credit

The simplest way to do this assignment is to check every triangle for the current position. For up to 20 points of extra credit, use the half-edge data structure to directly track the view position. Using this data structure, when you leave one triangle through one edge, you should immediately know exactly which triangle to check next.

Extra credit is only available if you submit by the original deadline or use your free late. If you submit late with the late penalty, you will not be eligible for any extra credit points.

You are also only eligible for extra credit if you tell us you did the extra credit in your README and where to find the mesh data structure definitions and code.

### Strategy

Plan ahead first. Know how you are going to find the position and view vector. Once you have a plan, implement in stages that each produce a visible, testable result. While it is not part of the assignment, it may be useful to add extra keys for debugging. For example, a key that switches between the perspective view and a top-down view with a sphere object at the current position could help debug your position code.

### What to turn in

Turn in this assignment electronically by pushing your source code to your assn3 GIT directory by 11:59 PM on the day of the deadline. We will be looking for multiple checkins documenting your development process.

As always, double check that you have submitted everything we need to build and run your submission, but no generated files (.o's, executables, or images). Be sure to include a readme.txt file telling us about your assignment. Do not forget to tell us what (if any) help did you receive from books, web sites or people other than the instructor and TA.

Be sure to include the details of the system you used for the assignment in your README in case we have problems.