Notes for Tuesday March 20:
Rendering Cylinders and Cubes as triangle strips

 

Cylinder as parametric surface

To create a cylinder as parametric surface we can use the infrastructure we already have for modeling spheres. We just need to change how we compute the position and normal at each vertex, given a value of the parameters (u,v).

As we discussed in class, we can continue to treat u the same way, by using u to compute the angle theta = 2*PI*u, and then using that angle to compute cos(theta) and sin(theta).

But for v, we want to march from 0 to 1 in increments of 1/5. For each value of u,v we want to create the following (x,y,z) coordinates for position, and (x,y,z) coordinates for normal as follows (where "c" is short for cos(theta) and "s" is short for sin(theta)", with nv = 5:

                     POSITION        NORMAL

v = 0                0  0 -1         0  0 -1
v = 1/5              c  s -1         0  0 -1
v = 2/5              c  s -1         c  s  0
v = 3/5              c  s  1         c  s  0
v = 4/5              c  s  1         0  0  1
v = 1                0  0  1         0  0  1

Cube as parametric surface

Use the same approach to computing v that you used for the cylinder, but compute u as follows, with nu = 8:

                     POSITION        NORMAL

u = 0                1  1  0         1  0  0
u = 1/8              1  1  0         0  1  0
u = 2/8             -1  1  0         0  1  0
u = 3/8             -1  1  0        -1  0  0
u = 4/8             -1 -1  0        -1  0  0
u = 5/8             -1 -1  0         0 -1  0
u = 6/8              1 -1  0         0 -1  0
u = 7/8              1 -1  0         1  0  0
u = 8                1  1  0         1  0  0

Homework, due before class on Tuesday March 27

Implement parametric cylinders and cubes. Create one or more example scenes that incorporate spheres, cylinders and cubes as primitives.

Note that by non-uniform scaling, you can convert cylinders into rods, and cubes into general boxes.