For next week I want you to do two things:
int faces[M*N]and an array of
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 ]
u = (double)i / M; v = (double)j / N;
You will want to implement a matrix
stack to do this, which is just an array of
as well as a top pointer
top = 0.
methods should access
currently at the top of the matrix stack,
and you'll need to implement two
As we discussed on Monday,
an example of using
pop methods can be
seen on-line at:
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: