31
Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

Embed Size (px)

Citation preview

Page 1: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

Managing Your Objects

Paul Taylor 2009Assignment Due Fri 5/6/2009

Page 2: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

What is an Object

• A Bunch of Polygons (or one), or a Sprite• Each Object can have:– A Translation– A Rotation– A Scale– A Shear (not super common)

Page 3: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

Our Test Objects

• A Sweet Car!

Page 4: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

The Simplest Representation

• Car Body Translation, Rotation and Scale• Wheel 1 Translation, Rotation and Scale• Wheel 2 Translation, Rotation and Scale

Page 5: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

ScaleRotateTranslate

ScaleRotateTranslate

ScaleRotateTranslate

Page 6: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

Using Hierarchical Objects

Page 7: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

With our Matricies

ScaleRotateTranslate

ScaleRotateTranslate

ScaleRotateTranslate

Page 8: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

Directed Acyclic Graphs (DAG)

• Technically this is a Specialised case of a Directed Graph

• The rule is there are no paths that start at a vertex and end at the same vertex (No Loops)

Page 9: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

What is the benefit?

We can Reuse Objects

Cars have four wheelsA flock of birds may all be the same

A turret may have 4 Cannons

Page 10: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

Sweet Car utilising a DAG

Page 11: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

Connecting All your Objects

• We are creating a Scene Graph

Page 12: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

In effect Object Storage Looks Like

Root

Child 1

Child 2 Sibling 1 Sibling 2

Sibling 2 Child 1

Sibling 2 Child 2

Sibling 2 Child 2 Sibling 1

Child 3

Page 13: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

Creating Bounding Boxes

BBs are typically used For Collision DetectionWith a Hierarchical Object generation can still be

relatively simple.Outlier detection in X Y Z and –X-Y-Z directionsA Bounding Sphere simply needs the most

distant vertex from the Object CenterMore Complicated routines can be used, or you

can use a Human!

Page 14: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

Constructive Geometry

• Not generally used during real time renders• Consist of using Logical Operators on Polygon

Objects to combine them– Intersections, Unions and Difference

• A Typical Use of Constructive Geometry is in 3D Game Level creation and CAD Design

Page 15: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

Constructive Solid Geometry CSG

• http://dic.academic.ru/pictures/enwiki/67/Csg_tree.png

Page 16: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

• http://brlcad.org/gallery/d/242-3/csg_example.png

Page 17: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

We have our Objects Nicely packed

• Why?• To Create Structures that define the 3D Worlds

we are creating• Intersecting the Bounding Boxes/Spheres in

the game world is much faster.• Once we know that 2 objects intersect (via BB

collision) we can go deeper into the collision (If needed)

Page 18: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

Space Subdivision

We have already covered BSP Trees, now we will look at 1 1/2 more Space Partitioning methods

Oct-TreesKD-Trees

Page 19: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

Quad-Trees

Quad Trees are the 2D baby brother of Oct TreesComputationally similar, conceptually easierSpace is Divided into 4 areasIf more than one object exists ina region it is again subdividedinto 4 sub-regions, and so on….

Page 21: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009
Page 23: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

Oct-Trees

• http://en.wikipedia.org/wiki/File:Octree2.png

Page 25: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

KD-Trees

• A specialisation of Binary Trees (Similar to BSP Trees)

• In a similar way to Oct Trees a KD Tree splits space in an Axis Aligned Fashion.

• Different to Oct-Trees a KD Tree does not always split the world into even parts

Page 26: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

KD-Trees

• http://en.wikipedia.org/wiki/Kd-tree

Page 28: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

What else can you do?

• Oct-Trees and KD-Trees can be used for:– View Frustum Culling– Occlusion Culling– Level of Detail Detection– Spatial Indexing (Similar to a BSP Tree)– Ray Casting

Page 29: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

Bringing it all together

• You organise all of your objects– Binary Tree, Object Tree, Hash Table etc

• You have a method of generating Collisions– Firstly by Simplifying objects

• Bounding Boxes, Spheres

– Secondly by finding Collisions between objects• Oct-Trees, KD-Trees

– Thirdly we can check the collision of the actual objects if required

• Finally we need to do something appropriate with the collision!

Page 30: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

That’s a lot of work!

Page 31: Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009

Open Scene Graph (OSG)

http://www.openscenegraph.org/Multipass Object Grouping and OrderingMiddleware that does Object HandlingThings you could do with it:• Prototyping• Offline Rendering• A Sluggish Game