Notes for Monday-Wednesday October 5-7 classes -- Transforming vertices

Triangle strips

We briefly described triangle strips, for efficiently storing geometry. We will go over these in more detail in subsequent weeks.

For now we are just using the simple triangle strip to define a square that we have been using when we were learning about ray tracing.

4x4 matrix transformations

We use 4x4 matrices for linear transformations of points and direction vectors. We are following the column major convention, in which the 16 numbers of the matrix are stored as:

   0  4  8 12
   1  5  9 13
   2  6 10 14
   3  7 11 15
We looked in more detail at the 4x4 matrix transformation primitives:
Identity:

   1 0 0 0
   0 1 0 0
   0 0 1 0
   0 0 0 1

Translate:

   1 0 0 tx
   0 1 0 ty
   0 0 1 tz
   0 0 0 1

Note: Using column major format, the above would be stored as:

   [ 1,0,0,0, 0,1,0,0, 0,0,1,0, tx,ty,tz,1 ]

In the following three primitives, c = cos(θ) and s = sin(θ).

Rotate about X:

   1 0  0 0
   0 c -s 0
   0 s  c 0
   0 0  0 1

Rotate about Y:

   c 0 s 0
   0 1 0 0
  -s 0 c 0
   0 0 0 1

Rotate about Z:

   c -s 0 0
   s  c 0 0
   0  0 1 0
   0  0 0 1

Scale:

   sx 0  0  0
   0  sy 0  0
   0  0  sz 0
   0  0  0  1

We showed how to implement matrix multiply and some of the matrix primitives (identity, translate, rotateX), and to send the result to the vertex shader as a uniform variable uMatrix, to transform the vertices of the triangle strip that describes our square.

Homework

Due next Wednesday before the start of class

Start with the included code in hw5.zip.

Implement the remaining primitives rotateX, rotateY and scale.

Create a cool animation of the square using all of the matrix primitives. See if you can make the square move and change in interesting ways.

Extra credit: Try to coordinate animation of the square with animation of the ray traced scene that is being rendered inside the square.