Scene Graphs Anthony Steed 1999 2005 1 Scene

  • Slides: 19
Download presentation
Scene Graphs ©Anthony Steed 1999 -2005 1

Scene Graphs ©Anthony Steed 1999 -2005 1

Scene Graph Overview Building Scene Structures n Traversal n Examples n Instancing and Re-Use

Scene Graph Overview Building Scene Structures n Traversal n Examples n Instancing and Re-Use n More Transformations n 2

Concept of Scene Graph n n n Objects placed relative to one another Objects

Concept of Scene Graph n n n Objects placed relative to one another Objects made of similar components Directed acyclic graph Links are transformations Nodes are empty or contain geometry The root of the graph corresponds to “world coordinates” Root 3

Use for Animation/Modelling Hand Fore Elbow Upper Shoulder Base 4

Use for Animation/Modelling Hand Fore Elbow Upper Shoulder Base 4

Robot as a Graph n n n Each node other than root contain a

Robot as a Graph n n n Each node other than root contain a piece of geometry Each link is a transformation matrix, MB, MS, etc. Main concept is that robot can be posed by changing rotation in Shoulder and Elbow Root MB Base Shoulder Upper MS MU ME Elbow Fore Hand MF MH 5

Local Coordinates n n Each part of the robot is modelled in its own

Local Coordinates n n Each part of the robot is modelled in its own local coordinate (LC) system Local coordinates are defined by the person modelling the system Choice is determined by convenience Common choices: Base p. B 2=(2, 1) p. B 1=(2, 0) Shoulder • The centre of the object • A corner of the object p. H 1=(2, 0. 5) Hand 6

World Coordinates Everything is eventually positioned relative to the world coordinates (WC) or room

World Coordinates Everything is eventually positioned relative to the world coordinates (WC) or room coordinates n We know how to convert WC to viewing coordinates (VC) – it’s the general camera model n Eventually we need to convert points in an object’s LC into WC n 7

Local Transform n An object’s local transformation maps LC to the parent’s LC •

Local Transform n An object’s local transformation maps LC to the parent’s LC • • • n shoulder is translation (0 1 0) from base (MS) upper arm is translation (0 3 0) from shoulder (MU) elbow is translation (0 3 0) from upper arm (ME) fore arm is rotation Z by 90 then translation (0 2 0) (MF) Etc. Note that directions such as “up” depend on what transformations have been defined by ancestors in the tree 8

Rendering Traverse Must get object definitions in WC before passing to camera n For

Rendering Traverse Must get object definitions in WC before passing to camera n For a vertex in the Base object n • p. MB is in WC Matrices are inherited down stack n So for object under shoulder n • p. MSMB is in WC • (Note that p. MS is in the local coordinates of the base!) 9

Implementation n Generally implemented by a straightforward recursive descent Root • “push” on graph

Implementation n Generally implemented by a straightforward recursive descent Root • “push” on graph descend • “pop” on graph ascend n The concatenation of all LT matrices above a node is called the current transformation matrix (CTM) 10

Sharing Nodes n n n Root A common “pattern” T 0 found in a

Sharing Nodes n n n Root A common “pattern” T 0 found in a scene graph Pair. Tables is a multiply instanced geometry T 1 One table many places T 2 Node Table 1 has CTM T 1 T 0 Node Table 2 has CTM Table 2 T 2 T 0 Table 1 T 3 T 4 T 3 =T 4 = I So Table. Geom appears in two different positions Table. Geom 11

Spherical Coordinates n Represent a point on a using two angles and . Where

Spherical Coordinates n Represent a point on a using two angles and . Where r = length(x, y, z) Z P (x, y, z) Y j O q Q X Q is projection of P onto XY plane is angle between X axis and OQ is angle between OP and Z axis 12

Spherical Coordinates Length OQ = r sin( ) n So n • x =

Spherical Coordinates Length OQ = r sin( ) n So n • x = r sin( )cos( ) • y = r sin( ) • z = r cos( ) 13

Rotation About an Arbitrary Axis Z p 2 Y O p 1 X 14

Rotation About an Arbitrary Axis Z p 2 Y O p 1 X 14

… 1. Translate p 1 so it is at the origin 2. Let p

… 1. Translate p 1 so it is at the origin 2. Let p 3 = p 2 -p 1 (new position of p 2) find spherical co-ordinate of p 3 (r, , ) 3. Rotate about Z by - to bring p 3 into ZX plane 4. Rotate about Y by - to bring p 3 onto Z axis 5. Now rotate about Z by 6. Invert steps 4 -1 15

… Z p 3 p 2 Z Y Y O p 1 Start O

… Z p 3 p 2 Z Y Y O p 1 Start O Translate 16

… p 3 Z Z Y Y Rotate 1 Rotate 2 17

… p 3 Z Z Y Y Rotate 1 Rotate 2 17

… p 3 n Z Y n Now we apply the transformation we are

… p 3 n Z Y n Now we apply the transformation we are after Invert steps 4 -1 After Steps 1 -4 18

Scene Graph Recap Use of scene graph to model environments n Notion of render

Scene Graph Recap Use of scene graph to model environments n Notion of render traversal and the current transformation matrix n Instancing and sharing of nodes n Rotation of objects around an arbitrary axis n 19