Lecture 12 - Pitch and Yaw Camera

As a look-ahead:

This week, we'll discuss:

Animation: Control Along Curves

When we did hiearchical modeling, we would instead probably want to animate over a curve instead:

We might also want to move some point along a curve that isn't linear, like shown above. But how do we represent these curves? The P4 code has some of these splines, and if we look in there in Bezier.h we can get a better idea of what's going on.

The Camera: The V Matrix

We use the View matrix V as a way to translate, rotate, etc. the world we've already made.

We already have this, so now we need to first know what the position of the camera/eye is in the world. We can use glm::LookAt() to generate this V matrix:

glm::LookAt(
	vec3 eyePositionInTheWorld,
	vec3 eyeLookAtPoint, // essentially helps generate the lookingDirection from eyeLookAtPoint - eyePositionInTheWorld
	vec3 UpVector, // almost always (0,1,0). Most games do this. Generates the 'barell-roll' angle in case we want to rotate our view in that plane. 
);

So for this camera you need to do:

We'll talk about Pitch and Yaw in more detail here.

Pitch and Yaw

We can use α as pitch and β as yaw. You can get the eyeLookAtPoint from getting the spherical coordinate into cartesian:

(x,y,z)=(sin(α)sin(β),sin(α)cos(β),cos(α))

and really when we move the mouse some position Δx,Δy we want to just change these angles as:

α=α0+Δxspeed of looking up

And β is very similar.

Strafing and Dollying

Say we want to strafe left/right. How do we translate to do that? You don't just move along x. That is fixed in the world. What we really want is to strafe relative to our view vector v:

Thus we need the cross product!:

vstrafe=vview×vup

and for dollying, we just move in the direction of the view vector:

vdolly=vview

Defining our Camera

We'll make a Camera Object Camera which will use our function above.

We'll want to use orthonormal basis vectors which are vectors of:

Namely, we can do a change of basis to convert our standard world basis vectors to our camera basis vectors:

Namely, we just use two matrices, the translation matrix, and the rotation matrix:

[uxuyuz0vxvyvz0wxwywz00001][100ex010ey001ez0001]

We form these basis vectors for the camera u,v,w as:

Look at how these are generated: