viewpoints and transformations csis 5838: graphics and animation for gaming

13
Viewpoints and Transformations CSIS 5838: Graphics and Animation for Gaming

Upload: bernice-richard

Post on 19-Jan-2016

242 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Viewpoints and Transformations CSIS 5838: Graphics and Animation for Gaming

Viewpoints and Transformations

CSIS 5838: Graphics and Animation for Gaming

Page 2: 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

Page 3: Viewpoints and Transformations CSIS 5838: Graphics and Animation for Gaming

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

Page 4: Viewpoints and Transformations CSIS 5838: Graphics and Animation for Gaming

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

Page 5: Viewpoints and Transformations CSIS 5838: Graphics and Animation for Gaming

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:

Page 6: Viewpoints and Transformations CSIS 5838: Graphics and Animation for Gaming

Translation and Scaling

• Translation by [p, q, r]:

• Scaling by [p, q, r]:

Page 7: Viewpoints and Transformations CSIS 5838: Graphics and Animation for Gaming

Rotation About Different Axes

• By α around x-axis:

• By α around x-axis:

• By α around z-axis:

Page 8: Viewpoints and Transformations CSIS 5838: Graphics and Animation for Gaming

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

Page 9: Viewpoints and Transformations CSIS 5838: Graphics and Animation for Gaming

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.)– …

Page 10: Viewpoints and Transformations CSIS 5838: Graphics and Animation for Gaming

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

Page 11: Viewpoints and Transformations CSIS 5838: Graphics and Animation for Gaming

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

Page 12: Viewpoints and Transformations CSIS 5838: Graphics and Animation for Gaming

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

Page 13: Viewpoints and Transformations CSIS 5838: Graphics and Animation for Gaming

Perspective Transformation

• Foreshortening:(x, y, z) in image space (xf/z, yf/z) on image plane

gamedev.com