Computer Graphics CC416 Week 14 3D Graphics.

Slides:



Advertisements
Similar presentations
Three Dimensional Viewing
Advertisements

1 Computer Graphics Chapter 8 3D Transformations.
Three-Dimensional Viewing Sang Il Park Sejong University Lots of slides are stolen from Jehee Lee’s.
Projection Projection - the transformation of points from a coordinate system in n dimensions to a coordinate system in m dimensions where m
Introduction to 3D viewing 3D is just like taking a photograph!
Viewing and Projections
UBI 516 Advanced Computer Graphics Three Dimensional Viewing
Advanced Computer Graphics Three Dimensional Viewing
The Viewing Pipeline (Chapter 4) 5/26/ Overview OpenGL viewing pipeline: OpenGL viewing pipeline: – Modelview matrix – Projection matrix Parallel.
3D Viewing.
Chi-Cheng Lin, Winona State University CS430 Computer Graphics 3D Viewing and Projections.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
Graphics Graphics Korea University cgvr.korea.ac.kr 3D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
Computer Graphics Bing-Yu Chen National Taiwan University.
CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 5.
Three-Dimensional Viewing Jehee Lee Seoul National University.
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 1 1.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Three-Dimensional Viewing
Three-Dimensional Viewing Hearn & Baker Chapter 7
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
CS552: Computer Graphics Lecture 11: Orthographic Projection.
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
Coordinate Systems Lecture 20 Wed, Oct 15, Object Coordinates Each object has its own “local” coordinate system, called object coordinates. Normally.
Chapter: Viewing.
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
Outline 3D Viewing Required readings: HB 10-1 to 10-10
Projection. Conceptual model of 3D viewing process.
Viewing in 3D Lecture 11. Viewing in 3D2 u The 3D viewing process is inherently more complex than is the 2D viewing process. F In 2D, we simply specify.
3 DIMENSIONAL VIEWING Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics.
Introduction to Computer Graphics
Chapter 11 Three-Dimensional Geometric and Modeling Transformations
Three Dimensional Viewing
Viewing Viewing and viewing space (camera space)
Rendering Pipeline Fall, 2015.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
Right-handed Coordinates System
University of North Carolina at Greensboro
3D Viewing cgvr.korea.ac.kr.
Prof. Lizhuang Ma Shanghai Jiao Tong University
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics
CSCE 441 Computer Graphics 3-D Viewing
Viewing in 3D Chapter 6.
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
Unit 4 3D Viewing Pipeline Part - 2
“Computer Science is no more about computers than astronomy is about telescopes.” Professor Edsger Dijkstra.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
CENG 477 Introduction to Computer Graphics
WINDOWING AND CLIPPING
Three Dimensional Viewing
OpenGL 2D Viewing Pipeline
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University View & Projection.
Computer Graphics Imaging
WINDOWING AND CLIPPING
Last Time Canonical view pipeline Projection Local Coordinate Space
3D Graphics.
Chap 3 Viewing Pipeline Reading:
Viewing (Projections)
Viewing (Projections)
Interactive Computer Graphics Viewing
Prof. Lizhuang Ma Shanghai Jiao Tong University
Viewing/Projections I Week 3, Fri Jan 25
3D Viewing.
THREE-DIMENSIONAL VIEWING II
THREE-DIMENSIONAL VIEWING
Viewing Transformations II
Presentation transcript:

Computer Graphics CC416 Week 14 3D Graphics

3D Viewing

3D Viewing Viewing: virtual camera Projection Depth Visible lines and surfaces Surface rendering

3D Viewing pipeline 1 Similar to making a photo Position and point virtuele camera, press button; Projection plane aka Viewing plane Pipeline has +/ same structure as in 2D

Synthetic Camera Metaphor for creating 3D scenes: Coordinate system: Camera: u, v, n Object: x, y, z

