Tuesday 1 October 2013

Viewpoint Projections and Specifications

Projections

projection is 'formed' on the view plane (planar geometric projection)
rays (projectors) projected from the center of projection pass through each point of the models and intersect projection plane.
Since everything is synthetic, the projection plane can be in front of the models, inside the models, or behind the models.
2 main types: perspective projection and parallel projection.
    parallel :
    • center of projection infinitely far from view plane
    • projectors will be parallel to each other
    • need to define the direction of projection (vector)
    • 2 sub-types
      • orthographic - direction of projection is normal to view plane
      • oblique - direction of projection not normal to view plane
    • better for drafting / CAD applications
    perspective :
    • center of projection finitely far from view plane
    • projectors will not be parallel to each other
    • need to define the location of the center of projection (point)
    • classified into 1, 2, or 3-point perspective
    • more visually realistic - has perspective foreshortening (objects further away appear smaller)
which type of projection is used depends on the needs of the user - whether the goal is the mathematically correct depiction of length and angles, or a realistic looking image of the object.

specifying a 3D view

Danger, watch out for acronyms being tossed out!
Need to know the type of projection
Need to know the clipping volume

in OpenGL there are the following functions:

    glFrustum(left, right, bottom, top, near, far);
    glOrtho(left, right, bottom, top, near, far);
View Plane defined by:
  • point on the plane - View Reference Point (VRP)
  • normal to the plane pointing towards the center of projection- View-Plane Normal (VPN)
view plane can be anywhere in the world-space
The center of projection represents the location of the viewer's eye or the camera's lens.
Need to define a 3D Viewing Reference Coordinate system (VRC) which has axis u, v, n

  • Origin of VRC is the VRP
  • n axis of VRC is the VPN
  • v axis of VRC is called the View-UP vector (VUP)
  • u axis of VRC is defined to form a right-hand coordinate system with n and v
since the View Plane (n=0) is infinite (as it is a plane) we need to declare a region of that plane to be our window.
  • (Umin, Vmin) to (Umax, Vmax)
  • Center of Window (CW) on View Plane does not have to be VRP
  • VRP may not even be within the window

Projection Reference Point (PRP) defines the Center of Projection and Direction of Projection (DOP)
  • PRP given in VRC coordinate system (that is, its position is given relative to the VRP)
  • parallel projection - DOP is from PRP to CW, and all projectors are parallel.
  • perspective projection - Center of Projection is the PRP


n-point perspective

Perspective projections are categorized by the number of axes the view plane cuts (ie 1-point perspective, 2-point perspective or 3-point perspective)
    If the plane cuts the z axis only, then lines parallel to the z axis will meet at infinity; lines parallel to the x or y axis will not meet at infinity because they are parallel to the view plane. This is 1-point perspective.
    If the plane cuts the x and z axes, then lines parallel to the x axis or the z axis will meet at infinity; lines parallel to the y axis will not meet at infinity because they are parallel to the view plane. This is 2-point perspective.
    If the plane cuts the x, y, and z axis then lines parallel to the x, y, or z axis will meet at infinity. This is 3-point perspective.
The n-point perspectives can work with any combination of the x, y, z axis.

View Volumes

The view volume in orthographic projection:

The view volume in perspective projection:

The front plane's location is given by the front distance F relative to the VRP
The back plane's location is given by the back distance B relative to the VRP
In both cases the positive direction is in the direction of the VPN
Viewing volume has 6 clipping planes (left, right, top, bottom, near (hither), far (yon)) instead of the 4 clipping lines we had in the 2D case, so clipping is a bit more complicated

    perspective - viewing volume is a frustum of a 4-sided pyramid
    parallel - viewing volume is a rectangular parallelepiped (ie a box)

Parallel Examples

In the red version of the Foley vanDam book see P.211-212.
In the white version of the Foley vanDam book see P.250-252.

Perspective Examples

Here are some examples using the same house as in the book (figure 6.18 in the red version of the Foley vanDam book, figure 6.24 in the white version of the Foley vanDam book, but using Andy Johnson's solution to the former HW3 as the viewing program:
The object is a house with vertices:
 0, 0,30
16, 0,30
16,10,30
 8,16,30
 0,10,30
 0, 0,54
16, 0,54
16,10,54
 8,16,54
 0,10,54

VRP= 0 0 54      or    VRP= 8 7 54
VPN= 0 0  1            VPN= 0 0  1
VUP= 0 1  0            VUP= 0 1  0
PRP= 8 7 30            PRP= 0 0 30

U: -1 to 17            U: -9 to 9
V: -2 to 16            V: -9 to 9

VRP= 16 0 54
VPN= 1  0  0
VUP= 0  1  0 
PRP= 12 8 16

U: -1 to 25
V: -5 to 21

VRP= 16 0 54
VPN= 1  0  1
VUP= 0  1  0
PRP= 6  8 10

U: -22 to 22
V:  -2 to 18
For other examples, in the red version of the Foley vanDambook see P.206-211.
In the white version of the Foley vanDam book see P.245-250.

Example with a Finite View Volume

In the red version of the Foley vanDam book see P.212-213.
In the white version of the Foley vanDam book see P.253.

Now, how do we actually IMPLEMENT this?!?!?!?

with lots and lots of matrices.
Method 1:
  1. Extend 3D coordinates to homogeneous coordinates
  2. Normalize the homogeneous coordinates
  3. Go back to 3D coordinates
  4. Clip
  5. Extend 3D coordinates to homogeneous coordinates
  6. Perform projection
  7. Translate and Scale into device coordinates
  8. Go to 2D coordinates
Method 2:
  1. Extend 3D coordinates to homogeneous coordinates
  2. Normalize the homogeneous coordinates
  3. Clip
  4. Translate and Scale into device coordinates
  5. Go to 2D coordinates

No comments:

Post a Comment