CPSC 441: Computer Graphics Hierarchical Models - PowerPoint PPT Presentation

1 / 95
About This Presentation
Title:

CPSC 441: Computer Graphics Hierarchical Models

Description:

... the designated transformation matrix on the right of the composite matrix ... must invoke the transformation in the opposite order from which they are applied. ... – PowerPoint PPT presentation

Number of Views:176
Avg rating:3.0/5.0
Slides: 96
Provided by: jch63
Category:

less

Transcript and Presenter's Notes

Title: CPSC 441: Computer Graphics Hierarchical Models


1
CPSC 441 Computer GraphicsHierarchical Models
  • Jinxiang Chai

2
Summary 3D Geometry Pipeline
View space
World space
Object space
Normalized project space
Image space
2
3
Complex Models
4
Outline
  • 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

5
Symbols and Instances
  • Most graphics API supports a few primitives
  • - sphere
  • - cube
  • - cylinders
  • These symbols are instanced using instance
    transformation

6
Symbols 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?
7
Symbols and Instances
  • Most graphics API supports a few primitives
  • - sphere
  • - cube
  • - cylinders
  • These instances are instanced using instance
    transformation

8
Sample Instance Trans.
  • In opengl, instance transformation is created by
    modifying the Model-view matrix

glMatrixMode(GL_MODELVIEW) glLoadIdentity() glT
ranslate() glRotate() glScale() house()
9
Sample 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?
10
Composite 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
11
3D 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
12
3D 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?
13
3D 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
14
3D 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
15
3D 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
16
3D 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
17
Robot Arm Implementation
  • The robot arm can be displayed by computing a
    global matrix and computing it at each step

18
Robot 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?
19
Better Implementation
  • Instead recalculating the global matrix each
    time, we can just update it in place

20
Opengl Implementation
  • Opengl maintains a global state matrix called
    model-view matrix

//set current matrix to identity
21
Another Example
  • A 2D lamp with 6 degrees of freedom

lower arm
middle arm
Upper arm
base
22
Another Example
  • A 2D lamp with 6 degrees of freedom

base
23
Another Example
  • A 2D lamp with 6 degrees of freedom

Upper arm
base
24
Another Example
  • A 2D lamp with 6 degrees of freedom

middle arm
Upper arm
base
25
Another Example
  • A 2D lamp with 6 degrees of freedom

lower arm
middle arm
Upper arm
base
26
Another 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)

27
Hierarchical Modeling
  • Consider a model of a car
  • 2 symbols
  • 5 instances

28
Hierarchical Modeling
  • Consider a model of a car
  • 2 symbols chassis wheel
  • 5 instances 1 chassis 4 wheel

29
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

30
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, wed like to only have that model
    appear once

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

What might we draw the tree for the robot arm?
33
Hierarchical Modeling
  • Hierarchical model can be composed of instances
    using trees or directed acyclic graphs (DAGs)
  • - edges contains geometric transformations
  • - nodes contains geometry

34
Hierarchical 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
35
A More Complex Example Human Figure
36
A More Complex Example Human Figure
37
A More Complex Example Human Figure
Whats the most efficient way to draw this figure?
38
A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
39
A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
40
A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
41
A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
42
A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
43
A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
44
A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
45
A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
46
A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
47
A More Complex Example Human Figure
Whats the most sensible way to traverse this
tree?
48
Opengl Implementation Human Figure
Mh
Mlua
Mlla
49
Opengl Implementation Human Figure
I
Mh
MhMlua
MhMluaMlla
50
Matrix Stack
  • glMatrixMode(GL_MODELVIEW)
  • - Initially, each of the stacks contains one
    matrix, an identity matrix.
  • - The depth is at least 32

M

51
Push and Pop the Current Matrix
  • glPushMatrix
  • glPopMatrix

M
M

M

M2
M1
M2


52
Opengl Implementation Human Figure
53
Opengl Implementation Human Figure
I
Mh
Mlua
Mlua Mlla
54
Outline
  • Hierarchical Models
  • Animation with motion capture data
  • - skeletal model (.asf)
  • - motion data (.amc)

55
3D 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.

56
Human 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
57
Human-body Animation

Movies!
58
Motion 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

59
Human skeletal file
Described in a default pose
60
Human skeletal model
This is still a tree!
61
Human 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

62
Individual 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

63
Individual 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
64
Individual 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
65
Individual 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
66
Individual 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)
67
Individual 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
68
Individual 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
69
Individual 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
70
Root representation
  • root
  • order TX TY TZ RX RY RZ
  • axis XYZ
  • position 0 0 0
  • orientation 0 0 0

71
Root 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?
72
Root 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?
73
Hierarchy/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
74
Hierarchy/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
75
Hierarchy/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
76
Hierarchy/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
77
Hierarchy/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
78
Hierarchy/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
79
What 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

80
From local coordinate to world coordinate
yk
81
From local coordinate to world coordinate
yk
82
From 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
83
Bone transform
parent
Tkk-1?
world
child
84
Bone transform
parent
Tkk-1?
world
child
Given Rk,Tk, Rk-1,Tk-1, - How can we compute
xk-1 from xk?
85
Bone transform
parent
Tkk-1?
world
child
86
Bone transform
parent
Tkk-1?
world
child
87
Motion 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

88
Motion 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
89
Composite 3D Transformation
From .asf file
90
Composite 3D Transformation
From .amc file
91
Composite 3D Transformation
92
Composite 3D Transformation
93
Composite 3D Transformation
94
Composite 3D Transformation
95
Human Figures
  • Traverse the whole tree to draw every bones

This is still a tree!
Write a Comment
User Comments (0)
About PowerShow.com