New version page

TAMU CSCE 441 - lecture12

Documents in this Course
Load more
Upgrade to remove ads
Upgrade to remove ads
Unformatted text preview:

CSCE 441: Computer Graphics: Hierarchical ModelsSummary: 3D Geometry PipelineComplex ModelsOutlineSymbols and InstancesSlide 6Slide 7Sample Instance Trans.Slide 9Composite Transformation: Opengl ImplementationLampSlide 12Slide 13Slide 14Slide 15Lamp ImplementationSlide 17Better ImplementationOpengl ImplementationHierarchical ModelingSlide 21Slide 22Slide 23Slide 24Slide 25Slide 26Slide 27Slide 28A More Complex Example: Human FigureSlide 30Slide 31Slide 32Slide 33Slide 34Slide 35Slide 36Slide 37Slide 38Slide 39Slide 40Slide 41Opengl Implementation: Human FigureSlide 43Slide 44Matrix StackPush and Pop the Current MatrixSlide 47Slide 48Slide 49CSCE 441: Computer Graphics:Hierarchical ModelsJinxiang ChaiImage space2Normalized project spaceView spaceWorld spaceObject spaceSummary: 3D Geometry PipelineComplex ModelsOutlineHierarchical ModelsReading: HB chapter 14, OpenGL Programming Guide, chapter 3, and course slides•Most graphics API supports a few primitives: - sphere - cube - cylinders•These symbols are instanced using instance transformation:Symbols and Instances•Most graphics API supports a few primitives: - sphere - cube - cylinders•These symbols are instanced using instance transformation:Symbols and InstancesWhat’s the matrix for the instance transformation above?•Most graphics API supports a few primitives: - sphere - cube - cylinders•These symbols are instanced using instance transformation:Symbols and Instances),(*)(*),(yxyxssSRttTM•In opengl, instance transformation is created by modifying the Model-view matrix:Sample Instance Trans.glMatrixMode(GL_MODELVIEW);glLoadIdentity(…);// set current matrix to the identityglTranslate(…); // translate glRotate(…); //rotateglScale(…);//scalehouse();),(*)(*),(*yxyxssSRttTI•In opengl, instance transformation is created by modifying the Model-view matrix:Sample Instance Trans.Does the transform seem to be backward? glMatrixMode(GL_MODELVIEW);glLoadIdentity(…);glTranslate(…);glRotate(…);glScale(…);house();•Opengl postmultiplies transformation matrices as they are called•Each subsequent transformation call concatenates the designated transformation matrix on the right of the composite matrix•We must invoke the transformation in the opposite order from which they are applied. Composite Transformation: Opengl ImplementationglMatrixMode(GL_MODELVIEW);glLoadIdentity(…);M4;M3;M2;M1;…xMMMMIx *****'1234Lamp•What’s the current coordinate A ?1233c2c1cA03221100)()0,()()0,()(),0()(),( pRlTRlTRlTRyxTp),,(0yx0c11Lamp•What’s the current coordinate A ?1233c2c1cA03221100)()0,()()0,()(),0()(),( pRlTRlTRlTRyxTp),,(0yx0c12Lamp•What’s the current coordinate A ?1233c2c1cA03221100)()0,()()0,()(),0()(),( pRlTRlTRlTRyxTp),,(0yx0c13Lamp•What’s the current coordinate A ?1233c2c1cA03221100)()0,()()0,()(),0()(),( pRlTRlTRlTRyxTp),,(0yx0c14Lamp•What’s the current coordinate A ?1233c2c1cA03221100)()0,()()0,()(),0()(),( pRlTRlTRlTRyxTp),,(0yx0c15Lamp Implementation•The lamp can be displayed by computing a global matrix and computing it at each step)(),(0RyxT)(),0()(),(100RlTRyxT)0,()()0,()(),0()(),(221100lTRlTRlTRyxTMatrix M_model;Main(){ … lamp();}lamp(){ M_model = base(); M_model = upper_arm(); M_model = middel_arm(); M_model = lower_arm();})()0,()()0,()(),0()(),(3221100RlTRlTRlTRyxTLamp Implementation•The lamp can be displayed by computing a global matrix and computing it at each step)(),(0RyxT)(),0()(),(100RlTRyxT)()0,()(),0()(),(21100RlTRlTRyxTMatrix M_model;Main(){ … lamp()}lamp(){ M_model = base(); M_model = upper_arm(); M_model = middel_arm(); M_model = lower_arm();})()0,()()0,()(),0()(),(3221100RlTRlTRlTRyxTCan we make it more efficiently?Better Implementation•Instead recalculating the global matrix each time, we can just update it in place)(),(0RyxT)(),0(10RlT)()0,(21RlTMatrix M_model;Main(){ … M_model=Identity() lamp();}lamp(){ M_model *= base(); M_model *= upper_arm(); M_model *= middel_arm(); M_model *= lower_arm();})()0,(32RlTOpengl Implementation•Opengl maintains a global state matrix called model-view matrix2D_lamp(x, y, θ0, θ1, θ2, θ3){ glTranslatef(x,y,0) glRotatef(θ0,0,0,1,); base(); glTranslatef(0,l0,0) glRotatef(θ1,0,0,1,); upper_arm(); glTranslatef(0,l1,0) glRotatef(θ2,0,0,1,); middel_arm(); glTranslatef(0,l2,0) glRotatef(θ3,0,0,1,); lower_arm();}Main(){ … glMatrixMode(GL_MODELVIEW); glLoadIdentity(); 2D_lamp(a,b,c,d,e,f) …} //set current matrixto identityHierarchical Modeling•Consider a model of a car – how many symbols? – how many instances?Hierarchical Modeling•Consider a model of a car – 2 symbols : – 5 instances :Hierarchical Modeling•Consider a model of a car – 2 symbols : chassis + wheel – 5 instances : 1 chassis + 4 wheel World systemfront-left wheel systemChasis systemHierarchical Modeling•Consider a model of a car – 2 symbols : chassis + wheel – 5 instances : 1 chassis + 4 wheel•We can represent our car as a tree to show the relationship between the partsHierarchical Modeling•Consider a model of a car – 2 symbols : chassis + wheel – 5 instances : 1 chassis + 4 wheel•We can represent our car as a tree to show the relationship between the parts•However, since all 4 wheels are instances of the same model, we’d like to only have that model appear onceHierarchical Modeling•Hierarchical model can be composed of instances using trees or directed acyclic graphs (DAGs) - edges contains geometric transformations - nodes contains geometryHierarchical Modeling•Hierarchical model can be composed of instances using trees or directed acyclic graphs (DAGs) - edges contains geometric transformations - nodes contains geometryWhat might we draw the tree for the lamp?Hierarchical Modeling•Hierarchical model can be composed of instances using trees or directed acyclic graphs (DAGs) - edges contains geometric transformations - nodes contains geometry123c2c1cAHierarchical Modeling•Hierarchical model can be composed of instances using trees or directed acyclic graphs (DAGs) - edges contains geometric transformations - nodes contains geometrylower armbaseUpper armworld)(),(0RyxT)(),0(10RlT)()0,(21RlT)()0,(32RlTmiddle


View Full Document
Download lecture12
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view lecture12 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view lecture12 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?