Assignment due Wednesday October 12

For next week I want you to do two things:

• Make shapes that are parametric meshes. At the very least, make spheres. Recall that to make a parametric mesh with M×N faces you need to define an array of `int faces[M*N][4]` and an array of `double vertices[(M+1)*(N+1)][6]`.

As we discussed in class, face (i,j) indexes vertices by

[ j * (M+1) + i , j * (M+1) + i+1 , (j+1) * (M+1) + i+1 , (j+1) * (M+1) + i ]

and where

```   u = (double)i / M;
v = (double)j / N;
```

• Build something cool. Make it animate. It can be a person, a car, a scene with houses and clouds, birds, a snowman, or anything else you can think of. Try to make things move relative to each other. In particular, try to make some things move within other things (like the wheels of a car turning, while the car itself is moving).

You will want to implement a matrix stack to do this, which is just an array of matrices `Matrix stack[];`, initialized to `stack[0].identity();`, as well as a top pointer `int top` initialized to `top = 0.`

All your `translate`, `rotate`, `scale`, and `transform` methods should access the matrix `stack[top]` currently at the top of the matrix stack, and you'll need to implement two additional methods:

• push():
stack[top+1].copy(stack[top])
top = top + 1, and

• pop():
top = top - 1

As we discussed on Monday, an example of using `push` and `pop` methods can be seen on-line at:

http://mrl.nyu.edu/~perlin/swinging_arm/.

A note about perspective:

As we discussed in class today, you can implement perspective (assuming that the camera is at the origin (0,0,0)) by the transformation:

(x,y,z) → ( fx/z , fy/z, 1/z )

where f is the negative value of z representing the distance from the camera at which objects will appear neither magnified nor reduced in size. A larger magnitude of f results in a telephoto view; A smaller magnitude of f results in a wide angle view.

After you have applied the perspective transformation, then you can apply the viewport transformation to convert x and y into pixels.

There's always room for JelloTM:

The little interactive example that we worked through in class is available on-line at:

http://mrl.nyu.edu/~perlin/a_test/