Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Scenes
Boris Reuderink
University of Twente, faculty of EEMCS
b.reuderink(a)student.utwente.nl
5. PREPROCESSING
5.1 Splitting
In order to cull away large portions of the scene when the scene
is rendered, it is necessary to split the scene in smaller parts.
These smaller parts can be drawn independently. In 3D, an
object can be split into two halves using a plane. This process is
drawn in Figure 4.
Figure 2 - Vertices
n = (b - a) × (c - a)
Listing 1 splitObject()
two triangles (1, 4, 5) and (1, 5, 3). An outline of this splitting
algorithm is given in Listing 2.
Now it is possible to split triangles using a splitting plane, an
object can be split by splitting all its triangles. All new triangles
on the front side of the splitting plane belong the sub object on
the front side; all triangles on the backside belong to the sub
object on the backside. An outline is given in pseudocode in
Listing 1.
Note that the two half objects are not closed any more.
When an object is split it's intersection with the splitting plane
has to be computed. A case of this problem is shown Figure 5.
The intersection is bounded with the vertices that were created
during splitting. The normal vectors of the planes that go
through the triangles that are split are projected onto the
splitting-hyperplane for each edge on the splitting plane. Now Figure 5 - Split an object using a splitting plane
we have edges lying on the splitting-hyperplane, with a vector
pointing away from the intersecting area. If the intersection is
calculated for multiple objects, their intersection with the
splitting-hyperplane can overlap. This overlap can be removed
5.2 Recursive subdivision
When the preprocessing starts, all we have is one big scene,
using a Boolean operation in 2D. The normals vectors are used
conforming to the rules stated before. For effective culling, the
by the Boolean operation. See for an algorithm [Weiler80]. The
scene will be subdivided into smaller parts. There are different
resulting polygon covers the intersection with the hyperplane.
ways to split the scene, such as octrees and BSP-trees
We now have defined the tool we will use during the process of [FFGH97]. We will use a specialized form of the BSP-tree,
spatial subdivision. namely the axis-aligned BSP-tree. An axis-aligned BSP-tree
(AABSP-tree from now on) is a regular BSP-tree, but the
splitting planes are guaranteed to be axis-aligned. This
splitTriangle(triangle, plane) limitation makes it possible to optimize the calculations. Later
{
Polygon front, back;
we will see this it has other implications, which will become
foreach Edge e in triangle beneficial.
{ An AABSP-tree was chosen instead of a BSP-tree because in an
if(onBack(e.v1) && onBack(e.v2))
back.add(e); architectural scene the large occluders are likely to be axis-
if(onFront(e.v1) && onFront(e.v2)) aligned too. A normal BSP-tree allows all orientations for
front.add(e); splitting planes, which complicates the heuristic for selecting a
else splitting plane.
{
Edge se = intersection(plane, e); An octree is axis aligned, but it subdivides space into eight
if(onBack(e.v1)) equal parts. This results in a lot of unnecessary splits.
{
back.add(Edge(e.v1, se)); The AABSP-tree of the scene is calculated recursively. First, a
front.add(Edge(se, e.v2)); splitting-plane has to be determined. When we start, we have no
}
information besides the volume of the scene. We select a
else
{ splitting-plane perpendicular to the largest dimension of the
front.add(Edge(e.v1, se)); scene, so the subspaces we will end up with will not become to
back.add(Edge(se, e.v2)); irregular.
}
} The whole scene is split using this splitting-plane. The
} intersection of the scene with splitting plane is calculated, and
return (front, back); stored along with the splitting-plane. Now we have two halve
}
scenes, defined by a splitting-plane. For each halve, the process
Listing 2 splitTriangle() is repeated. See Figure 6. First, the scene is split using a vertical
hyperplane. The red part of the splitting plane represents the
intersection of the splitting plane with the scene. The left
subspace is further subdivided; the right sub space is simple
enough to remain as it is. The splitting of the left subspace
generates another splitting plane, and an associated intersection.
The upper part of the left subspace is then subdivided again.
Figure 7 - Sudvision in a more complex scene