Computer Graphics

Lab Exercise 7: Parallel Projection II

This week we implement the second part of the camera model, adding the camera transformation part. You have to transform the scene from XYZ coordinates to the UVN coordinates used by the camera. After coding, think about the following questions:

PerspectiveCamera.java
protected Point3D cameraTransform(final Point3D p){}

public void setupUVN(Point3D vrp_, Vector3D vpn_, Vector3D vuv_){}

private Matrix m=new Matrix(); //camera transformation matrix
{ m.setIdentity(); }
 
private Point3D vrp=new Point3D(0,0,0); //view reference point: the origin of camera coordinating system
 
private Vector3D vpn=new Vector3D(0,0,1), vuv=new Vector3D(0,1,0);  //view plane normal (axis n) and the view up vector (axis v)
PerspectiveAnimator.java
public class PerspectiveAnimator extends ParallelAnimator
{
  protected void setupCamera()
  {
    camera= new PerspectiveCamera(-5,5,-5,5);
    ((PerspectiveCamera)camera).setupUVN(new Point3D(0,0,0), new Vector3D(0,0,1), new Vector3D(0,1,0));
    ((PerspectiveCamera)camera).setupCOP(new Point3D(0,0,3));
  }

  public static void main(String[] args)
  { 
    new PerspectiveAnimator().loop();
  }
}