Game Development Reference

In-Depth Information

be determined by locating each surface whose bounding volume reaches within a

certain distance of the point
P
. For each potentially affected surface, we individ-

ually examine every triangle in the surface's mesh. Let
M
denote the unit normal

direction corresponding to the plane of a triangle in the mesh. We throw out any

triangles for which

N M
for some fixed positive value
ε
since these triangles

are facing away from the decal's normal direction
N
. The remaining triangles are

clipped to the planes given by Equations (9.12) and (9.13) and stored in a new

triangle mesh.

When a triangle overlaps any of the planes and needs to be clipped, we inter-

polate the normal vectors as well as the vertex positions so that we can later ap-

ply coloring to the clipped vertices that reflects the angle between each vertex's

normal direction and the decal's normal direction. This has the effect of smoothly

fading the decal texture in relation to each triangle's orientation relative to the

plane of the decal. We assign an alpha value to each vertex using the equation

⋅

<

ε

NR

R

⋅

−

ε

alpha

=

,

(9.14)

1

−

ε

where
R
is the (possibly unnormalized due to interpolation) normal vector corre-

sponding to the vertex. This maps the dot product range

]

[

,
ε
to the alpha value

]

range

0,1 .

Texture mapping coordinates are applied to the resulting triangle mesh by

measuring the distance from each vertex to the planes passing through the point

P
and having normal directions
T
and
B
. Let
Q
be the position of a vertex in the

decal's triangle mesh. Then the texture coordinates
s
and
t
are given by

[

(

)

TQP

⋅

−

1

2

1

2

s

=

+

w

(

)

BQP

⋅

−

.

(9.15)

t

=

+

h

9.2.2 Polygon Clipping

Each triangle belonging to a surface that could potentially be affected by the de-

cal is treated as a convex polygon and clipped to each of the six boundary planes,

one at a time. Clipping a convex polygon having
n
vertices to a plane results in a

new convex polygon having at most

vertices. Thus, polygons that have been

clipped against all six planes may possess as many as nine vertices. Once the

n

+

1

Search Nedrilad ::

Custom Search