720 likes | 912 Views
CA 302 Computer Graphics and Visual Programming. Aydın Öztürk aydin.ozturk @ ege.edu.tr http://www. ube.ege.edu.tr/~ozturk. 3D vIEWING. Overview. Viewing a 3D scene Projections Parallel and perspective. Overview. Depth cueing and hidden surfaces Identifying visible lines and surfaces.
E N D
CA 302 Computer Graphics and VisualProgramming Aydın Öztürk aydin.ozturk@ege.edu.tr http://www.ube.ege.edu.tr/~ozturk 3D vIEWING
Overview • Viewing a 3D scene • Projections • Parallel and perspective
Overview • Depth cueing and hidden surfaces • Identifying visible lines and surfaces
Overview • Surface rendering
Overview • Exploded and cutaway views
Overview • 3D and stereoscopic viewing
3D ViewingPipeline MC DC ViewportTransformation ModelingTransformation NC WC Normalization Transformation and Clipping ViewingTransformation VC PC ProjectionTransformation
ViewingCoordinates • Generating a view of an object in 3D is similar to photographing the object. • Whatever appears in the viewfinder is projected onto the flat film surface. • Depending on the position, orientation and aperture size of the camera corresponding views of the scene is obtained.
SpecifyingTheViewCoordinates • For a particular view of a scene first we establishviewing-coordinate system. • Aview-plane (orprojection plane)is set up perpendicular to the viewing z-axis. • World coordinates are transformed to viewing coordinates, then viewing coordinates are projected onto the view plane. xv yv yw zv P0=(x0 , y0 , z0) xw zw
SpecifyingTheViewCoordinates • Toestablishtheviewingreferenceframe, wefirstpick a worldcoordinatepositionP0=(x0 , y0 , z0)calletheviewpointorviewingposition (sometimestheeyepositionorthecameraposition. • Thispoint is theorigin of ourviewingcoordinate system. • Ifwechoose a point on an objectwe can think of thispoint as thepositionwhereweaim a cameratotake a picture of theobject.
SpecifyingTheViewCoordinates • Next, we select the positive direction for the viewing z-axis, and the orientation of the view plane, by specifying the view-plane normal vector, N. yv xv xv yw zv N P0 P xw zw
SpecifyingTheViewCoordinates • We choose a world coordinate position P on an object (we can think of this point as the position where we aim a camera to take a picture of the object and this point establishes the direction forN. yv xv xv yw zv N P0 P xw zw
SpecifyingTheViewCoordinates • OpenGL establishes the direction for N using the point P as a look at point relative to the viewing coordinate origin yv xv xv yw zv N P0 P xw zw
SpecifyingTheViewCoordinates • Finally, we choose the up direction for the view by specifying view-up vector V. • This vector is used to establish the positive direction for the yvaxis. • The vector V is perpendicular to N and is defined by selecting a positon relative to the world coordinate origin. yv xv V yw zv N P0 P xw zw
SpecifyingTheViewCoordinates • Using N and V, we can compute a third vector U, perpendicular to both N and V, to define the direction for the xv axis. yv xv V yw zv N P0 P xw zw
SpecifyingTheViewCoordinates • Usually, it can be difficult to determine a direction for V that is precisely prependicular to N. • Therefore, the user defined orientation of V is projected onto a plane that is prependicular to N. • Any direction for the view-up vector V can be chosen. A convenient choice is often in a direction parallel to the world yw axis that is V=(0,1,0) yv xv V yw zv N P0 P xw zw
SpecifyingTheViewCoordinates To obtain a series of views of a scene , we can keep the the view reference point fixed and change the direcion of N. This corresponds to generating views as we move around the viewing coordinate origin. V P0 N N
yv xv zv Transformation From World To Viewing Coordinates Conversion of object descriptions from world to viewing coordinates is equivalent to transformation that superimpoes the viewing reference frame onto the world frame using the translation and rotation. yw xw zw
yv xv zv Transformation From World To Viewing Coordinates First, we translate the view reference point to the origin of the world coordinate system yw xw zw
xv zv yv yv zv TransformationFromWorldToViewingCoordinates Second, we apply rotations to align the xv,, yvand zv axes with the world xw, ywand zw axes, respectively. yw xw xv zw
TransformationFromWorldToViewingCoordinates If the view reference point is specified at word position (x0, y0, z0), this point is translated to the world origin with the translation matrix T.
TransformationFromWorldToViewingCoordinates • The rotation sequence requires 3 coordinate-axis transformation depending on the direction of N. • First we rotatearound xw-axis to bring zv into the xw -zw plane.
Transformation From World To Viewing Coordinates Then, we rotate around the world ywaxis to align the zwand zv axes.
Transformation From World To Viewing Coordinates The final rotation is about the world zwaxis to align the ywand yvaxes.
Transformation From World To Viewing Coordinates The complete transformation from world to viewing coordinate transformation matrix is obtaine as the matrix product
Transformation From World To Viewing Coordinates Another method for generating the rotation-transformation matrix is to calculate uvn vectors and obtain the composite rotation matrix directly. Given the vectors N and V , these unit vectors are calculated as
Transformation From World To Viewing Coordinates This method also automatically adjusts the direction for V so that v is perpendicular to n. The rotation matrix for the viewing transformation is then
Transformation From World To Viewing Coordinates The matrix for translating the viewing origin to the world origin is
Transformation From World To Viewing Coordinates The composite matrix for the viewing transformation is then
Transformation From World To Viewing Coordinates: An Example For 2D System y P=(5,5) y′ 2 x′ Θ=300 2 0 2 4 6 P0=(4,3) x 0 2 4 6
Transformation From World To Viewing Coordinates: An Example For 2d System Translation: y 0 2 4 6 P y′ x′ 2 2 Θ=300 P0 2 4 6 x
y y′ P x x′ P0 2 4 6 Transformation From World To Viewing Coordinates: An Example For 2d System Rotation 0 2 4 6
Transformation From World To Viewing Coordinates: An Example For 2d System New coordinates
Transformation From World To Viewing Coordinates: An Example For 2d System Alternative Method y 0 1 2 3 P 1 x′ y′ 1 n v Θ=300 x 1 2 3 P0
Projections • Once WC description of the objects in a scene are converted to VC we can project the 3D objects onto 2D view-plane. • Two types of projections: -Parallel Projection -Perspective Projection
Classical Viewings • Hand drawings : Determined by a specificrelationship between the object and the viewer.
Parallel Projections Coordinate Positions are transformed to the view plane along parallel lines. View Plane P′2 P2 P1 P′1
Parallel Projections • Orthographic parallel projection: The projection is perpendicular to the view plane. • Oblique parallel projecion: The parallel projection is not perpendicular to the view plane.
Orthographic Parallel Projection The orthographic transformation
Oblique Parallel Projection • The projectors are still ortogonal to the projection plane • But the projection plane can have any orientation with respect to the object. • It is used extensively in architectural and mechanical design.
Oblique Parallel Projection • Preserve parallel lines but not angles • Isometric view : Projection plane is placed symmetrically with respect to the threeprincipal faces that meet at a corner of object. • Dimetric view : Symmetric with two faces. • Trimetric view : General case.
Oblique Parallel Projection • Preserve parallel lines but not angles • Isometric view : Projection plane is placed symmetrically with respect to the threeprincipal faces that meet at a corner of object. • Dimetric view : Symmetric with two faces. • Trimetric view : General case.
Oblique Parallel Projection yv (xp, yp) α (x, y, z) L φ xv (x, y) zv
Oblique Parallel Projection The oblique transformation
Perspective Projections • First discovered by Donatello, Brunelleschi, and DaVinci during Renaissance • Objects closer to viewer look larger • Parallel lines appear to converge to single point
Perspective Projections In perspective projection object positions are transformed to the view plane along lines that converge to a point called the projection reference point (or center of projection)
Perspective Projections • In the real world, objects exhibit perspective foreshortening: distant objects appear smaller • The basic situation:
How tall shouldthis bunny be? Perspective Projections When we do 3-D graphics, we think of the screen as a 2-D window onto the 3-D world: