Scene Graphs Anthony Steed 1999 2002 1 Scene
















- Slides: 16

Scene Graphs ©Anthony Steed 1999 -2002 1

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

Concept of Scene Graph Objects placed relative to one another n Objects made of similar components n Directed acyclic graph n root 3

Use for Animation/Modelling 4

n One object has a local transformation relative to its parent • shoulder is translation (0 1 0) from base • upper arm is translation (0 3 0) from shoulder • elbow is translation (0 3 0) from upper arm • fore arm is rotation Z by 90 then translation (0 2 0) 5

Rendering Traverse Must get object definitions in WC before passing to camera n For object under Base n • p. B is in WC “inherit” matrices down stack n So for object under shoulder n • p. SB is in WC • (p. S is in base coordinates) 6

In general n On traverse • “push” on graph descend • “pop” on graph ascend n Combined matrix is current transform (CTM) 7

Sharing Nodes E. G. One table many places n Table 1 has CTM T 1 T 0 n Table 2 has CTM T 2 T 0 n T 1 T 2 table 1 table 2 table 8

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 9

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

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

… 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 12

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

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

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

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 16