Presentation is loading. Please wait.

Presentation is loading. Please wait.

Interactive Computer Graphics Viewing

Similar presentations


Presentation on theme: "Interactive Computer Graphics Viewing"— Presentation transcript:

1 Interactive Computer Graphics Viewing
James Gain and Edwin Blake Department of Computer Science University of Cape Town July 2002 Collaborative Visual Computing Laboratory

2 Interactive Computer Graphics Contents
Map of the Lecture Classical Viewing: Orthographic, Axonometric, Oblique, Perspective Camera Positioning and Viewing APIs Simple Projection Matrices Implementing Projections in OpenGL Projections and Shadows Transformations Viewing Shading 6/04/2019 Interactive Computer Graphics Contents

3 Viewing Principles Image formed by intersection of projection plane and lines of projection from object to viewer Perspective Viewing: Projectors converge to a finite Centre of Projection (COP) Objects in the distance are shrunk Parallel Viewing: As COP is moved to infinity, projectors become parallel Projectors oriented along a Direction of Projection (DOP) Preserves relative lengths and angles Perspective Projection Parallel Projection 6/04/2019 Interactive Computer Graphics Contents

4 Classical Viewing: Parallel I
Unlike CG, Classical viewing depends on a specific relationship between object and viewer Many objects (e.g. buildings) have a box-like shape with 6 principal faces oriented relative to the projection plane Orthographic: projection plane is parallel to a single principal face Preserves both distance and angles But usually need multiple projections because only on face visible at a time 6/04/2019 Interactive Computer Graphics Contents

5 Classical Viewing: Parallel II
Axonometric: Projectors are orthogonal to projection plane Angles are no longer preserved Isometric: three principal faces symmetric with respect to the plane Dimetric: two prinicipal faces symmetric with respect to plane Trimetric: general case Oblique: Projectors are parallel to each other but make an arbitrary angle with the projection plane Not physically realistic 6/04/2019 Interactive Computer Graphics Contents

6 Classical Viewing: Perspective
Characterized by diminution Distortion is non-linear: Unable to take measurements But more realistic Categorised according to number of visible faces and consequent number of vanishing points for principal directions All classical views are simply a subset of either general parallel or perspective CG viewing Three-point Two-Point One-Point 6/04/2019 Interactive Computer Graphics Contents

7 Transformation Pipeline
Modelling Transform Object in object co-ordinates Object in world co-ordinates Viewing Transform Object in 2D screen co-ordinates Perspective Projection Object in viewing co-ordinates 6/04/2019 Interactive Computer Graphics Contents

8 Positioning of the Camera
The viewpoint (camera) is located at the origin and the projection plane is parallel to the plane at a distance along the negative axis Camera Transformation: Must be able to position and orient the camera arbitrarily Transform objects from modelling coordinates to camera coordinates Need an appropriate way of specifying the camera position and orientation OpenGL: Camera has a left-hand coordinate system Camera transformation is part of the GL_MODELVIEW state 6/04/2019 Interactive Computer Graphics Contents

9 Interactive Computer Graphics Contents
u-v-n Viewing Create a camera frame (point and orthonormal vectors): Positioned at a view-reference point (VRP) Viewing pointed along the view plane normal ( ). Determines the orientation of the viewplane Viewing oriented by the view-up vector (VUP). Sets the roll of the viewplane Construct a camera frame = Projection of VUP onto plane = Normalizaion of 6/04/2019 Interactive Computer Graphics Contents

10 Interactive Computer Graphics Contents
Look-At Viewing Camera located at an eyepoint (eye) specified in world coordinates, pointed towards an atpoint (at) with a view-up vector (up) gluLookAt(eyex, eyey, eyez, atx, aty, atz, upi, upj, upk); Alters the modelview matrix to match this camera transform 6/04/2019 Interactive Computer Graphics Contents

11 Euler and Polar Viewing
Other applications require a non-rectilinear coordinate system Flight Simulation: Three Euler angles (roll, pitch and yaw) relative to a vehicle’s centre of mass Stellar Cartography: Polar coordinates (azimuth, elevation and distance) relative to a ground plane and position 6/04/2019 Interactive Computer Graphics Contents

