Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Scene Graphs ©Anthony Steed 1999-2005. 2 Scene Graph Overview n Building Scene Structures n Traversal n Examples n Instancing and Re-Use n More Transformations.

Similar presentations


Presentation on theme: "1 Scene Graphs ©Anthony Steed 1999-2005. 2 Scene Graph Overview n Building Scene Structures n Traversal n Examples n Instancing and Re-Use n More Transformations."— Presentation transcript:

1 1 Scene Graphs ©Anthony Steed 1999-2005

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

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

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

5 5 Robot as a Graph n Each node other than root contain a piece of geometry n Each link is a transformation matrix, M B, M S, etc. n Main concept is that robot can be posed by changing rotation in Shoulder and Elbow Root Base Shoulder Upper Elbow Fore Hand MBMB MSMS MUMU MEME MFMF MHMH

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

7 7 World Coordinates n 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

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

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

10 10 Implementation n Generally implemented by a straightforward recursive descent “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) Root

11 11 Sharing Nodes n A common “pattern” found in a scene graph is a multiply instanced geometry n One table many places n Node Table1 has CTM T 1 T 0 n Node Table2 has CTM T 2 T 0 n T 3 =T 4 = I n So TableGeom appears in two different positions TableGeom Table2 Table1 T1T1 T2T2 T0T0 PairTables T3T3 T4T4 Root

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

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

14 14 Rotation About an Arbitrary Axis Z X Y O p1 p2 

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

16 16 … Z Y O p1 p2 Z Y O p3 StartTranslate

17 17 … Z Y p3 Rotate1 Z Y p3 Rotate2 

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

19 19 Scene Graph Recap n 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


Download ppt "1 Scene Graphs ©Anthony Steed 1999-2005. 2 Scene Graph Overview n Building Scene Structures n Traversal n Examples n Instancing and Re-Use n More Transformations."

Similar presentations


Ads by Google