Lecture10 – Scene Management

advertisement
Advanced
Scene Management
System
1
Scene Management in Hierarchical Form


A tree-based or graph-based representation is good for 3D data
management
 Scene tree
 Scene graph
3D data management including :
 Transformations for each 3D object
 Hierarchical relationship
 Space coherence
 Data instancing
 Geometric computation
 Hit test
 Collision detection
 Terrain following
 Rendering management
 Visibility
 Alpha Sorting
2
An Object in the Scene (An Example from TheFly)
Hierarchy
Parent Object
Parameters
Etc
Transformation
Move
Animation
Motion Data
Shape
Geometric Data
Clone
3
A Scene Tree (An Example) 1/2


A tree-based representation
A simplified scene graph
Root
4
A Scene Tree (An Example) 2/2


A tree-based representation
A simplified scene graph
Root
5
Bounding Volume

Bounding sphere
Bounding cylinder
Axis-aligned bounding box (AABB)
Oriented bounding box (OBB)

Discrete oriented polytope (k-DOP)



Bounding Sphere
Bounding Cylinder
AABB
k-DOP
OBB
6
Bounding Volume - Applications




Collision detection
Visibility culling
Hit test
Steering behavior
 In “Game AI” section
7
Application Example - Bounding Sphere
B2
B1
D
c2
c1
Bounding sphere B1(c1, r1), B2(c2, r2)
If the distance between two bounding spheres is
larger than the sum of radius of the spheres, than
these two objects have no chance to collide.
D > Sum(r1, r2)
8
Application Example - AABB

Axis-aligned bounding box (AABB)
 Simplified calculation using axis-alignment feature
 But need run-timely to track the bounding box
AABB
9
Application Example - OBB


Oriented bounding box (OBB)
 Need intersection calculation using the transformed OBB
geometric data
 3D containment test
 Line intersection with plane
For games, 
OBB
10
Advanced Scene Graphs






This is a game-type-oriented issue.
Bounding volume hierarchies (BVHs)
Binary space partition trees (BSP Trees)
 “Quake”
Octree & quadtree
Possible Visible Set
Culling Skills
11
Bounding Volume Hierarchies (BVHs)


Bounding spheres or AABB in hierarchy
Can be used for dynamic scene objects
R
B
12
BVH Construction - LBVH

LBVH
 Linear BVH
 Tree construction using Morton Code
13
Morton Code (1/2)

2D example

Generate the Morton Code
 Convert the x and y coordinate numbers into binary
 Then “interleave” the bits to get the Morton number
-0-0-1 : 1 in binary
1-0-1- : 5 in binary
xyxyxy
100011 : 35 Your interleaved Morton number
14
Morton Code (2/2)






By constructing a 2kx2kx2k lattice within the AABB of the whole scene,
we can quantize each of the 3 coordinates of the center of the
bounding volume of the scene object.
The 3-bit Morton Code of the object is constructed by interleaving the
successive bits of these coordinates.
Sorting the objects in increasing order along the Morton curve.
We construct the 1st level split by examining the most significant bit
of all codes, placing those with 0 and 1 bits in the 1st and 2nd child,
respectively, of the root.
Applying the bucketing procedures recursively in each child, looking at
the 2nd most significant bit.
In each recursive step, we look at the next bit in the Morton code
until all bits are consumed.
15
BVH Construction – SAH Hierarchy Construction

SAH


Surface Area Heuristic method
Calculate the cost to bin the tree node into two children
 SAH cost function
SA(N) the surface area of the node’s bounding volume
KT & KI are constants
nl : object number of left child node
nr : object number of right child node

Can be applied to BVH and KD Tree.
16
BSP Tree


Two variants
 Axis-aligned
 KD tree
 Polygon-aligned
The trees are created by using a plane to divide the space into two,
and then sorting the geometry into two spaces.
17
Axis-aligned BSP Tree
0
plane
plane
3
plane1
2
1
0
plane2
3
18
Polygon-aligned BSP Tree
F
A
C
G
B
A
B
C
D
E
D
E
F
G
19
Why BSP Tree ?




Quickly to identify where you are
 BSP = Sorting
Need a pre-processor to generate the PVS
 Visibility culling + occlusion culling
 PVS : Possible Visible Set
Optimized for in-door game environment
[Fuch80]
 Fuchs, H.,
 On Visible Surface Generation by a Priori Tree Structures,
 Computer Graphics, 14, 124-33, (Proc. SIGGRAPH’80)
20
Octree & Quadtree





Very similar to axis-aligned BSP tree.
Except that a box is split simultaneously along all three axes.
The split point should be the center of the box.
This creates eight new boxes.
Quadtree is the 2D version of octree.
21
Quadtree - Example
22
Octree – Some Discussion




Data structure coherence
Apply visibility culling from parents
Split or not split ?
Outdoor game scene ?
23
Culling (1/2)




Culling means “remove from a flock”
Visibility culling
 Remove the object not in view frustum
 A “must” feature within the game engine
Backface culling
 Remove the polygons facing away from camera
 Hardware standard
Occlusion culling
 Remove the objects hidden by the others
 A complicated issue for games
24
Culling (2/2)
View frustum
Occlusion
culling
eye
Visibility
culling
Backface
culling
25
BSP Implementation


A Pre-processor
 Space partition the scene data from artist
 Generate the BSP data structure
 Generate the PVS
BSP walk through
 Identify the room where you are
 Show/hide the rooms according to the PVS
 Perform terrain following & collision detection
 Or all interaction between the player’s character and the scene
26
BSP Preprocessor (1/2)


Input
 A scene from artist
 Cutting planes (optional)
 Can be procedurally generated by algorithm
 Cutting policy
 Split or not split
 Ray casting resolution for PVS
Output
 A BSP file
 BSP Tree
 PVS
 Geometry Data
27
BSP Preprocessor (2/2)

Process
 Generate the BSP tree according to the cutting policy
 Split or sort the geometry into BSP room (leaves)
 For each “room”, ray cast all rooms to generate the possible visible
room set
 2D layers or 3D
 Time consuming
28
BSP Challenges



Effectiveness of PVS
 Data set size
 The range
Hard for dynamic scene objects
 Apply BSP to static scene objects
 Apply visibility culling and collision detection to dynamic scene
objects
Room size
29
Download