The final stages of Transformation
- one last trip through the pipeline for transformation
- For reference draw a positive x, y and z axis and label them.
- State 0
- This needs to gluLookat () called
- Tw2m = gluLookAt(eye, center, up)
- The frustum is 1 to 10, so the axis are outside of the frustum without this transformation.
- Note also, that after this transformation, the positive z axis is headed out of the screen (in modeling coordinates)
- We can move about (the eye position) with x:4-6, y: 8-2, z:1-3
- We model a unit cube centered at 0,0,0.
- State 1
- No transformations, except for the final model to viewing transformation are applied at this point.
- The actual cube drawn is transformed by Tw2m
- The cube is modeled (-.5, -.5, -.5) to (.5, .5, .5)
- And the eye position is (0,0,2)
- So the cube is actually drawn at (-.5, -.5, -2.5) to (.5, .5, -1.5)
- Draw some numbers on the faces of the cube,
- State 2
- They are drawn at the origin, but I want to center them at the origin
- This will make them easier to move to the right place on the cube.
- 0 is approximately 77 wide by 152 tall.
- So I translate them by (-charWidth/2, -charHeight/2)
- They are too tall, I want them to fit in the unit cube
- So I need to scale them by 1/(152*1.2).
- So I scale them by 1/largest dimension * .7
- .7 is completely arbitrary, it looks good to me.
- This will make it fit in the unit square.
- I want to rotate them to align them with the face
- By +/- 90 about y for the two sides (2,5)
- By 180 about y for the back (6)
- By +/- 90 about x for the top/bottom
- Finally they need to be translated into the proper location
- 1 on the front face, translate by (0,0, .5)
- 6 on the back face, translate by (0,0, -.5)
- In this case, the letters are translated, scaled, rotated, and translated from their modeling coordinates to the modeling coordinates of the die.
- I'd like to display a pair of dice, further back in the scene, showing 1 and 3.
- The first Die
- State 3
- I want to do this at the origin as this is where they are modeled.
- Otherwise, I would need to move them onto an axis then rotate.
- The first I will rotate by -90 about the x axis.
- This is really moving it into world coordinates.
- It is in the wrong place
- State 4
- It needs translated up by 0.5,
- And needs moved over and back
- So the translation matrix (3, 0.5, -4)
- The second die
- State 5
- Rotate by 180 about the z axis
- Rotate by 45 about the y axis.
- Translate by 2, 0.5, -3
- Look at the two dice.
- Turn off the axis.
- A note about the unity camera.
- The camera documentation
- Note, the camera is specified in world coordinate system.
- But it has most of the properties of the openGL camera.
- One last transformation
- After projection, items are in NDC space (-1, -1) to (1,1)
- The openGL standard
- The actual display window is (0,0) to (w, h)
- specified by glViewport(0,0, w,h)
- But remember, in X at least, we need to flip the y.
- Can we do this?