3D Viewing pipeline 2 MC: Modeling Coordinates WC: World Coordinates VC: Viewing Coordinates PC: Projection Coordinates NC: Normalized Coordinates DC: Device Coordinates Apply model transformations To camera coordinates Project To standard coordinates Clip and convert to pixels

Right hand coordinate system Coordinate Systems Y +z x x +z Left hand coordinate system Not used in this class and Not in OpenGL Right hand coordinate system

3D viewing coordinates 1 zvp Specification of projection: P0 : View or eye point Pref : Center or look-at point V: View-up vector (projection along vertical axis) zvp : positie view plane yw P0 N V Pref xw zw P0, Pref , V: define viewing coordinate system Several variants possible

3D viewing coordinates 2 xview yview zview yw P0 N V Pref xw zw P0, Pref , V: define viewing coordinate system Several variants possible

3D view coordinates 3 n xview yview u v zview yw P0 N V Pref xw zw

Transform the left-handed eye coordinate system defined by v, u and VPN into the right-handed world coordinate system The origin of the eye coordinate system, COP is translated to the origin (0, 0, 0,) of the world coordinate system. Rotate so that The axis in the u direction is parallel to the world coordinate x-axis. The axis in the v direction is parallel to the world coordinate y-axis. The VPN is parallel to the negative z-axis, that is, going into the display screen. Make the negative z-axis the positive direction so that the positive z direction goes into the screen, i.e., make the eye coordinate system left-handed.

The matrices required to accomplish this transformation are given next. The viewing coordinate origin is at a world position P0 (x0, y0, z0), the translation matrix to translate the viewing origin to the world origin is: 1 0 0 -x0 T = 0 1 0 -y0 0 0 1 -z0 0 0 0 1 The rotation matrix that super imposes the viewing axes onto the world frame, using the u, v, n unit vectors, is ux uy uz 0 R = vx vy vz 0 nx ny nz 0

The coordinate transformation matrix is obtained by product R.T MWC, VC = R.T ux uy uz -u.P0 = vx vy vz -v.P0 nx ny nz -n.P0 0 0 0 1 Where the translation unit vectors are the dot product: u.P0 = -x0ux – y0uy – z0uz v.P0 = -x0vx – y0vy – z0vz n.P0 = -x0nx – y0ny – z0nz

Steps in 3D Viewing Projection type specification Why projection? Objects 3D, device 2D Two most important Perspective Parallel orthographic Viewing parameter specification Viewing plane Viewing (eye) coordinate system Scene coordinate system

Projections Projection Our concern Terminology Transformation from n-D coordinate system to m-D coordinate system, where m < n Our concern n = 3 and m = 2  projection from 3D to 2D Terminology Projectors: Straight projection rays Center of projection: Where the projectors emanated from Projection plane: Where the projection forms

Projections Projection from 3D to 2D defined by Projectors emanate from center of projection (COP), pass through each point of the object, and intersect the projection plane Planar geometric projections Projection is onto a plane Referred to as "projections" here

Projections Two Basic Classes Perspective Parallel Distance between projection plane and COP is finite Visual effect similar to human visual system Perspective foreshortening: distance from COP longer, size smaller Exact shape, measurement, parallelism not reserved

Perspective Projection Given a vertex in the eye coordinate system, v = (xe, ye, ze), the projected screen coordinates, (xs, ys) are computed as: Where d is the distance from COP to the view plane. These formulas are easily derived by considering the projection onto the x-z and y-z planes

Projections Parallel Distance between projection plane and COP is infinite Less realistic view Exact measurement and parallelism preserved Perspective Parallel

Classification of Planar Geometric Projections

Specification of an Arbitrary 3D View View Plane Projection Plane Defined by VRP (View Reference Point) look at point in OpenGL VPN (View Plane Normal) (eye - look) in OpenGL

Specification of an Arbitrary 3D View Window Similar to the window in 2D Contents mapped to the viewport Projection on the view plane outside the window not shown Specification needs the following Minimum and maximum window coordinates Two orthogonal axes Can be defined by view volume

