400 likes | 410 Views
Viewing Transformation and Back-face culling. Tong-Yee Lee. OpenGL Graphics Pipeline. From world coordinate to eye coordinate. Note: eye is defined at world coordinate. Note: visible object’s Z is negative. Front and Back Clipping Planes. Frustum
E N D
Viewing Transformationand Back-face culling Tong-Yee Lee
From world coordinate to eye coordinate Note: eye is defined at world coordinate Note: visible object’s Z is negative
Front and Back Clipping Planes • Frustum • Volume of space between front and back clipping planes • What camera can see – what drawn on screen • Near and far clipping planes defined by distance along Look Vector • Objects appearing outside of view volume don't get drawn • Objects intersecting view volume get clipped
OpenGL: Field of View, gluPerspectiveYet another way to set viewing front plane aspect = w/h • Can always use: glFrustum(left, right, bottom, top, near, far) • This is certainly sufficient • But may be inconvenient in some applications • Can be difficult to get desired view • May want to use: gluPerspective(fovy, aspect, near, far) • specifies field of view along y axis • angle θ made by the sides of frustum • aspect ratio of viewport • just (width / height)
Back-face culling (trivial rejection) One method of implementing back-face culling is by discarding all triangles where the dot product of their surface normal and the camera-to-triangle vector is greater than or equal to zero where P is the view point, V0 is the first vertex of a triangle and N is its normal, defined as a cross product of two vectors representing sides of the triangle adjacent to V0 Reject condition N V2 P V1 V0
Back-face culling (trivial rejection), i.e., almost cull-off 50%
Ans: set up camera orientation
X axis vector Y axis vector Z axis vector
Not easy for user to pick up exact up vector!! So, we compute v automatically from up vector.
俯仰 偏航 翻滾 u (i.e., x) axis n (i.e.,z) axis v (i.e., y) axis Treat yourself (viewer) as a airplane heading to –Zc Note that: as a viewer is moving, the object is moving in opposite direction on the viewing plane!!
How about slide() • Sliding a camera means to move it along one of its own axes-that is in the u,v,n direction-without rotating it. • Along n means forward or backward • Along u is left and right • Along v is up and down • Assume slide(delU, delV, delN) 延camera座標軸 walking
Flythrough a Scene!!! ‘P’-64 =ctrl+‘P’ Homework #2 (optional) Add this camera control!!
Light v.s. Eye coordinate Camera Frame
Motion Overview of Human Actions http://graphics.csie.ncku.edu.tw/Motion_Overview/ Same v.s. Different camera paths for different motions
v’ n’ n u n’ u’ v n This is x-like rotation (pitch) This is y-like rotation (yaw)