p trp
play

p' = TRp B A except 6.1.6, 6.3.1 (1,1) A intuitive? FCG Sect - PowerPoint PPT Presentation

University of British Columbia Readings for Jan 15-22 Review: Interpreting Transformations Correction/More: Arbitrary Rotation CPSC 314 Computer Graphics (b x , b y , b z , 1) Y right to left: moving object (a x , a y , a z , 1) Y FCG


  1. University of British Columbia Readings for Jan 15-22 Review: Interpreting Transformations Correction/More: Arbitrary Rotation CPSC 314 Computer Graphics (b x , b y , b z , 1) Y right to left: moving object (a x , a y , a z , 1) Y • FCG Chap 6 Transformation Matrices Jan-Apr 2007 B p' = TRp B A • except 6.1.6, 6.3.1 (1,1) A intuitive? • FCG Sect 13.3 Scene Graphs Tamara Munzner X C X translate by (-1,0) Z C • RB Chap Viewing Z (c x , c y , c z , 1) • arbitrary rotation: change of basis • Viewing and Modeling Transforms until Viewing (2,1) Transformations IV left to right: changing coordinate system Transformations • given two orthonormal coordinate systems XYZ and ABC • Examples of Composing Several Transformations • A ’ s location in the XYZ coordinate system is (a x , a y , a z , 1), ... (1,1) through Building an Articulated Robot Arm • transformation from one to the other is matrix R whose Week 3, Mon Jan 22 OpenGL • RB Appendix Homogeneous Coordinates and columns are A,B,C: a b c 0 1     Transformation Matrices x x x http://www.ugrad.cs.ubc.ca/~cs314/Vjan2007     a b c 0 0 • until Perspective Projection y y y • same relative position between object and R ( X )     = ( a , a , a , 1 ) A = = a b c 0 0 x y z     • RB Chap Display Lists z z z basis vectors     0 0 0 1 1 2 3     Transformation Hierarchies Transformation Hierarchy Example 1 Transformation Hierarchies • scene may have a hierarchy of coordinate • hierarchies don’t fall apart when changed systems • transforms apply to graph nodes beneath • stores matrix at each level with incremental world world transform from parent’s coordinate system Transformation Hierarchies torso torso head LUleg LUleg RUleg RUleg LUarm LUarm RUarm RUarm head • scene graph road road LLleg LLleg RLleg RLleg LLarm LLarm RLarm RLarm Lfoot Lfoot Rfoot Rfoot Lhand Lhand Rhand Rhand ... ... ... ... car1 car1 car2 car2 stripe1 stripe1 stripe2 stripe2 trans(0.30,0,0) rot(z, ) trans(0.30,0,0) rot(z, ) θ w1 w1 w2 w2 w3 w3 w4 w4 5 6 7 8 Demo: Brown Applets Transformation Hierarchy Example 2 Matrix Stacks Matrix Stacks • draw same 3D data with different • challenge of avoiding unnecessary http://www.cs http://www. cs.brown. .brown.edu edu/ /exploratories exploratories/ / transformations: instancing computation freeSoftware/catalogs/ freeSoftware /catalogs/scenegraphs scenegraphs.html .html D = C scale(2,2,2) trans(1,0,0) D = C scale(2,2,2) trans(1,0,0) glPushMatrix() glPushMatrix () • using inverse to return to origin glPopMatrix() glPopMatrix () • computing incremental T 1 -> T 2 C C D D Object coordinates Object coordinates DrawSquare() DrawSquare () C C C C C C C glPushMatrix glPushMatrix() () C glScale3f(2,2,2) glScale3f(2,2,2) B B B B B B B B glTranslate3f(1,0,0) glTranslate3f(1,0,0) A A A A A A A A DrawSquare() () DrawSquare T T 2 2 (x) (x) glPopMatrix() () glPopMatrix T 1 T 1 (x) (x) T 3 T 3 (x) (x) World coordinates World coordinates 9 10 11 12 Modularization Matrix Stacks Transformation Hierarchy Example 3 Transformation Hierarchy Example 4 • drawing a scaled square • advantages glTranslate3f(x,y,0); glTranslate3f(x,y,0); • no need to compute inverse matrices all the time • push/pop ensures no coord system change glRotatef( ,0,0,1); ( ,0,0,1); glRotatef θ 1 • modularize changes to pipeline state DrawBody(); (); DrawBody void drawBlock void drawBlock(float k) { (float k) { glPushMatrix(); (); glPushMatrix glPushMatrix(); glPushMatrix (); • avoids incremental changes to coordinate systems θ glTranslate3f(0,7,0); glTranslate3f(0,7,0); 2 • accumulation of numerical errors glLoadIdentity(); (); θ DrawHead(); DrawHead (); glLoadIdentity glScalef glScalef(k,k,k); (k,k,k); F h F 4 h glTranslatef(4,1,0); (4,1,0); glPopMatrix(); glPopMatrix (); glBegin glBegin(GL_LINE_LOOP); (GL_LINE_LOOP); glTranslatef • practical issues glPushMatrix(); (); glPushMatrix glPushMatrix(); (); glVertex3f(0,0,0); glVertex3f(0,0,0); glPushMatrix F h F h glVertex3f(1,0,0); glVertex3f(1,0,0); glRotatef glRotatef(45,0,0,1); (45,0,0,1); glTranslate(2.5,5.5,0); glTranslate (2.5,5.5,0); • in graphics hardware, depth of matrix stacks is F F h h θ glVertex3f(1,1,0); θ glVertex3f(1,1,0); glTranslatef glTranslatef(0,2,0); (0,2,0); glRotatef( ,0,0,1); glRotatef ( ,0,0,1); θ θ 3 5 limited 2 glVertex3f(0,1,0); glVertex3f(0,1,0); 1 glScalef(2,1,1); glScalef (2,1,1); DrawUArm(); DrawUArm (); F F h h F h F h F F glEnd(); glEnd (); h h • (typically 16 for model/view and about 4 for projective glTranslate glTranslate(1,0,0); (1,0,0); glTranslate glTranslate(0,-3.5,0); (0,-3.5,0); F 1 F F F h 1 y y glPopMatrix glPopMatrix(); (); glRotatef( ,0,0,1); glRotatef ( ,0,0,1); matrix) h θ glPopMatrix glPopMatrix(); (); 3 F F W DrawLArm DrawLArm(); (); } } W x x glPopMatrix glPopMatrix(); (); ... (draw other arm) ... (draw other arm) 13 14 15 16

Recommend


More recommend