hierarchical transformations and models cse 3541 matt boggus

42
Hierarchical Transformations and Models CSE 3541 Matt Boggus

Upload: sibyl-lawson

Post on 22-Dec-2015

220 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Hierarchical Transformations and Models CSE 3541 Matt Boggus

Hierarchical Transformations and Models

CSE 3541Matt Boggus

Page 2: Hierarchical Transformations and Models CSE 3541 Matt 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

Page 3: Hierarchical Transformations and Models CSE 3541 Matt Boggus

Unity parenting and lab2 demo

ParentingExample Unity Package

Page 4: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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)

Page 5: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 6: Hierarchical Transformations and Models CSE 3541 Matt Boggus

Symbol-Instance Table

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

Page 7: Hierarchical Transformations and Models CSE 3541 Matt Boggus

Scene example

Page 8: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 9: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 10: Hierarchical Transformations and Models CSE 3541 Matt Boggus

Draw a robot

Images by Denis Zorin

Page 11: Hierarchical Transformations and Models CSE 3541 Matt Boggus

Draw a robot

Images by Denis Zorin

Page 12: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 13: Hierarchical Transformations and Models CSE 3541 Matt Boggus

Graphs

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

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

loop

Page 14: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 15: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Images by Denis Zorin

Page 16: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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)

Page 17: Hierarchical Transformations and Models CSE 3541 Matt Boggus

Robot Arm

robot arm parts in their own coordinate systems

Page 18: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 19: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 20: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 21: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 22: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 23: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 24: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 25: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 26: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 27: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 28: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 29: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 30: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 31: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 32: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 33: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 34: Hierarchical Transformations and Models CSE 3541 Matt Boggus

Robot as a hierarchy(save intermediate transformations)

Images by Denis Zorin

Page 35: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 36: Hierarchical Transformations and Models CSE 3541 Matt Boggus

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

Page 37: Hierarchical Transformations and Models CSE 3541 Matt Boggus

Sample Scene

Page 38: Hierarchical Transformations and Models CSE 3541 Matt Boggus

Hierarchical scene – chair 1

Page 39: Hierarchical Transformations and Models CSE 3541 Matt Boggus

Hierarchical scene – chair 2

Page 40: Hierarchical Transformations and Models CSE 3541 Matt Boggus

Hierarchical scene - chessboard

Page 41: Hierarchical Transformations and Models CSE 3541 Matt Boggus

White chess pieces – child of chessboard

Page 42: Hierarchical Transformations and Models CSE 3541 Matt Boggus

Rook piece – child of white chess pieces