# CMSC 435/634: Introduction to Computer Graphics

## Assignment 4 Modeling Due April 14, 2014 (Late submission April 16, 2014)

### The Assignment

For this assignment, you will modify the original terrain sample code to model an asteroid or planet. The planet will be constructed by recursive subdivision starting from an octahedron (a). At each level of subdivision, each existing triangle should be divided into four new triangles, introducing a new vertex along each edge (b). You should first normalize the new vertex locations to lie at a radius half-way between the radii of the other two vertices on the edge (c). Without the next step, this will give you a finer and finer sphere as you continue the subdivision, but to develop your planetary surface, you will further displace the new vertex position radially in or out by a random amount determined by the level of subdivision (d). The first set of new vertices will get the greatest displacement, the next set will get half that, then 1/4, 1/8, .... Recursively applying this procedure will give you your lumpy planet or asteroid.

Add levels of subdivision when the user presses '+' or '=' (which are on the same key). Reduce the level of subdivision when they press '-' (or '_'). Your view should use the original orbit controls.

You should compute the normal at each vertex as the average of the individual triangle normals around it (which can be computed using the cross product of two edges).

### 634 only

Use the same vertex, texture coordinates, normals, and tangents for each vertex as computed at the level of subdivision when it is added (this will give slightly different normals and tangents than the 435 version). Organize your vertex array ordering so new vertices are added at the end of the array, but existing vertices are left at their original array locations. This should allow you to add new levels of subdivision by adding vertices to the end of the arrays and using a new index buffer. You should then be able to reduce the level of subdivision, or return to an already computed higher level of subdivision just by changing the index array used to draw.

### Extra credit

For up to 25 points of extra credit, adapt the first person view controls from assignment 3 to allow you to walk over the surface of the planet. Toggle between the orbit view and first-person view when the user presses 'm'. This is more complicated than the last assignment, since you are walking over the surface of a sphere instead of a plane.

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. Also, you will only be considered for extra credit if you mention your extra credit work in your readme.

### Strategy

Think first. The most important decision is what additional data structures to use to store your geometry. What kind of access patterns will your data structures need to support? Which need to be fast, and which could be slower? Once you've made that decision, incremental development is once again probably your best choice. You could try implementing just the octahedron (without subdivision) in place of the original terrain. Then you could add subdivision and the first normalization step to make a sphere. Finally, you could add the random displacement to make your planet.

### What to turn in

Turn in this assignment electronically by checking your source code into your assn4 CVS directory by 11:59 PM on the day of the deadline. Do your development in the assn4 directory so we can find it. As always, double check that you have submitted everything we need to build and run your submission, but not any generated files. In particular, no executables, or any of the other files xcode or visual studio generate beyond the ones already checked in.

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