Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a...

31
Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation of a system using geometric shapes Symbol: Representation of system component Instance: Each occurrence of a symbol within a model

Transcript of Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a...

Page 1: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Hierarchical Modeling

Model: Representation of a system

Modeling: Creation and manipulation of a system representation

Geometric Model: Graphical representation of a system using geometric shapes

Symbol: Representation of system component

Instance: Each occurrence of a symbol within a model

Page 2: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Hierarchical Tree Structure

robot

base body

headtorso left arm

right arm

basic symbols (number of instances)

head(1)base(1) torso(1) arm(2)

wb

lb

wh

lh

wt

lt

wa

la

Page 3: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Ingredients of a geometric model:• Geometric shapes and other attributes of components• Interconnection between components• Other properties of components (physical properties, text

description, etc.)

Interconnections

waist

neck

base and body torso and head torso and arms

shoulders

1 2

Page 4: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Local Coordinates and World Coordinates

World Coordinates (Global Coordinates): A global reference frame that contains all the models.

Local Coordinates (Modeling Coordinates, Master Coordinates): Coordinate system that is attached to an individual component.

x

y

World coordinate system

Page 5: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Local coordinate systems

robot base body

headtorso arm

x

y

x

y

x

y

x

y

x

y

x

y

Page 6: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Modeling Transformation

Modeling Transformation: Transform model components from local coordinate system to world coordinate system.

Two different views of modeling transformation:• Global View: Transform object in world coordinate system• Local View: Transform local coordinate system of an object

Page 7: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Global View:

Local View:

Rz(45)

Rz(45)

T(10, 0, 0)

T(10, 0, 0)

Page 8: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Global View:

Local View:

T(10, 0, 0)

T(10, 0, 0)

Rz(45)

Rz(45)

Page 9: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

The following two views are equivalent for composite transformation:M = Mn Mn-1 ... M2 M1

Global View:• Transform the object with M1.• Transform the object with M2.• . . .• Transform the object with Mn.• Draw the object in world coordinate system.

Local View:• Transform the local coordinate system with Mn.• Transform the local coordinate system with Mn-1.• . . .• Transform the local coordinate system with M1.• Draw the object in local coordinate system.

Transformation of local coordinate system is relative to itself

Page 10: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

In hierarchical tree structure, each tree node stores transformation matrix from its parent’s local coordinate system to its own local coordinate system.

x

y

robotM IM base

Page 11: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

