1.03k likes | 1.3k Views
CSCE 441 Computer Graphics 3-D Viewing. Dr. Jinxiang Chai. Outline. 3D Viewing Required readings: HB 7-1 to 7-10 Compile and run the codes in page 388. 1. Taking Pictures Using A Real Camera. Steps: - Identify interesting objects
E N D
CSCE 441 Computer Graphics3-D Viewing Dr. Jinxiang Chai
Outline 3D Viewing Required readings: HB 7-1 to 7-10 Compile and run the codes in page 388 1
Taking Pictures Using A Real Camera Steps: - Identify interesting objects - Rotate and translate the camera to a desire camera viewpoint - Adjust camera settings such as focal length - Choose desired resolution and aspect ratio, etc. - Take a snapshot
Taking Pictures Using A Real Camera Steps: - Identify interesting objects - Rotate and translate the camera to a desire camera viewpoint - Adjust camera settings such as focal length - Choose desired resolution and aspect ratio, etc. - Take a snapshot Graphics does the same thing for rendering an image for 3D geometric objects
3D Geometry Pipeline Rotate and translate the camera Object space World space View space Focal length Aspect ratio & resolution Normalized projection space Image space 4
3D Geometry Pipeline Model space (Object space) Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...
3D Geometry Pipeline World space (Object space) Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...
3D Geometry Pipeline Eye space (View space) Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...
3D Geometry Pipeline Normalized projection space Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...
3D Geometry Pipeline Image space, window space, raster space, screen space, device space Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...
3D Geometry Pipeline Object space World space View space Normalized project space Image space
3D Geometry Pipeline Translate, scale &rotate Object space World space glTranslate*(tx,ty,tz)
3D Geometry Pipeline Translate, scale &rotate Object space World space glScale*(sx,sy,sz)
3D Geometry Pipeline Translate, scale &rotate Object space World space Rotate about r by the angle glRotate*
3D Geometry Pipeline Object space World space View space Normalized project space Image space Screen space
3D Geometry Pipeline World space View space Now look at how we would compute the world->eye transformation
3D Geometry Pipeline Rotate&translate World space View space Now look at how we would compute the world->eye transformation
Camera Coordinate Canonical coordinate system - usually right handed (looking down –z axis) - convenient for project and clipping
Camera Coordinate Mapping from world to eye coordinates - eye position maps to origin - right vector maps to x axis - up vector maps to y axis - back vector maps to z axis
Viewing Transformation We have the camera in world coordinates We want to transformation T which takes object from world to camera
Viewing Transformation We have the camera in world coordinates We want to transformation T which takes object from world to camera Trick: find T-1 taking object from camera to world
Viewing Transformation ? We have the camera in world coordinates We want to transformation T which takes object from world to camera Trick: find T-1 taking object from camera to world
Review: 3D Coordinate Trans. p Transform object description from to
Review: 3D Coordinate Trans. p Transform object description from to 24
Review: 3D Coordinate Trans. Transform object description from camera to world
Viewing Transformation Trick: find T-1 taking object from camera to world - eye position maps to origin - back vector maps to z axis - up vector maps to y axis - right vector maps to x axis
Viewing Transformation H&B equation (7-4) Trick: find T-1 taking object from camera to world
Viewing Trans: gluLookAt gluLookAt(eyex,eyey,eyez,atx,aty,atz,upx,upy,upz)
Viewing Trans: gluLookAt gluLookAt(eyex,eyey,eyez,atx,aty,atz,upx,upy,upz) How to determine ? Mapping from world to eye coordinates
Viewing Trans: gluLookAt gluLookAt(eyex,eyey,eyez,atx,aty,atz,upx,upy,upz) Mapping from world to eye coordinates
Viewing Trans: gluLookAt gluLookAt(eyex,eyey,eyez,atx,aty,atz,upx,upy,upz) Mapping from world to eye coordinates
Viewing Trans: gluLookAt gluLookAt(eyex,eyey,eyez,atx,aty,atz,upx,upy,upz) H&B equation (7-1) Mapping from world to eye coordinates
3D Geometry Pipeline 3D-3D viewing transformation World space View space
Projection General definition transform points in n-space to m-space (m<n) In computer graphics map 3D coordinates to 2D screen coordinates
Projection How can we project 3d objects to 2d screen space? General definition transform points in n-space to m-space (m<n) In computer graphics map 3D coordinates to 2D screen coordinates
How Do We See the World? Let’s design a camera: idea 1: put a piece of film in front of camera Do we get a reasonable picture?
Pin-hole Camera • Add a barrier to block off most of the rays • This reduces blurring • The opening known as the aperture • How does this transform the image?
Camera Obscura • The first camera • Known to Aristotle • Depth of the room is the focal length • Pencil of rays – all rays through a point
Perspective Projection Maps points onto “view plane” along projectors emanating from “center of projection” (COP)
Perspective Projection What’s relationship between 3D points and projected 2D points? Maps points onto “view plane” along projectors emanating from “center of projection” (COP) 40
3D->2D Consider the projection of a 3D point on the camera plane
3D->2D Consider the projection of a 3D point on the camera plane 42
3D->2D By similar triangles, we can compute how much the x and y coordinates are scaled Consider the projection of a point on the camera plane
3D->2D By similar triangles, we can compute how much the x and y coordinates are scaled Consider the projection of a point on the camera plane
Homogeneous Coordinates Is this a linear transformation?
Homogeneous Coordinates Is this a linear transformation? • no—division by z is nonlinear
Homogeneous Coordinates Is this a linear transformation? • Trick: add one more coordinate: • no—division by z is nonlinear homogeneous image coordinates homogeneous scene coordinates
Homogeneous Point Revisited If w=1, nothing happens Sometimes, we call this division step the “perspective divide” Remember how we said 2D/3D geometric transformations work with the last coordinate always set to one What happens if the coordinate is not one We divide all coordinates by w:
The Perspective Matrix Now we can rewrite the perspective projection equation as matrix-vector multiplications