Specifications of 3 D Views PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Outline: Implementing projections Specification of 3D views

v
• Specification of a 3D view.
View
plane
• Implementing parallel projections. VUP
VRP
• Implementing perspective projections. VPN
n u

• The projection plane = view plane.

• Defined using:

– View Reference Point (VRP), View Plane Normal (VPN)

– and View Up Vector (VUP)

Specification of 3D views Specification of 3D views

v
• The view window is then defined by (umin, vmin), (umax, vmax).
View
plane
VUP • The centre of projection and Direction Of Projection (DOP) are
VRP defined by a Projection Reference Point (PRP) and an indicator
VPN
u of the projection type:
n

• The coordinates of the PRP are defined in the VRC.


• Together define the Viewing Reference Coordinate (VRC)
system.

• The VRP (point) and VPN and VUP (directions) are specified in
a right handed world (application model) coordinate system.

Perspective projection Specification of 3D views

• Parallel projection

View
plane
v DOP
View
plane CW

CW VRP
VRP
VPN PRP
u VPN
n
n

Center of
projection • If the projection is parallel, the the DOP is defined by the
(PRP) direction between the PRP and the centre of the projection
window.

Specification of 3D views Specification of 3D views

• It is simpler for the programmer to change the direction of • Finite view volumes are defined by selecting the signed
projection required (rotate / move the camera), at the expense quantities F and B which define the locations of the front and
of extra complexity if the PRP is moved (i.e. to get different back clipping planes.
views of the object – change the lens).
• Both these planes are parallel to the view plane, thus F and B
• OpenGL uses a very similar method to specify the view volumes are defined along the VPN.
– we will come back to this. Back
clipping
plane
• The camera analogy is very powerful and general. Front
View
plane
clipping
plane
VRP

VPN

F B
Specification of 3D views Specification of 3D views

• We want a finite view volume because we do not want to draw • To display the contents of the view volume the objects are
objects close (or behind us) and objects which we cannot see. mapped into a unit cube whose axes are aligned with the VRC
system (called the Normalised Projection Coordinates (NPC)).
Back
clipping
View plane • Objects which are far away are squashed more (small)!
Front plane
clipping • To create a wire-frame display of the contents of the 3D
plane VRP
viewport we can simply drop the z coordinate.
VPN

DOP
B
F

Implementing 3D→2D projections Parallel projections

• Define normalising transformations Npar (parallel) and Nper


(perspective) that transform the points in world coordinates
within the view volume to points in the normalised projection • Canonical view volume is the unit parallelepiped defined by the
coordinates. planes, x = −1, x = 1, y = −1, y = 1, z = 0 and z = −1. The
steps necessary to achieve a canonical view volume are
• Can apply clipping and hidden line removal to these canonical
view volumes. 1. Translate the VRP to the origin.

2. Rotate the VRC such that it is aligned with the world


• Next section gives the details necessary to implement (and coordinate system.
understand?) planar geometric projections.
3. Shear (in x and y) so that the direction of projection is
aligned with the z axis.

4. Translate and scale into the canonical view volume


(parallelepiped).

Parallel projections Parallel projections

• Steps 1 and 2 combined produce the view orientation matrix • Step 3, shearing (so that z value represents distance from the
(GL MODELVIEW), while steps 3 and 4 give the view mapping matrix viewer:
(GL PROJECTION). y y

DOP
• Steps 1 and 2 are logical.
shear DOP’
VPN
• BUT .... VPN
-z -z

• Step 4 is not necessary for display, however most clipping


algorithms require a canonical volume element.

• Npar = Spar Tpar Hpar RT (−V RP )

Perspective projections Perspective projections

• Steps 1 and 2 are the same as those in the parallel case but an • The final composite transformation matrix is given by
additional step brings the PRP to origin. ∗ =S
Nper per Hpar T (−P RP )RT (−V RP ).

1. Translate the VRP to the origin.


• Npar and Nper
∗ will not affect the homogeneous coordinate w.

2. Rotate the VRC such that it is aligned with the world However the additional step to the computation of Nper
coordinate system. transforming the truncated pyramid to a parallelepiped will:
 
3. Translate so that the centre of projection (i.e. the PRP) is at 1 0 0 0
0 1 0 0
 
the origin.

M =
0 0 1  .
−zmin 
 1+zmin 1+zmin 
4. Shear (in x and y) so that the direction of projection is 0 0 −1 0
aligned with the z axis.
∗ .
• Nper = M Nper
5. Scale into the canonical view volume (truncated pyramid).
Clipping and projection to 2D The whole process

• Clipping is usually carried out in the canonical view volume since • To summarise the process of 2D viewing of 3D objects is:
the algorithm will be independent of the projection type.
– 3D → homogeneous,
• Projecting the 3D canonical volumes to 2D is very simple, we – apply Npar or Nper ,
just retain the x and y coordinates.
– homogeneous → 3D,
• The matrix to do this is just: – clip,
   
1 0 0 0 1 0 0 0
0 1 0 0 0 1 – 3D → homogeneous,
0 0
Mort =   or Mper =   .
   
0 0 0 0 0 0 0 0 – project using Mort or Mper ,
0 0 0 1 0 0 −1 1
– transform into device coordinates (window to viewport):
homogeneous → 2D.

Summary

• Having finished this lecture you should:

– understand how to implement projection in computer


graphics;

– contrast perspective and parallel projections;

• This is possibly the most complex part of computer graphics,


but is so central it cannot be skipped.

You might also like