Game Development Reference
In-Depth Information
so fast that we
// might move forward two control points in
one frame.
if t >= 1.0f
index ++
t = t - 1.0f
end
// Should check that index+1 and index+2 are
valid points
// If not, this spline path is complete
...
ComputeMatrix()
end
end
Camera Support Algorithms
The implementations covered in the preceding section should provide enough in-
formation to get a camera that works on a basic level. But basic operation is only
a small part of implementing a successful camera. In order to implement a camera
that is useful for the player, additional support algorithms should be considered.
Camera Collision
Camera collision strives to solve a very common problem with many types of
cameras: when there is an opaque object between the camera and the target. The
simplest (though not the best) way to fix this is by performing a ray cast from
the target position to the camera position. If the ray cast collides with an object,
the camera can be moved to a position that's in front of the object that's blocking
the camera, as shown in Figure 8.12 . Unfortunately, this behavior can be jarring;
a more robust solution is to make a physics object representing the camera, but
that's beyond the scope of this section.
Search WWH ::




Custom Search