Documentation
FAQ
Q: The demos are rather slow, why?
A:The
ODE drawstuff library is only meant to visualize the
demos. They have never been optimized much for performance
and are therefore rather slow. This is NOT a problem with
lwjgl.
Q: Up
to version 0.12.0-j1.4 cylinder collision causes problems,
why?
A:
Cylinder
collision is somewhat problematic ion ODE 0.12.0. To solve
this one can use the alternative libCCD cylinder
colliders. They can be enabled by calling
OdeConfig.setLibCCDEndabled(true) before
doing anything else. From version 0.12.0-j1.4 on, libCCD
will become the default collider.
ode4j
documentation
This only contains ported javadoc and documentation
specific to the Java version of ODE. For documentation on
physics and mathematics please refer to the 'ODE
documentation' further down.
The demos in the source code provide good examples for many applications
Bugs can be reported here. ode4j also has a small wiki.
ODE documentation
ODE
docs
ODE-Wiki
ODE
community
GIMPACT
Home
libccd
Home
Further links:
http://www.essentialmath.com/tutorial.htm
http://realtimecollisiondetection.net/books/list
Performance & Multi-Threading
ode4j has some Java performance optimisations, leading to a
significant differences to the original code, mostly with
respect to the handling of DVector3
and DMatrix3 classes.
More improvements are on the way.
For evaluating performance, please do NOT use the demos!
They rely on the internal 'drawstuff' library. The way in
which drawstuff uses OpenGL is not optimal. While this
does not affect performance much under C/C++, it severely
affects performance when using the Java-OpenGL API
provided by lwjgl. In other words:
- When profiling any of the included demos, you will
see that most of the time is spent in OpenGL calls (at
least on my SUSE 11.1 64bit system / ATI Radeon HD
3850).
- As far as I can tell, this is not a problem with
lwjgl, but could be fixed by optimizing 'drawstuff'.
- To profile ode4j, please use applications that do
not use drawstuff. To profile the existing demos,
drawstuff can be disabled by calling
DS_API.dsSetOutputNull()
at the beginning of any demo.
- ode4j is in certain cases faster that ODE. I have
investigated this only briefly, but I have the
impression that Java can draw its advantage from using
the garbage collector for arrays. This means
de-allocation in Java occurs in a 2nd thread in
parallel to computations, while in C/C++ de-allocation
(which is expensive) occurs in the main thread.
Multi-Threading
The ODE threading model has been partly ported, but is not fully there yet.
So far there is only a simple approach to
multi-threading support by avoid mutable static fields.
That means ode4j can be used in a multi-threaded
environment under the following conditions:
- Any particular world should not be used be more then
one thread at a time, reading or writing
- Multiple worlds can be used in concurrently by
multiple threads as long as every world is only access
by a single thread at a given time
- A world can be passed around (and then used) between
threads simply by passing on the reference (this is
unlike ODE in C/C++)
- The method
OdeHelper.allocateODEDataForThread(int)
does not need to be called as it does nothing (and
never did). Actually it will be removed in one of the
next releases.
-
OdeHelper.init2(...) needs to be
called only once per application, not for every thread
(in fact, calling it multiple times should fail).
OdeHelper.init2(...) needs to have
returned before any thread uses ode4j.
- A future release may introduce more powerful
multi-threading.
Differences to ODE for C/C++
- API: The preferred API of the ODE projects appears
to be the C API (it is more complete and contains all
the documentation). The preferred API in ode4j is the
OO-API.
- Class names all start with a 'D' rather than 'd'.
- The d***ID types have not been ported. Simply use
the according D*** interfaces. Also, the type
hierarchy has changed, the D*** classes are now
interfaces that are implemented by the according Dx***
classes.
- Main access points in ode4j are
OdeHelper
(initialisation methods and a factory for creating
most classes), OdeConfig (for
configuration) and OdeConstants
(providing many of the contants used in ode4j).
- Some of the math has been moved inside the
DVector3
and DMatrix3 classes.
- ode4j provides
DVector3C and DMatrix3C
interfaces that provide immutable encapsulation.
Methods
- All global methods have the leading 'd' removed and
the 2nd letter lowercased. Most of the global methods
can be found in
OdeHelper . For example:
dInitOde2(...) -> OdeHelper.initOde2(...) .
- All 'create' methods have the 'create' moved to the
beginning:
OdeHelper.createMass() .
- To find the Java method name for a global C method,
one can usually remove the dClassName from the
beginning and remove the first argument, for example
dJointAttach(
myJoint, b1, b2 ) becomes myJoint.attach(
b1, b2 ) . This is also valid when looking for
C++ function names in ODE itself.
Another example: dJointSetPistonAnchor (
piston, ... ); becomes piston.setAnchor
( ... ); .
- Unlike ODE, the preferred policy for getting complex
values from an object is not to pass in an empty
array:
DVector3 result = new DVector3();
box.getSides( result ) ;
but to return an immutable object:
DVector3C result = box.getLengths();
//The trailing 'C ' on DVector3C
and other classes indicates and constant / immutable
object.
In many cases this avoids creating unnecessary
temporary objects and also makes the code more
compact. It also avoids a possible spelling mistake,
when typing 'g' instead of 's' (get <-> set).
Migration Guide
The migration guide is not only for migrating code from
C/C++ to Java, but also for better understanding the
existing documentation.
TBW.
|