Chapter 5, Viewing
- So far we have looked at everything from a single location.
- and we have had a Direction of Projection
- We would like to have a movable camera.
- Or we will need to transform the scene from World coordinates to camera coordinates.
- Where the origin is a the Look at position.
- And the the camera out the z-axis.
- We also want to change the projection.
- Right now we are "dropping" the final z coordinate (after transformation)
- This is a orthogonal projection
- This is a view where parallel lines do not meet in the distance.
- But angles are preserved.
- But we probably want to change to a perspective projection
- There is a center of projection
- Objects that are further away appear smaller.
- We will use the vertex shader to accomplish these tasks.
- Once the elements of the model have been established in a world coordinate system, we wish to transform them to a camera coordinate system.
- We first need to specify a camera location
- Specify a camera location (x,y,z)
- Specify a look at position(x,y,z)
- Use these two to create a look at vector
- But this only fixes a line along which we are viewing.
- We can specify either a right or an up vector.
- Up is the usual vector to specify
- Cross the up with the look at to give us a right vector.
- This will give us an orthogonal vector to the first two.
- Cross the right with the look at, which will give us a new up.
- Which is orthogonal to the look at - right plane
- This forms the basis of the camera vector space in terms of the world vector space.
- So I can use this as a transformation from the world coordinate system to the camera coordinate system.
- If I remember my linear properly.
- lookAt in MV.js
- Takes a eye position, at position and an up position.
- And returns the transformation matrix to change from world to camera .
- Demo