Presentation is loading. Please wait.

Presentation is loading. Please wait.

Graphics CSCI 343, Fall 2015 Lecture 16 Viewing I

Similar presentations


Presentation on theme: "Graphics CSCI 343, Fall 2015 Lecture 16 Viewing I"— Presentation transcript:

1 Graphics CSCI 343, Fall 2015 Lecture 16 Viewing I

2 Viewing Viewing refers to positioning the camera in a coordinate frame and projection of the 3D object onto the 2D image plane of the camera. Positioning the camera is very similar to positioning an object. Moving the camera relative to an object is the same as moving the object relative to the camera, in the opposite direction. In openGL the modeling and viewing transformations are combined into one transformation matrix. First the object is positioned by multiplying the vertices by the object transformation matrices. Then the camera is positioned by multiplying by camera transformation matrices.

3 Default Position of Camera
The default camera position is centered at the origin, pointing along the negative Z axis. If we create an object (e.g. a cube) centered on the origin, part of it will be behind the camera. To gain a view of the entire object, we need to move the camera by a distance, d, along the positive Z axis. This is equivalent to moving the object by a distance, -d, along the negative Z axis.

4 Moving the camera backward
Object Frame y' y translate(0.0, 0.0, -d) x' x y z' d z x z Camera Frame

5 Looking at the side of an Object
To move the camera to look at the side of an object that is centered on the origin: 1. Rotate the camera 90 deg. (Equivalent to rotating the object by -90 deg) 2. Translate the camera backward along +Z axis. (Equivalent to translating the object along -Z axis) mvMatrix = translate(0.0, 0.0, -d); mvMatrix = mult(mvMatrix, rotate(-90.0, 0.0, 1.0, 0.0));

6 Isometric view of a cube
The isometric view of a cube, is one in which the projection plane is placed symmetrically with respect to 3 faces of the cube. We can gain an isometric view by rotating the camera (or cube centered on the origin), first about the Y axis and then about the X axis. We then translate the camera backward to view it. M = TRxRy

7 Rotation matrix for Rotation about the Y axis
1. Rotate the cube 45 deg about the Y axis. 2 x z Top-down view after 45 deg rotation Ry = ?

8 Rotation Matrix for Rotation about Y axis
2. Rotate about the X Axis: y 1 z q Slice through Y-Z plane. (Through diagonal of cube) Rx = ?

9 Translate along -Z axis
3. Translate by -d along Z axis. Final Matrix: M = TRxRy

10 The UVN System Other graphics systems may define the camera viewing plane differently. The U-V-N system is one example: The camera plane is defined by 3 parameters: View Reference Point (VRP): A point (in the world frame) indicating the center of the camera's image plane. This specifies the position of the camera in space. View Plane Normal (VPN): A unit vector perpendicular to the camera's image plane. This specifies the orientation of the camera. View Up (VUP): A vector indicating the up direction (in world coordinates) for the camera.

11 The UVN vector coordinates
VUP n v VUP does not have to lie in the image plane. u The projection of VUP onto the image plane is v. v is perpendicular to n. These define 2 of our three basis vectors for the camera coordinate system. We define a third basis vector, u, such that u = v x n. Together, u, v and n make up the camera coordinate system.

12 The look-at function The look-at function allows the camera to remain aimed at a given point even as its position in the world changes. The camera is centered at the eye (VRP = e) The camera is pointed at the "at" point (VPN = a - e) The up vector (VUP) must be defined to specify the camera orientation. a VPN e In MV.js: function lookAt( eye, at, up )

13 Yaw, Pitch and Roll y y y z x z x Roll Pitch x
q q x z x Camera in nose of plane. Roll Pitch x In flight simulators, the angles of rotation are about the center of mass of the airplane. The camera is in the nose of the plane. q z Yaw

14 Parallel projections In parallel projections, the lines projecting from an object onto the image plane are parallel. Two parallel projection systems: Orthographic projection: Projection lines are perpendicular to the image plane. Oblique projection: The view plane is tilted so the projection lines are not perpendicular to the plane. x x z z Orthographic Oblique

15 Matrix for Orthographic Projection
xp = x yp = y zp = 0 M = ? p'= Mp = ?

16 Perspective Projection
y x (X, -Z) (xp, -d) (Y, -Z) (yp, -d) -z -d -d -z

17 Matrix for Perspective Projection
Representation of a point, P, in homogeneous coordinates: Perspective projection Matrix:


Download ppt "Graphics CSCI 343, Fall 2015 Lecture 16 Viewing I"

Similar presentations


Ads by Google