waist

)(0),(,0 21 ytbbody ll RTM IM torso

neck

)(0),(,0 21 yhthead ll RTM

Page 12: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

left shoulder

1

0,,0)(0,),( 21

121

21

axtat

leftarm

llww TRT

M

right shoulder

2

0,,0)(0,),( 21

221

21

axtat

rightarm

llww TRT

M

Page 13: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Hierarchical Tree Traversal

Tree_traverse( NODE n, MATRIX M ){

M1 = local transformation matrix of n;M = M M1;if (n is a leaf){

Set current transformation matrix to M;Draw object associated with leaf n;

}else{

for (each child node n1 of n)Tree_traverse( n1, M );

}}

NODE: Data structure for hierarchical tree nodeMATRIX: Data structure for 4 by 4 transformation matrix

Page 14: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Example for the robot:

Draw_robot( MATRIX M ){

Draw_base( M );Draw_body( M );

}

Draw_base( MATRIX M ){

M = M Mbase;Set current transformation matrix to M; Draw geometric structure for base;

}

Draw_body( MATRIX M ){

M = M Mbody;Draw_torso( M );Draw_head( M );Draw_arm( M Mleftarm );Draw_arm( M Mrightarm );

}

Page 15: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Draw_torso( MATRIX M ){

M = M Mtorso;Set current transformation matrix to M; Draw geometric structure for torso;

}

Draw_head( MATRIX M ){

M = M Mhead;Set current transformation matrix to M; Draw geometric structure for head;

}

Draw_arm( MATRIX M ){

Set current transformation matrix to M; Draw geometric structure for arm;

}

Page 16: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Physics Based Modeling

Particle Systems

Collection of particles moving under external forces. Can be used to model clouds, smoke, fire, fireworks, explosion, waterfalls, fountain, etc.

Particle Properties:• position• velocity• mass• age• life span• shape, color, texture, etc.

Particle System• Particle generation and annihilation• External force field construction• Particle movement control• Particle rendering

Page 17: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Particle generation and annihilation

Controlled randomization on initial properties of particles

Fireworks Fountain Waterfall

while (…){

Get elapsed time dt;n = generation rate * dt;Generate n new particles;for (each particle){

Update particle velocity and position;age += dt;if (age > life span) delete particle;

}}

Page 18: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

External force field construction

Gravity

Buoyant force

),0,0( mgF

Sine wave

),0,0( gVF

Air friction

)sin( xLAF tvvF

1 kc

Add randomization to the force field

Particle movement control

Newtonian lawmdt

d Fx

2

2

Numerical time integration

t

tm

vxx

avv

Fa

Page 19: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Particle rendering

Render particle as a texture mapped quad

The quad should always face the viewer (billboard effect)

F: Camera Forward DirectionU: Camera Up DirectionR: Camera Right DirectionP: Particle Positiona: Particle Size

P

F

U

R

A

B

C

D

URPD

URPC

URPB

URPA

22

22

22

22

aa

aa

aa

aa

Page 20: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Cloth simulation using Mass-Spring model

A number of particles with mass interconnected by springs

(i, j) (i+1, j) (i+2, j)

(i, j+1)

(i, j+2)

(i+1, j+1)

Page 21: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Types of springs

(i, j) (i+2, j)

(i, j+2)

(i, j) (i+1, j)

(i, j+1)

(i, j) (i+1, j)

(i, j+1) (i+1, j+1)

Tensile spring Shear spring

Bending spring

Page 22: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Spring forces

xi

xjvi

vj

Elastic force

Damping force

mass particle original position position velocity

i x0i xi vi

j x0j xj vj

ij xxR Rll

Rr 00

0 ijl xx

rFF )( 0llkijjielastic

ijelastic

rrvvFF )( ijijjidamp

ijdamp c

Page 23: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Dynamic equations for mass particles

i

j

ijdamp

ijelasticexti

to connected all

)( FFFF

i

ii

mdt

d Fx

2

2

Numerical time integration

t

tm

iii

iii

i

ii

vxx

avv

Fa

Collision detection and collision response

Page 24: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Examples

Page 25: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Skeletal Animation

Hierarchical Bone Structure

neckright

shoulder

right elbow

right wrist

left shoulder

left elbow

left wrist

chest

waist

hip

right thigh

right knee

right ankle

left thigh

Left knee

left ankle

hip

waist

right thigh left thigh

chest

neckright shoulder

left shoulder

right elbow

right wrist

left elbow

left wrist

right knee

right ankle

Left knee

left ankle

Joint tree

Page 26: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Joint Transformations

For joint i:Tilocal: Position relative to its parent joint

Rilocal: Rotation transformation relative to its parent joint

Tiworld: Position in world coordinate system

Riworld: Rotation transformation in world coordinate system

Assume joint i’s parent is joint j, then:

locali

worldj

worldi RRR

locali

worldj

worldj

worldi TRTT

Page 27: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Vertex Skinning

Each vertex is attached to one or more joints

For vertex i:wij: Weight for joint jPijlocal: Position in joint j’s local coordinate systemPiworld: Position in world coordinate system

j

localij

worldj

worldjij

worldi w PRTP

Page 28: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Key Frame Animation

Key frames

Frame 0 Frame 1 Frame 2 ......

tt t

......

Frame interval: tFrame rate: 1/t

Page 29: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Key Frame Interpolation

Frame k Frame k+1

t

t

Intermediate Frame

h

t

hs

Position interpolation

1)1( kk ss TTT

)10( s

Page 30: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Slerp (Spherical Linear Interpolation) for rotation

Linear interpolation Slerp

Slerp in 2D

A

B

P

BAP vu

cos

cos

1

PA

BA

P

sin

sinsin

)sin(

v

u

BAP

sin

sin

sin

)sin(

Page 31: Hierarchical Modeling Model: Representation of a system Modeling: Creation and manipulation of a system representation Geometric Model: Graphical representation.

Quaternion Slerp

1sin

sin

sin

)1(sin

kk qs

qs

q

1cos kk qq

When cos > 0

1sin

sin

sin

)1(sin

kk qs

qs

q

When cos < 0

coscos