Download presentation
Presentation is loading. Please wait.
Published byFrederick Martin Modified over 8 years ago
1
CSCE 441: Computer Graphics: Hierarchical Models Jinxiang Chai
2
Image space 2 Normalized project space View space World spaceObject space Summary: 3D Geometry Pipeline
3
Complex Models
4
Outline Hierarchical Models Reading: HB 9-8&9-9, HB chapter 11, OpenGL Programming Guide, chapter 3, and course slides
5
Most graphics API supports a few primitives: - sphere - cube - cylinders These symbols are instanced using instance/model transformation: Symbols and Instances
6
Most graphics API supports a few primitives: - sphere - cube - cylinders These symbols are instanced using instance transformation: Symbols and Instances What’s the matrix for the instance transformation above?
7
Most graphics API supports a few primitives: - sphere - cube - cylinders These symbols are instanced using instance transformation: Symbols and Instances
8
In opengl, instance/model transformation is created by modifying the Model-view matrix: Sample Instance Trans. glMatrixMode(GL_MODELVIEW); glLoadIdentity(…);// set current matrix to the identity glTranslate(…); // translate glRotate(…); //rotate glScale(…);//scale house();
9
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();
10
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 Implementation glMatrixMode(GL_MODELVIEW); glLoadIdentity(…); M 4 ; M 3 ; M 2 ; M 1 ; …
11
Lamp What’s the current coordinate A ? 11
12
Lamp Suppose we know how to draw each bone in local reference frames
13
Lamp How can we draw the character under a particular pose
14
Lamp How can we draw the character under a particular pose base(); upper_arm(); middel_arm(); lower_arm();
15
Lamp What’s the current coordinate A ? 15
16
Lamp What’s the current coordinate A ? 16
17
Lamp What’s the current coordinate A ? 17
18
Lamp What’s the current coordinate A ? 18
19
Lamp Implementation The lamp can be displayed by computing a global matrix and computing it at each step lamp() { M_model = base(); M_model = upper_arm(); M_model = middel_arm(); M_model = lower_arm(); } Matrix M_model; Main() { … M_model=Identity() lamp(); }
20
Lamp Implementation The lamp can be displayed by computing a global matrix and computing it at each step lamp() { M_model = base(); M_model = upper_arm(); M_model = middel_arm(); M_model = lower_arm(); } Can we make it more efficiently? Matrix M_model; Main() { … M_model=Identity() lamp(); }
21
Better Implementation Instead of recalculating the global matrix each time, we can just update it in place Matrix M_model; Main() { … M_model=Identity() lamp(); } lamp() { M_model *= base(); M_model *= upper_arm(); M_model *= middel_arm(); M_model *= lower_arm(); }
22
Opengl Implementation Opengl maintains a global state matrix called model-view matrix 2D_lamp(x, y, θ 0, θ 1, θ 2, θ 3 ) { glTranslatef(x,y,0) glRotatef(θ 0,0,0,1, ); base(); glTranslatef(0,l 0,0) glRotatef(θ 1,0,0,1, ); upper_arm(); glTranslatef(0,l 1,0) glRotatef(θ 2,0,0,1, ); middel_arm(); glTranslatef(0,l 2,0) glRotatef(θ 3,0,0,1, ); lower_arm(); } Main() { … glMatrixMode(GL_MODELVIEW); glLoadIdentity(); 2D_lamp(a,b,c,d,e,f) … } //set current matrix to identity
23
More Complex Objects
24
Hierarchical Modeling Consider a model of a car – how many symbols/primitives? – how many instances?
25
Hierarchical Modeling Consider a model of a car – 2 primitives : – 5 instances :
26
Hierarchical Modeling Consider a model of a car – 2 primitives : chassis + wheel – 5 instances : 1 chassis + 4 wheel World system front-left wheel system Chasis system
27
Hierarchical Modeling Consider a model of a car – 2 primitives : chassis + wheel – 5 instances : 1 chassis + 4 wheel We can represent our car as a tree to show the relationship between the parts - tree nodes store subparts (i.e., instances) - transition edges represent relationship between the parts
28
Hierarchical 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 once
29
Hierarchical Modeling Hierarchical model can be composed of instances using trees or directed acyclic graphs (DAGs) - edges contains geometric transformations - nodes contains geometry of subparts (i.e., primitives) This allows us to decompose geometry representation of a complex object into a set of geometric primitives and the geometric transformations between the primitives.
30
Hierarchical Modeling What might we draw the tree for the lamp? Hierarchical model can be composed of instances using trees or directed acyclic graphs (DAGs) - edges contains geometric transformations - nodes contains geometry of subparts (i.e., primitives)
31
Hierarchical Modeling Hierarchical model can be composed of instances using trees or directed acyclic graphs (DAGs) - edges contains geometric transformations - nodes contains geometry
32
Hierarchical Modeling Hierarchical model can be composed of instances using trees or directed acyclic graphs (DAGs) - edges contains geometric transformations - nodes contains geometry lower arm base Upper arm world middle arm
33
Different geometric models for Lamp
34
More Complex Objects
35
A More Complex Example: Human Figure torso
36
A More Complex Example: Human Figure torso
37
A More Complex Example: Human Figure torso
38
A More Complex Example: Human Figure What’s the most efficient way to draw this figure? Suppose we know how to draw each primitive in local reference frames torso
39
A More Complex Example: Human Figure What’s the most sensible way to traverse this tree? torso
40
A More Complex Example: Human Figure What’s the most sensible way to traverse this tree? torso
41
A More Complex Example: Human Figure What’s the most sensible way to traverse this tree? torso
42
A More Complex Example: Human Figure What’s the most sensible way to traverse this tree? torso
43
A More Complex Example: Human Figure What’s the most sensible way to traverse this tree? torso
44
A More Complex Example: Human Figure What’s the most sensible way to traverse this tree? torso
45
A More Complex Example: Human Figure What’s the most sensible way to traverse this tree? torso
46
A More Complex Example: Human Figure What’s the most sensible way to traverse this tree? torso
47
A More Complex Example: Human Figure What’s the most sensible way to traverse this tree? torso
48
A More Complex Example: Human Figure What’s the most sensible way to traverse this tree? torso
49
Opengl Implementation: Human Figure MhMh M lua M lla torso
50
Opengl Implementation: Human Figure MhMh M lua M lla torso Is this correct?
51
Opengl Implementation: Human Figure MhMh M h *M lua should be Mlua M h *M lua *M lla should be Mlua*Mlla I torso Is this correct? No
52
Matrix Stack glMatrixMode(GL_MODELVIEW) - Initially, each of the stacks contains one matrix, an identity matrix. - The top matrix in the stack is “current matrix” - The depth is at least 32 McMc … I
53
Push and Pop the Current Matrix glPushMatrix() copy the current matrix at the top of the stack McMc … McMc … McMc I I
54
Push and Pop the Current Matrix glPopMatrix() destroys the matrix at the top of stack M top-1 … M top M top-1 … I I
55
Opengl Implementation: Human Figure
56
I
57
I I
58
I MhMh
59
I
60
I I
61
I M lua
62
Opengl Implementation: Human Figure I M lua
63
Opengl Implementation: Human Figure I M lua M lua *M lla
64
Opengl Implementation: Human Figure I M lua
65
Opengl Implementation: Human Figure I
66
I MhMh M lua M lua M lla
67
Articulated Models You can draw these models as long as - you know how to draw each primitive in local reference frames - you know how to call transformation matrices to model the relationship between the primitives
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.