Specification of an Arbitrary 3D View PRP (Projection Reference Point) Parallel: Direction of Projection (DOP) = from PRP to CW Perspective: COP “Eye” in OpenGL View volume Clipping and projection Perspective Semi-infinite pyramid with apex at PRP and edges passing through window corners Parallel Infinite parallelepiped with sides parallel to DOP

Specification of an Arbitrary 3D View View volume (cont’d) Finite view volume Front clipping plane Parallel to VRP Specified by F (front distance) = distance(FCP - VRP) Back clipping plane Specified by B (back distance) = distance(BCP - VRP) In OpenGL, “near” and “far” represents “front” and “back”, respectively, in the camera coordinate

Finite View Volumes Parallel Perspective

Specification of an Arbitrary 3D View Mapping from view volume to 2D display View volume --> NPC (Normalized Projection Coordinates), i.e., standard cube 3D viewport specified in NPC z=1 face of NPC cube mapped to display If wire-frame, z coordinate discarded If surface, hidden-surface removal

OpenGL 3D Viewing 1 3D Viewing in OpenGL: Position camera; Specify projection.

OpenGL 3D Viewing 2 View volume y x z Camera always in origin, in direction of negative z-axis. Convenient for 2D, but not for 3D.

OpenGL 3D Viewing 3 Solution for view transform: Transform your model such that you look at it in a convenient way. Approach 1: Do it yourself. Apply rotations, translations, scaling, etc., before rendering the model. Surprisingly difficult and error-prone. Approach 2: Use gluLookAt();

OpenGL 3D Viewing 4 MatrixMode(GL_MODELVIEW); gluLookAt(x0,y0,z0, xref,yref,zref, Vx,Vy,Vz); x0,y0,z0: P0, viewpoint, location of camera; xref,yref,zref: Pref, centerpoint; Vx,Vy,Vz: V, view-up vector. Default: P0 = (0, 0, 0); Pref = (0, 0, 1); V=(0, 1, 0).

OpenGL 3D Viewing 5 Orthogonal projection: y x z MatrixMode(GL_PROJECTION); glOrtho(xwmin, xwmax, ywmin, ywmax, dnear, dfar); xwmin, xwmax, ywmin,ywmax: specification window dnear: distance to near clipping plane dfar : distance to far clipping plane dnear dfar y ywmax x Select dnear and dfar right: dnear < dfar, model fits between clipping planes. z xwmax ywmin xwmin

OpenGL 3D Viewing 6 Perspective projection: y x z MatrixMode(GL_PROJECTION); glFrustrum(xwmin, xwmax, ywmin, ywmax, dnear, dfar); xwmin, xwmax, ywmin,ywmax: specification window dnear: distance to near clipping plane dfar : distance to far clipping plane dfar dnear y x ywmax Select dnear and dfar right: 0 < dnear < dfar, model fits between clipping planes. z ywmin xwmax xwmin Standard projection: xwmin = -xwmax, ywmin = -ywmax

OpenGL 3D Viewing 7 Finally, specify the viewport (just like in 2D): glViewport(xvmin, yvmin, vpWidth, vpHeight); xvmin, yvmin: coordinates lower left corner (in pixel coordinates); vpWidth, vpHeight: width and height (in pixel coordinates); vpHeight vpWidth (xvmin, yvmin)

OpenGL 2D Viewing 8 In short: To prevent distortion, make sure that: glMatrixMode(GL_PROJECTION); glFrustrum(xwmin, xwmax, ywmin, ywmax, dnear, dfar); glViewport(xvmin, yvmin, vpWidth, vpHeight); glMatrixMode(GL_MODELVIEW); gluLookAt(x0,y0,z0, xref,yref,zref, Vx,Vy,Vz); To prevent distortion, make sure that: (ywmax – ywmin)/(xwmax – xwmin) = vpWidth/vpHeight Make sure that you can deal with resize/reshape of the (OS) window.

3D NDC to 2D Image (Near) Plane Resulting image on the near plane Chapter 14