Title: CPSC 441: Computer Graphics Hierarchical Models
1CPSC 441 Computer GraphicsHierarchical Models
2Summary 3D Geometry Pipeline
View space
World space
Object space
Normalized project space
Image space
2
3Complex Models
4Outline
- Hierarchical Models
- Animation with motion capture data
- - skeletal model (.asf)
- - motion data (.amc)
- Reading HB chapter 14, OpenGL Programming
Guide, chapter 3, and course slides
5Symbols and Instances
- Most graphics API supports a few primitives
- - sphere
- - cube
- - cylinders
- These symbols are instanced using instance
transformation
6Symbols and Instances
- Most graphics API supports a few primitives
- - sphere
- - cube
- - cylinders
- These instances are instanced using instance
transformation
Whats the matrix for the instance transformation
above?
7Symbols and Instances
- Most graphics API supports a few primitives
- - sphere
- - cube
- - cylinders
- These instances are instanced using instance
transformation
8Sample Instance Trans.
- In opengl, instance transformation is created by
modifying the Model-view matrix
glMatrixMode(GL_MODELVIEW) glLoadIdentity() glT
ranslate() glRotate() glScale() house()
9Sample Instance Trans.
- In opengl, instance transformation is created by
modifying the Model-view matrix
glMatrixMode(GL_MODELVIEW) glLoadIdentity() glT
ranslate() glRotate() glScale() house()
Does the transform seem to be backward?
10Composite transformation opengl
- 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.
glMatrixMode(GL_MODELVIEW) glLoadIdentity() M4
M3 M2 M1
113D Example A Robot Arm
- Consider a robot arm with 3 degrees of freedom
- - Base rotates about vertical axis by ?
- - Lower arm rotates about z axis by F
- - Upper arm rotates about z axis by ?
lower arm
Upper arm
h2
h3
h1
base
123D Example A Robot Arm
- Consider a robot arm with 3 degrees of freedom
- - Base rotates about vertical axis by ?
- - Lower arm rotates about z axis by F
- - Upper arm rotates about z axis by ?
lower arm
Upper arm
h2
h3
h1
base
What are matrices we use to transform base, upper
arm and lower arm respectively?
133D Example A Robot Arm
- Consider a robot arm with 3 degrees of freedom
- - Base rotates about vertical axis by ?
- - Lower arm rotates about z axis by F
- - Upper arm rotates about z axis by ?
lower arm
Upper arm
base
143D Example A Robot Arm
- Consider a robot arm with 3 degrees of freedom
- - Base rotates about vertical axis by ?
- - Lower arm rotates about z axis by F
- - Upper arm rotates about z axis by ?
base
153D Example A Robot Arm
- Consider a robot arm with 3 degrees of freedom
- - Base rotates about vertical axis by ?
- - Lower arm rotates about z axis by F
- - Upper arm rotates about z axis by ?
Upper arm
163D Example A Robot Arm
- Consider a robot arm with 3 degrees of freedom
- - Base rotates about vertical axis by ?
- - Lower arm rotates about z axis by F
- - Upper arm rotates about z axis by ?
lower arm
17Robot Arm Implementation
- The robot arm can be displayed by computing a
global matrix and computing it at each step
18Robot Arm Implementation
- The robot arm can be displayed by computing a
global matrix and computing it at each step
Can we make it more efficient?
19Better Implementation
- Instead recalculating the global matrix each
time, we can just update it in place
20Opengl Implementation
- Opengl maintains a global state matrix called
model-view matrix
//set current matrix to identity
21Another Example
- A 2D lamp with 6 degrees of freedom
lower arm
middle arm
Upper arm
base
22Another Example
- A 2D lamp with 6 degrees of freedom
base
23Another Example
- A 2D lamp with 6 degrees of freedom
Upper arm
base
24Another Example
- A 2D lamp with 6 degrees of freedom
middle arm
Upper arm
base
25Another Example
- A 2D lamp with 6 degrees of freedom
lower arm
middle arm
Upper arm
base
26Another Example
- 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,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)
27Hierarchical Modeling
- Consider a model of a car
- 2 symbols
- 5 instances
-
28Hierarchical Modeling
- Consider a model of a car
- 2 symbols chassis wheel
- 5 instances 1 chassis 4 wheel
-
29Hierarchical 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 -
30Hierarchical 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, wed like to only have that model
appear once -
31Hierarchical Modeling
- Hierarchical model can be composed of instances
using trees or directed acyclic graphs (DAGs) - - edges contains geometric transformations
- - nodes contains geometry
32Hierarchical Modeling
- Hierarchical model can be composed of instances
using trees or directed acyclic graphs (DAGs) - - edges contains geometric transformations
- - nodes contains geometry
What might we draw the tree for the robot arm?
33Hierarchical Modeling
- Hierarchical model can be composed of instances
using trees or directed acyclic graphs (DAGs) - - edges contains geometric transformations
- - nodes contains geometry
34Hierarchical Modeling
- Hierarchical model can be composed of instances
using trees or directed acyclic graphs (DAGs) - - edges contains geometric transformations
- - nodes contains geometry
world
base
Upper arm
lower arm
35A More Complex Example Human Figure
36A More Complex Example Human Figure
37A More Complex Example Human Figure
Whats the most efficient way to draw this figure?
38A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
39A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
40A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
41A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
42A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
43A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
44A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
45A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
46A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
47A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
48Opengl Implementation Human Figure
Mh
Mlua
Mlla
49Opengl Implementation Human Figure
I
Mh
MhMlua
MhMluaMlla
50Matrix Stack
- glMatrixMode(GL_MODELVIEW)
- - Initially, each of the stacks contains one
matrix, an identity matrix. - - The depth is at least 32
M
51Push and Pop the Current Matrix
M
M
M
M2
M1
M2
52Opengl Implementation Human Figure
53Opengl Implementation Human Figure
I
Mh
Mlua
Mlua Mlla
54Outline
- Hierarchical Models
- Animation with motion capture data
- - skeletal model (.asf)
- - motion data (.amc)
553D Human Characters
- Articulated Human models
- - rigid parts
- - connected by joints
- They can be animated by specifying the joint
angles (or other display parameters) as functions
of time.
56Human motion representation
A sequence of poses q1,q2,qT Each pose is
represented as a high-dimensional vector qt
Rn
Motion trajectories
Pose qt
Motion q1,qT
57Human-body Animation
Movies!
58Motion capture data files
- Each sequence of human motion data contains two
files - Skeleton file (.asf) Specify the skeleton model
of character - Motion data file (.amc) Specify the joint angle
values over the frame/time - Both files are generated by Vicon software
59Human skeletal file
Described in a default pose
60Human skeletal model
This is still a tree!
61Human skeletal file (.asf)
- individual bone information
- - length of the bone
- - direction of the bone
- - local coordinate frame
- - number of Dofs
- - joint limits
- bone hierarchy/connections
62Individual bone information
- begin id bone_id / Unique
id for each bone /name bone_name /
Unique name for each bone /direction dX dY
dZ / Vector describing direction of the
bone in world / coor. system length
7.01722 / Length of the bone/
axis 0 0 20 XYZ / Rotation of local
coordinate system for
this bone relative to the world
coordinate
system. In .AMC file the rotation angles
for this
bone for each time frame will be
defined
relative to this local coordinate
system/
dof rx ry rz / Degrees of
freedom for this bone. limits (-160.0 20.0)
/ joint limits/ (-70.0 70.0)
(-60.0 70.0) end
63Individual bone information
begin id 2 name
lfemur direction 0.34 -0.93 0
length 7.01722 axis 0 0 20
XYZ dof rx ry rz
limits (-160.0 20.0) (-70.0 70.0)
(-60.0 70.0) end
64Individual bone information
begin id 2 name
lfemur direction 0.34 -0.93 0
length 7.01722 axis 0 0 20
XYZ dof rx ry rz
limits (-160.0 20.0) (-70.0 70.0)
(-60.0 70.0) end
65Individual bone information
begin id 2 name
lfemur direction 0.34 -0.93 0
length 7.01722 axis 0 0 20
XYZ dof rx ry rz
limits (-160.0 20.0) (-70.0 70.0)
(-60.0 70.0) end
66Individual bone information
begin id 2 name
lfemur direction 0.34 -0.93 0
length 7.01722 axis 0 0 20
XYZ dof rx ry rz
limits (-160.0 20.0) (-70.0 70.0)
(-60.0 70.0) end
yk
xk
zk
Euler angle representation
RkRz(?)Ry(ß)Rx(a)
67Individual bone information
begin id 2 name
lfemur direction 0.34 -0.93 0
length 7.01722 axis 0 0 20
XYZ dof rx ry rz
limits (-160.0 20.0) (-70.0 70.0)
(-60.0 70.0) end
yk
xk
zk
- The number of dof for this joint - The minimal
and maximum joint angle for each dof
68Individual bone information
begin id 2 name
lfemur direction 0.34 -0.93 0
length 7.01722 axis 0 0 20
XYZ dof rx ry rz
limits (-160.0 20.0) (-70.0 70.0)
(-60.0 70.0) end
yk
1-dof joint
2-dof joint
3-dof joint
69Individual bone information
begin id 2 name
lfemur direction 0.34 -0.93 0
length 7.01722 axis 0 0 20
XYZ dof rx ry rz
limits (-160.0 20.0) (-70.0 70.0)
(-60.0 70.0) end
yk
yk1
Xk1
zk1
begin id 3 name
ltibia direction 0.34 -0.93 0
length 7.2138 axis 0 0 20
XYZ dof rx limits
(-10.0 170.0) end
70Root representation
- root
- order TX TY TZ RX RY RZ
- axis XYZ
- position 0 0 0
- orientation 0 0 0
71Root representation
- root
- order TX TY TZ RX RY RZ
- axis XYZ
- position 0 0 0
- orientation 0 0 0
How to compute the coordinate of a joint in the
world coordinate frame?
72Root representation
- root
- order TX TY TZ RX RY RZ
- axis XYZ
- position 0 0 0
- orientation 0 0 0
How to compute the coordinate of a joint in the
world coordinate frame?
73Hierarchy/Bone Connections
hierarchy begin root lhipjoint rhipjoint
lowerback lhipjoint lfemur lfemur ltibia
ltibia lfoot lfoot ltoes rhipjoint
rfemur rfemur rtibia rtibia rfoot
rfoot rtoes lowerback upperback upperback
thorax thorax lowerneck lclavicle rclavicle
end
74Hierarchy/Bone Connections
hierarchy begin root lhipjoint rhipjoint
lowerback lhipjoint lfemur lfemur ltibia
ltibia lfoot lfoot ltoes rhipjoint
rfemur rfemur rtibia rtibia rfoot
rfoot rtoes lowerback upperback upperback
thorax thorax lowerneck lclavicle rclavicle
end
lowerback
root
rhipjoint
75Hierarchy/Bone Connections
hierarchy begin root lhipjoint rhipjoint
lowerback lhipjoint lfemur lfemur ltibia
ltibia lfoot lfoot ltoes rhipjoint
rfemur rfemur rtibia rtibia rfoot
rfoot rtoes lowerback upperback upperback
thorax thorax lowerneck lclavicle rclavicle
end
lowerback
root
rhipjoint
lhipjoint
lfemur
76Hierarchy/Bone Connections
hierarchy begin root lhipjoint rhipjoint
lowerback lhipjoint lfemur lfemur ltibia
ltibia lfoot lfoot ltoes rhipjoint
rfemur rfemur rtibia rtibia rfoot
rfoot rtoes lowerback upperback upperback
thorax thorax lowerneck lclavicle rclavicle
end
lowerback
root
rhipjoint
lhipjoint
lfemur
ltibia
77Hierarchy/Bone Connections
hierarchy begin root lhipjoint rhipjoint
lowerback lhipjoint lfemur lfemur ltibia
ltibia lfoot lfoot ltoes rhipjoint
rfemur rfemur rtibia rtibia rfoot
rfoot rtoes lowerback upperback upperback
thorax thorax lowerneck lclavicle rclavicle
end
lowerback
root
rhipjoint
lhipjoint
lfemur
ltibia
lfoot
78Hierarchy/Bone Connections
hierarchy begin root lhipjoint rhipjoint
lowerback lhipjoint lfemur lfemur ltibia
ltibia lfoot lfoot ltoes rhipjoint
rfemur rfemur rtibia rtibia rfoot
rfoot rtoes lowerback upperback upperback
thorax thorax lowerneck lclavicle rclavicle
end
lowerback
root
rhipjoint
lhipjoint
lfemur
ltibia
lfoot
ltoe
79What can we do with .asf file?
- We can visualize the default pose
- We can compute various transforms in the default
pose - - between world coordinate frame and local
coordinate - - between parent coordinate frame and child
coordinate frame -
80From local coordinate to world coordinate
yk
81From local coordinate to world coordinate
yk
82From child to parent node
- How to Compute the transformation Tkk-1 from a
child local coordinate frame to its parent local
coordinate frame
Tkk-1
x
83Bone transform
parent
Tkk-1?
world
child
84Bone transform
parent
Tkk-1?
world
child
Given Rk,Tk, Rk-1,Tk-1, - How can we compute
xk-1 from xk?
85Bone transform
parent
Tkk-1?
world
child
86Bone transform
parent
Tkk-1?
world
child
87Motion data file (.amc)
- i
// frame
number - root 2.36756 16.4521 12.3335 -165.118 31.188
-179.889 // root position and orientation - lowerback -17.2981 -0.243065 -1.41128
// joint angles for lowerback joint - upperback 0.421503 -0.161394 2.20925
// joint angles for thorax joint - thorax 10.2185 -0.176777 3.1832
- lowerneck -15.0172 -5.84786 -7.55529
- upperneck 30.0554 -3.19622 -4.68899
- head 12.6247 -2.35554 -0.876544
- rclavicle 4.77083e-014 -3.02153e-014
- rhumerus -23.3927 30.8588 -91.7324
- rradius 108.098
- rwrist -35.4375
- rhand -5.30059 11.2226
- rfingers 7.12502
- rthumb 20.5046 -17.7147
- lclavicle 4.77083e-014 -3.02153e-014
- lhumerus -35.2156 -19.5059 100.612
88Motion data file (.amc)
- i
// frame
number - root 2.36756 16.4521 12.3335 -165.118 31.188
-179.889 // root position and orientation - lowerback -17.2981 -0.243065 -1.41128
// joint angles for lowerback joint - upperback 0.421503 -0.161394 2.20925
// joint angles for thorax joint - thorax 10.2185 -0.176777 3.1832
- lowerneck -15.0172 -5.84786 -7.55529
- upperneck 30.0554 -3.19622 -4.68899
- head 12.6247 -2.35554 -0.876544
- rclavicle 4.77083e-014 -3.02153e-014
- rhumerus -23.3927 30.8588 -91.7324
- rradius 108.098
- rwrist -35.4375
- rhand -5.30059 11.2226
- rfingers 7.12502
- rthumb 20.5046 -17.7147
- lclavicle 4.77083e-014 -3.02153e-014
- lhumerus -35.2156 -19.5059 100.612
- Rotation described in local coordinate frame -
Euler angle representation x-y-z
89Composite 3D Transformation
From .asf file
90Composite 3D Transformation
From .amc file
91Composite 3D Transformation
92Composite 3D Transformation
93Composite 3D Transformation
94Composite 3D Transformation
95Human Figures
- Traverse the whole tree to draw every bones
This is still a tree!