Game Development Reference
In-Depth Information
Building the ODE physical library
This recipe is dedicated to the building of the open source ODE (Open Dynamics Engine)
physical simulation library, which is one of the oldest rigid body simulators for
interactive applications.
Getting ready
Download the most recent source code from the library home page: http://www.ode.org/
download.html .
How to do it...
1.
Compiling ODE is no different from other libraries. One subtle point, is the selection
between single and double loating-point precision. Standard compilation
involves the autoconf and automake tools, but here we just prepare Android.
mk , makefile as usual, and odeconfig.h . We need to deine either the dDOUBLE
or dSINGLE symbol there to enable the single or double precision calculations.
There is this line in the beginning of the odeconfig.h ile:
#define dSINGLE
2.
It enables the single-precision, 32-bit loating point calculations which are suficient
for simple interactive applications. Changing the value to dDOUBLE enables the
double-precision, 64-bit loating point calculations:
#define dDOUBLE
3.
ODE is rather complex software and it includes the Ice collision detection library,
which unfortunately, has compilation problems when the strictest possible settings
of the Clang compiler are used. However, it is easily ixed by commenting out the
contents of the _prefetch function in the OPCODE/Ice/IceUtils.h ile.
How it works...
Since ODE calculates positions and orientations of the rigid bodies in 3D space, we have to
set up a tiny 3D rendering pipeline on top of the simple 2D rendering we have done in this
chapter. To demonstrate the ODE library we cannot avoid some 3D math. All objects in the
scene (world) have their coordinates and orientations speciied as a pair of values consisting
of a 3D vector and a quaternion. We convert them to a 4 x 4 afine transformation matrix.
Then, we follow the chain of coordinate transforms: we convert the object space to world
space, world space to camera space and the camera space to post-perspective space with
a multiplication by the projection matrix.
 
Search WWH ::




Custom Search