Game Development Reference
In-Depth Information
* The explicit constructor creates a vector with the given
* components.
Vector3(const real x, const real y, const real z)
: x(x), y(y), z(z) {}
/** Flips all the components of the vector. */
void invert()
x = -x;
y = -y;
x = -z;
All the code is contained within the cyclone namespace, as promised in the
introduction to the topic. This makes it easier to organize code written in
C++, and in particular it ensures that names from several libraries will not
clash. Wrapping all the code samples in the namespace declaration is a waste
of time, however; so in the remaining excerpts in this topic, I will not show
the namespace explicitly.
Also to avoid clashing names, I have placed the header files in the directory
include/cyclone/ , with the intention of having the include/ directory on the
include path for a compiler (see your compiler's documentation for how to
achieve this). This means that to include a header we will use an include of
the format:
#include <cyclone/core.h>
#include "cyclone/core.h"
I find this to be a useful way of making sure the compiler knows which header
to bring in, especially with large projects that are using multiple libraries, sev-
eral of which may have the same name for some header files (I have at least
four math.h headers that I use regularly in different libraries—which is part of
my motivation for putting our mathematics code in a header called core.h ).
Search Nedrilad ::

Custom Search