initial commit
This commit is contained in:
18
ode/include/ode/README
Normal file
18
ode/include/ode/README
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
this is the public C interface to the ODE library.
|
||||
|
||||
all these files should be includable from C, i.e. they should not use any
|
||||
C++ features. everything should be protected with
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
...
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
the only exceptions are the odecpp.h and odecpp_collisioh.h files, which define a C++ wrapper for
|
||||
the C interface. remember to keep this in sync!
|
1379
ode/include/ode/collision.h
Normal file
1379
ode/include/ode/collision.h
Normal file
File diff suppressed because it is too large
Load Diff
76
ode/include/ode/collision_space.h
Normal file
76
ode/include/ode/collision_space.h
Normal file
@ -0,0 +1,76 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. *
|
||||
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of EITHER: *
|
||||
* (1) The GNU Lesser General Public License as published by the Free *
|
||||
* Software Foundation; either version 2.1 of the License, or (at *
|
||||
* your option) any later version. The text of the GNU Lesser *
|
||||
* General Public License is included with this library in the *
|
||||
* file LICENSE.TXT. *
|
||||
* (2) The BSD-style license that is included with this library in *
|
||||
* the file LICENSE-BSD.TXT. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
|
||||
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef _ODE_COLLISION_SPACE_H_
|
||||
#define _ODE_COLLISION_SPACE_H_
|
||||
|
||||
#include <ode/common.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct dContactGeom;
|
||||
|
||||
/**
|
||||
* @brief User callback for geom-geom collision testing.
|
||||
*
|
||||
* @param data The user data object, as passed to dSpaceCollide.
|
||||
* @param o1 The first geom being tested.
|
||||
* @param o2 The second geom being test.
|
||||
*
|
||||
* @remarks The callback function can call dCollide on o1 and o2 to generate
|
||||
* contact points between each pair. Then these contact points may be added
|
||||
* to the simulation as contact joints. The user's callback function can of
|
||||
* course chose not to call dCollide for any pair, e.g. if the user decides
|
||||
* that those pairs should not interact.
|
||||
*
|
||||
* @ingroup collide
|
||||
*/
|
||||
typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2);
|
||||
|
||||
|
||||
ODE_API dSpaceID dSimpleSpaceCreate (dSpaceID space);
|
||||
ODE_API dSpaceID dHashSpaceCreate (dSpaceID space);
|
||||
ODE_API dSpaceID dQuadTreeSpaceCreate (dSpaceID space, dVector3 Center, dVector3 Extents, int Depth);
|
||||
|
||||
ODE_API void dSpaceDestroy (dSpaceID);
|
||||
|
||||
ODE_API void dHashSpaceSetLevels (dSpaceID space, int minlevel, int maxlevel);
|
||||
ODE_API void dHashSpaceGetLevels (dSpaceID space, int *minlevel, int *maxlevel);
|
||||
|
||||
ODE_API void dSpaceSetCleanup (dSpaceID space, int mode);
|
||||
ODE_API int dSpaceGetCleanup (dSpaceID space);
|
||||
|
||||
ODE_API void dSpaceAdd (dSpaceID, dGeomID);
|
||||
ODE_API void dSpaceRemove (dSpaceID, dGeomID);
|
||||
ODE_API int dSpaceQuery (dSpaceID, dGeomID);
|
||||
ODE_API void dSpaceClean (dSpaceID);
|
||||
ODE_API int dSpaceGetNumGeoms (dSpaceID);
|
||||
ODE_API dGeomID dSpaceGetGeom (dSpaceID, int i);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
205
ode/include/ode/collision_trimesh.h
Normal file
205
ode/include/ode/collision_trimesh.h
Normal file
@ -0,0 +1,205 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. *
|
||||
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of EITHER: *
|
||||
* (1) The GNU Lesser General Public License as published by the Free *
|
||||
* Software Foundation; either version 2.1 of the License, or (at *
|
||||
* your option) any later version. The text of the GNU Lesser *
|
||||
* General Public License is included with this library in the *
|
||||
* file LICENSE.TXT. *
|
||||
* (2) The BSD-style license that is included with this library in *
|
||||
* the file LICENSE-BSD.TXT. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
|
||||
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/*
|
||||
* TriMesh code by Erwin de Vries.
|
||||
*
|
||||
* Trimesh data.
|
||||
* This is where the actual vertexdata (pointers), and BV tree is stored.
|
||||
* Vertices should be single precision!
|
||||
* This should be more sophisticated, so that the user can easyly implement
|
||||
* another collision library, but this is a lot of work, and also costs some
|
||||
* performance because some data has to be copied.
|
||||
*/
|
||||
|
||||
#ifndef _ODE_COLLISION_TRIMESH_H_
|
||||
#define _ODE_COLLISION_TRIMESH_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Data storage for triangle meshes.
|
||||
*/
|
||||
struct dxTriMeshData;
|
||||
typedef struct dxTriMeshData* dTriMeshDataID;
|
||||
|
||||
/*
|
||||
* These dont make much sense now, but they will later when we add more
|
||||
* features.
|
||||
*/
|
||||
ODE_API dTriMeshDataID dGeomTriMeshDataCreate(void);
|
||||
ODE_API void dGeomTriMeshDataDestroy(dTriMeshDataID g);
|
||||
|
||||
|
||||
|
||||
enum { TRIMESH_FACE_NORMALS };
|
||||
ODE_API void dGeomTriMeshDataSet(dTriMeshDataID g, int data_id, void* in_data);
|
||||
ODE_API void* dGeomTriMeshDataGet(dTriMeshDataID g, int data_id);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* We need to set the last transform after each time step for
|
||||
* accurate collision response. These functions get and set that transform.
|
||||
* It is stored per geom instance, rather than per dTriMeshDataID.
|
||||
*/
|
||||
ODE_API void dGeomTriMeshSetLastTransform( dGeomID g, dMatrix4 last_trans );
|
||||
ODE_API dReal* dGeomTriMeshGetLastTransform( dGeomID g );
|
||||
|
||||
/*
|
||||
* Build TriMesh data with single precision used in vertex data .
|
||||
*/
|
||||
ODE_API void dGeomTriMeshDataBuildSingle(dTriMeshDataID g,
|
||||
const void* Vertices, int VertexStride, int VertexCount,
|
||||
const void* Indices, int IndexCount, int TriStride);
|
||||
/* same again with a normals array (used as trimesh-trimesh optimization) */
|
||||
ODE_API void dGeomTriMeshDataBuildSingle1(dTriMeshDataID g,
|
||||
const void* Vertices, int VertexStride, int VertexCount,
|
||||
const void* Indices, int IndexCount, int TriStride,
|
||||
const void* Normals);
|
||||
/*
|
||||
* Build TriMesh data with double pricision used in vertex data .
|
||||
*/
|
||||
ODE_API void dGeomTriMeshDataBuildDouble(dTriMeshDataID g,
|
||||
const void* Vertices, int VertexStride, int VertexCount,
|
||||
const void* Indices, int IndexCount, int TriStride);
|
||||
/* same again with a normals array (used as trimesh-trimesh optimization) */
|
||||
ODE_API void dGeomTriMeshDataBuildDouble1(dTriMeshDataID g,
|
||||
const void* Vertices, int VertexStride, int VertexCount,
|
||||
const void* Indices, int IndexCount, int TriStride,
|
||||
const void* Normals);
|
||||
|
||||
/*
|
||||
* Simple build. Single/double precision based on dSINGLE/dDOUBLE!
|
||||
*/
|
||||
ODE_API void dGeomTriMeshDataBuildSimple(dTriMeshDataID g,
|
||||
const dReal* Vertices, int VertexCount,
|
||||
const int* Indices, int IndexCount);
|
||||
/* same again with a normals array (used as trimesh-trimesh optimization) */
|
||||
ODE_API void dGeomTriMeshDataBuildSimple1(dTriMeshDataID g,
|
||||
const dReal* Vertices, int VertexCount,
|
||||
const int* Indices, int IndexCount,
|
||||
const int* Normals);
|
||||
|
||||
/* Preprocess the trimesh data to remove mark unnecessary edges and vertices */
|
||||
ODE_API void dGeomTriMeshDataPreprocess(dTriMeshDataID g);
|
||||
/* Get and set the internal preprocessed trimesh data buffer, for loading and saving */
|
||||
ODE_API void dGeomTriMeshDataGetBuffer(dTriMeshDataID g, unsigned char** buf, int* bufLen);
|
||||
ODE_API void dGeomTriMeshDataSetBuffer(dTriMeshDataID g, unsigned char* buf);
|
||||
|
||||
|
||||
/*
|
||||
* Per triangle callback. Allows the user to say if he wants a collision with
|
||||
* a particular triangle.
|
||||
*/
|
||||
typedef int dTriCallback(dGeomID TriMesh, dGeomID RefObject, int TriangleIndex);
|
||||
ODE_API void dGeomTriMeshSetCallback(dGeomID g, dTriCallback* Callback);
|
||||
ODE_API dTriCallback* dGeomTriMeshGetCallback(dGeomID g);
|
||||
|
||||
/*
|
||||
* Per object callback. Allows the user to get the list of triangles in 1
|
||||
* shot. Maybe we should remove this one.
|
||||
*/
|
||||
typedef void dTriArrayCallback(dGeomID TriMesh, dGeomID RefObject, const int* TriIndices, int TriCount);
|
||||
ODE_API void dGeomTriMeshSetArrayCallback(dGeomID g, dTriArrayCallback* ArrayCallback);
|
||||
ODE_API dTriArrayCallback* dGeomTriMeshGetArrayCallback(dGeomID g);
|
||||
|
||||
/*
|
||||
* Ray callback.
|
||||
* Allows the user to say if a ray collides with a triangle on barycentric
|
||||
* coords. The user can for example sample a texture with alpha transparency
|
||||
* to determine if a collision should occur.
|
||||
*/
|
||||
typedef int dTriRayCallback(dGeomID TriMesh, dGeomID Ray, int TriangleIndex, dReal u, dReal v);
|
||||
ODE_API void dGeomTriMeshSetRayCallback(dGeomID g, dTriRayCallback* Callback);
|
||||
ODE_API dTriRayCallback* dGeomTriMeshGetRayCallback(dGeomID g);
|
||||
|
||||
/*
|
||||
* Trimesh class
|
||||
* Construction. Callbacks are optional.
|
||||
*/
|
||||
ODE_API dGeomID dCreateTriMesh(dSpaceID space, dTriMeshDataID Data, dTriCallback* Callback, dTriArrayCallback* ArrayCallback, dTriRayCallback* RayCallback);
|
||||
|
||||
ODE_API void dGeomTriMeshSetData(dGeomID g, dTriMeshDataID Data);
|
||||
ODE_API dTriMeshDataID dGeomTriMeshGetData(dGeomID g);
|
||||
|
||||
|
||||
// enable/disable/check temporal coherence
|
||||
ODE_API void dGeomTriMeshEnableTC(dGeomID g, int geomClass, int enable);
|
||||
ODE_API int dGeomTriMeshIsTCEnabled(dGeomID g, int geomClass);
|
||||
|
||||
/*
|
||||
* Clears the internal temporal coherence caches. When a geom has its
|
||||
* collision checked with a trimesh once, data is stored inside the trimesh.
|
||||
* With large worlds with lots of seperate objects this list could get huge.
|
||||
* We should be able to do this automagically.
|
||||
*/
|
||||
ODE_API void dGeomTriMeshClearTCCache(dGeomID g);
|
||||
|
||||
|
||||
/*
|
||||
* returns the TriMeshDataID
|
||||
*/
|
||||
ODE_API dTriMeshDataID dGeomTriMeshGetTriMeshDataID(dGeomID g);
|
||||
|
||||
/*
|
||||
* Gets a triangle.
|
||||
*/
|
||||
ODE_API void dGeomTriMeshGetTriangle(dGeomID g, int Index, dVector3* v0, dVector3* v1, dVector3* v2);
|
||||
|
||||
/*
|
||||
* Gets the point on the requested triangle and the given barycentric
|
||||
* coordinates.
|
||||
*/
|
||||
ODE_API void dGeomTriMeshGetPoint(dGeomID g, int Index, dReal u, dReal v, dVector3 Out);
|
||||
|
||||
/*
|
||||
|
||||
This is how the strided data works:
|
||||
|
||||
struct StridedVertex{
|
||||
dVector3 Vertex;
|
||||
// Userdata
|
||||
};
|
||||
int VertexStride = sizeof(StridedVertex);
|
||||
|
||||
struct StridedTri{
|
||||
int Indices[3];
|
||||
// Userdata
|
||||
};
|
||||
int TriStride = sizeof(StridedTri);
|
||||
|
||||
*/
|
||||
|
||||
|
||||
ODE_API int dGeomTriMeshGetTriangleCount (dGeomID g);
|
||||
|
||||
ODE_API void dGeomTriMeshDataUpdate(dTriMeshDataID g);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ODE_COLLISION_TRIMESH_H_ */
|
||||
|
374
ode/include/ode/common.h
Normal file
374
ode/include/ode/common.h
Normal file
@ -0,0 +1,374 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
|
||||
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of EITHER: *
|
||||
* (1) The GNU Lesser General Public License as published by the Free *
|
||||
* Software Foundation; either version 2.1 of the License, or (at *
|
||||
* your option) any later version. The text of the GNU Lesser *
|
||||
* General Public License is included with this library in the *
|
||||
* file LICENSE.TXT. *
|
||||
* (2) The BSD-style license that is included with this library in *
|
||||
* the file LICENSE-BSD.TXT. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
|
||||
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef _ODE_COMMON_H_
|
||||
#define _ODE_COMMON_H_
|
||||
#include <ode/config.h>
|
||||
#include <ode/error.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* configuration stuff */
|
||||
|
||||
/* the efficient alignment. most platforms align data structures to some
|
||||
* number of bytes, but this is not always the most efficient alignment.
|
||||
* for example, many x86 compilers align to 4 bytes, but on a pentium it
|
||||
* is important to align doubles to 8 byte boundaries (for speed), and
|
||||
* the 4 floats in a SIMD register to 16 byte boundaries. many other
|
||||
* platforms have similar behavior. setting a larger alignment can waste
|
||||
* a (very) small amount of memory. NOTE: this number must be a power of
|
||||
* two. this is set to 16 by default.
|
||||
*/
|
||||
#define EFFICIENT_ALIGNMENT 16
|
||||
|
||||
|
||||
/* constants */
|
||||
|
||||
/* pi and 1/sqrt(2) are defined here if necessary because they don't get
|
||||
* defined in <math.h> on some platforms (like MS-Windows)
|
||||
*/
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI REAL(3.1415926535897932384626433832795029)
|
||||
#endif
|
||||
#ifndef M_SQRT1_2
|
||||
#define M_SQRT1_2 REAL(0.7071067811865475244008443621048490)
|
||||
#endif
|
||||
|
||||
|
||||
/* debugging:
|
||||
* IASSERT is an internal assertion, i.e. a consistency check. if it fails
|
||||
* we want to know where.
|
||||
* UASSERT is a user assertion, i.e. if it fails a nice error message
|
||||
* should be printed for the user.
|
||||
* AASSERT is an arguments assertion, i.e. if it fails "bad argument(s)"
|
||||
* is printed.
|
||||
* DEBUGMSG just prints out a message
|
||||
*/
|
||||
|
||||
#ifndef dNODEBUG
|
||||
#ifdef __GNUC__
|
||||
#define dIASSERT(a) if (!(a)) dDebug (d_ERR_IASSERT, \
|
||||
"assertion \"" #a "\" failed in %s() [%s]",__FUNCTION__,__FILE__);
|
||||
#define dUASSERT(a,msg) if (!(a)) dDebug (d_ERR_UASSERT, \
|
||||
msg " in %s()", __FUNCTION__);
|
||||
#define dDEBUGMSG(msg) dMessage (d_ERR_UASSERT, \
|
||||
msg " in %s() File %s Line %d", __FUNCTION__, __FILE__,__LINE__);
|
||||
#else
|
||||
#define dIASSERT(a) if (!(a)) dDebug (d_ERR_IASSERT, \
|
||||
"assertion \"" #a "\" failed in %s:%d",__FILE__,__LINE__);
|
||||
#define dUASSERT(a,msg) if (!(a)) dDebug (d_ERR_UASSERT, \
|
||||
msg " (%s:%d)", __FILE__,__LINE__);
|
||||
#define dDEBUGMSG(msg) dMessage (d_ERR_UASSERT, \
|
||||
msg " (%s:%d)", __FILE__,__LINE__);
|
||||
#endif
|
||||
#else
|
||||
#define dIASSERT(a) ;
|
||||
#define dUASSERT(a,msg) ;
|
||||
#define dDEBUGMSG(msg) ;
|
||||
#endif
|
||||
#define dAASSERT(a) dUASSERT(a,"Bad argument(s)")
|
||||
|
||||
/* floating point data type, vector, matrix and quaternion types */
|
||||
|
||||
#if defined(dSINGLE)
|
||||
typedef float dReal;
|
||||
#ifdef dDOUBLE
|
||||
#error You can only #define dSINGLE or dDOUBLE, not both.
|
||||
#endif // dDOUBLE
|
||||
#elif defined(dDOUBLE)
|
||||
typedef double dReal;
|
||||
#else
|
||||
#error You must #define dSINGLE or dDOUBLE
|
||||
#endif
|
||||
|
||||
|
||||
/* round an integer up to a multiple of 4, except that 0 and 1 are unmodified
|
||||
* (used to compute matrix leading dimensions)
|
||||
*/
|
||||
#define dPAD(a) (((a) > 1) ? ((((a)-1)|3)+1) : (a))
|
||||
|
||||
/* these types are mainly just used in headers */
|
||||
typedef dReal dVector3[4];
|
||||
typedef dReal dVector4[4];
|
||||
typedef dReal dMatrix3[4*3];
|
||||
typedef dReal dMatrix4[4*4];
|
||||
typedef dReal dMatrix6[8*6];
|
||||
typedef dReal dQuaternion[4];
|
||||
|
||||
|
||||
/* precision dependent scalar math functions */
|
||||
|
||||
#if defined(dSINGLE)
|
||||
|
||||
#define REAL(x) (x ## f) /* form a constant */
|
||||
#define dRecip(x) ((1.0f/(x))) /* reciprocal */
|
||||
#define dSqrt(x) (sqrtf(x)) /* square root */
|
||||
#define dRecipSqrt(x) ((1.0f/sqrtf(x))) /* reciprocal square root */
|
||||
#define dSin(x) (sinf(x)) /* sine */
|
||||
#define dCos(x) (cosf(x)) /* cosine */
|
||||
#define dFabs(x) (fabsf(x)) /* absolute value */
|
||||
#define dAtan2(y,x) (atan2f(y,x)) /* arc tangent with 2 args */
|
||||
#define dFMod(a,b) (fmodf(a,b)) /* modulo */
|
||||
|
||||
#ifdef HAVE___ISNANF
|
||||
#define dIsNan(x) (__isnanf(x))
|
||||
#elif defined(HAVE__ISNANF)
|
||||
#define dIsNan(x) (_isnanf(x))
|
||||
#elif defined(HAVE_ISNANF)
|
||||
#define dIsNan(x) (isnanf(x))
|
||||
#else
|
||||
/*
|
||||
fall back to _isnan which is the VC way,
|
||||
this may seem redundant since we already checked
|
||||
for _isnan before, but if isnan is detected by
|
||||
configure but is not found during compilation
|
||||
we should always make sure we check for __isnanf,
|
||||
_isnanf and isnanf in that order before falling
|
||||
back to a default
|
||||
*/
|
||||
#define dIsNan(x) (_isnan(x))
|
||||
#endif
|
||||
|
||||
#define dCopySign(a,b) ((dReal)copysignf(a,b))
|
||||
|
||||
#elif defined(dDOUBLE)
|
||||
|
||||
#define REAL(x) (x)
|
||||
#define dRecip(x) (1.0/(x))
|
||||
#define dSqrt(x) sqrt(x)
|
||||
#define dRecipSqrt(x) (1.0/sqrt(x))
|
||||
#define dSin(x) sin(x)
|
||||
#define dCos(x) cos(x)
|
||||
#define dFabs(x) fabs(x)
|
||||
#define dAtan2(y,x) atan2((y),(x))
|
||||
#define dFMod(a,b) (fmod((a),(b)))
|
||||
#ifdef HAVE___ISNAN
|
||||
#define dIsNan(x) (__isnan(x))
|
||||
#elif defined(HAVE__ISNAN)
|
||||
#define dIsNan(x) (_isnan(x))
|
||||
#elif defined(HAVE_ISNAN)
|
||||
#define dIsNan(x) (isnan(x))
|
||||
#else
|
||||
#define dIsNan(x) (_isnan(x))
|
||||
#endif
|
||||
|
||||
#define dCopySign(a,b) (copysign((a),(b)))
|
||||
|
||||
#else
|
||||
#error You must #define dSINGLE or dDOUBLE
|
||||
#endif
|
||||
|
||||
|
||||
/* utility */
|
||||
|
||||
|
||||
/* round something up to be a multiple of the EFFICIENT_ALIGNMENT */
|
||||
|
||||
#define dEFFICIENT_SIZE(x) ((((x)-1)|(EFFICIENT_ALIGNMENT-1))+1)
|
||||
|
||||
|
||||
/* alloca aligned to the EFFICIENT_ALIGNMENT. note that this can waste
|
||||
* up to 15 bytes per allocation, depending on what alloca() returns.
|
||||
*/
|
||||
|
||||
#define dALLOCA16(n) \
|
||||
((char*)dEFFICIENT_SIZE(((size_t)(alloca((n)+(EFFICIENT_ALIGNMENT-1))))))
|
||||
|
||||
|
||||
// Use the error-checking memory allocation system. Because this system uses heap
|
||||
// (malloc) instead of stack (alloca), it is slower. However, it allows you to
|
||||
// simulate larger scenes, as well as handle out-of-memory errors in a somewhat
|
||||
// graceful manner
|
||||
|
||||
// #define dUSE_MALLOC_FOR_ALLOCA
|
||||
|
||||
#ifdef dUSE_MALLOC_FOR_ALLOCA
|
||||
enum {
|
||||
d_MEMORY_OK = 0, /* no memory errors */
|
||||
d_MEMORY_OUT_OF_MEMORY /* malloc failed due to out of memory error */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* internal object types (all prefixed with `dx') */
|
||||
|
||||
struct dxWorld; /* dynamics world */
|
||||
struct dxSpace; /* collision space */
|
||||
struct dxBody; /* rigid body (dynamics object) */
|
||||
struct dxGeom; /* geometry (collision object) */
|
||||
struct dxJoint;
|
||||
struct dxJointNode;
|
||||
struct dxJointGroup;
|
||||
|
||||
typedef struct dxWorld *dWorldID;
|
||||
typedef struct dxSpace *dSpaceID;
|
||||
typedef struct dxBody *dBodyID;
|
||||
typedef struct dxGeom *dGeomID;
|
||||
typedef struct dxJoint *dJointID;
|
||||
typedef struct dxJointGroup *dJointGroupID;
|
||||
|
||||
|
||||
/* error numbers */
|
||||
|
||||
enum {
|
||||
d_ERR_UNKNOWN = 0, /* unknown error */
|
||||
d_ERR_IASSERT, /* internal assertion failed */
|
||||
d_ERR_UASSERT, /* user assertion failed */
|
||||
d_ERR_LCP /* user assertion failed */
|
||||
};
|
||||
|
||||
|
||||
/* joint type numbers */
|
||||
|
||||
enum {
|
||||
dJointTypeNone = 0, /* or "unknown" */
|
||||
dJointTypeBall,
|
||||
dJointTypeHinge,
|
||||
dJointTypeSlider,
|
||||
dJointTypeContact,
|
||||
dJointTypeUniversal,
|
||||
dJointTypeHinge2,
|
||||
dJointTypeFixed,
|
||||
dJointTypeNull,
|
||||
dJointTypeAMotor,
|
||||
dJointTypeLMotor,
|
||||
dJointTypePlane2D,
|
||||
dJointTypePR
|
||||
};
|
||||
|
||||
|
||||
/* an alternative way of setting joint parameters, using joint parameter
|
||||
* structures and member constants. we don't actually do this yet.
|
||||
*/
|
||||
|
||||
/*
|
||||
typedef struct dLimot {
|
||||
int mode;
|
||||
dReal lostop, histop;
|
||||
dReal vel, fmax;
|
||||
dReal fudge_factor;
|
||||
dReal bounce, soft;
|
||||
dReal suspension_erp, suspension_cfm;
|
||||
} dLimot;
|
||||
|
||||
enum {
|
||||
dLimotLoStop = 0x0001,
|
||||
dLimotHiStop = 0x0002,
|
||||
dLimotVel = 0x0004,
|
||||
dLimotFMax = 0x0008,
|
||||
dLimotFudgeFactor = 0x0010,
|
||||
dLimotBounce = 0x0020,
|
||||
dLimotSoft = 0x0040
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
/* standard joint parameter names. why are these here? - because we don't want
|
||||
* to include all the joint function definitions in joint.cpp. hmmmm.
|
||||
* MSVC complains if we call D_ALL_PARAM_NAMES_X with a blank second argument,
|
||||
* which is why we have the D_ALL_PARAM_NAMES macro as well. please copy and
|
||||
* paste between these two.
|
||||
*/
|
||||
|
||||
#define D_ALL_PARAM_NAMES(start) \
|
||||
/* parameters for limits and motors */ \
|
||||
dParamLoStop = start, \
|
||||
dParamHiStop, \
|
||||
dParamVel, \
|
||||
dParamFMax, \
|
||||
dParamFudgeFactor, \
|
||||
dParamBounce, \
|
||||
dParamCFM, \
|
||||
dParamStopERP, \
|
||||
dParamStopCFM, \
|
||||
/* parameters for suspension */ \
|
||||
dParamSuspensionERP, \
|
||||
dParamSuspensionCFM,
|
||||
|
||||
#define D_ALL_PARAM_NAMES_X(start,x) \
|
||||
/* parameters for limits and motors */ \
|
||||
dParamLoStop ## x = start, \
|
||||
dParamHiStop ## x, \
|
||||
dParamVel ## x, \
|
||||
dParamFMax ## x, \
|
||||
dParamFudgeFactor ## x, \
|
||||
dParamBounce ## x, \
|
||||
dParamCFM ## x, \
|
||||
dParamStopERP ## x, \
|
||||
dParamStopCFM ## x, \
|
||||
/* parameters for suspension */ \
|
||||
dParamSuspensionERP ## x, \
|
||||
dParamSuspensionCFM ## x,
|
||||
|
||||
enum {
|
||||
D_ALL_PARAM_NAMES(0)
|
||||
D_ALL_PARAM_NAMES_X(0x100,2)
|
||||
D_ALL_PARAM_NAMES_X(0x200,3)
|
||||
|
||||
/* add a multiple of this constant to the basic parameter numbers to get
|
||||
* the parameters for the second, third etc axes.
|
||||
*/
|
||||
dParamGroup=0x100
|
||||
};
|
||||
|
||||
|
||||
/* angular motor mode numbers */
|
||||
|
||||
enum{
|
||||
dAMotorUser = 0,
|
||||
dAMotorEuler = 1
|
||||
};
|
||||
|
||||
|
||||
/* joint force feedback information */
|
||||
|
||||
typedef struct dJointFeedback {
|
||||
dVector3 f1; /* force applied to body 1 */
|
||||
dVector3 t1; /* torque applied to body 1 */
|
||||
dVector3 f2; /* force applied to body 2 */
|
||||
dVector3 t2; /* torque applied to body 2 */
|
||||
} dJointFeedback;
|
||||
|
||||
|
||||
/* private functions that must be implemented by the collision library:
|
||||
* (1) indicate that a geom has moved, (2) get the next geom in a body list.
|
||||
* these functions are called whenever the position of geoms connected to a
|
||||
* body have changed, e.g. with dBodySetPosition(), dBodySetRotation(), or
|
||||
* when the ODE step function updates the body state.
|
||||
*/
|
||||
|
||||
void dGeomMoved (dGeomID);
|
||||
dGeomID dGeomGetBodyNext (dGeomID);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
40
ode/include/ode/compatibility.h
Normal file
40
ode/include/ode/compatibility.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
|
||||
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of EITHER: *
|
||||
* (1) The GNU Lesser General Public License as published by the Free *
|
||||
* Software Foundation; either version 2.1 of the License, or (at *
|
||||
* your option) any later version. The text of the GNU Lesser *
|
||||
* General Public License is included with this library in the *
|
||||
* file LICENSE.TXT. *
|
||||
* (2) The BSD-style license that is included with this library in *
|
||||
* the file LICENSE-BSD.TXT. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
|
||||
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef _ODE_COMPATIBILITY_H_
|
||||
#define _ODE_COMPATIBILITY_H_
|
||||
|
||||
/*
|
||||
* ODE's backward compatibility system ensures that as ODE's API
|
||||
* evolves, user code will not break.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These new rotation function names are more consistent with the
|
||||
* rest of the API.
|
||||
*/
|
||||
#define dQtoR(q,R) dRfromQ((R),(q))
|
||||
#define dRtoQ(R,q) dQfromR((q),(R))
|
||||
#define dWtoDQ(w,q,dq) dDQfromW((dq),(w),(q))
|
||||
|
||||
|
||||
#endif
|
168
ode/include/ode/config.h
Normal file
168
ode/include/ode/config.h
Normal file
@ -0,0 +1,168 @@
|
||||
/* This file was autogenerated by Premake */
|
||||
#ifndef _ODE_CONFIG_H_
|
||||
#define _ODE_CONFIG_H_
|
||||
|
||||
|
||||
/******************************************************************
|
||||
* CONFIGURATON SETTINGS - you can change these, and then rebuild
|
||||
* ODE to modify the behavior of the library.
|
||||
*
|
||||
* dSINGLE/dDOUBLE - force ODE to use single-precision (float)
|
||||
* or double-precision (double) for numbers.
|
||||
* Only one should be defined.
|
||||
*
|
||||
* dTRIMESH_ENABLED - enable/disable trimesh support
|
||||
* dTRIMESH_OPCODE - use the OPCODE trimesh engine
|
||||
* dTRIMESH_GIMPACT - use the GIMPACT trimesh engine
|
||||
*
|
||||
* dUSE_MALLOC_FOR_ALLOCA (experimental)-
|
||||
* Use malloc() instead of alloca(). Slower,
|
||||
* but allows for larger systems and more
|
||||
* graceful out-of-memory handling.
|
||||
******************************************************************/
|
||||
|
||||
//#define dSINGLE
|
||||
#define dDOUBLE
|
||||
|
||||
#define dTRIMESH_ENABLED 1
|
||||
#define dTRIMESH_OPCODE 1
|
||||
|
||||
/* #define dUSE_MALLOC_FOR_ALLOCA */
|
||||
|
||||
|
||||
/******************************************************************
|
||||
* SYSTEM SETTINGS - you shouldn't need to change these. If you
|
||||
* run into an issue with these settings, please report it to
|
||||
* the ODE bug tracker at:
|
||||
* http://sf.net/tracker/?group_id=24884&atid=382799
|
||||
******************************************************************/
|
||||
|
||||
/* Try to identify the platform */
|
||||
#if defined(_XENON)
|
||||
#define ODE_PLATFORM_XBOX360
|
||||
#elif defined(SN_TARGET_PSP_HW)
|
||||
#define ODE_PLATFORM_PSP
|
||||
#elif defined(SN_TARGET_PS3)
|
||||
#define ODE_PLATFORM_PS3
|
||||
#elif defined(_MSC_VER) || defined(__CYGWIN32__) || defined(__MINGW32__)
|
||||
#define ODE_PLATFORM_WINDOWS
|
||||
#elif defined(__linux__)
|
||||
#define ODE_PLATFORM_LINUX
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
#define ODE_PLATFORM_OSX
|
||||
#else
|
||||
#error "Need some help identifying the platform!"
|
||||
#endif
|
||||
|
||||
/* Additional platform defines used in the code */
|
||||
#if defined(ODE_PLATFORM_WINDOWS) && !defined(WIN32)
|
||||
#define WIN32
|
||||
#endif
|
||||
|
||||
#if defined(__CYGWIN32__) || defined(__MINGW32__)
|
||||
#define CYGWIN
|
||||
#endif
|
||||
|
||||
#if defined(ODE_PLATFORM_OSX)
|
||||
#define macintosh
|
||||
#endif
|
||||
|
||||
|
||||
/* Define a DLL export symbol for those platforms that need it */
|
||||
#if defined(ODE_PLATFORM_WINDOWS)
|
||||
#if defined(ODE_DLL)
|
||||
#define ODE_API __declspec(dllexport)
|
||||
#elif !defined(ODE_LIB)
|
||||
#define ODE_DLL_API __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(ODE_API)
|
||||
#define ODE_API
|
||||
#endif
|
||||
|
||||
|
||||
/* Pull in the standard headers */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <float.h>
|
||||
|
||||
#if !defined(ODE_PLATFORM_PS3)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#if !defined(ODE_PLATFORM_WINDOWS)
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* Visual C does not define these functions */
|
||||
#if defined(_MSC_VER)
|
||||
#define copysignf _copysign
|
||||
#define copysign _copysign
|
||||
#endif
|
||||
|
||||
|
||||
/* Define a value for infinity */
|
||||
#if defined(HUGE_VALF)
|
||||
#define ODE_INFINITY4 HUGE_VALF
|
||||
#define ODE_INFINITY8 HUGE_VAL
|
||||
#elif defined(FLT_MAX)
|
||||
#define ODE_INFINITY4 FLT_MAX
|
||||
#define ODE_INFINITY8 DBL_MAX
|
||||
#else
|
||||
static union { unsigned char __c[4]; float __f; } __ode_huge_valf = {{0,0,0x80,0x7f}};
|
||||
static union { unsigned char __c[8]; double __d; } __ode_huge_val = {{0,0,0,0,0,0,0xf0,0x7f}};
|
||||
#define ODE_INFINITY4 (__ode_huge_valf.__f)
|
||||
#define ODE_INFINITY8 (__ode_huge_val.__d)
|
||||
#endif
|
||||
|
||||
#ifdef dSINGLE
|
||||
#define dInfinity ODE_INFINITY4
|
||||
#define dEpsilon FLT_EPSILON
|
||||
#else
|
||||
#define dInfinity ODE_INFINITY8
|
||||
#define dEpsilon DBL_EPSILON
|
||||
#endif
|
||||
|
||||
|
||||
/* Well-defined common data types...need to define for 64 bit systems */
|
||||
#if defined(_M_IA64) || defined(__ia64__) || defined(_M_AMD64) || defined(__x86_64__)
|
||||
#define X86_64_SYSTEM 1
|
||||
typedef int int32;
|
||||
typedef unsigned int uint32;
|
||||
typedef short int16;
|
||||
typedef unsigned short uint16;
|
||||
typedef char int8;
|
||||
typedef unsigned char uint8;
|
||||
#else
|
||||
typedef int int32;
|
||||
typedef unsigned int uint32;
|
||||
typedef short int16;
|
||||
typedef unsigned short uint16;
|
||||
typedef char int8;
|
||||
typedef unsigned char uint8;
|
||||
#endif
|
||||
|
||||
/* An integer type that can be safely cast to a pointer. This definition
|
||||
* should be safe even on 64-bit systems */
|
||||
typedef size_t intP;
|
||||
|
||||
|
||||
/* The efficient alignment. most platforms align data structures to some
|
||||
* number of bytes, but this is not always the most efficient alignment.
|
||||
* for example, many x86 compilers align to 4 bytes, but on a pentium it is
|
||||
* important to align doubles to 8 byte boundaries (for speed), and the 4
|
||||
* floats in a SIMD register to 16 byte boundaries. many other platforms have
|
||||
* similar behavior. setting a larger alignment can waste a (very) small
|
||||
* amount of memory. NOTE: this number must be a power of two. */
|
||||
#define EFFICIENT_ALIGNMENT 16
|
||||
|
||||
|
||||
/* Define this if your system supports anonymous memory maps (linux does) */
|
||||
#define MMAP_ANONYMOUS
|
||||
|
||||
#endif
|
103
ode/include/ode/contact.h
Normal file
103
ode/include/ode/contact.h
Normal file
@ -0,0 +1,103 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
|
||||
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of EITHER: *
|
||||
* (1) The GNU Lesser General Public License as published by the Free *
|
||||
* Software Foundation; either version 2.1 of the License, or (at *
|
||||
* your option) any later version. The text of the GNU Lesser *
|
||||
* General Public License is included with this library in the *
|
||||
* file LICENSE.TXT. *
|
||||
* (2) The BSD-style license that is included with this library in *
|
||||
* the file LICENSE-BSD.TXT. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
|
||||
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef _ODE_CONTACT_H_
|
||||
#define _ODE_CONTACT_H_
|
||||
|
||||
#include <ode/common.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
enum {
|
||||
dContactMu2 = 0x001,
|
||||
dContactFDir1 = 0x002,
|
||||
dContactBounce = 0x004,
|
||||
dContactSoftERP = 0x008,
|
||||
dContactSoftCFM = 0x010,
|
||||
dContactMotion1 = 0x020,
|
||||
dContactMotion2 = 0x040,
|
||||
dContactSlip1 = 0x080,
|
||||
dContactSlip2 = 0x100,
|
||||
|
||||
dContactApprox0 = 0x0000,
|
||||
dContactApprox1_1 = 0x1000,
|
||||
dContactApprox1_2 = 0x2000,
|
||||
dContactApprox1 = 0x3000
|
||||
};
|
||||
|
||||
|
||||
typedef struct dSurfaceParameters {
|
||||
/* must always be defined */
|
||||
int mode;
|
||||
dReal mu;
|
||||
|
||||
/* only defined if the corresponding flag is set in mode */
|
||||
dReal mu2;
|
||||
dReal bounce;
|
||||
dReal bounce_vel;
|
||||
dReal soft_erp;
|
||||
dReal soft_cfm;
|
||||
dReal motion1,motion2;
|
||||
dReal slip1,slip2;
|
||||
} dSurfaceParameters;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Describe the contact point between two geoms.
|
||||
*
|
||||
* If two bodies touch, or if a body touches a static feature in its
|
||||
* environment, the contact is represented by one or more "contact
|
||||
* points", described by dContactGeom.
|
||||
*
|
||||
* The convention is that if body 1 is moved along the normal vector by
|
||||
* a distance depth (or equivalently if body 2 is moved the same distance
|
||||
* in the opposite direction) then the contact depth will be reduced to
|
||||
* zero. This means that the normal vector points "in" to body 1.
|
||||
*
|
||||
* @ingroup collide
|
||||
*/
|
||||
typedef struct dContactGeom {
|
||||
dVector3 pos; ///< contact position
|
||||
dVector3 normal; ///< normal vector
|
||||
dReal depth; ///< penetration depth
|
||||
dGeomID g1,g2; ///< the colliding geoms
|
||||
int side1,side2; ///< (to be documented)
|
||||
} dContactGeom;
|
||||
|
||||
|
||||
/* contact info used by contact joint */
|
||||
|
||||
typedef struct dContact {
|
||||
dSurfaceParameters surface;
|
||||
dContactGeom geom;
|
||||
dVector3 fdir1;
|
||||
} dContact;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
63
ode/include/ode/error.h
Normal file
63
ode/include/ode/error.h
Normal file
@ -0,0 +1,63 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
|
||||
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of EITHER: *
|
||||
* (1) The GNU Lesser General Public License as published by the Free *
|
||||
* Software Foundation; either version 2.1 of the License, or (at *
|
||||
* your option) any later version. The text of the GNU Lesser *
|
||||
* General Public License is included with this library in the *
|
||||
* file LICENSE.TXT. *
|
||||
* (2) The BSD-style license that is included with this library in *
|
||||
* the file LICENSE-BSD.TXT. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
|
||||
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/* this comes from the `reuse' library. copy any changes back to the source */
|
||||
|
||||
#ifndef _ODE_ERROR_H_
|
||||
#define _ODE_ERROR_H_
|
||||
|
||||
#include <ode/config.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* all user defined error functions have this type. error and debug functions
|
||||
* should not return.
|
||||
*/
|
||||
typedef void dMessageFunction (int errnum, const char *msg, va_list ap);
|
||||
|
||||
/* set a new error, debug or warning handler. if fn is 0, the default handlers
|
||||
* are used.
|
||||
*/
|
||||
ODE_API void dSetErrorHandler (dMessageFunction *fn);
|
||||
ODE_API void dSetDebugHandler (dMessageFunction *fn);
|
||||
ODE_API void dSetMessageHandler (dMessageFunction *fn);
|
||||
|
||||
/* return the current error, debug or warning handler. if the return value is
|
||||
* 0, the default handlers are in place.
|
||||
*/
|
||||
ODE_API dMessageFunction *dGetErrorHandler(void);
|
||||
ODE_API dMessageFunction *dGetDebugHandler(void);
|
||||
ODE_API dMessageFunction *dGetMessageHandler(void);
|
||||
|
||||
/* generate a fatal error, debug trap or a message. */
|
||||
ODE_API void dError (int num, const char *msg, ...);
|
||||
ODE_API void dDebug (int num, const char *msg, ...);
|
||||
ODE_API void dMessage (int num, const char *msg, ...);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
32
ode/include/ode/export-dif.h
Normal file
32
ode/include/ode/export-dif.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
|
||||
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of EITHER: *
|
||||
* (1) The GNU Lesser General Public License as published by the Free *
|
||||
* Software Foundation; either version 2.1 of the License, or (at *
|
||||
* your option) any later version. The text of the GNU Lesser *
|
||||
* General Public License is included with this library in the *
|
||||
* file LICENSE.TXT. *
|
||||
* (2) The BSD-style license that is included with this library in *
|
||||
* the file LICENSE-BSD.TXT. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
|
||||
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef _ODE_EXPORT_DIF_
|
||||
#define _ODE_EXPORT_DIF_
|
||||
|
||||
#include <ode/common.h>
|
||||
|
||||
|
||||
ODE_API void dWorldExportDIF (dWorldID w, FILE *file, const char *world_name);
|
||||
|
||||
|
||||
#endif
|
123
ode/include/ode/mass.h
Normal file
123
ode/include/ode/mass.h
Normal file
@ -0,0 +1,123 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
|
||||
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of EITHER: *
|
||||
* (1) The GNU Lesser General Public License as published by the Free *
|
||||
* Software Foundation; either version 2.1 of the License, or (at *
|
||||
* your option) any later version. The text of the GNU Lesser *
|
||||
* General Public License is included with this library in the *
|
||||
* file LICENSE.TXT. *
|
||||
* (2) The BSD-style license that is included with this library in *
|
||||
* the file LICENSE-BSD.TXT. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
|
||||
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef _ODE_MASS_H_
|
||||
#define _ODE_MASS_H_
|
||||
|
||||
#include <ode/common.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct dMass;
|
||||
typedef struct dMass dMass;
|
||||
|
||||
/**
|
||||
* Check if a mass structure has valid value.
|
||||
* The function check if the mass and innertia matrix are positive definits
|
||||
*
|
||||
* @param m A mass structure to check
|
||||
*
|
||||
* @return 1 if both codition are met
|
||||
*/
|
||||
ODE_API int dMassCheck(const dMass *m);
|
||||
|
||||
ODE_API void dMassSetZero (dMass *);
|
||||
|
||||
ODE_API void dMassSetParameters (dMass *, dReal themass,
|
||||
dReal cgx, dReal cgy, dReal cgz,
|
||||
dReal I11, dReal I22, dReal I33,
|
||||
dReal I12, dReal I13, dReal I23);
|
||||
|
||||
ODE_API void dMassSetSphere (dMass *, dReal density, dReal radius);
|
||||
ODE_API void dMassSetSphereTotal (dMass *, dReal total_mass, dReal radius);
|
||||
|
||||
ODE_API void dMassSetCapsule (dMass *, dReal density, int direction,
|
||||
dReal radius, dReal length);
|
||||
ODE_API void dMassSetCapsuleTotal (dMass *, dReal total_mass, int direction,
|
||||
dReal radius, dReal length);
|
||||
|
||||
ODE_API void dMassSetCylinder (dMass *, dReal density, int direction,
|
||||
dReal radius, dReal length);
|
||||
ODE_API void dMassSetCylinderTotal (dMass *, dReal total_mass, int direction,
|
||||
dReal radius, dReal length);
|
||||
|
||||
ODE_API void dMassSetBox (dMass *, dReal density,
|
||||
dReal lx, dReal ly, dReal lz);
|
||||
ODE_API void dMassSetBoxTotal (dMass *, dReal total_mass,
|
||||
dReal lx, dReal ly, dReal lz);
|
||||
|
||||
ODE_API void dMassSetTrimesh (dMass *, dReal density, dGeomID g);
|
||||
|
||||
ODE_API void dMassAdjust (dMass *, dReal newmass);
|
||||
|
||||
ODE_API void dMassTranslate (dMass *, dReal x, dReal y, dReal z);
|
||||
|
||||
ODE_API void dMassRotate (dMass *, const dMatrix3 R);
|
||||
|
||||
ODE_API void dMassAdd (dMass *a, const dMass *b);
|
||||
|
||||
// Backwards compatible API
|
||||
#define dMassSetCappedCylinder dMassSetCapsule
|
||||
#define dMassSetCappedCylinderTotal dMassSetCapsuleTotal
|
||||
|
||||
|
||||
struct dMass {
|
||||
dReal mass;
|
||||
dVector4 c;
|
||||
dMatrix3 I;
|
||||
|
||||
#ifdef __cplusplus
|
||||
dMass()
|
||||
{ dMassSetZero (this); }
|
||||
void setZero()
|
||||
{ dMassSetZero (this); }
|
||||
void setParameters (dReal themass, dReal cgx, dReal cgy, dReal cgz,
|
||||
dReal I11, dReal I22, dReal I33,
|
||||
dReal I12, dReal I13, dReal I23)
|
||||
{ dMassSetParameters (this,themass,cgx,cgy,cgz,I11,I22,I33,I12,I13,I23); }
|
||||
void setSphere (dReal density, dReal radius)
|
||||
{ dMassSetSphere (this,density,radius); }
|
||||
void setCapsule (dReal density, int direction, dReal a, dReal b)
|
||||
{ dMassSetCappedCylinder (this,density,direction,a,b); }
|
||||
void setCappedCylinder (dReal density, int direction, dReal a, dReal b)
|
||||
{ setCapsule(density, direction, a, b); }
|
||||
void setBox (dReal density, dReal lx, dReal ly, dReal lz)
|
||||
{ dMassSetBox (this,density,lx,ly,lz); }
|
||||
void adjust (dReal newmass)
|
||||
{ dMassAdjust (this,newmass); }
|
||||
void translate (dReal x, dReal y, dReal z)
|
||||
{ dMassTranslate (this,x,y,z); }
|
||||
void rotate (const dMatrix3 R)
|
||||
{ dMassRotate (this,R); }
|
||||
void add (const dMass *b)
|
||||
{ dMassAdd (this,b); }
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
194
ode/include/ode/matrix.h
Normal file
194
ode/include/ode/matrix.h
Normal file
@ -0,0 +1,194 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
|
||||
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of EITHER: *
|
||||
* (1) The GNU Lesser General Public License as published by the Free *
|
||||
* Software Foundation; either version 2.1 of the License, or (at *
|
||||
* your option) any later version. The text of the GNU Lesser *
|
||||
* General Public License is included with this library in the *
|
||||
* file LICENSE.TXT. *
|
||||
* (2) The BSD-style license that is included with this library in *
|
||||
* the file LICENSE-BSD.TXT. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
|
||||
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/* optimized and unoptimized vector and matrix functions */
|
||||
|
||||
#ifndef _ODE_MATRIX_H_
|
||||
#define _ODE_MATRIX_H_
|
||||
|
||||
#include <ode/common.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* set a vector/matrix of size n to all zeros, or to a specific value. */
|
||||
|
||||
ODE_API void dSetZero (dReal *a, int n);
|
||||
ODE_API void dSetValue (dReal *a, int n, dReal value);
|
||||
|
||||
|
||||
/* get the dot product of two n*1 vectors. if n <= 0 then
|
||||
* zero will be returned (in which case a and b need not be valid).
|
||||
*/
|
||||
|
||||
ODE_API dReal dDot (const dReal *a, const dReal *b, int n);
|
||||
|
||||
|
||||
/* get the dot products of (a0,b), (a1,b), etc and return them in outsum.
|
||||
* all vectors are n*1. if n <= 0 then zeroes will be returned (in which case
|
||||
* the input vectors need not be valid). this function is somewhat faster
|
||||
* than calling dDot() for all of the combinations separately.
|
||||
*/
|
||||
|
||||
/* NOT INCLUDED in the library for now.
|
||||
void dMultidot2 (const dReal *a0, const dReal *a1,
|
||||
const dReal *b, dReal *outsum, int n);
|
||||
*/
|
||||
|
||||
|
||||
/* matrix multiplication. all matrices are stored in standard row format.
|
||||
* the digit refers to the argument that is transposed:
|
||||
* 0: A = B * C (sizes: A:p*r B:p*q C:q*r)
|
||||
* 1: A = B' * C (sizes: A:p*r B:q*p C:q*r)
|
||||
* 2: A = B * C' (sizes: A:p*r B:p*q C:r*q)
|
||||
* case 1,2 are equivalent to saying that the operation is A=B*C but
|
||||
* B or C are stored in standard column format.
|
||||
*/
|
||||
|
||||
ODE_API void dMultiply0 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r);
|
||||
ODE_API void dMultiply1 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r);
|
||||
ODE_API void dMultiply2 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r);
|
||||
|
||||
|
||||
/* do an in-place cholesky decomposition on the lower triangle of the n*n
|
||||
* symmetric matrix A (which is stored by rows). the resulting lower triangle
|
||||
* will be such that L*L'=A. return 1 on success and 0 on failure (on failure
|
||||
* the matrix is not positive definite).
|
||||
*/
|
||||
|
||||
ODE_API int dFactorCholesky (dReal *A, int n);
|
||||
|
||||
|
||||
/* solve for x: L*L'*x = b, and put the result back into x.
|
||||
* L is size n*n, b is size n*1. only the lower triangle of L is considered.
|
||||
*/
|
||||
|
||||
ODE_API void dSolveCholesky (const dReal *L, dReal *b, int n);
|
||||
|
||||
|
||||
/* compute the inverse of the n*n positive definite matrix A and put it in
|
||||
* Ainv. this is not especially fast. this returns 1 on success (A was
|
||||
* positive definite) or 0 on failure (not PD).
|
||||
*/
|
||||
|
||||
ODE_API int dInvertPDMatrix (const dReal *A, dReal *Ainv, int n);
|
||||
|
||||
|
||||
/* check whether an n*n matrix A is positive definite, return 1/0 (yes/no).
|
||||
* positive definite means that x'*A*x > 0 for any x. this performs a
|
||||
* cholesky decomposition of A. if the decomposition fails then the matrix
|
||||
* is not positive definite. A is stored by rows. A is not altered.
|
||||
*/
|
||||
|
||||
ODE_API int dIsPositiveDefinite (const dReal *A, int n);
|
||||
|
||||
|
||||
/* factorize a matrix A into L*D*L', where L is lower triangular with ones on
|
||||
* the diagonal, and D is diagonal.
|
||||
* A is an n*n matrix stored by rows, with a leading dimension of n rounded
|
||||
* up to 4. L is written into the strict lower triangle of A (the ones are not
|
||||
* written) and the reciprocal of the diagonal elements of D are written into
|
||||
* d.
|
||||
*/
|
||||
ODE_API void dFactorLDLT (dReal *A, dReal *d, int n, int nskip);
|
||||
|
||||
|
||||
/* solve L*x=b, where L is n*n lower triangular with ones on the diagonal,
|
||||
* and x,b are n*1. b is overwritten with x.
|
||||
* the leading dimension of L is `nskip'.
|
||||
*/
|
||||
ODE_API void dSolveL1 (const dReal *L, dReal *b, int n, int nskip);
|
||||
|
||||
|
||||
/* solve L'*x=b, where L is n*n lower triangular with ones on the diagonal,
|
||||
* and x,b are n*1. b is overwritten with x.
|
||||
* the leading dimension of L is `nskip'.
|
||||
*/
|
||||
ODE_API void dSolveL1T (const dReal *L, dReal *b, int n, int nskip);
|
||||
|
||||
|
||||
/* in matlab syntax: a(1:n) = a(1:n) .* d(1:n) */
|
||||
|
||||
ODE_API void dVectorScale (dReal *a, const dReal *d, int n);
|
||||
|
||||
|
||||
/* given `L', a n*n lower triangular matrix with ones on the diagonal,
|
||||
* and `d', a n*1 vector of the reciprocal diagonal elements of an n*n matrix
|
||||
* D, solve L*D*L'*x=b where x,b are n*1. x overwrites b.
|
||||
* the leading dimension of L is `nskip'.
|
||||
*/
|
||||
|
||||
ODE_API void dSolveLDLT (const dReal *L, const dReal *d, dReal *b, int n, int nskip);
|
||||
|
||||
|
||||
/* given an L*D*L' factorization of an n*n matrix A, return the updated
|
||||
* factorization L2*D2*L2' of A plus the following "top left" matrix:
|
||||
*
|
||||
* [ b a' ] <-- b is a[0]
|
||||
* [ a 0 ] <-- a is a[1..n-1]
|
||||
*
|
||||
* - L has size n*n, its leading dimension is nskip. L is lower triangular
|
||||
* with ones on the diagonal. only the lower triangle of L is referenced.
|
||||
* - d has size n. d contains the reciprocal diagonal elements of D.
|
||||
* - a has size n.
|
||||
* the result is written into L, except that the left column of L and d[0]
|
||||
* are not actually modified. see ldltaddTL.m for further comments.
|
||||
*/
|
||||
ODE_API void dLDLTAddTL (dReal *L, dReal *d, const dReal *a, int n, int nskip);
|
||||
|
||||
|
||||
/* given an L*D*L' factorization of a permuted matrix A, produce a new
|
||||
* factorization for row and column `r' removed.
|
||||
* - A has size n1*n1, its leading dimension in nskip. A is symmetric and
|
||||
* positive definite. only the lower triangle of A is referenced.
|
||||
* A itself may actually be an array of row pointers.
|
||||
* - L has size n2*n2, its leading dimension in nskip. L is lower triangular
|
||||
* with ones on the diagonal. only the lower triangle of L is referenced.
|
||||
* - d has size n2. d contains the reciprocal diagonal elements of D.
|
||||
* - p is a permutation vector. it contains n2 indexes into A. each index
|
||||
* must be in the range 0..n1-1.
|
||||
* - r is the row/column of L to remove.
|
||||
* the new L will be written within the old L, i.e. will have the same leading
|
||||
* dimension. the last row and column of L, and the last element of d, are
|
||||
* undefined on exit.
|
||||
*
|
||||
* a fast O(n^2) algorithm is used. see ldltremove.m for further comments.
|
||||
*/
|
||||
ODE_API void dLDLTRemove (dReal **A, const int *p, dReal *L, dReal *d,
|
||||
int n1, int n2, int r, int nskip);
|
||||
|
||||
|
||||
/* given an n*n matrix A (with leading dimension nskip), remove the r'th row
|
||||
* and column by moving elements. the new matrix will have the same leading
|
||||
* dimension. the last row and column of A are untouched on exit.
|
||||
*/
|
||||
ODE_API void dRemoveRowCol (dReal *A, int n, int nskip, int r);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
59
ode/include/ode/memory.h
Normal file
59
ode/include/ode/memory.h
Normal file
@ -0,0 +1,59 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
|
||||
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of EITHER: *
|
||||
* (1) The GNU Lesser General Public License as published by the Free *
|
||||
* Software Foundation; either version 2.1 of the License, or (at *
|
||||
* your option) any later version. The text of the GNU Lesser *
|
||||
* General Public License is included with this library in the *
|
||||
* file LICENSE.TXT. *
|
||||
* (2) The BSD-style license that is included with this library in *
|
||||
* the file LICENSE-BSD.TXT. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
|
||||
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/* this comes from the `reuse' library. copy any changes back to the source */
|
||||
|
||||
#ifndef _ODE_MEMORY_H_
|
||||
#define _ODE_MEMORY_H_
|
||||
|
||||
#include "ode/config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* function types to allocate and free memory */
|
||||
typedef void * dAllocFunction (size_t size);
|
||||
typedef void * dReallocFunction (void *ptr, size_t oldsize, size_t newsize);
|
||||
typedef void dFreeFunction (void *ptr, size_t size);
|
||||
|
||||
/* set new memory management functions. if fn is 0, the default handlers are
|
||||
* used. */
|
||||
ODE_API void dSetAllocHandler (dAllocFunction *fn);
|
||||
ODE_API void dSetReallocHandler (dReallocFunction *fn);
|
||||
ODE_API void dSetFreeHandler (dFreeFunction *fn);
|
||||
|
||||
/* get current memory management functions */
|
||||
ODE_API dAllocFunction *dGetAllocHandler (void);
|
||||
ODE_API dReallocFunction *dGetReallocHandler (void);
|
||||
ODE_API dFreeFunction *dGetFreeHandler (void);
|
||||
|
||||
/* allocate and free memory. */
|
||||
ODE_API void * dAlloc (size_t size);
|
||||
ODE_API void * dRealloc (void *ptr, size_t oldsize, size_t newsize);
|
||||
ODE_API void dFree (void *ptr, size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
85
ode/include/ode/misc.h
Normal file
85
ode/include/ode/misc.h
Normal file
@ -0,0 +1,85 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
|
||||
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of EITHER: *
|
||||
* (1) The GNU Lesser General Public License as published by the Free *
|
||||
* Software Foundation; either version 2.1 of the License, or (at *
|
||||
* your option) any later version. The text of the GNU Lesser *
|
||||
* General Public License is included with this library in the *
|
||||
* file LICENSE.TXT. *
|
||||
* (2) The BSD-style license that is included with this library in *
|
||||
* the file LICENSE-BSD.TXT. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
|
||||
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/* miscellaneous math functions. these are mostly useful for testing */
|
||||
|
||||
#ifndef _ODE_MISC_H_
|
||||
#define _ODE_MISC_H_
|
||||
|
||||
#include <ode/common.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* return 1 if the random number generator is working. */
|
||||
ODE_API int dTestRand(void);
|
||||
|
||||
/* return next 32 bit random number. this uses a not-very-random linear
|
||||
* congruential method.
|
||||
*/
|
||||
ODE_API unsigned long dRand(void);
|
||||
|
||||
/* get and set the current random number seed. */
|
||||
ODE_API unsigned long dRandGetSeed(void);
|
||||
ODE_API void dRandSetSeed (unsigned long s);
|
||||
|
||||
/* return a random integer between 0..n-1. the distribution will get worse
|
||||
* as n approaches 2^32.
|
||||
*/
|
||||
ODE_API int dRandInt (int n);
|
||||
|
||||
/* return a random real number between 0..1 */
|
||||
ODE_API dReal dRandReal(void);
|
||||
|
||||
/* print out a matrix */
|
||||
#ifdef __cplusplus
|
||||
ODE_API void dPrintMatrix (const dReal *A, int n, int m, char *fmt = "%10.4f ",
|
||||
FILE *f=stdout);
|
||||
#else
|
||||
ODE_API void dPrintMatrix (const dReal *A, int n, int m, char *fmt, FILE *f);
|
||||
#endif
|
||||
|
||||
/* make a random vector with entries between +/- range. A has n elements. */
|
||||
ODE_API void dMakeRandomVector (dReal *A, int n, dReal range);
|
||||
|
||||
/* make a random matrix with entries between +/- range. A has size n*m. */
|
||||
ODE_API void dMakeRandomMatrix (dReal *A, int n, int m, dReal range);
|
||||
|
||||
/* clear the upper triangle of a square matrix */
|
||||
ODE_API void dClearUpperTriangle (dReal *A, int n);
|
||||
|
||||
/* return the maximum element difference between the two n*m matrices */
|
||||
ODE_API dReal dMaxDifference (const dReal *A, const dReal *B, int n, int m);
|
||||
|
||||
/* return the maximum element difference between the lower triangle of two
|
||||
* n*n matrices */
|
||||
ODE_API dReal dMaxDifferenceLowerTriangle (const dReal *A, const dReal *B, int n);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
1941
ode/include/ode/objects.h
Normal file
1941
ode/include/ode/objects.h
Normal file
File diff suppressed because it is too large
Load Diff
47
ode/include/ode/ode.h
Normal file
47
ode/include/ode/ode.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
|
||||
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of EITHER: *
|
||||
* (1) The GNU Lesser General Public License as published by the Free *
|
||||
* Software Foundation; either version 2.1 of the License, or (at *
|
||||
* your option) any later version. The text of the GNU Lesser *
|
||||
* General Public License is included with this library in the *
|
||||
* file LICENSE.TXT. *
|
||||
* (2) The BSD-style license that is included with this library in *
|
||||
* the file LICENSE-BSD.TXT. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
|
||||
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef _ODE_ODE_H_
|
||||
#define _ODE_ODE_H_
|
||||
|
||||
/* include *everything* here */
|
||||
|
||||
#include <ode/config.h>
|
||||
#include <ode/compatibility.h>
|
||||
#include <ode/common.h>
|
||||
#include <ode/contact.h>
|
||||
#include <ode/error.h>
|
||||
#include <ode/memory.h>
|
||||
#include <ode/odemath.h>
|
||||
#include <ode/matrix.h>
|
||||
#include <ode/timer.h>
|
||||
#include <ode/rotation.h>
|
||||
#include <ode/mass.h>
|
||||
#include <ode/misc.h>
|
||||
#include <ode/objects.h>
|
||||
#include <ode/odecpp.h>
|
||||
#include <ode/collision_space.h>
|
||||
#include <ode/collision.h>
|
||||
#include <ode/odecpp_collision.h>
|
||||
#include <ode/export-dif.h>
|
||||
|
||||
#endif
|
702
ode/include/ode/odecpp.h
Normal file
702
ode/include/ode/odecpp.h
Normal file
@ -0,0 +1,702 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
|
||||
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of EITHER: *
|
||||
* (1) The GNU Lesser General Public License as published by the Free *
|
||||
* Software Foundation; either version 2.1 of the License, or (at *
|
||||
* your option) any later version. The text of the GNU Lesser *
|
||||
* General Public License is included with this library in the *
|
||||
* file LICENSE.TXT. *
|
||||
* (2) The BSD-style license that is included with this library in *
|
||||
* the file LICENSE-BSD.TXT. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
|
||||
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/* C++ interface for non-collision stuff */
|
||||
|
||||
|
||||
#ifndef _ODE_ODECPP_H_
|
||||
#define _ODE_ODECPP_H_
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <ode/error.h>
|
||||
|
||||
|
||||
class dWorld {
|
||||
dWorldID _id;
|
||||
|
||||
// intentionally undefined, don't use these
|
||||
dWorld (const dWorld &);
|
||||
void operator= (const dWorld &);
|
||||
|
||||
public:
|
||||
dWorld()
|
||||
{ _id = dWorldCreate(); }
|
||||
~dWorld()
|
||||
{ dWorldDestroy (_id); }
|
||||
|
||||
dWorldID id() const
|
||||
{ return _id; }
|
||||
operator dWorldID() const
|
||||
{ return _id; }
|
||||
|
||||
void setGravity (dReal x, dReal y, dReal z)
|
||||
{ dWorldSetGravity (_id,x,y,z); }
|
||||
void getGravity (dVector3 g) const
|
||||
{ dWorldGetGravity (_id,g); }
|
||||
|
||||
void setERP (dReal erp)
|
||||
{ dWorldSetERP(_id, erp); }
|
||||
dReal getERP() const
|
||||
{ return dWorldGetERP(_id); }
|
||||
|
||||
void setCFM (dReal cfm)
|
||||
{ dWorldSetCFM(_id, cfm); }
|
||||
dReal getCFM() const
|
||||
{ return dWorldGetCFM(_id); }
|
||||
|
||||
void step (dReal stepsize)
|
||||
{ dWorldStep (_id,stepsize); }
|
||||
|
||||
void stepFast1 (dReal stepsize, int maxiterations)
|
||||
{ dWorldStepFast1 (_id,stepsize,maxiterations); }
|
||||
void setAutoEnableDepthSF1(dWorldID, int depth)
|
||||
{ dWorldSetAutoEnableDepthSF1 (_id, depth); }
|
||||
int getAutoEnableDepthSF1(dWorldID)
|
||||
{ return dWorldGetAutoEnableDepthSF1 (_id); }
|
||||
|
||||
void setAutoDisableLinearThreshold (dReal threshold)
|
||||
{ dWorldSetAutoDisableLinearThreshold (_id,threshold); }
|
||||
dReal getAutoDisableLinearThreshold()
|
||||
{ return dWorldGetAutoDisableLinearThreshold (_id); }
|
||||
void setAutoDisableAngularThreshold (dReal threshold)
|
||||
{ dWorldSetAutoDisableAngularThreshold (_id,threshold); }
|
||||
dReal getAutoDisableAngularThreshold()
|
||||
{ return dWorldGetAutoDisableAngularThreshold (_id); }
|
||||
void setAutoDisableSteps (int steps)
|
||||
{ dWorldSetAutoDisableSteps (_id,steps); }
|
||||
int getAutoDisableSteps()
|
||||
{ return dWorldGetAutoDisableSteps (_id); }
|
||||
void setAutoDisableTime (dReal time)
|
||||
{ dWorldSetAutoDisableTime (_id,time); }
|
||||
dReal getAutoDisableTime()
|
||||
{ return dWorldGetAutoDisableTime (_id); }
|
||||
void setAutoDisableFlag (int do_auto_disable)
|
||||
{ dWorldSetAutoDisableFlag (_id,do_auto_disable); }
|
||||
int getAutoDisableFlag()
|
||||
{ return dWorldGetAutoDisableFlag (_id); }
|
||||
|
||||
void impulseToForce (dReal stepsize, dReal ix, dReal iy, dReal iz,
|
||||
dVector3 force)
|
||||
{ dWorldImpulseToForce (_id,stepsize,ix,iy,iz,force); }
|
||||
};
|
||||
|
||||
|
||||
class dBody {
|
||||
dBodyID _id;
|
||||
|
||||
// intentionally undefined, don't use these
|
||||
dBody (const dBody &);
|
||||
void operator= (const dBody &);
|
||||
|
||||
public:
|
||||
dBody()
|
||||
{ _id = 0; }
|
||||
dBody (dWorldID world)
|
||||
{ _id = dBodyCreate (world); }
|
||||
~dBody()
|
||||
{ if (_id) dBodyDestroy (_id); }
|
||||
|
||||
void create (dWorldID world) {
|
||||
if (_id) dBodyDestroy (_id);
|
||||
_id = dBodyCreate (world);
|
||||
}
|
||||
|
||||
dBodyID id() const
|
||||
{ return _id; }
|
||||
operator dBodyID() const
|
||||
{ return _id; }
|
||||
|
||||
void setData (void *data)
|
||||
{ dBodySetData (_id,data); }
|
||||
void *getData() const
|
||||
{ return dBodyGetData (_id); }
|
||||
|
||||
void setPosition (dReal x, dReal y, dReal z)
|
||||
{ dBodySetPosition (_id,x,y,z); }
|
||||
void setRotation (const dMatrix3 R)
|
||||
{ dBodySetRotation (_id,R); }
|
||||
void setQuaternion (const dQuaternion q)
|
||||
{ dBodySetQuaternion (_id,q); }
|
||||
void setLinearVel (dReal x, dReal y, dReal z)
|
||||
{ dBodySetLinearVel (_id,x,y,z); }
|
||||
void setAngularVel (dReal x, dReal y, dReal z)
|
||||
{ dBodySetAngularVel (_id,x,y,z); }
|
||||
|
||||
const dReal * getPosition() const
|
||||
{ return dBodyGetPosition (_id); }
|
||||
const dReal * getRotation() const
|
||||
{ return dBodyGetRotation (_id); }
|
||||
const dReal * getQuaternion() const
|
||||
{ return dBodyGetQuaternion (_id); }
|
||||
const dReal * getLinearVel() const
|
||||
{ return dBodyGetLinearVel (_id); }
|
||||
const dReal * getAngularVel() const
|
||||
{ return dBodyGetAngularVel (_id); }
|
||||
|
||||
void setMass (const dMass *mass)
|
||||
{ dBodySetMass (_id,mass); }
|
||||
void getMass (dMass *mass) const
|
||||
{ dBodyGetMass (_id,mass); }
|
||||
|
||||
void addForce (dReal fx, dReal fy, dReal fz)
|
||||
{ dBodyAddForce (_id, fx, fy, fz); }
|
||||
void addTorque (dReal fx, dReal fy, dReal fz)
|
||||
{ dBodyAddTorque (_id, fx, fy, fz); }
|
||||
void addRelForce (dReal fx, dReal fy, dReal fz)
|
||||
{ dBodyAddRelForce (_id, fx, fy, fz); }
|
||||
void addRelTorque (dReal fx, dReal fy, dReal fz)
|
||||
{ dBodyAddRelTorque (_id, fx, fy, fz); }
|
||||
void addForceAtPos (dReal fx, dReal fy, dReal fz,
|
||||
dReal px, dReal py, dReal pz)
|
||||
{ dBodyAddForceAtPos (_id, fx, fy, fz, px, py, pz); }
|
||||
void addForceAtRelPos (dReal fx, dReal fy, dReal fz,
|
||||
dReal px, dReal py, dReal pz)
|
||||
{ dBodyAddForceAtRelPos (_id, fx, fy, fz, px, py, pz); }
|
||||
void addRelForceAtPos (dReal fx, dReal fy, dReal fz,
|
||||
dReal px, dReal py, dReal pz)
|
||||
{ dBodyAddRelForceAtPos (_id, fx, fy, fz, px, py, pz); }
|
||||
void addRelForceAtRelPos (dReal fx, dReal fy, dReal fz,
|
||||
dReal px, dReal py, dReal pz)
|
||||
{ dBodyAddRelForceAtRelPos (_id, fx, fy, fz, px, py, pz); }
|
||||
|
||||
const dReal * getForce() const
|
||||
{ return dBodyGetForce(_id); }
|
||||
const dReal * getTorque() const
|
||||
{ return dBodyGetTorque(_id); }
|
||||
void setForce (dReal x, dReal y, dReal z)
|
||||
{ dBodySetForce (_id,x,y,z); }
|
||||
void setTorque (dReal x, dReal y, dReal z)
|
||||
{ dBodySetTorque (_id,x,y,z); }
|
||||
|
||||
void enable()
|
||||
{ dBodyEnable (_id); }
|
||||
void disable()
|
||||
{ dBodyDisable (_id); }
|
||||
int isEnabled() const
|
||||
{ return dBodyIsEnabled (_id); }
|
||||
|
||||
void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result) const
|
||||
{ dBodyGetRelPointPos (_id, px, py, pz, result); }
|
||||
void getRelPointVel (dReal px, dReal py, dReal pz, dVector3 result) const
|
||||
{ dBodyGetRelPointVel (_id, px, py, pz, result); }
|
||||
void getPointVel (dReal px, dReal py, dReal pz, dVector3 result) const
|
||||
{ dBodyGetPointVel (_id,px,py,pz,result); }
|
||||
void getPosRelPoint (dReal px, dReal py, dReal pz, dVector3 result) const
|
||||
{ dBodyGetPosRelPoint (_id,px,py,pz,result); }
|
||||
void vectorToWorld (dReal px, dReal py, dReal pz, dVector3 result) const
|
||||
{ dBodyVectorToWorld (_id,px,py,pz,result); }
|
||||
void vectorFromWorld (dReal px, dReal py, dReal pz, dVector3 result) const
|
||||
{ dBodyVectorFromWorld (_id,px,py,pz,result); }
|
||||
|
||||
void setFiniteRotationMode (int mode)
|
||||
{ dBodySetFiniteRotationMode (_id, mode); }
|
||||
void setFiniteRotationAxis (dReal x, dReal y, dReal z)
|
||||
{ dBodySetFiniteRotationAxis (_id, x, y, z); }
|
||||
|
||||
int getFiniteRotationMode() const
|
||||
{ return dBodyGetFiniteRotationMode (_id); }
|
||||
void getFiniteRotationAxis (dVector3 result) const
|
||||
{ dBodyGetFiniteRotationAxis (_id, result); }
|
||||
|
||||
int getNumJoints() const
|
||||
{ return dBodyGetNumJoints (_id); }
|
||||
dJointID getJoint (int index) const
|
||||
{ return dBodyGetJoint (_id, index); }
|
||||
|
||||
void setGravityMode (int mode)
|
||||
{ dBodySetGravityMode (_id,mode); }
|
||||
int getGravityMode() const
|
||||
{ return dBodyGetGravityMode (_id); }
|
||||
|
||||
int isConnectedTo (dBodyID body) const
|
||||
{ return dAreConnected (_id, body); }
|
||||
|
||||
void setAutoDisableLinearThreshold (dReal threshold)
|
||||
{ dBodySetAutoDisableLinearThreshold (_id,threshold); }
|
||||
dReal getAutoDisableLinearThreshold()
|
||||
{ return dBodyGetAutoDisableLinearThreshold (_id); }
|
||||
void setAutoDisableAngularThreshold (dReal threshold)
|
||||
{ dBodySetAutoDisableAngularThreshold (_id,threshold); }
|
||||
dReal getAutoDisableAngularThreshold()
|
||||
{ return dBodyGetAutoDisableAngularThreshold (_id); }
|
||||
void setAutoDisableSteps (int steps)
|
||||
{ dBodySetAutoDisableSteps (_id,steps); }
|
||||
int getAutoDisableSteps()
|
||||
{ return dBodyGetAutoDisableSteps (_id); }
|
||||
void setAutoDisableTime (dReal time)
|
||||
{ dBodySetAutoDisableTime (_id,time); }
|
||||
dReal getAutoDisableTime()
|
||||
{ return dBodyGetAutoDisableTime (_id); }
|
||||
void setAutoDisableFlag (int do_auto_disable)
|
||||
{ dBodySetAutoDisableFlag (_id,do_auto_disable); }
|
||||
int getAutoDisableFlag()
|
||||
{ return dBodyGetAutoDisableFlag (_id); }
|
||||
};
|
||||
|
||||
|
||||
class dJointGroup {
|
||||
dJointGroupID _id;
|
||||
|
||||
// intentionally undefined, don't use these
|
||||
dJointGroup (const dJointGroup &);
|
||||
void operator= (const dJointGroup &);
|
||||
|
||||
public:
|
||||
dJointGroup (int dummy_arg=0)
|
||||
{ _id = dJointGroupCreate (0); }
|
||||
~dJointGroup()
|
||||
{ dJointGroupDestroy (_id); }
|
||||
void create (int dummy_arg=0) {
|
||||
if (_id) dJointGroupDestroy (_id);
|
||||
_id = dJointGroupCreate (0);
|
||||
}
|
||||
|
||||
dJointGroupID id() const
|
||||
{ return _id; }
|
||||
operator dJointGroupID() const
|
||||
{ return _id; }
|
||||
|
||||
void empty()
|
||||
{ dJointGroupEmpty (_id); }
|
||||
};
|
||||
|
||||
|
||||
class dJoint {
|
||||
private:
|
||||
// intentionally undefined, don't use these
|
||||
dJoint (const dJoint &) ;
|
||||
void operator= (const dJoint &);
|
||||
|
||||
protected:
|
||||
dJointID _id;
|
||||
|
||||
public:
|
||||
dJoint()
|
||||
{ _id = 0; }
|
||||
~dJoint()
|
||||
{ if (_id) dJointDestroy (_id); }
|
||||
|
||||
dJointID id() const
|
||||
{ return _id; }
|
||||
operator dJointID() const
|
||||
{ return _id; }
|
||||
|
||||
void attach (dBodyID body1, dBodyID body2)
|
||||
{ dJointAttach (_id, body1, body2); }
|
||||
|
||||
void setData (void *data)
|
||||
{ dJointSetData (_id, data); }
|
||||
void *getData() const
|
||||
{ return dJointGetData (_id); }
|
||||
|
||||
int getType() const
|
||||
{ return dJointGetType (_id); }
|
||||
|
||||
dBodyID getBody (int index) const
|
||||
{ return dJointGetBody (_id, index); }
|
||||
|
||||
void setFeedback(dJointFeedback *fb)
|
||||
{ dJointSetFeedback(_id, fb); }
|
||||
dJointFeedback *getFeedback() const
|
||||
{ return dJointGetFeedback(_id); }
|
||||
};
|
||||
|
||||
|
||||
class dBallJoint : public dJoint {
|
||||
private:
|
||||
// intentionally undefined, don't use these
|
||||
dBallJoint (const dBallJoint &);
|
||||
void operator= (const dBallJoint &);
|
||||
|
||||
public:
|
||||
dBallJoint() { }
|
||||
dBallJoint (dWorldID world, dJointGroupID group=0)
|
||||
{ _id = dJointCreateBall (world, group); }
|
||||
|
||||
void create (dWorldID world, dJointGroupID group=0) {
|
||||
if (_id) dJointDestroy (_id);
|
||||
_id = dJointCreateBall (world, group);
|
||||
}
|
||||
|
||||
void setAnchor (dReal x, dReal y, dReal z)
|
||||
{ dJointSetBallAnchor (_id, x, y, z); }
|
||||
void getAnchor (dVector3 result) const
|
||||
{ dJointGetBallAnchor (_id, result); }
|
||||
void getAnchor2 (dVector3 result) const
|
||||
{ dJointGetBallAnchor2 (_id, result); }
|
||||
} ;
|
||||
|
||||
|
||||
class dHingeJoint : public dJoint {
|
||||
// intentionally undefined, don't use these
|
||||
dHingeJoint (const dHingeJoint &);
|
||||
void operator = (const dHingeJoint &);
|
||||
|
||||
public:
|
||||
dHingeJoint() { }
|
||||
dHingeJoint (dWorldID world, dJointGroupID group=0)
|
||||
{ _id = dJointCreateHinge (world, group); }
|
||||
|
||||
void create (dWorldID world, dJointGroupID group=0) {
|
||||
if (_id) dJointDestroy (_id);
|
||||
_id = dJointCreateHinge (world, group);
|
||||
}
|
||||
|
||||
void setAnchor (dReal x, dReal y, dReal z)
|
||||
{ dJointSetHingeAnchor (_id, x, y, z); }
|
||||
void getAnchor (dVector3 result) const
|
||||
{ dJointGetHingeAnchor (_id, result); }
|
||||
void getAnchor2 (dVector3 result) const
|
||||
{ dJointGetHingeAnchor2 (_id, result); }
|
||||
|
||||
void setAxis (dReal x, dReal y, dReal z)
|
||||
{ dJointSetHingeAxis (_id, x, y, z); }
|
||||
void getAxis (dVector3 result) const
|
||||
{ dJointGetHingeAxis (_id, result); }
|
||||
|
||||
dReal getAngle() const
|
||||
{ return dJointGetHingeAngle (_id); }
|
||||
dReal getAngleRate() const
|
||||
{ return dJointGetHingeAngleRate (_id); }
|
||||
|
||||
void setParam (int parameter, dReal value)
|
||||
{ dJointSetHingeParam (_id, parameter, value); }
|
||||
dReal getParam (int parameter) const
|
||||
{ return dJointGetHingeParam (_id, parameter); }
|
||||
|
||||
void addTorque (dReal torque)
|
||||
{ dJointAddHingeTorque(_id, torque); }
|
||||
};
|
||||
|
||||
|
||||
class dSliderJoint : public dJoint {
|
||||
// intentionally undefined, don't use these
|
||||
dSliderJoint (const dSliderJoint &);
|
||||
void operator = (const dSliderJoint &);
|
||||
|
||||
public:
|
||||
dSliderJoint() { }
|
||||
dSliderJoint (dWorldID world, dJointGroupID group=0)
|
||||
{ _id = dJointCreateSlider (world, group); }
|
||||
|
||||
void create (dWorldID world, dJointGroupID group=0) {
|
||||
if (_id) dJointDestroy (_id);
|
||||
_id = dJointCreateSlider (world, group);
|
||||
}
|
||||
|
||||
void setAxis (dReal x, dReal y, dReal z)
|
||||
{ dJointSetSliderAxis (_id, x, y, z); }
|
||||
void getAxis (dVector3 result) const
|
||||
{ dJointGetSliderAxis (_id, result); }
|
||||
|
||||
dReal getPosition() const
|
||||
{ return dJointGetSliderPosition (_id); }
|
||||
dReal getPositionRate() const
|
||||
{ return dJointGetSliderPositionRate (_id); }
|
||||
|
||||
void setParam (int parameter, dReal value)
|
||||
{ dJointSetSliderParam (_id, parameter, value); }
|
||||
dReal getParam (int parameter) const
|
||||
{ return dJointGetSliderParam (_id, parameter); }
|
||||
|
||||
void addForce (dReal force)
|
||||
{ dJointAddSliderForce(_id, force); }
|
||||
};
|
||||
|
||||
|
||||
class dUniversalJoint : public dJoint {
|
||||
// intentionally undefined, don't use these
|
||||
dUniversalJoint (const dUniversalJoint &);
|
||||
void operator = (const dUniversalJoint &);
|
||||
|
||||
public:
|
||||
dUniversalJoint() { }
|
||||
dUniversalJoint (dWorldID world, dJointGroupID group=0)
|
||||
{ _id = dJointCreateUniversal (world, group); }
|
||||
|
||||
void create (dWorldID world, dJointGroupID group=0) {
|
||||
if (_id) dJointDestroy (_id);
|
||||
_id = dJointCreateUniversal (world, group);
|
||||
}
|
||||
|
||||
void setAnchor (dReal x, dReal y, dReal z)
|
||||
{ dJointSetUniversalAnchor (_id, x, y, z); }
|
||||
void setAxis1 (dReal x, dReal y, dReal z)
|
||||
{ dJointSetUniversalAxis1 (_id, x, y, z); }
|
||||
void setAxis2 (dReal x, dReal y, dReal z)
|
||||
{ dJointSetUniversalAxis2 (_id, x, y, z); }
|
||||
void setParam (int parameter, dReal value)
|
||||
{ dJointSetUniversalParam (_id, parameter, value); }
|
||||
|
||||
void getAnchor (dVector3 result) const
|
||||
{ dJointGetUniversalAnchor (_id, result); }
|
||||
void getAnchor2 (dVector3 result) const
|
||||
{ dJointGetUniversalAnchor2 (_id, result); }
|
||||
void getAxis1 (dVector3 result) const
|
||||
{ dJointGetUniversalAxis1 (_id, result); }
|
||||
void getAxis2 (dVector3 result) const
|
||||
{ dJointGetUniversalAxis2 (_id, result); }
|
||||
dReal getParam (int parameter) const
|
||||
{ return dJointGetUniversalParam (_id, parameter); }
|
||||
void getAngles(dReal *angle1, dReal *angle2) const
|
||||
{ dJointGetUniversalAngles (_id, angle1, angle2); }
|
||||
|
||||
dReal getAngle1() const
|
||||
{ return dJointGetUniversalAngle1 (_id); }
|
||||
dReal getAngle1Rate() const
|
||||
{ return dJointGetUniversalAngle1Rate (_id); }
|
||||
dReal getAngle2() const
|
||||
{ return dJointGetUniversalAngle2 (_id); }
|
||||
dReal getAngle2Rate() const
|
||||
{ return dJointGetUniversalAngle2Rate (_id); }
|
||||
|
||||
void addTorques (dReal torque1, dReal torque2)
|
||||
{ dJointAddUniversalTorques(_id, torque1, torque2); }
|
||||
};
|
||||
|
||||
|
||||
class dHinge2Joint : public dJoint {
|
||||
// intentionally undefined, don't use these
|
||||
dHinge2Joint (const dHinge2Joint &);
|
||||
void operator = (const dHinge2Joint &);
|
||||
|
||||
public:
|
||||
dHinge2Joint() { }
|
||||
dHinge2Joint (dWorldID world, dJointGroupID group=0)
|
||||
{ _id = dJointCreateHinge2 (world, group); }
|
||||
|
||||
void create (dWorldID world, dJointGroupID group=0) {
|
||||
if (_id) dJointDestroy (_id);
|
||||
_id = dJointCreateHinge2 (world, group);
|
||||
}
|
||||
|
||||
void setAnchor (dReal x, dReal y, dReal z)
|
||||
{ dJointSetHinge2Anchor (_id, x, y, z); }
|
||||
void setAxis1 (dReal x, dReal y, dReal z)
|
||||
{ dJointSetHinge2Axis1 (_id, x, y, z); }
|
||||
void setAxis2 (dReal x, dReal y, dReal z)
|
||||
{ dJointSetHinge2Axis2 (_id, x, y, z); }
|
||||
|
||||
void getAnchor (dVector3 result) const
|
||||
{ dJointGetHinge2Anchor (_id, result); }
|
||||
void getAnchor2 (dVector3 result) const
|
||||
{ dJointGetHinge2Anchor2 (_id, result); }
|
||||
void getAxis1 (dVector3 result) const
|
||||
{ dJointGetHinge2Axis1 (_id, result); }
|
||||
void getAxis2 (dVector3 result) const
|
||||
{ dJointGetHinge2Axis2 (_id, result); }
|
||||
|
||||
dReal getAngle1() const
|
||||
{ return dJointGetHinge2Angle1 (_id); }
|
||||
dReal getAngle1Rate() const
|
||||
{ return dJointGetHinge2Angle1Rate (_id); }
|
||||
dReal getAngle2Rate() const
|
||||
{ return dJointGetHinge2Angle2Rate (_id); }
|
||||
|
||||
void setParam (int parameter, dReal value)
|
||||
{ dJointSetHinge2Param (_id, parameter, value); }
|
||||
dReal getParam (int parameter) const
|
||||
{ return dJointGetHinge2Param (_id, parameter); }
|
||||
|
||||
void addTorques(dReal torque1, dReal torque2)
|
||||
{ dJointAddHinge2Torques(_id, torque1, torque2); }
|
||||
};
|
||||
|
||||
|
||||
class dPRJoint : public dJoint {
|
||||
dPRJoint (const dPRJoint &);
|
||||
void operator = (const dPRJoint &);
|
||||
|
||||
public:
|
||||
dPRJoint() { }
|
||||
dPRJoint (dWorldID world, dJointGroupID group=0)
|
||||
{ _id = dJointCreatePR (world, group); }
|
||||
|
||||
void create (dWorldID world, dJointGroupID group=0) {
|
||||
if (_id) dJointDestroy (_id);
|
||||
_id = dJointCreatePR (world, group);
|
||||
}
|
||||
|
||||
void setAnchor (dReal x, dReal y, dReal z)
|
||||
{ dJointSetPRAnchor (_id, x, y, z); }
|
||||
void setAxis1 (dReal x, dReal y, dReal z)
|
||||
{ dJointSetPRAxis1 (_id, x, y, z); }
|
||||
void setAxis2 (dReal x, dReal y, dReal z)
|
||||
{ dJointSetPRAxis2 (_id, x, y, z); }
|
||||
|
||||
void getAnchor (dVector3 result) const
|
||||
{ dJointGetPRAnchor (_id, result); }
|
||||
void getAxis1 (dVector3 result) const
|
||||
{ dJointGetPRAxis1 (_id, result); }
|
||||
void getAxis2 (dVector3 result) const
|
||||
{ dJointGetPRAxis2 (_id, result); }
|
||||
|
||||
dReal getPosition() const
|
||||
{ return dJointGetPRPosition (_id); }
|
||||
dReal getPositionRate() const
|
||||
{ return dJointGetPRPositionRate (_id); }
|
||||
|
||||
void setParam (int parameter, dReal value)
|
||||
{ dJointSetPRParam (_id, parameter, value); }
|
||||
dReal getParam (int parameter) const
|
||||
{ return dJointGetPRParam (_id, parameter); }
|
||||
};
|
||||
|
||||
|
||||
class dFixedJoint : public dJoint {
|
||||
// intentionally undefined, don't use these
|
||||
dFixedJoint (const dFixedJoint &);
|
||||
void operator = (const dFixedJoint &);
|
||||
|
||||
public:
|
||||
dFixedJoint() { }
|
||||
dFixedJoint (dWorldID world, dJointGroupID group=0)
|
||||
{ _id = dJointCreateFixed (world, group); }
|
||||
|
||||
void create (dWorldID world, dJointGroupID group=0) {
|
||||
if (_id) dJointDestroy (_id);
|
||||
_id = dJointCreateFixed (world, group);
|
||||
}
|
||||
|
||||
void set()
|
||||
{ dJointSetFixed (_id); }
|
||||
};
|
||||
|
||||
|
||||
class dContactJoint : public dJoint {
|
||||
// intentionally undefined, don't use these
|
||||
dContactJoint (const dContactJoint &);
|
||||
void operator = (const dContactJoint &);
|
||||
|
||||
public:
|
||||
dContactJoint() { }
|
||||
dContactJoint (dWorldID world, dJointGroupID group, dContact *contact)
|
||||
{ _id = dJointCreateContact (world, group, contact); }
|
||||
|
||||
void create (dWorldID world, dJointGroupID group, dContact *contact) {
|
||||
if (_id) dJointDestroy (_id);
|
||||
_id = dJointCreateContact (world, group, contact);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class dNullJoint : public dJoint {
|
||||
// intentionally undefined, don't use these
|
||||
dNullJoint (const dNullJoint &);
|
||||
void operator = (const dNullJoint &);
|
||||
|
||||
public:
|
||||
dNullJoint() { }
|
||||
dNullJoint (dWorldID world, dJointGroupID group=0)
|
||||
{ _id = dJointCreateNull (world, group); }
|
||||
|
||||
void create (dWorldID world, dJointGroupID group=0) {
|
||||
if (_id) dJointDestroy (_id);
|
||||
_id = dJointCreateNull (world, group);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class dAMotorJoint : public dJoint {
|
||||
// intentionally undefined, don't use these
|
||||
dAMotorJoint (const dAMotorJoint &);
|
||||
void operator = (const dAMotorJoint &);
|
||||
|
||||
public:
|
||||
dAMotorJoint() { }
|
||||
dAMotorJoint (dWorldID world, dJointGroupID group=0)
|
||||
{ _id = dJointCreateAMotor (world, group); }
|
||||
|
||||
void create (dWorldID world, dJointGroupID group=0) {
|
||||
if (_id) dJointDestroy (_id);
|
||||
_id = dJointCreateAMotor (world, group);
|
||||
}
|
||||
|
||||
void setMode (int mode)
|
||||
{ dJointSetAMotorMode (_id, mode); }
|
||||
int getMode() const
|
||||
{ return dJointGetAMotorMode (_id); }
|
||||
|
||||
void setNumAxes (int num)
|
||||
{ dJointSetAMotorNumAxes (_id, num); }
|
||||
int getNumAxes() const
|
||||
{ return dJointGetAMotorNumAxes (_id); }
|
||||
|
||||
void setAxis (int anum, int rel, dReal x, dReal y, dReal z)
|
||||
{ dJointSetAMotorAxis (_id, anum, rel, x, y, z); }
|
||||
void getAxis (int anum, dVector3 result) const
|
||||
{ dJointGetAMotorAxis (_id, anum, result); }
|
||||
int getAxisRel (int anum) const
|
||||
{ return dJointGetAMotorAxisRel (_id, anum); }
|
||||
|
||||
void setAngle (int anum, dReal angle)
|
||||
{ dJointSetAMotorAngle (_id, anum, angle); }
|
||||
dReal getAngle (int anum) const
|
||||
{ return dJointGetAMotorAngle (_id, anum); }
|
||||
dReal getAngleRate (int anum)
|
||||
{ return dJointGetAMotorAngleRate (_id,anum); }
|
||||
|
||||
void setParam (int parameter, dReal value)
|
||||
{ dJointSetAMotorParam (_id, parameter, value); }
|
||||
dReal getParam (int parameter) const
|
||||
{ return dJointGetAMotorParam (_id, parameter); }
|
||||
|
||||
void addTorques(dReal torque1, dReal torque2, dReal torque3)
|
||||
{ dJointAddAMotorTorques(_id, torque1, torque2, torque3); }
|
||||
};
|
||||
|
||||
|
||||
class dLMotorJoint : public dJoint {
|
||||
// intentionally undefined, don't use these
|
||||
dLMotorJoint (const dLMotorJoint &);
|
||||
void operator = (const dLMotorJoint &);
|
||||
|
||||
public:
|
||||
dLMotorJoint() { }
|
||||
dLMotorJoint (dWorldID world, dJointGroupID group=0)
|
||||
{ _id = dJointCreateLMotor (world, group); }
|
||||
|
||||
void create (dWorldID world, dJointGroupID group=0) {
|
||||
if (_id) dJointDestroy (_id);
|
||||
_id = dJointCreateLMotor (world, group);
|
||||
}
|
||||
|
||||
void setNumAxes (int num)
|
||||
{ dJointSetLMotorNumAxes (_id, num); }
|
||||
int getNumAxes() const
|
||||
{ return dJointGetLMotorNumAxes (_id); }
|
||||
|
||||
void setAxis (int anum, int rel, dReal x, dReal y, dReal z)
|
||||
{ dJointSetLMotorAxis (_id, anum, rel, x, y, z); }
|
||||
void getAxis (int anum, dVector3 result) const
|
||||
{ dJointGetLMotorAxis (_id, anum, result); }
|
||||
|
||||
void setParam (int parameter, dReal value)
|
||||
{ dJointSetLMotorParam (_id, parameter, value); }
|
||||
dReal getParam (int parameter) const
|
||||
{ return dJointGetLMotorParam (_id, parameter); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
346
ode/include/ode/odecpp_collision.h
Normal file
346
ode/include/ode/odecpp_collision.h
Normal file
@ -0,0 +1,346 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
|
||||
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of EITHER: *
|
||||
* (1) The GNU Lesser General Public License as published by the Free *
|
||||
* Software Foundation; either version 2.1 of the License, or (at *
|
||||
* your option) any later version. The text of the GNU Lesser *
|
||||
* General Public License is included with this library in the *
|
||||
* file LICENSE.TXT. *
|
||||
* (2) The BSD-style license that is included with this library in *
|
||||
* the file LICENSE-BSD.TXT. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
|
||||
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/* C++ interface for new collision API */
|
||||
|
||||
|
||||
#ifndef _ODE_ODECPP_COLLISION_H_
|
||||
#define _ODE_ODECPP_COLLISION_H_
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <ode/error.h>
|
||||
|
||||
|
||||
class dGeom {
|
||||
// intentionally undefined, don't use these
|
||||
dGeom (dGeom &);
|
||||
void operator= (dGeom &);
|
||||
|
||||
protected:
|
||||
dGeomID _id;
|
||||
|
||||
public:
|
||||
dGeom()
|
||||
{ _id = 0; }
|
||||
~dGeom()
|
||||
{ if (_id) dGeomDestroy (_id); }
|
||||
|
||||
dGeomID id() const
|
||||
{ return _id; }
|
||||
operator dGeomID() const
|
||||
{ return _id; }
|
||||
|
||||
void destroy() {
|
||||
if (_id) dGeomDestroy (_id);
|
||||
_id = 0;
|
||||
}
|
||||
|
||||
int getClass() const
|
||||
{ return dGeomGetClass (_id); }
|
||||
|
||||
dSpaceID getSpace() const
|
||||
{ return dGeomGetSpace (_id); }
|
||||
|
||||
void setData (void *data)
|
||||
{ dGeomSetData (_id,data); }
|
||||
void *getData() const
|
||||
{ return dGeomGetData (_id); }
|
||||
|
||||
void setBody (dBodyID b)
|
||||
{ dGeomSetBody (_id,b); }
|
||||
dBodyID getBody() const
|
||||
{ return dGeomGetBody (_id); }
|
||||
|
||||
void setPosition (dReal x, dReal y, dReal z)
|
||||
{ dGeomSetPosition (_id,x,y,z); }
|
||||
const dReal * getPosition() const
|
||||
{ return dGeomGetPosition (_id); }
|
||||
|
||||
void setRotation (const dMatrix3 R)
|
||||
{ dGeomSetRotation (_id,R); }
|
||||
const dReal * getRotation() const
|
||||
{ return dGeomGetRotation (_id); }
|
||||
|
||||
void setQuaternion (const dQuaternion quat)
|
||||
{ dGeomSetQuaternion (_id,quat); }
|
||||
void getQuaternion (dQuaternion quat) const
|
||||
{ dGeomGetQuaternion (_id,quat); }
|
||||
|
||||
void getAABB (dReal aabb[6]) const
|
||||
{ dGeomGetAABB (_id, aabb); }
|
||||
|
||||
int isSpace()
|
||||
{ return dGeomIsSpace (_id); }
|
||||
|
||||
void setCategoryBits (unsigned long bits)
|
||||
{ dGeomSetCategoryBits (_id, bits); }
|
||||
void setCollideBits (unsigned long bits)
|
||||
{ dGeomSetCollideBits (_id, bits); }
|
||||
unsigned long getCategoryBits()
|
||||
{ return dGeomGetCategoryBits (_id); }
|
||||
unsigned long getCollideBits()
|
||||
{ return dGeomGetCollideBits (_id); }
|
||||
|
||||
void enable()
|
||||
{ dGeomEnable (_id); }
|
||||
void disable()
|
||||
{ dGeomDisable (_id); }
|
||||
int isEnabled()
|
||||
{ return dGeomIsEnabled (_id); }
|
||||
|
||||
void collide2 (dGeomID g, void *data, dNearCallback *callback)
|
||||
{ dSpaceCollide2 (_id,g,data,callback); }
|
||||
};
|
||||
|
||||
|
||||
class dSpace : public dGeom {
|
||||
// intentionally undefined, don't use these
|
||||
dSpace (dSpace &);
|
||||
void operator= (dSpace &);
|
||||
|
||||
protected:
|
||||
// the default constructor is protected so that you
|
||||
// can't instance this class. you must instance one
|
||||
// of its subclasses instead.
|
||||
dSpace () { _id = 0; }
|
||||
|
||||
public:
|
||||
dSpaceID id() const
|
||||
{ return (dSpaceID) _id; }
|
||||
operator dSpaceID() const
|
||||
{ return (dSpaceID) _id; }
|
||||
|
||||
void setCleanup (int mode)
|
||||
{ dSpaceSetCleanup (id(), mode); }
|
||||
int getCleanup()
|
||||
{ return dSpaceGetCleanup (id()); }
|
||||
|
||||
void add (dGeomID x)
|
||||
{ dSpaceAdd (id(), x); }
|
||||
void remove (dGeomID x)
|
||||
{ dSpaceRemove (id(), x); }
|
||||
int query (dGeomID x)
|
||||
{ return dSpaceQuery (id(),x); }
|
||||
|
||||
int getNumGeoms()
|
||||
{ return dSpaceGetNumGeoms (id()); }
|
||||
dGeomID getGeom (int i)
|
||||
{ return dSpaceGetGeom (id(),i); }
|
||||
|
||||
void collide (void *data, dNearCallback *callback)
|
||||
{ dSpaceCollide (id(),data,callback); }
|
||||
};
|
||||
|
||||
|
||||
class dSimpleSpace : public dSpace {
|
||||
// intentionally undefined, don't use these
|
||||
dSimpleSpace (dSimpleSpace &);
|
||||
void operator= (dSimpleSpace &);
|
||||
|
||||
public:
|
||||
dSimpleSpace (dSpaceID space)
|
||||
{ _id = (dGeomID) dSimpleSpaceCreate (space); }
|
||||
};
|
||||
|
||||
|
||||
class dHashSpace : public dSpace {
|
||||
// intentionally undefined, don't use these
|
||||
dHashSpace (dHashSpace &);
|
||||
void operator= (dHashSpace &);
|
||||
|
||||
public:
|
||||
dHashSpace (dSpaceID space)
|
||||
{ _id = (dGeomID) dHashSpaceCreate (space); }
|
||||
void setLevels (int minlevel, int maxlevel)
|
||||
{ dHashSpaceSetLevels (id(),minlevel,maxlevel); }
|
||||
};
|
||||
|
||||
|
||||
class dQuadTreeSpace : public dSpace {
|
||||
// intentionally undefined, don't use these
|
||||
dQuadTreeSpace (dQuadTreeSpace &);
|
||||
void operator= (dQuadTreeSpace &);
|
||||
|
||||
public:
|
||||
dQuadTreeSpace (dSpaceID space, dVector3 center, dVector3 extents, int depth)
|
||||
{ _id = (dGeomID) dQuadTreeSpaceCreate (space,center,extents,depth); }
|
||||
};
|
||||
|
||||
|
||||
class dSphere : public dGeom {
|
||||
// intentionally undefined, don't use these
|
||||
dSphere (dSphere &);
|
||||
void operator= (dSphere &);
|
||||
|
||||
public:
|
||||
dSphere () { }
|
||||
dSphere (dSpaceID space, dReal radius)
|
||||
{ _id = dCreateSphere (space, radius); }
|
||||
|
||||
void create (dSpaceID space, dReal radius) {
|
||||
if (_id) dGeomDestroy (_id);
|
||||
_id = dCreateSphere (space, radius);
|
||||
}
|
||||
|
||||
void setRadius (dReal radius)
|
||||
{ dGeomSphereSetRadius (_id, radius); }
|
||||
dReal getRadius() const
|
||||
{ return dGeomSphereGetRadius (_id); }
|
||||
};
|
||||
|
||||
|
||||
class dBox : public dGeom {
|
||||
// intentionally undefined, don't use these
|
||||
dBox (dBox &);
|
||||
void operator= (dBox &);
|
||||
|
||||
public:
|
||||
dBox () { }
|
||||
dBox (dSpaceID space, dReal lx, dReal ly, dReal lz)
|
||||
{ _id = dCreateBox (space,lx,ly,lz); }
|
||||
|
||||
void create (dSpaceID space, dReal lx, dReal ly, dReal lz) {
|
||||
if (_id) dGeomDestroy (_id);
|
||||
_id = dCreateBox (space,lx,ly,lz);
|
||||
}
|
||||
|
||||
void setLengths (dReal lx, dReal ly, dReal lz)
|
||||
{ dGeomBoxSetLengths (_id, lx, ly, lz); }
|
||||
void getLengths (dVector3 result) const
|
||||
{ dGeomBoxGetLengths (_id,result); }
|
||||
};
|
||||
|
||||
|
||||
class dPlane : public dGeom {
|
||||
// intentionally undefined, don't use these
|
||||
dPlane (dPlane &);
|
||||
void operator= (dPlane &);
|
||||
|
||||
public:
|
||||
dPlane() { }
|
||||
dPlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d)
|
||||
{ _id = dCreatePlane (space,a,b,c,d); }
|
||||
|
||||
void create (dSpaceID space, dReal a, dReal b, dReal c, dReal d) {
|
||||
if (_id) dGeomDestroy (_id);
|
||||
_id = dCreatePlane (space,a,b,c,d);
|
||||
}
|
||||
|
||||
void setParams (dReal a, dReal b, dReal c, dReal d)
|
||||
{ dGeomPlaneSetParams (_id, a, b, c, d); }
|
||||
void getParams (dVector4 result) const
|
||||
{ dGeomPlaneGetParams (_id,result); }
|
||||
};
|
||||
|
||||
|
||||
class dCapsule : public dGeom {
|
||||
// intentionally undefined, don't use these
|
||||
dCapsule (dCapsule &);
|
||||
void operator= (dCapsule &);
|
||||
|
||||
public:
|
||||
dCapsule() { }
|
||||
dCapsule (dSpaceID space, dReal radius, dReal length)
|
||||
{ _id = dCreateCapsule (space,radius,length); }
|
||||
|
||||
void create (dSpaceID space, dReal radius, dReal length) {
|
||||
if (_id) dGeomDestroy (_id);
|
||||
_id = dCreateCapsule (space,radius,length);
|
||||
}
|
||||
|
||||
void setParams (dReal radius, dReal length)
|
||||
{ dGeomCapsuleSetParams (_id, radius, length); }
|
||||
void getParams (dReal *radius, dReal *length) const
|
||||
{ dGeomCapsuleGetParams (_id,radius,length); }
|
||||
};
|
||||
|
||||
|
||||
class dRay : public dGeom {
|
||||
// intentionally undefined, don't use these
|
||||
dRay (dRay &);
|
||||
void operator= (dRay &);
|
||||
|
||||
public:
|
||||
dRay() { }
|
||||
dRay (dSpaceID space, dReal length)
|
||||
{ _id = dCreateRay (space,length); }
|
||||
|
||||
void create (dSpaceID space, dReal length) {
|
||||
if (_id) dGeomDestroy (_id);
|
||||
_id = dCreateRay (space,length);
|
||||
}
|
||||
|
||||
void setLength (dReal length)
|
||||
{ dGeomRaySetLength (_id, length); }
|
||||
dReal getLength()
|
||||
{ return dGeomRayGetLength (_id); }
|
||||
|
||||
void set (dReal px, dReal py, dReal pz, dReal dx, dReal dy, dReal dz)
|
||||
{ dGeomRaySet (_id, px, py, pz, dx, dy, dz); }
|
||||
void get (dVector3 start, dVector3 dir)
|
||||
{ dGeomRayGet (_id, start, dir); }
|
||||
|
||||
void setParams (int firstContact, int backfaceCull)
|
||||
{ dGeomRaySetParams (_id, firstContact, backfaceCull); }
|
||||
void getParams (int *firstContact, int *backfaceCull)
|
||||
{ dGeomRayGetParams (_id, firstContact, backfaceCull); }
|
||||
void setClosestHit (int closestHit)
|
||||
{ dGeomRaySetClosestHit (_id, closestHit); }
|
||||
int getClosestHit()
|
||||
{ return dGeomRayGetClosestHit (_id); }
|
||||
};
|
||||
|
||||
|
||||
class dGeomTransform : public dGeom {
|
||||
// intentionally undefined, don't use these
|
||||
dGeomTransform (dGeomTransform &);
|
||||
void operator= (dGeomTransform &);
|
||||
|
||||
public:
|
||||
dGeomTransform() { }
|
||||
dGeomTransform (dSpaceID space)
|
||||
{ _id = dCreateGeomTransform (space); }
|
||||
|
||||
void create (dSpaceID space=0) {
|
||||
if (_id) dGeomDestroy (_id);
|
||||
_id = dCreateGeomTransform (space);
|
||||
}
|
||||
|
||||
void setGeom (dGeomID geom)
|
||||
{ dGeomTransformSetGeom (_id, geom); }
|
||||
dGeomID getGeom() const
|
||||
{ return dGeomTransformGetGeom (_id); }
|
||||
|
||||
void setCleanup (int mode)
|
||||
{ dGeomTransformSetCleanup (_id,mode); }
|
||||
int getCleanup ()
|
||||
{ return dGeomTransformGetCleanup (_id); }
|
||||
|
||||
void setInfo (int mode)
|
||||
{ dGeomTransformSetInfo (_id,mode); }
|
||||
int getInfo()
|
||||
{ return dGeomTransformGetInfo (_id); }
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
316
ode/include/ode/odecpp_old.h
Normal file
316
ode/include/ode/odecpp_old.h
Normal file
@ -0,0 +1,316 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
|
||||
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of EITHER: *
|
||||
* (1) The GNU Lesser General Public License as published by the Free *
|
||||
* Software Foundation; either version 2.1 of the License, or (at *
|
||||
* your option) any later version. The text of the GNU Lesser *
|
||||
* General Public License is included with this library in the *
|
||||
* file LICENSE.TXT. *
|
||||
* (2) The BSD-style license that is included with this library in *
|
||||
* the file LICENSE-BSD.TXT. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
|
||||
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/* this is the old C++ interface, the new C++ interface is not quite
|
||||
* compatible with this. but this file is kept around in case you were
|
||||
* using the old interface.
|
||||
*/
|
||||
|
||||
#ifndef _ODE_ODECPP_H_
|
||||
#define _ODE_ODECPP_H_
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <ode/error.h>
|
||||
|
||||
|
||||
class dWorld {
|
||||
dWorldID _id;
|
||||
|
||||
dWorld (dWorld &) { dDebug (0,"bad"); }
|
||||
void operator= (dWorld &) { dDebug (0,"bad"); }
|
||||
|
||||
public:
|
||||
dWorld()
|
||||
{ _id = dWorldCreate(); }
|
||||
~dWorld()
|
||||
{ dWorldDestroy (_id); }
|
||||
dWorldID id()
|
||||
{ return _id; }
|
||||
|
||||
void setGravity (dReal x, dReal y, dReal z)
|
||||
{ dWorldSetGravity (_id,x,y,z); }
|
||||
void getGravity (dVector3 g)
|
||||
{ dWorldGetGravity (_id,g); }
|
||||
void step (dReal stepsize)
|
||||
{ dWorldStep (_id,stepsize); }
|
||||
};
|
||||
|
||||
|
||||
class dBody {
|
||||
dBodyID _id;
|
||||
|
||||
dBody (dBody &) { dDebug (0,"bad"); }
|
||||
void operator= (dBody &) { dDebug (0,"bad"); }
|
||||
|
||||
public:
|
||||
dBody()
|
||||
{ _id = 0; }
|
||||
dBody (dWorld &world)
|
||||
{ _id = dBodyCreate (world.id()); }
|
||||
~dBody()
|
||||
{ dBodyDestroy (_id); }
|
||||
void create (dWorld &world)
|
||||
{ if (_id) dBodyDestroy (_id); _id = dBodyCreate (world.id()); }
|
||||
dBodyID id()
|
||||
{ return _id; }
|
||||
|
||||
void setData (void *data)
|
||||
{ dBodySetData (_id,data); }
|
||||
void *getData()
|
||||
{ return dBodyGetData (_id); }
|
||||
|
||||
void setPosition (dReal x, dReal y, dReal z)
|
||||
{ dBodySetPosition (_id,x,y,z); }
|
||||
void setRotation (const dMatrix3 R)
|
||||
{ dBodySetRotation (_id,R); }
|
||||
void setQuaternion (const dQuaternion q)
|
||||
{ dBodySetQuaternion (_id,q); }
|
||||
void setLinearVel (dReal x, dReal y, dReal z)
|
||||
{ dBodySetLinearVel (_id,x,y,z); }
|
||||
void setAngularVel (dReal x, dReal y, dReal z)
|
||||
{ dBodySetAngularVel (_id,x,y,z); }
|
||||
|
||||
const dReal * getPosition()
|
||||
{ return dBodyGetPosition (_id); }
|
||||
const dReal * getRotation()
|
||||
{ return dBodyGetRotation (_id); }
|
||||
const dReal * getQuaternion()
|
||||
{ return dBodyGetQuaternion (_id); }
|
||||
const dReal * getLinearVel()
|
||||
{ return dBodyGetLinearVel (_id); }
|
||||
const dReal * getAngularVel()
|
||||
{ return dBodyGetAngularVel (_id); }
|
||||
|
||||
void setMass (const dMass *mass)
|
||||
{ dBodySetMass (_id,mass); }
|
||||
void getMass (dMass *mass)
|
||||
{ dBodyGetMass (_id,mass); }
|
||||
|
||||
void addForce (dReal fx, dReal fy, dReal fz)
|
||||
{ dBodyAddForce (_id, fx, fy, fz); }
|
||||
void addTorque (dReal fx, dReal fy, dReal fz)
|
||||
{ dBodyAddTorque (_id, fx, fy, fz); }
|
||||
void addRelForce (dReal fx, dReal fy, dReal fz)
|
||||
{ dBodyAddRelForce (_id, fx, fy, fz); }
|
||||
void addRelTorque (dReal fx, dReal fy, dReal fz)
|
||||
{ dBodyAddRelTorque (_id, fx, fy, fz); }
|
||||
void addForceAtPos (dReal fx, dReal fy, dReal fz,
|
||||
dReal px, dReal py, dReal pz)
|
||||
{ dBodyAddForceAtPos (_id, fx, fy, fz, px, py, pz); }
|
||||
void addRelForceAtPos (dReal fx, dReal fy, dReal fz,
|
||||
dReal px, dReal py, dReal pz)
|
||||
{ dBodyAddRelForceAtPos (_id, fx, fy, fz, px, py, pz); }
|
||||
void addRelForceAtRelPos (dReal fx, dReal fy, dReal fz,
|
||||
dReal px, dReal py, dReal pz)
|
||||
{ dBodyAddRelForceAtRelPos (_id, fx, fy, fz, px, py, pz); }
|
||||
|
||||
void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result)
|
||||
{ dBodyGetRelPointPos (_id, px, py, pz, result); }
|
||||
void getRelPointVel (dReal px, dReal py, dReal pz, dVector3 result)
|
||||
{ dBodyGetRelPointVel (_id, px, py, pz, result); }
|
||||
|
||||
int isConnectedTo (const dBody &b)
|
||||
{ return dAreConnected (_id,b._id); }
|
||||
};
|
||||
|
||||
|
||||
class dJointGroup {
|
||||
dJointGroupID _id;
|
||||
|
||||
dJointGroup (dJointGroup &) { dDebug (0,"bad"); }
|
||||
void operator= (dJointGroup &) { dDebug (0,"bad"); }
|
||||
|
||||
public:
|
||||
dJointGroup()
|
||||
{ _id = 0; }
|
||||
dJointGroup (int max_size)
|
||||
{ _id = dJointGroupCreate (max_size); }
|
||||
~dJointGroup()
|
||||
{ dJointGroupDestroy (_id); }
|
||||
void create (int max_size)
|
||||
{ if (_id) dJointGroupDestroy (_id); _id = dJointGroupCreate (max_size); }
|
||||
dJointGroupID id()
|
||||
{ return _id; }
|
||||
|
||||
void empty()
|
||||
{ dJointGroupEmpty (_id); }
|
||||
};
|
||||
|
||||
|
||||
class dJoint {
|
||||
dJointID _id;
|
||||
|
||||
dJoint (dJoint &) { dDebug (0,"bad"); }
|
||||
void operator= (dJoint &) { dDebug (0,"bad"); }
|
||||
|
||||
public:
|
||||
dJoint()
|
||||
{ _id = 0; }
|
||||
~dJoint()
|
||||
{ dJointDestroy (_id); }
|
||||
dJointID id()
|
||||
{ return _id; }
|
||||
|
||||
void createBall (dWorld &world, dJointGroup *group=0) {
|
||||
if (_id) dJointDestroy (_id);
|
||||
_id = dJointCreateBall (world.id(), group ? group->id() : 0);
|
||||
}
|
||||
void createHinge (dWorld &world, dJointGroup *group=0) {
|
||||
if (_id) dJointDestroy (_id);
|
||||
_id = dJointCreateHinge (world.id(), group ? group->id() : 0);
|
||||
}
|
||||
void createSlider (dWorld &world, dJointGroup *group=0) {
|
||||
if (_id) dJointDestroy (_id);
|
||||
_id = dJointCreateSlider (world.id(), group ? group->id() : 0);
|
||||
}
|
||||
void createContact (dWorld &world, dJointGroup *group, dContact *contact) {
|
||||
if (_id) dJointDestroy (_id);
|
||||
_id = dJointCreateContact (world.id(), group ? group->id() : 0, contact);
|
||||
}
|
||||
|
||||
void attach (dBody &body1, dBody &body2)
|
||||
{ dJointAttach (_id, body1.id(), body2.id()); }
|
||||
|
||||
void setBallAnchor (dReal x, dReal y, dReal z)
|
||||
{ dJointSetBallAnchor (_id, x, y, z); }
|
||||
void setHingeAnchor (dReal x, dReal y, dReal z)
|
||||
{ dJointSetHingeAnchor (_id, x, y, z); }
|
||||
|
||||
void setHingeAxis (dReal x, dReal y, dReal z)
|
||||
{ dJointSetHingeAxis (_id, x, y, z); }
|
||||
void setSliderAxis (dReal x, dReal y, dReal z)
|
||||
{ dJointSetSliderAxis (_id, x, y, z); }
|
||||
|
||||
void getBallAnchor (dVector3 result)
|
||||
{ dJointGetBallAnchor (_id, result); }
|
||||
void getHingeAnchor (dVector3 result)
|
||||
{ dJointGetHingeAnchor (_id, result); }
|
||||
|
||||
void getHingeAxis (dVector3 result)
|
||||
{ dJointGetHingeAxis (_id, result); }
|
||||
void getSliderAxis (dVector3 result)
|
||||
{ dJointGetSliderAxis (_id, result); }
|
||||
};
|
||||
|
||||
|
||||
class dSpace {
|
||||
dSpaceID _id;
|
||||
|
||||
dSpace (dSpace &) { dDebug (0,"bad"); }
|
||||
void operator= (dSpace &) { dDebug (0,"bad"); }
|
||||
|
||||
public:
|
||||
dSpace ()
|
||||
{ _id = dHashSpaceCreate(); }
|
||||
~dSpace()
|
||||
{ dSpaceDestroy (_id); }
|
||||
dSpaceID id()
|
||||
{ return _id; }
|
||||
void collide (void *data, dNearCallback *callback)
|
||||
{ dSpaceCollide (_id,data,callback); }
|
||||
};
|
||||
|
||||
|
||||
class dGeom {
|
||||
dGeomID _id;
|
||||
|
||||
dGeom (dGeom &) { dDebug (0,"bad"); }
|
||||
void operator= (dGeom &) { dDebug (0,"bad"); }
|
||||
|
||||
public:
|
||||
dGeom()
|
||||
{ _id = 0; }
|
||||
~dGeom()
|
||||
{ dGeomDestroy (_id); }
|
||||
dGeomID id()
|
||||
{ return _id; }
|
||||
|
||||
void createSphere (dSpace &space, dReal radius) {
|
||||
if (_id) dGeomDestroy (_id);
|
||||
_id = dCreateSphere (space.id(),radius);
|
||||
}
|
||||
|
||||
void createBox (dSpace &space, dReal lx, dReal ly, dReal lz) {
|
||||
if (_id) dGeomDestroy (_id);
|
||||
_id = dCreateBox (space.id(),lx,ly,lz);
|
||||
}
|
||||
|
||||
void createPlane (dSpace &space, dReal a, dReal b, dReal c, dReal d) {
|
||||
if (_id) dGeomDestroy (_id);
|
||||
_id = dCreatePlane (space.id(),a,b,c,d);
|
||||
}
|
||||
|
||||
void createCCylinder (dSpace &space, dReal radius, dReal length) {
|
||||
if (_id) dGeomDestroy (_id);
|
||||
_id = dCreateCCylinder (space.id(),radius,length);
|
||||
}
|
||||
|
||||
void destroy() {
|
||||
if (_id) dGeomDestroy (_id);
|
||||
_id = 0;
|
||||
}
|
||||
|
||||
int getClass()
|
||||
{ return dGeomGetClass (_id); }
|
||||
|
||||
dReal sphereGetRadius()
|
||||
{ return dGeomSphereGetRadius (_id); }
|
||||
|
||||
void boxGetLengths (dVector3 result)
|
||||
{ dGeomBoxGetLengths (_id,result); }
|
||||
|
||||
void planeGetParams (dVector4 result)
|
||||
{ dGeomPlaneGetParams (_id,result); }
|
||||
|
||||
void CCylinderGetParams (dReal *radius, dReal *length)
|
||||
{ dGeomCCylinderGetParams (_id,radius,length); }
|
||||
|
||||
void setData (void *data)
|
||||
{ dGeomSetData (_id,data); }
|
||||
|
||||
void *getData()
|
||||
{ return dGeomGetData (_id); }
|
||||
|
||||
void setBody (dBody &b)
|
||||
{ dGeomSetBody (_id,b.id()); }
|
||||
void setBody (dBodyID b)
|
||||
{ dGeomSetBody (_id,b); }
|
||||
|
||||
dBodyID getBody()
|
||||
{ return dGeomGetBody (_id); }
|
||||
|
||||
void setPosition (dReal x, dReal y, dReal z)
|
||||
{ dGeomSetPosition (_id,x,y,z); }
|
||||
|
||||
void setRotation (const dMatrix3 R)
|
||||
{ dGeomSetRotation (_id,R); }
|
||||
|
||||
const dReal * getPosition()
|
||||
{ return dGeomGetPosition (_id); }
|
||||
|
||||
const dReal * getRotation()
|
||||
{ return dGeomGetRotation (_id); }
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
308
ode/include/ode/odemath.h
Normal file
308
ode/include/ode/odemath.h
Normal file
@ -0,0 +1,308 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
|
||||
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of EITHER: *
|
||||
* (1) The GNU Lesser General Public License as published by the Free *
|
||||
* Software Foundation; either version 2.1 of the License, or (at *
|
||||
* your option) any later version. The text of the GNU Lesser *
|
||||
* General Public License is included with this library in the *
|
||||
* file LICENSE.TXT. *
|
||||
* (2) The BSD-style license that is included with this library in *
|
||||
* the file LICENSE-BSD.TXT. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
|
||||
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef _ODE_ODEMATH_H_
|
||||
#define _ODE_ODEMATH_H_
|
||||
|
||||
#include <ode/common.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define PURE_INLINE extern inline
|
||||
#else
|
||||
#define PURE_INLINE inline
|
||||
#endif
|
||||
|
||||
/*
|
||||
* macro to access elements i,j in an NxM matrix A, independent of the
|
||||
* matrix storage convention.
|
||||
*/
|
||||
#define dACCESS33(A,i,j) ((A)[(i)*4+(j)])
|
||||
|
||||
/*
|
||||
* Macro to test for valid floating point values
|
||||
*/
|
||||
#define dVALIDVEC3(v) (!(dIsNan(v[0]) || dIsNan(v[1]) || dIsNan(v[2])))
|
||||
#define dVALIDVEC4(v) (!(dIsNan(v[0]) || dIsNan(v[2]) || dIsNan(v[2]) || dIsNan(v[3])))
|
||||
#define dVALIDMAT3(m) (!(dIsNan(m[0]) || dIsNan(m[1]) || dIsNan(m[2]) || dIsNan(m[3]) || dIsNan(m[4]) || dIsNan(m[5]) || dIsNan(m[6]) || dIsNan(m[7]) || dIsNan(m[8]) || dIsNan(m[9]) || dIsNan(m[10]) || dIsNan(m[11])))
|
||||
#define dVALIDMAT4(m) (!(dIsNan(m[0]) || dIsNan(m[1]) || dIsNan(m[2]) || dIsNan(m[3]) || dIsNan(m[4]) || dIsNan(m[5]) || dIsNan(m[6]) || dIsNan(m[7]) || dIsNan(m[8]) || dIsNan(m[9]) || dIsNan(m[10]) || dIsNan(m[11]) || dIsNan(m[12]) || dIsNan(m[13]) || dIsNan(m[14]) || dIsNan(m[15]) ))
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* General purpose vector operations with other vectors or constants.
|
||||
*/
|
||||
|
||||
#define dOP(a,op,b,c) \
|
||||
(a)[0] = ((b)[0]) op ((c)[0]); \
|
||||
(a)[1] = ((b)[1]) op ((c)[1]); \
|
||||
(a)[2] = ((b)[2]) op ((c)[2]);
|
||||
#define dOPC(a,op,b,c) \
|
||||
(a)[0] = ((b)[0]) op (c); \
|
||||
(a)[1] = ((b)[1]) op (c); \
|
||||
(a)[2] = ((b)[2]) op (c);
|
||||
#define dOPE(a,op,b) \
|
||||
(a)[0] op ((b)[0]); \
|
||||
(a)[1] op ((b)[1]); \
|
||||
(a)[2] op ((b)[2]);
|
||||
#define dOPEC(a,op,c) \
|
||||
(a)[0] op (c); \
|
||||
(a)[1] op (c); \
|
||||
(a)[2] op (c);
|
||||
|
||||
|
||||
/*
|
||||
* Length, and squared length helpers. dLENGTH returns the length of a dVector3.
|
||||
* dLENGTHSQUARED return the squared length of a dVector3.
|
||||
*/
|
||||
|
||||
#define dLENGTHSQUARED(a) (((a)[0])*((a)[0]) + ((a)[1])*((a)[1]) + ((a)[2])*((a)[2]))
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
PURE_INLINE dReal dLENGTH (const dReal *a) { return dSqrt(dLENGTHSQUARED(a)); }
|
||||
|
||||
#else
|
||||
|
||||
#define dLENGTH(a) ( dSqrt( ((a)[0])*((a)[0]) + ((a)[1])*((a)[1]) + ((a)[2])*((a)[2]) ) )
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 3-way dot product. dDOTpq means that elements of `a' and `b' are spaced
|
||||
* p and q indexes apart respectively. dDOT() means dDOT11.
|
||||
* in C++ we could use function templates to get all the versions of these
|
||||
* functions - but on some compilers this will result in sub-optimal code.
|
||||
*/
|
||||
|
||||
#define dDOTpq(a,b,p,q) ((a)[0]*(b)[0] + (a)[p]*(b)[q] + (a)[2*(p)]*(b)[2*(q)])
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
PURE_INLINE dReal dDOT (const dReal *a, const dReal *b) { return dDOTpq(a,b,1,1); }
|
||||
PURE_INLINE dReal dDOT13 (const dReal *a, const dReal *b) { return dDOTpq(a,b,1,3); }
|
||||
PURE_INLINE dReal dDOT31 (const dReal *a, const dReal *b) { return dDOTpq(a,b,3,1); }
|
||||
PURE_INLINE dReal dDOT33 (const dReal *a, const dReal *b) { return dDOTpq(a,b,3,3); }
|
||||
PURE_INLINE dReal dDOT14 (const dReal *a, const dReal *b) { return dDOTpq(a,b,1,4); }
|
||||
PURE_INLINE dReal dDOT41 (const dReal *a, const dReal *b) { return dDOTpq(a,b,4,1); }
|
||||
PURE_INLINE dReal dDOT44 (const dReal *a, const dReal *b) { return dDOTpq(a,b,4,4); }
|
||||
|
||||
#else
|
||||
|
||||
#define dDOT(a,b) dDOTpq(a,b,1,1)
|
||||
#define dDOT13(a,b) dDOTpq(a,b,1,3)
|
||||
#define dDOT31(a,b) dDOTpq(a,b,3,1)
|
||||
#define dDOT33(a,b) dDOTpq(a,b,3,3)
|
||||
#define dDOT14(a,b) dDOTpq(a,b,1,4)
|
||||
#define dDOT41(a,b) dDOTpq(a,b,4,1)
|
||||
#define dDOT44(a,b) dDOTpq(a,b,4,4)
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/*
|
||||
* cross product, set a = b x c. dCROSSpqr means that elements of `a', `b'
|
||||
* and `c' are spaced p, q and r indexes apart respectively.
|
||||
* dCROSS() means dCROSS111. `op' is normally `=', but you can set it to
|
||||
* +=, -= etc to get other effects.
|
||||
*/
|
||||
|
||||
#define dCROSS(a,op,b,c) \
|
||||
do { \
|
||||
(a)[0] op ((b)[1]*(c)[2] - (b)[2]*(c)[1]); \
|
||||
(a)[1] op ((b)[2]*(c)[0] - (b)[0]*(c)[2]); \
|
||||
(a)[2] op ((b)[0]*(c)[1] - (b)[1]*(c)[0]); \
|
||||
} while(0)
|
||||
#define dCROSSpqr(a,op,b,c,p,q,r) \
|
||||
do { \
|
||||
(a)[ 0] op ((b)[ q]*(c)[2*r] - (b)[2*q]*(c)[ r]); \
|
||||
(a)[ p] op ((b)[2*q]*(c)[ 0] - (b)[ 0]*(c)[2*r]); \
|
||||
(a)[2*p] op ((b)[ 0]*(c)[ r] - (b)[ q]*(c)[ 0]); \
|
||||
} while(0)
|
||||
#define dCROSS114(a,op,b,c) dCROSSpqr(a,op,b,c,1,1,4)
|
||||
#define dCROSS141(a,op,b,c) dCROSSpqr(a,op,b,c,1,4,1)
|
||||
#define dCROSS144(a,op,b,c) dCROSSpqr(a,op,b,c,1,4,4)
|
||||
#define dCROSS411(a,op,b,c) dCROSSpqr(a,op,b,c,4,1,1)
|
||||
#define dCROSS414(a,op,b,c) dCROSSpqr(a,op,b,c,4,1,4)
|
||||
#define dCROSS441(a,op,b,c) dCROSSpqr(a,op,b,c,4,4,1)
|
||||
#define dCROSS444(a,op,b,c) dCROSSpqr(a,op,b,c,4,4,4)
|
||||
|
||||
|
||||
/*
|
||||
* set a 3x3 submatrix of A to a matrix such that submatrix(A)*b = a x b.
|
||||
* A is stored by rows, and has `skip' elements per row. the matrix is
|
||||
* assumed to be already zero, so this does not write zero elements!
|
||||
* if (plus,minus) is (+,-) then a positive version will be written.
|
||||
* if (plus,minus) is (-,+) then a negative version will be written.
|
||||
*/
|
||||
|
||||
#define dCROSSMAT(A,a,skip,plus,minus) \
|
||||
do { \
|
||||
(A)[1] = minus (a)[2]; \
|
||||
(A)[2] = plus (a)[1]; \
|
||||
(A)[(skip)+0] = plus (a)[2]; \
|
||||
(A)[(skip)+2] = minus (a)[0]; \
|
||||
(A)[2*(skip)+0] = minus (a)[1]; \
|
||||
(A)[2*(skip)+1] = plus (a)[0]; \
|
||||
} while(0)
|
||||
|
||||
|
||||
/*
|
||||
* compute the distance between two 3D-vectors
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
PURE_INLINE dReal dDISTANCE (const dVector3 a, const dVector3 b)
|
||||
{ return dSqrt( (a[0]-b[0])*(a[0]-b[0]) + (a[1]-b[1])*(a[1]-b[1]) + (a[2]-b[2])*(a[2]-b[2]) ); }
|
||||
#else
|
||||
#define dDISTANCE(a,b) \
|
||||
(dSqrt( ((a)[0]-(b)[0])*((a)[0]-(b)[0]) + ((a)[1]-(b)[1])*((a)[1]-(b)[1]) + ((a)[2]-(b)[2])*((a)[2]-(b)[2]) ))
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* special case matrix multipication, with operator selection
|
||||
*/
|
||||
|
||||
#define dMULTIPLYOP0_331(A,op,B,C) \
|
||||
do { \
|
||||
(A)[0] op dDOT((B),(C)); \
|
||||
(A)[1] op dDOT((B+4),(C)); \
|
||||
(A)[2] op dDOT((B+8),(C)); \
|
||||
} while(0)
|
||||
#define dMULTIPLYOP1_331(A,op,B,C) \
|
||||
do { \
|
||||
(A)[0] op dDOT41((B),(C)); \
|
||||
(A)[1] op dDOT41((B+1),(C)); \
|
||||
(A)[2] op dDOT41((B+2),(C)); \
|
||||
} while(0)
|
||||
#define dMULTIPLYOP0_133(A,op,B,C) \
|
||||
do { \
|
||||
(A)[0] op dDOT14((B),(C)); \
|
||||
(A)[1] op dDOT14((B),(C+1)); \
|
||||
(A)[2] op dDOT14((B),(C+2)); \
|
||||
} while(0)
|
||||
#define dMULTIPLYOP0_333(A,op,B,C) \
|
||||
do { \
|
||||
(A)[0] op dDOT14((B),(C)); \
|
||||
(A)[1] op dDOT14((B),(C+1)); \
|
||||
(A)[2] op dDOT14((B),(C+2)); \
|
||||
(A)[4] op dDOT14((B+4),(C)); \
|
||||
(A)[5] op dDOT14((B+4),(C+1)); \
|
||||
(A)[6] op dDOT14((B+4),(C+2)); \
|
||||
(A)[8] op dDOT14((B+8),(C)); \
|
||||
(A)[9] op dDOT14((B+8),(C+1)); \
|
||||
(A)[10] op dDOT14((B+8),(C+2)); \
|
||||
} while(0)
|
||||
#define dMULTIPLYOP1_333(A,op,B,C) \
|
||||
do { \
|
||||
(A)[0] op dDOT44((B),(C)); \
|
||||
(A)[1] op dDOT44((B),(C+1)); \
|
||||
(A)[2] op dDOT44((B),(C+2)); \
|
||||
(A)[4] op dDOT44((B+1),(C)); \
|
||||
(A)[5] op dDOT44((B+1),(C+1)); \
|
||||
(A)[6] op dDOT44((B+1),(C+2)); \
|
||||
(A)[8] op dDOT44((B+2),(C)); \
|
||||
(A)[9] op dDOT44((B+2),(C+1)); \
|
||||
(A)[10] op dDOT44((B+2),(C+2)); \
|
||||
} while(0)
|
||||
#define dMULTIPLYOP2_333(A,op,B,C) \
|
||||
do { \
|
||||
(A)[0] op dDOT((B),(C)); \
|
||||
(A)[1] op dDOT((B),(C+4)); \
|
||||
(A)[2] op dDOT((B),(C+8)); \
|
||||
(A)[4] op dDOT((B+4),(C)); \
|
||||
(A)[5] op dDOT((B+4),(C+4)); \
|
||||
(A)[6] op dDOT((B+4),(C+8)); \
|
||||
(A)[8] op dDOT((B+8),(C)); \
|
||||
(A)[9] op dDOT((B+8),(C+4)); \
|
||||
(A)[10] op dDOT((B+8),(C+8)); \
|
||||
} while(0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#define DECL template <class TA, class TB, class TC> PURE_INLINE void
|
||||
|
||||
DECL dMULTIPLY0_331(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_331(A,=,B,C); }
|
||||
DECL dMULTIPLY1_331(TA *A, const TB *B, const TC *C) { dMULTIPLYOP1_331(A,=,B,C); }
|
||||
DECL dMULTIPLY0_133(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_133(A,=,B,C); }
|
||||
DECL dMULTIPLY0_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_333(A,=,B,C); }
|
||||
DECL dMULTIPLY1_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP1_333(A,=,B,C); }
|
||||
DECL dMULTIPLY2_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP2_333(A,=,B,C); }
|
||||
|
||||
DECL dMULTIPLYADD0_331(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_331(A,+=,B,C); }
|
||||
DECL dMULTIPLYADD1_331(TA *A, const TB *B, const TC *C) { dMULTIPLYOP1_331(A,+=,B,C); }
|
||||
DECL dMULTIPLYADD0_133(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_133(A,+=,B,C); }
|
||||
DECL dMULTIPLYADD0_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_333(A,+=,B,C); }
|
||||
DECL dMULTIPLYADD1_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP1_333(A,+=,B,C); }
|
||||
DECL dMULTIPLYADD2_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP2_333(A,+=,B,C); }
|
||||
|
||||
#undef DECL
|
||||
|
||||
#else
|
||||
|
||||
#define dMULTIPLY0_331(A,B,C) dMULTIPLYOP0_331(A,=,B,C)
|
||||
#define dMULTIPLY1_331(A,B,C) dMULTIPLYOP1_331(A,=,B,C)
|
||||
#define dMULTIPLY0_133(A,B,C) dMULTIPLYOP0_133(A,=,B,C)
|
||||
#define dMULTIPLY0_333(A,B,C) dMULTIPLYOP0_333(A,=,B,C)
|
||||
#define dMULTIPLY1_333(A,B,C) dMULTIPLYOP1_333(A,=,B,C)
|
||||
#define dMULTIPLY2_333(A,B,C) dMULTIPLYOP2_333(A,=,B,C)
|
||||
|
||||
#define dMULTIPLYADD0_331(A,B,C) dMULTIPLYOP0_331(A,+=,B,C)
|
||||
#define dMULTIPLYADD1_331(A,B,C) dMULTIPLYOP1_331(A,+=,B,C)
|
||||
#define dMULTIPLYADD0_133(A,B,C) dMULTIPLYOP0_133(A,+=,B,C)
|
||||
#define dMULTIPLYADD0_333(A,B,C) dMULTIPLYOP0_333(A,+=,B,C)
|
||||
#define dMULTIPLYADD1_333(A,B,C) dMULTIPLYOP1_333(A,+=,B,C)
|
||||
#define dMULTIPLYADD2_333(A,B,C) dMULTIPLYOP2_333(A,+=,B,C)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* normalize 3x1 and 4x1 vectors (i.e. scale them to unit length)
|
||||
*/
|
||||
ODE_API void dNormalize3 (dVector3 a);
|
||||
ODE_API void dNormalize4 (dVector4 a);
|
||||
|
||||
|
||||
/*
|
||||
* given a unit length "normal" vector n, generate vectors p and q vectors
|
||||
* that are an orthonormal basis for the plane space perpendicular to n.
|
||||
* i.e. this makes p,q such that n,p,q are all perpendicular to each other.
|
||||
* q will equal n x p. if n is not unit length then p will be unit length but
|
||||
* q wont be.
|
||||
*/
|
||||
|
||||
ODE_API void dPlaneSpace (const dVector3 n, dVector3 p, dVector3 q);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
70
ode/include/ode/rotation.h
Normal file
70
ode/include/ode/rotation.h
Normal file
@ -0,0 +1,70 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
|
||||
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of EITHER: *
|
||||
* (1) The GNU Lesser General Public License as published by the Free *
|
||||
* Software Foundation; either version 2.1 of the License, or (at *
|
||||
* your option) any later version. The text of the GNU Lesser *
|
||||
* General Public License is included with this library in the *
|
||||
* file LICENSE.TXT. *
|
||||
* (2) The BSD-style license that is included with this library in *
|
||||
* the file LICENSE-BSD.TXT. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
|
||||
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef _ODE_ROTATION_H_
|
||||
#define _ODE_ROTATION_H_
|
||||
|
||||
#include <ode/common.h>
|
||||
#include <ode/compatibility.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
ODE_API void dRSetIdentity (dMatrix3 R);
|
||||
|
||||
ODE_API void dRFromAxisAndAngle (dMatrix3 R, dReal ax, dReal ay, dReal az,
|
||||
dReal angle);
|
||||
|
||||
ODE_API void dRFromEulerAngles (dMatrix3 R, dReal phi, dReal theta, dReal psi);
|
||||
|
||||
ODE_API void dRFrom2Axes (dMatrix3 R, dReal ax, dReal ay, dReal az,
|
||||
dReal bx, dReal by, dReal bz);
|
||||
|
||||
ODE_API void dRFromZAxis (dMatrix3 R, dReal ax, dReal ay, dReal az);
|
||||
|
||||
ODE_API void dQSetIdentity (dQuaternion q);
|
||||
|
||||
ODE_API void dQFromAxisAndAngle (dQuaternion q, dReal ax, dReal ay, dReal az,
|
||||
dReal angle);
|
||||
|
||||
/* Quaternion multiplication, analogous to the matrix multiplication routines. */
|
||||
/* qa = rotate by qc, then qb */
|
||||
ODE_API void dQMultiply0 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc);
|
||||
/* qa = rotate by qc, then by inverse of qb */
|
||||
ODE_API void dQMultiply1 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc);
|
||||
/* qa = rotate by inverse of qc, then by qb */
|
||||
ODE_API void dQMultiply2 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc);
|
||||
/* qa = rotate by inverse of qc, then by inverse of qb */
|
||||
ODE_API void dQMultiply3 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc);
|
||||
|
||||
ODE_API void dRfromQ (dMatrix3 R, const dQuaternion q);
|
||||
ODE_API void dQfromR (dQuaternion q, const dMatrix3 R);
|
||||
ODE_API void dDQfromW (dReal dq[4], const dVector3 w, const dQuaternion q);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
76
ode/include/ode/timer.h
Normal file
76
ode/include/ode/timer.h
Normal file
@ -0,0 +1,76 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
|
||||
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of EITHER: *
|
||||
* (1) The GNU Lesser General Public License as published by the Free *
|
||||
* Software Foundation; either version 2.1 of the License, or (at *
|
||||
* your option) any later version. The text of the GNU Lesser *
|
||||
* General Public License is included with this library in the *
|
||||
* file LICENSE.TXT. *
|
||||
* (2) The BSD-style license that is included with this library in *
|
||||
* the file LICENSE-BSD.TXT. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
|
||||
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef _ODE_TIMER_H_
|
||||
#define _ODE_TIMER_H_
|
||||
|
||||
#include <ode/config.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* stop watch objects */
|
||||
|
||||
typedef struct dStopwatch {
|
||||
double time; /* total clock count */
|
||||
unsigned long cc[2]; /* clock count since last `start' */
|
||||
} dStopwatch;
|
||||
|
||||
ODE_API void dStopwatchReset (dStopwatch *);
|
||||
ODE_API void dStopwatchStart (dStopwatch *);
|
||||
ODE_API void dStopwatchStop (dStopwatch *);
|
||||
ODE_API double dStopwatchTime (dStopwatch *); /* returns total time in secs */
|
||||
|
||||
|
||||
/* code timers */
|
||||
|
||||
ODE_API void dTimerStart (const char *description); /* pass a static string here */
|
||||
ODE_API void dTimerNow (const char *description); /* pass a static string here */
|
||||
ODE_API void dTimerEnd(void);
|
||||
|
||||
/* print out a timer report. if `average' is nonzero, print out the average
|
||||
* time for each slot (this is only meaningful if the same start-now-end
|
||||
* calls are being made repeatedly.
|
||||
*/
|
||||
ODE_API void dTimerReport (FILE *fout, int average);
|
||||
|
||||
|
||||
/* resolution */
|
||||
|
||||
/* returns the timer ticks per second implied by the timing hardware or API.
|
||||
* the actual timer resolution may not be this great.
|
||||
*/
|
||||
ODE_API double dTimerTicksPerSecond(void);
|
||||
|
||||
/* returns an estimate of the actual timer resolution, in seconds. this may
|
||||
* be greater than 1/ticks_per_second.
|
||||
*/
|
||||
ODE_API double dTimerResolution(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user