Hierarchical Transformations and Models CSE 3541 Matt Boggus

Preview:

Citation preview

Hierarchical Transformations and Models

CSE 3541Matt Boggus

Overview• Previously – Modeling Transformations

– Translate, Rotate, Scale (Fortress Quest)

• Parenting in Unity• Scene Modeling – instances• Hierarchical modeling

– Place model pieces relative to other model pieces– Place objects relative to other objects– Tree representation and traversal

• Examples– Robot arm– Humanoid robot– Scene graphs

Unity parenting and lab2 demo

ParentingExample Unity Package

Modeling Objects

• A model has a default size, position, and orientation

• Modeling transformations set its appearance within the scene

Create a unit cylinder with its origin at (0,0,0)

Instance Transformation

• Start with an object – a symbol• Each appearance of the object in the scene is

an instance– Has its own scale, rotate, and translate

Symbol-Instance Table

Store a model by assigning a number to each symbol and storing the parameters for the instance transformation

Scene example

Critical Thinking – Symbol-Instance Table

• What does not have the be recomputed when using a symbol-instance table?

A. Vertex positions in local/model spaceB. Transformation matricesC. BothD. Neither

Symbol-Instance table efficiency

• 1 scale, 1 rotate, and 1 translate for each house

• Symbol-instance tables reuse data, but not the result of transformations

Draw a robot

Images by Denis Zorin

Draw a robot

Images by Denis Zorin

Draw a robot

• Positioning individual parts is hard• If the whole robot moves

– Reposition everything• If only the upper arm moves

– Reposition the upper and lower arm

• Divide the robot into pieces!– Combine as a hierarchy

Graphs

• Set of nodes and edges (links)• Edge connects a pair of nodes

– Directed or undirected• Cycle: directed path that is a loop

loop

Tree

• Graph in which each node (except the root) has exactly one parent node– May have multiple children– Leaf or terminal node: no children

root node

leaf node

Robot as a hierarchya.k.a. tree or directed acyclic graph

Images by Denis Zorin

Modeling with Trees/Graphs

• Nodes– What to draw– Pointers to children

• Edges– May have information on incremental changes to

transformation matrices (can also store in nodes)

Robot Arm

robot arm parts in their own coordinate systems

Articulated Models

• Robot arm is an example of an articulated model– Parts connected at joints– Can specify state of model by

giving all joint angles

Relationships in Robot Arm

• Base rotates independently– Single angle determines position

• Lower arm attached to base– Its position depends on rotation of

base– Must also translate relative

to base and rotate about connecting joint

Relationships in Robot Arm

• Upper arm attached to lower arm– Its position depends on both

base and lower arm– Must translate relative to

lower arm and rotate about joint connecting to lower arm

Required Matrices

• Rotation of base: Rb

– Apply M = Rb to base

• Translate lower arm relative to base: Tla

• Rotate lower arm around joint: Rla

– Apply M = Rb Tla Rla to lower arm

• Translate upper arm relative to lower arm: Tua

• Rotate upper arm around joint: Rua

– Apply M = Rb Tla Rla Tua Rua to upper arm

Tree Model of Robot

• Note code shows relationships between parts of model– Can change “look” of parts

easily without altering relationships

• Simple example of tree model• Want a general node structurefor nodes

A Chain of Transformations

1

0

0

1

Ty

x

e

e

100

010

01

100

0cossin

0sincos

100

010

01

100

0cossin

0sincos 2

22

221

11

11

2211

ll

translrottranslrotT

2

11l

X Y

2l

X

Y

Thinking of Transformations• In a view of body-attached coordinate system

100

010

01

100

0cossin

0sincos

100

010

01

100

0cossin

0sincos 2

22

221

11

11

2211

ll

translrottranslrotT

X

Y

X Y

X

Y

Thinking of Transformations• In a view of body-attached coordinate system

1X

Y

100

010

01

100

0cossin

0sincos

100

010

01

100

0cossin

0sincos 2

22

221

11

11

2211

ll

translrottranslrotT

Thinking of Transformations• In a view of body-attached coordinate system

11L

X Y

X

Y

100

010

01

100

0cossin

0sincos

100

010

01

100

0cossin

0sincos 2

22

221

11

11

2211

ll

translrottranslrotT

2

11L

X Y

Thinking of Transformations• In a view of body-attached coordinate system

X

Y

100

010

01

100

0cossin

0sincos

100

010

01

100

0cossin

0sincos 2

22

221

11

11

2211

ll

translrottranslrotT

2

11L

X Y

2L

Thinking of Transformations• In a view of body-attached coordinate system

X

Y

100

010

01

100

0cossin

0sincos

100

010

01

100

0cossin

0sincos 2

22

221

11

11

2211

ll

translrottranslrotT

Thinking of Transformations• In a view of global coordinate system

X

Y

X Y

100

010

01

100

0cossin

0sincos

100

010

01

100

0cossin

0sincos 2

22

221

11

11

2211

ll

translrottranslrotT

Thinking of Transformations• In a view of global coordinate system

X

Y

2L

X

Y

100

010

01

100

0cossin

0sincos

100

010

01

100

0cossin

0sincos 2

22

221

11

11

2211

ll

translrottranslrotT

2

X Y

2L

Thinking of Transformations• In a view of global coordinate system

X

Y

100

010

01

100

0cossin

0sincos

100

010

01

100

0cossin

0sincos 2

22

221

11

11

2211

ll

translrottranslrotT

Thinking of Transformations• In a view of global coordinate system

21L

X Y

2L

X

Y

100

010

01

100

0cossin

0sincos

100

010

01

100

0cossin

0sincos 2

22

221

11

11

2211

ll

translrottranslrotT

Thinking of Transformations• In a view of global coordinate system

2

11L

X Y

2L

X

Y

100

010

01

100

0cossin

0sincos

100

010

01

100

0cossin

0sincos 2

22

221

11

11

2211

ll

translrottranslrotT

Robot as a hierarchy(save intermediate transformations)

Images by Denis Zorin

Scene Graphs

• Encoding the information in software lacks reusability

• Want a flexible, data-driven and extensible approach

• Scene-graphs– OpenInventor (http://www.coin3d.org/)

– Open Scene Graph (http://www.openscenegraph.com/)

– Many others

Scene Graph• Convenient Data structure for scene representation

– Transformations– Materials, color– Multiple instances

• Basic idea: Hierarchical Tree• Useful for manipulation/animation

– Especially for articulated figures• Useful for rendering too

– Multi-pass rendering, occlusion culling

Sample Scene

Hierarchical scene – chair 1

Hierarchical scene – chair 2

Hierarchical scene - chessboard

White chess pieces – child of chessboard

Rook piece – child of white chess pieces

Recommended