Making a path

Coding a path

After making static 3D scenes, I've thought to move the camera along a predifined path. Basically, a path can be elaborated by a mathematic function or by using a list of points.

The use of a function can be costly in cpu time and difficult to define, how to define the function that could generate a complex path?

The use of a list of points may consume a lot of memory, how many points allow to define a complex path?

The answer is the use of an interpolation method and a reasonnable set of points that are called check points. For a good and smooth interpolation I've decided to use the Spline interpolation that uses low-degree polynomials in each of the intervals. Note that the path is automatically closed by using the interpolation method, this is why you must not close it.

A path is a polyline object

Basically, a path is an open polyline and thus a set of points. It is quite easy to draw an overlayed polyline over your 3D scene by using your favorite 3D modeler. Here is an example of such a path drawn with the 3D modeler (the path is the white polyline):


When the path is like the one you wish, you just have to export it to Wavefront OBJ format:


Then use my converter tool to export the path as binary resource (you can also save the reversed path, the order of point list is then reversed):

Now your path is ready to be used, you just have to embed the binary file as binary resource in your HB++ projet. The clsCameraPath class has methods for loading a path from binary resource and for moving the camera along this path.