12 Perspective Projection
From 3D world co-ordinates to 2D screen co-ordinates Perspective projection provides an illusion of depth in an image by giving distant objects a smaller projected screen size The screen co-ordinates of a point are calculated using similar triangles 6/04/2019 Interactive Computer Graphics Contents

13 Geometry of Perspective Projection
Triangle is similar to Similarly: The Projection Transform is: 6/04/2019 Interactive Computer Graphics Contents

14 Exercise: Binocular Projection
Calculate the separate screen projections and for the left and right eyes of a point The eyes are located at and 6/04/2019 Interactive Computer Graphics Contents

15 Solution: Binocular Projection
Right eye: Triangle is similar to Left eye: By a similar derivation The co-ordinate projection is unchanged because our eyes are only separated horizontally. 6/04/2019 Interactive Computer Graphics Contents

16 Orthogonal Projection
Projectors are perpendicular to the viewplane Points retain their and values: 6/04/2019 Interactive Computer Graphics Contents

17 Interactive Computer Graphics Contents
Projections in OpenGL Need to consider focal length and size of the film plane View Volume: Determines the field of view for clipping objects A truncated pyramid (frustum) with apex at the COP Specified by front and back clipping planes and a horizontal and vertical angle of view 6/04/2019 Interactive Computer Graphics Contents

18 Perspective Viewing in OpenGL
glFrustum(xmin, xmax, ymin, ymax, near, far); near and far must both be positive. Note: they are specified in camera coordinates, so gluPerspective(fovy, aspect, near, far); fovy is the angle between the top and bottom frustum planes, aspect = width / height Must make sure to first select the GL_PROJECTION matrix mode: glMatrixMode(GL_PROJECTION); 6/04/2019 Interactive Computer Graphics Contents

19 Parallel Viewing in OpenGL
glOrtho(xmin, xmax, ymin, ymax, near, far); Again But near and far are not restricted to being positive 6/04/2019 Interactive Computer Graphics Contents

20 Hidden Surface Removal
Opaque surfaces cause occlusion Use Hidden-Surface Removal to delete invisible surfaces Z-buffer algorithm: As polygons are rasterized store depth value of projected points. Only render a point with current minimum depth Worst-case complexity equals number of polygons Need specialized memory - depth or z buffer Amenable to hardware implementation z-buffer Algorithm OpenGL z-buffer: glutInitDisplayMode(GLUT_DEPTH); initialize z-buffer in display glEnable(GL_DEPTH_TEST); enable hidden surface removal glClear(GL_DEPTH_BUFFER_BIT); clear z-buffer before rendering 6/04/2019 Interactive Computer Graphics Contents

21 Projection Normalization
Projection Requirements: Handle general view volumes Retain depth information (required by HSR) as far down the pipeline as possible Projection Solution: Decompose projection into a distortion and canonical orthographic projection Canonical View Volume glOrtho(-1.0, 1.0, -1.0, 1.0, , 1.0); Perspective Projection = Distortion and Orthographic projection 6/04/2019 Interactive Computer Graphics Contents

22 Orthogonal Projection
glOrtho(xmin, xmax, ymin, ymax, near, far)  glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0) Translate: Centre of view volume to origin Scale: View volume to cube with sides of length 2 6/04/2019 Interactive Computer Graphics Contents

23 Perspective Normalization
Convert perspective view frustrum to orthographic cube gluPerspective(90.0, 1.0, zmin, zmax)  glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0) Near plane at zmin, far plane at zmax, fovy = 90 deg, aspect = square Mapping is non-linear but preserves the ordering of depth 6/04/2019 Interactive Computer Graphics Contents

24 Projection and Shadows
Shadows are useful shape cues Fully general shadowing algorithms are expensive But simple shadows (from a point light source onto a flat plane) can be simulated with projection Set COP to light source, apply perspective transform to polygon in front of projection plane to create shadow polygon Example: Light source Shadow projection onto Exercise: Write out 6/04/2019 Interactive Computer Graphics Contents


Download ppt "Interactive Computer Graphics Viewing"

Similar presentations


Ads by Google