Title: Estruturas de Dados Espaciais
1Estruturas de Dados Espaciais
2Speeding Up Ray Tracing
3Estruturas de Dados Espaciais
4Bounding Volumes
5Hierarquical Bounding Volume
6Grids
- Data structure a 3-D array of cells (voxels)
that tile space - Each cell points to list of all surfaces
intersecting that cell
7Mais sobre Grids
- Be Careful! The fact that a ray passes through a
cell and hits na object doesnt mean the ray hit
that object in that cell - Optimization cache intersection point and ray id
in mailbox associated with each object - Grids are a poor choice when the world is
nonhomogeneous (clumpy) - e.g. a teapot in a stadium many polygons
clustered in a small space - How many cells to use?
- too few Þ many objects per cell Þ slow
- too many Þ many empty cells to step through Þ
slow - Grids work well when you can arrange that each
cell lists a few (ten, say) objects - Better strategy for some scenes nested grids
8Octrees
9Which Structure is Best for Ray Tracing?
10K-d Trees and BSP Trees
11Building a BSP Tree
d
1
2
c
a
3
1
2
b
a
b
c
d
3
the subdivision of space it implies
a BSP tree using 2 as root
viewpoint
12Building the Tree 2
Using line 3 for the root requires a split
3
1
2a
2a
2b
3
2b
1
viewpoint
13Building a Good Tree - the tricky part
14Uses for Binary Space Partitioning (BSP) Trees
15Painters Algorithm with BSP trees
16Drawing a BSP Tree
front_to_back(tree, viewpt) if
(tree null) return if
(positive_side_of(root(tree), viewpt))
front_to_back(positive_branch(tree, viewpt)
display_polygon(root(tree))
front_to_back(negative_branch(tree, viewpt)
else draw negative branch
first
17Drawing Back to Front
Hidden surface removal
3
1
2a
2a
2b
3
2b
1
viewpoint
18Clipping BSP Trees
19Clipping BSP Trees
20Clipping Using Spatial Data Structures