viewpoints and transformations csis 5838: graphics and animation for gaming
TRANSCRIPT
Viewpoints and Transformations
CSIS 5838: Graphics and Animation for Gaming
Coordinate Systems
• Object Space: Coordinate space of an individual mesh– Edit mode in Blender
• Translating/rotating/scaling in this space changes location of individual vertices in this coordinate system– Usually with respect to some “object center”
Howard Hamilton, University of Regina
Coordinate Systems
• World Space: Overall coordinate space of all elements– Object mode in Blender
• Translating/rotating/scaling object in this space changes object space relative to world space– “Object center” manipulated– All vertices move with center
Howard Hamilton, University of Regina
Coordinate Systems
• Image Space: Coordinate system from POV of viewer/camera– Camera view in Blender
• Convention: Center of Interest (COI) along z-axis in this space• Moving camera/viewpoint changes this space relative to
world space
Howard Hamilton, University of Regina
Affine Transformations
• Transformation between coordinate systems using matrix multiplication
• General affine transformation of point (x, y, z) in one coordinate system to (x’, y’, z’) in another coordinate system:
Translation and Scaling
• Translation by [p, q, r]:
• Scaling by [p, q, r]:
Rotation About Different Axes
• By α around x-axis:
• By α around x-axis:
• By α around z-axis:
Combined Transformations
• Can combine all transformation into single matrix with multiplication
• Mobj2world = Mobjtrans x Mobjscale x MobjrotX x MobjrotY x MobjrotZ
• Mworld2eye = Mworldtrans x Mworldscale x MworldrotX x MworldrotY x MworldrotZ
• Mobj2eye = Mobj2world x Mworld2eye
• Efficiency:– Compute Mobj2world for each object
– Compute Mworld2eye once for entire world
– Compute Mobj2eye for each object
– Apply Mobj2eye to each vertex in each object
The Rendering Pipeline
• Conversion of vertices, etc. on mesh in object space to world space
• Projection of points in 3D world space into 2D image space
• Other modifiers– Surface features (colors, UV images etc.)– Transformation of apparent surfaces (smoothing,
etc.)– …
Visual Frustum
• Area of world rendered to screen (“field of view”)• Near clip plane = image plane
(where image “projected”)• Far clip plane = limit of view– Nothing further from camera
rendered– Also nothing outside of
“cone” rendered
Orthographic vs. Perspective View
• Projecting vertices in 3D image space to 2D image plane• Orthographic view:
(x, y, z) in image space (x, y) on image plane– No foreshortening– Makes editing objects simpler
blender.org
Perspective View
• “Normal” vision with foreshortening• Image projected to point representing location of viewer• Focal length f =
distance between viewer and image plane– Smaller f = more foreshortening
blender.org
Perspective Transformation
• Foreshortening:(x, y, z) in image space (xf/z, yf/z) on image plane
gamedev.com