Game Development Reference
In-Depth Information
(6) x is not visible to the NPC.
−2
−3
0
−3
4
−
8
=
√
√
cos θ =
≈ 0.371 < 0.707
−2
−3
0
−3
4
(
29)(
16)
−
(7) x is not visible to the NPC.
−2
−6
−3.5
−3
4
−
0
cos θ =
=
√
29)(
√
65.25)
= 0 < 0.707
−2
−6
−3.5
−3
4
(
−
(c) The NPC can see a distance of only 7 units, so only those points that are both within
the FOV and within this distance will be visible.
(1) x is visible to the NPC.
√
0
0
−3
4
−4
−
=
=
25 = 5 < 7
(2) x is not visible to the NPC; it is outside the FOV.
(3) x is not visible to the NPC; it is outside the FOV.
(4) x is not visible to the NPC; it is outside the FOV.
(5) x is not visible to the NPC.
√
5
5
−3
4
8
1
−
=
=
65 ≈ 8.062 > 7
(6) x is not visible to the NPC; it is outside the FOV.
(7) x is not visible to the NPC; it is outside the FOV.
22.
(a) Let v
ab
= b−a and v
bc
= c−b. Since the three points lie in the xz-plane, the two
vectors also lie in the xz-plane and we have
2
4
3
5
2
4
3
5
x
ab
0
z
ab
x
bc
0
z
bc
v
ab
=
,
v
bc
=
.
Taking the cross product of the vectors in the order that the points are traversed
gives.
2
4
3
5
0
x
bc
z
ab
−x
ab
z
bc
0
v
ab
×v
bc
=
The sign of x
bc
z
ab
−x
ab
z
bc
can then be used to determine the NPC's turning direction.
Because we are working in a left-handed coordinate system, if the value is negative,
the NPC is turning counterclockwise; if it's positive he's turning clockwise. The
special case of 0 signifies that the NPC is either walking forward in a straight line or
walks forward and then back along the same line.
Search WWH ::
Custom Search