feat: copy webots headers (/include)

This commit is contained in:
insleker 2026-05-21 10:21:26 +08:00
parent 10cb4bdb4a
commit d877661507
71 changed files with 14226 additions and 0 deletions

7
include/.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
/libassimp
/libOIS
/libpico
/openvr
/libssh
/libzip
/qt

2224
include/glad/glad.h Normal file

File diff suppressed because it is too large Load Diff

18
include/ode/ode/README Normal file
View 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!

1468
include/ode/ode/collision.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,177 @@
/*************************************************************************
* *
* 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, const dVector3 Center, const dVector3 Extents, int Depth);
/* SAP */
/* Order XZY or ZXY usually works best, if your Y is up. */
#define dSAP_AXES_XYZ ((0)|(1<<2)|(2<<4))
#define dSAP_AXES_XZY ((0)|(2<<2)|(1<<4))
#define dSAP_AXES_YXZ ((1)|(0<<2)|(2<<4))
#define dSAP_AXES_YZX ((1)|(2<<2)|(0<<4))
#define dSAP_AXES_ZXY ((2)|(0<<2)|(1<<4))
#define dSAP_AXES_ZYX ((2)|(1<<2)|(0<<4))
ODE_API dSpaceID dSweepAndPruneSpaceCreate( dSpaceID space, int axisorder );
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);
/**
* @brief Sets sublevel value for a space.
*
* Sublevel affects how the space is handled in dSpaceCollide2 when it is collided
* with another space. If sublevels of both spaces match, the function iterates
* geometries of both spaces and collides them with each other. If sublevel of one
* space is greater than the sublevel of another one, only the geometries of the
* space with greater sublevel are iterated, another space is passed into
* collision callback as a geometry itself. By default all the spaces are assigned
* zero sublevel.
*
* @note
* The space sublevel @e IS @e NOT automatically updated when one space is inserted
* into another or removed from one. It is a client's responsibility to update sublevel
* value if necessary.
*
* @param space the space to modify
* @param sublevel the sublevel value to be assigned
* @ingroup collide
* @see dSpaceGetSublevel
* @see dSpaceCollide2
*/
ODE_API void dSpaceSetSublevel (dSpaceID space, int sublevel);
/**
* @brief Gets sublevel value of a space.
*
* Sublevel affects how the space is handled in dSpaceCollide2 when it is collided
* with another space. See @c dSpaceSetSublevel for more details.
*
* @param space the space to query
* @returns the sublevel value of the space
* @ingroup collide
* @see dSpaceSetSublevel
* @see dSpaceCollide2
*/
ODE_API int dSpaceGetSublevel (dSpaceID space);
/**
* @brief Sets manual cleanup flag for a space.
*
* Manual cleanup flag marks a space as eligible for manual thread data cleanup.
* This function should be called for every space object right after creation in
* case if ODE has been initialized with @c dInitFlagManualThreadCleanup flag.
*
* Failure to set manual cleanup flag for a space may lead to some resources
* remaining leaked until the program exit.
*
* @param space the space to modify
* @param mode 1 for manual cleanup mode and 0 for default cleanup mode
* @ingroup collide
* @see dSpaceGetManualCleanup
* @see dInitODE2
*/
ODE_API void dSpaceSetManualCleanup (dSpaceID space, int mode);
/**
* @brief Get manual cleanup flag of a space.
*
* Manual cleanup flag marks a space space as eligible for manual thread data cleanup.
* See @c dSpaceSetManualCleanup for more details.
*
* @param space the space to query
* @returns 1 for manual cleanup mode and 0 for default cleanup mode of the space
* @ingroup collide
* @see dSpaceSetManualCleanup
* @see dInitODE2
*/
ODE_API int dSpaceGetManualCleanup (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);
/**
* @brief Given a space, this returns its class.
*
* The ODE classes are:
* @li dSimpleSpaceClass
* @li dHashSpaceClass
* @li dSweepAndPruneSpaceClass
* @li dQuadTreeSpaceClass
* @li dFirstUserClass
* @li dLastUserClass
*
* The class id not defined by the user should be between
* dFirstSpaceClass and dLastSpaceClass.
*
* User-defined class will return their own number.
*
* @param space the space to query
* @returns The space class ID.
* @ingroup collide
*/
ODE_API int dSpaceGetClass(dSpaceID space);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,207 @@
/*************************************************************************
* *
* 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 a TriMesh data object with single precision 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 a TriMesh data object with double precision 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 dTriIndex* 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 dTriIndex* 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);
/*
* Triangle merging callback.
* Allows the user to generate a fake triangle index for a new contact generated
* from merging of two other contacts. That index could later be used by the
* user to determine attributes of original triangles used as sources for a
* merged contact.
*/
typedef int dTriTriMergeCallback(dGeomID TriMesh, int FirstTriangleIndex, int SecondTriangleIndex);
ODE_API void dGeomTriMeshSetTriMergeCallback(dGeomID g, dTriTriMergeCallback* Callback);
ODE_API dTriTriMergeCallback* dGeomTriMeshGetTriMergeCallback(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_ */

379
include/ode/ode/common.h Normal file
View File

@ -0,0 +1,379 @@
/*************************************************************************
* *
* 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/odeconfig.h>
#include <ode/error.h>
#ifdef __cplusplus
extern "C" {
#endif
/* configuration stuff */
/* 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_PI_2
#define M_PI_2 REAL(1.5707963267948966192313216916398)
#endif
#ifndef M_SQRT1_2
#define M_SQRT1_2 REAL(0.7071067811865475244008443621048490)
#endif
/* 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
/* Detect if we've got both trimesh engines enabled. */
#if dTRIMESH_ENABLED
#if dTRIMESH_OPCODE && dTRIMESH_GIMPACT
#error You can only #define dTRIMESH_OPCODE or dTRIMESH_GIMPACT, not both.
#endif
#endif /* dTRIMESH_ENABLED */
/*
* Define a type for indices, either 16 or 32 bit, based on build option
* TODO: Currently GIMPACT only supports 32 bit indices.
*/
#if dTRIMESH_16BIT_INDICES
#if dTRIMESH_GIMPACT
typedef duint32 dTriIndex;
#else /* dTRIMESH_GIMPACT */
typedef duint16 dTriIndex;
#endif /* dTRIMESH_GIMPACT */
#else /* dTRIMESH_16BIT_INDICES */
typedef duint32 dTriIndex;
#endif /* dTRIMESH_16BIT_INDICES */
/* 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 dAcos(x) (acosf(x))
#define dFMod(a,b) (fmodf(a,b)) /* modulo */
#define dFloor(x) floorf(x) /* floor */
#define dCeil(x) ceilf(x) /* ceil */
#define dCopySign(a,b) _ode_copysignf(a, b) /* copy value sign */
#define dNextAfter(x, y) _ode_nextafterf(x, y) /* next value after */
#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
#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 dAcos(x) acos(x)
#define dFMod(a,b) (fmod((a),(b)))
#define dFloor(x) floor(x)
#define dCeil(x) ceil(x)
#define dCopySign(a,b) _ode_copysign(a, b)
#define dNextAfter(x, y) _ode_nextafter(x, y)
#define dMax(a, b) ((a) > (b) ? (a) : (b))
#define dMin(a, b) ((a) > (b) ? (b) : (a))
#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
#else
#error You must #define dSINGLE or dDOUBLE
#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;
struct dxWorldProcessThreadingManager;
typedef struct dxWorld *dWorldID;
typedef struct dxSpace *dSpaceID;
typedef struct dxBody *dBodyID;
typedef struct dxGeom *dGeomID;
typedef struct dxJoint *dJointID;
typedef struct dxJointGroup *dJointGroupID;
typedef struct dxWorldProcessThreadingManager *dWorldStepThreadingManagerID;
/* 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 */
typedef enum {
dJointTypeNone = 0, /* or "unknown" */
dJointTypeBall,
dJointTypeHinge,
dJointTypeSlider,
dJointTypeContact,
dJointTypeUniversal,
dJointTypeHinge2,
dJointTypeFixed,
dJointTypeNull,
dJointTypeAMotor,
dJointTypeLMotor,
dJointTypePlane2D,
dJointTypePR,
dJointTypePU,
dJointTypePiston,
dJointTypeDBall,
dJointTypeDHinge,
dJointTypeTransmission,
} dJointType;
/* 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, \
dParamLoVel, \
dParamHiVel, \
dParamFMax, \
dParamFudgeFactor, \
dParamBounce, \
dParamCFM, \
dParamStopERP, \
dParamStopCFM, \
/* parameters for suspension */ \
dParamSuspensionERP, \
dParamSuspensionCFM, \
dParamERP, \
/*
* \enum D_ALL_PARAM_NAMES_X
*
* \var dParamGroup This is the starting value of the different group
* (i.e. dParamGroup1, dParamGroup2, dParamGroup3)
* It also helps in the use of parameter
* (dParamGroup2 | dParamFMax) == dParamFMax2
*/
#define D_ALL_PARAM_NAMES_X(start,x) \
dParamGroup ## x = start, \
/* parameters for limits and motors */ \
dParamLoStop ## x = start, \
dParamHiStop ## x, \
dParamVel ## x, \
dParamLoVel ## x, \
dParamHiVel ## x, \
dParamFMax ## x, \
dParamFudgeFactor ## x, \
dParamBounce ## x, \
dParamCFM ## x, \
dParamStopERP ## x, \
dParamStopCFM ## x, \
/* parameters for suspension */ \
dParamSuspensionERP ## x, \
dParamSuspensionCFM ## x, \
dParamERP ## x,
enum {
D_ALL_PARAM_NAMES(0)
dParamsInGroup, /* < Number of parameter in a group */
D_ALL_PARAM_NAMES_X(0x000,1)
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
};
/* transmission joint mode numbers */
enum {
dTransmissionParallelAxes = 0,
dTransmissionIntersectingAxes = 1,
dTransmissionChainDrive = 2
};
/* 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);
/**
* dGetConfiguration returns the specific ODE build configuration as
* a string of tokens. The string can be parsed in a similar way to
* the OpenGL extension mechanism, the naming convention should be
* familiar too. The following extensions are reported:
*
* ODE
* ODE_single_precision
* ODE_double_precision
* ODE_EXT_no_debug
* ODE_EXT_trimesh
* ODE_EXT_opcode
* ODE_EXT_gimpact
* ODE_OPC_16bit_indices
* ODE_OPC_new_collider
* ODE_EXT_mt_collisions
* ODE_EXT_threading
* ODE_THR_builtin_impl
*/
ODE_API const char* dGetConfiguration (void);
/**
* Helper to check for a token in the ODE configuration string.
* Caution, this function is case sensitive.
*
* @param token A configuration token, see dGetConfiguration for details
*
* @return 1 if exact token is present, 0 if not present
*/
ODE_API int dCheckConfiguration( const char* token );
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,39 @@
/*************************************************************************
* *
* 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

105
include/ode/ode/contact.h Normal file
View File

@ -0,0 +1,105 @@
/*************************************************************************
* *
* 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, /**< Use axis dependent friction */
dContactAxisDep = 0x001, /**< Same as above */
dContactFDir1 = 0x002, /**< Use FDir for the first friction value */
dContactBounce = 0x004, /**< Restore collision energy anti-parallel to the normal */
dContactSoftERP = 0x008, /**< Don't use global erp for penetration reduction */
dContactSoftCFM = 0x010, /**< Don't use global cfm for penetration constraint */
dContactMotion1 = 0x020, /**< Use a non-zero target velocity for the constraint */
dContactMotion2 = 0x040,
dContactMotionN = 0x080,
dContactSlip1 = 0x100, /**< Force-dependent slip. */
dContactSlip2 = 0x200,
dContactRolling = 0x400, /**< Rolling/Angular friction */
dContactApprox0 = 0x0000,
dContactApprox1_1 = 0x1000,
dContactApprox1_2 = 0x2000,
dContactApprox1_N = 0x4000, /**< For rolling friction */
dContactApprox1 = 0x7000
};
typedef struct dSurfaceParameters {
/* must always be defined */
int mode;
dReal mu;
/* only defined if the corresponding flag is set in mode */
dReal mu2;
dReal rho; /**< Rolling friction */
dReal rho2;
dReal rhoN; /**< Spinning friction */
dReal bounce; /**< Coefficient of restitution */
dReal bounce_vel; /**< Bouncing threshold */
dReal soft_erp;
dReal soft_cfm;
dReal motion1,motion2,motionN;
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

62
include/ode/ode/error.h Normal file
View File

@ -0,0 +1,62 @@
/*************************************************************************
* *
* 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/odeconfig.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

View File

@ -0,0 +1,38 @@
/*************************************************************************
* *
* 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>
#ifdef __cplusplus
extern "C" {
#endif
ODE_API void dWorldExportDIF (dWorldID w, FILE *file, const char *world_name);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,50 @@
/*************************************************************************
* *
* 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_FLUID_DYNAMICS_H_
#define _ODE_COMMON_FLUID_DYNAMICS_H_
#include <ode/common.h>
#ifdef __cplusplus
extern "C" {
#endif
/* internal object types (all prefixed with `dx') */
struct dxFluid; /* fluid */
struct dxImmersionLink;
struct dxImmersionLinkGroup;
struct dxImmersionOutline;
typedef struct dxFluid *dFluidID;
typedef struct dxImmersionLink *dImmersionLinkID;
typedef struct dxImmersionLinkGroup *dImmersionLinkGroupID;
typedef struct dxImmersionOutline *dImmersionOutlineID;
dGeomID dGeomGetFluidNext (dGeomID);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,465 @@
/*************************************************************************
* *
* 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_FLUID_DYNAMICS_H_
#define _ODE_FLUID_DYNAMICS_H_
#include <ode/common.h>
#include <ode/fluid_dynamics/common_fluid_dynamics.h>
#include <ode/fluid_dynamics/immersion.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup immerse Immersion Detection
*
* ODE has two main components: a dynamics simulation engine and a collision
* detection engine. The collision engine is given information about the
* shape of each body. At each time step it figures out which bodies touch
* each other and passes the resulting contact point information (rigid body vs. rigid body) or immersion information (rigid body vs. fluid) to the user.
* The user in turn creates contact joints between bodies.
*
* Using ODE's collision detection is optional - an alternative collision
* detection system can be used as long as it can supply the right kinds of
* contact information.
*/
/* ************************************************************************ */
/* general functions */
/**
* @brief Set the fluid associated with a placeable geom.
*
* @param geom the geom to connect
* @param fluid the fluid to attach to the geom
* @ingroup immerse
*/
ODE_API void dGeomSetFluid (dGeomID geom, dFluidID fluid);
/**
* @brief Get the fluid associated with a placeable geom.
* @param geom the geom to query.
* @sa dGeomSetFluid
* @ingroup immerse
*/
ODE_API dFluidID dGeomGetFluid (dGeomID geom);
/**
* @brief Get the geom area.
* @param geom the geom to query.
* @ingroup immerse
*/
ODE_API dReal dGeomGetArea (dGeomID geom);
/**
* @brief Get the geom volume.
* @param geom the geom to query.
* @ingroup immerse
*/
ODE_API dReal dGeomGetVolume (dGeomID geom);
/**
* @brief Get the geom immersion plane.
* @param geom the geom to query.
* @param plane the returned plane.
* @ingroup immerse
*/
ODE_API void dGeomGetImmersionPlane(dGeomID geom, dVector4 plane);
/**
* @brief return 1 if the point is below the immersion plane of the geom, 0 otherwise
* @param geom the geom to query.
* @param x the X coordinate of the point.
* @param y the Y coordinate of the point.
* @param z the Z coordinate of the point.
* @ingroup immerse
*/
ODE_API int dGeomIsBelowImmersionPlane(dGeomID geom, dReal x, dReal y, dReal z);
/**
* @brief Determines whether the given point is inside the geom
*
* @param geom the geom to query.
* @param x the X coordinate of the point.
* @param y the Y coordinate of the point.
* @param z the Z coordinate of the point.
*
* @sa dGeomIsInside
* @ingroup immerse_geom
*/
ODE_API int dGeomIsInside (dGeomID geom, dReal x, dReal y, dReal z);
/**
* @brief Get the geom flags
* @param geom the geom to query.
* @ingroup immerse
*/
ODE_API int dGeomGetFlags (dGeomID geom);
/* ************************************************************************ */
/* immersion detection */
/**
*
* @brief Given two geoms o1 and o2 that potentially intersect,
* generate contact information for them.
*
* Internally, this just calls the correct class-specific collision
* functions for o1 and o2.
*
* @param o1 The first geom to test.
* @param o2 The second geom to test.
*
* @param flags The flags specify how immmersion should be generated
* In the future it may be used to select from different
* immersion generation strategies.
*
* @param contact Points to an dImmersionGeom structure.
*
* @returns If the geoms intersect, this function returns 1, else 0.
*
* @remarks This function does not care if o1 and o2 are in the same space or not
* (or indeed if they are in any space at all).
*
* @ingroup immerse
*/
ODE_API int dImmerse (dGeomID o1, dGeomID o2, int flags, dImmersionGeom *immersion);
/**
* @brief Retrieves the volume of a sphere geom.
*
* @param box the box to query.
*
* @sa dGeomBoxGetVolume
* @ingroup immerse_box
*/
ODE_API dReal dGeomBoxGetVolume (dGeomID box);
/**
* @brief Retrieves the area of a box geom.
*
* @param box the box to query.
*
* @sa dGeomBoxGetArea
* @ingroup immerse_box
*/
ODE_API dReal dGeomBoxGetArea (dGeomID box);
/**
* @brief Retrieves the tangent plane to a box geom at a given point.
*
* @param box the box to query.
* @param x the X coordinate of the point.
* @param y the Y coordinate of the point.
* @param z the Z coordinate of the point.
* @param plane the tangent plane.
*
* @sa dGeomBoxGetTangentPlane
* @ingroup immerse_box
*/
ODE_API void dGeomBoxGetTangentPlane (dGeomID box, dReal x, dReal y, dReal z, dVector4 plane);
/**
* @brief Retrieves plane equation of a given box face.
*
* @param box the box to query.
* @param faceIndex the face index (in the range {-1, -2, -3, 1, 2, 3}).
* @param plane the face plane.
*
* @sa dGeomBoxGetFacePlane
* @ingroup immerse_box
*/
ODE_API void dGeomBoxGetFacePlane (dGeomID box, int faceIndex, dVector4 plane);
/**
* @brief Retrieves the immersion plane used for a fluid bounded by a box.
*
* @param box the box to query.
* @param plane the immersion plane.
*
* @sa dGeomCylinderGetImmersionPlane
* @ingroup immerse_box
*/
ODE_API void dGeomBoxGetImmersionPlane (dGeomID box, dVector4 plane);
/**
* @brief Retrieves the volume of a cylinder geom.
*
* @param cylinder the cylinder to query.
*
* @sa dGeomCylinderGetVolume
* @ingroup immerse_capsule
*/
ODE_API dReal dGeomCapsuleGetVolume (dGeomID capsule);
/**
* @brief Retrieves the area of a capsule geom.
*
* @param capsule the capsule to query.
*
* @sa dGeomCapsuleGetArea
* @ingroup immerse_capsule
*/
ODE_API dReal dGeomCapsuleGetArea (dGeomID capsule);
/**
* @brief Retrieves the tangent plane to a capsule geom at a given point.
*
* @param capsule the capsule to query.
* @param x the X coordinate of the point.
* @param y the Y coordinate of the point.
* @param z the Z coordinate of the point.
* @param plane the tangent plane.
*
* @sa dGeomCapsuleGetTangentPlane
* @ingroup immerse_capsule
*/
ODE_API void dGeomCapsuleGetTangentPlane (dGeomID capsule, dReal x, dReal y, dReal z, dVector4 plane);
/**
* @brief Retrieves the immersion plane used for a fluid bounded by a capsule.
*
* @param capsule the capsule to query.
* @param plane the immersion plane.
*
* @sa dGeomCapsuleGetImmersionPlane
* @ingroup immerse_capsule
*/
ODE_API void dGeomCapsuleGetImmersionPlane (dGeomID capsule, dVector4 plane);
/**
* @brief Retrieves the volume of a cylinder geom.
*
* @param cylinder the cylinder to query.
*
* @sa dGeomCylinderGetVolume
* @ingroup immerse_cylinder
*/
ODE_API dReal dGeomCylinderGetVolume (dGeomID cylinder);
/**
* @brief Retrieves the area of a cylinder geom.
*
* @param cylinder the cylinder to query.
*
* @sa dGeomCylinderGetArea
* @ingroup immerse_cylinder
*/
ODE_API dReal dGeomCylinderGetArea (dGeomID cylinder);
/**
* @brief Retrieves the tangent plane to a cylinder geom at a given point.
*
* @param cylinder the cylinder to query.
* @param x the X coordinate of the point.
* @param y the Y coordinate of the point.
* @param z the Z coordinate of the point.
* @param plane the tangent plane.
*
* @sa dGeomCylinderGetTangentPlane
* @ingroup immerse_cylinder
*/
ODE_API void dGeomCylinderGetTangentPlane (dGeomID cylinder, dReal x, dReal y, dReal z, dVector4 plane);
/**
* @brief Retrieves plane equation of a given cylinder disk.
*
* @param cylinder the cylinder to query.
* @param faceIndex the disk index (in the range {-1, 1}).
* @param plane the disk plane (not normalized).
*
* @sa dGeomCylinderGetFacePlane
* @ingroup immerse_cylinder
*/
ODE_API void dGeomCylinderGetDiskPlane (dGeomID cylinder, int diskIndex, dVector4 plane);
/**
* @brief Retrieves the immersion plane used for a fluid bounded by a cylinder.
*
* @param cylinder the cylinder to query.
* @param plane the immersion plane.
*
* @sa dGeomCylinderGetImmersionPlane
* @ingroup immerse_cylinder
*/
ODE_API void dGeomCylinderGetImmersionPlane (dGeomID cylinder, dVector4 plane);
/**
* @brief Retrieves the depth of the given point in the cylinder (negative if the point is outside, else min(distance to the caps, distance to the body) >= 0)
*
* @param cylinder the cylinder to query.
* @param x the X coordinate of the point.
* @param y the Y coordinate of the point.
* @param z the Z coordinate of the point.
*
* @sa dGeomCylinderIsInside
* @ingroup immerse_cylinder
*/
ODE_API dReal dGeomCylinderPointDepth (dGeomID cylinder, dReal x, dReal y, dReal z);
/**
* @brief Retrieves the volume of a sphere geom.
*
* @param sphere the sphere to query.
*
* @sa dGeomSphereGetVolume
* @ingroup immerse_sphere
*/
ODE_API dReal dGeomSphereGetVolume (dGeomID sphere);
/**
* @brief Retrieves the area of a sphere geom.
*
* @param sphere the sphere to query.
*
* @sa dGeomSphereGetArea
* @ingroup immerse_sphere
*/
ODE_API dReal dGeomSphereGetArea (dGeomID sphere);
/**
* @brief Retrieves the tangent plane to a sphere geom at a given point.
*
* @param sphere the sphere to query.
* @param x the X coordinate of the point.
* @param y the Y coordinate of the point.
* @param z the Z coordinate of the point.
* @param plane the tangent plane.
*
* @sa dGeomSphereGetTangentPlane
* @ingroup immerse_sphere
*/
ODE_API void dGeomSphereGetTangentPlane (dGeomID sphere, dReal x, dReal y, dReal z, dVector4 plane);
/**
* @brief Retrieves the immersion plane used for a fluid bounded by a sphere.
*
* @param cylinder the sphere to query.
* @param plane the immersion plane.
*
* @sa dGeomSphereGetImmersionPlane
* @ingroup immerse_sphere
*/
ODE_API void dGeomSphereGetImmersionPlane (dGeomID sphere, dVector4 plane);
/**
* @brief Retrieves the volume of a trimesh geom.
*
* @param trimesh the trimesh to query.
*
* @sa dGeomTriMeshGetVolume
* @ingroup immerse_trimesh
*/
ODE_API dReal dGeomTriMeshGetVolume (dGeomID trimesh);
/**
* @brief Retrieves the area of a trimesh geom.
*
* @param trimesh the trimesh to query.
*
* @sa dGeomTriMeshGetArea
* @ingroup immerse_trimesh
*/
ODE_API dReal dGeomTriMeshGetArea (dGeomID trimesh);
/**
* @brief Retrieves the center of mass of a trimesh geom.
*
* @param trimesh the trimesh to query.
* @param c the trimesh's center of mass.
*
* @sa dGeomTriMeshGetCenterOfMass
* @ingroup immerse_trimesh
*/
ODE_API void dGeomTriMeshGetCenterOfMass (dGeomID trimesh, dVector3 c);
/**
* @brief Retrieves the center of mass of a trimesh geom expressed in relative coordinates.
*
* @param trimesh the trimesh to query.
*
* @sa dGeomTriMeshGetRelCenterOfMass
* @ingroup immerse_trimesh
*/
ODE_API const dReal *dGeomTriMeshGetRelCenterOfMass (dGeomID trimesh);
/**
* @brief Retrieves the inertia matrix of a trimesh geom with density 1.
*
* @param trimesh the trimesh to query.
*
* @sa dGeomTriMeshGetInertiaMatrix
* @ingroup immerse_trimesh
*/
ODE_API const dReal *dGeomTriMeshGetInertiaMatrix (dGeomID trimesh);
/**
* @brief Retrieves the immersion plane used for a fluid bounded by a trimesh.
*
* @param cylinder the trimesh to query.
* @param plane the immersion plane.
*
* @sa dGeomTriMeshGetImmersionPlane
* @ingroup immerse_trimesh
*/
ODE_API void dGeomTriMeshGetImmersionPlane (dGeomID trimesh, dVector4 plane);
/**
* @brief Retrieves plane equation of a given trimesh's bounding plane.
*
* @param trimesh the trimesh to query.
* @param planeIndex the bounding plane index (in the range {-1, -2, -3, 1, 2, 3}).
* @param plane the bounding plane.
*
* @sa dGeomTriMeshGetFacePlane
* @ingroup immerse_trimesh
*/
ODE_API void dGeomTriMeshGetBoundingPlane (dGeomID trimesh, int planeIndex, dVector4 plane);
/**
* @brief Calculate the depth of the a given point within a trimesh.
*
* @param trimesh the trimesh to query.
* @param x the X coordinate of the point.
* @param y the Y coordinate of the point.
* @param z the Z coordinate of the point.
*
* @returns The depth of the point. Points inside the trimesh will have a
* positive depth, points outside it will have a negative depth, and points
* on the surface will have a depth of zero.
*
* @ingroup collide_trimesh
*/
ODE_API dReal dGeomTriMeshPointDepth (dGeomID trimesh, dReal x, dReal y, dReal z);
typedef int dImmerserFn (dGeomID o1, dGeomID o2,
int flags, dImmersionGeom *immersion);
typedef dImmerserFn * dGetImmerserFnFn (int num);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,89 @@
/*************************************************************************
* *
* 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_IMMERSION_H_
#define _ODE_IMMERSION_H_
#include <ode/common.h>
#include <ode/fluid_dynamics/common_fluid_dynamics.h>
#ifdef __cplusplus
extern "C" {
#endif
enum {
dImmersionProjectedAreas = 0x001,
dImmersionImmersedArea = 0x002,
dImmersionExposedArea = 0x003
};
typedef struct dImmersionSurfaceParameters {
int mode;
dVector3 dragForceCoefficients; // drag force coefficients along three different axes
dVector3 dragTorqueCoefficients; // drag torque coefficients along three different axes
dReal viscousResistanceForceCoefficient, viscousResistanceTorqueCoefficient;
dReal maxAngularVel, maxLinearVel;
} dImmersionSurfaceParameters;
/**
* @brief Describe the immersion locus between two geoms.
*
*
* @ingroup collide
*/
typedef struct dStraightEdge {
dVector3 origin, end;
} dStraightEdge;
typedef struct dCurvedEdge {
// ellipse half axes
dVector3 e1, e2;
// ellipse center
dVector3 center;
// min angle, max angle
dReal minAngle, maxAngle;
} dCurvedEdge;
typedef struct dImmersionGeom {
dVector3 buoyancyCenter; ///< center of buoyancy
dReal volume; ///< immersed volume
dReal area; ///< immersed area
dReal referenceArea; ///< immersed reference area (depend on relative motion)
dVector3 projectedAreas; /// projections of the immersed area along the three immersed dGeom axes
dImmersionOutlineID outline; ///< optional immersion outline info
dGeomID g1,g2; ///< the colliding geoms
} dImmersionGeom;
/* immersion info used by immersion links */
typedef struct dImmersion {
dImmersionSurfaceParameters surface;
dImmersionGeom geom;
} dImmersion;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,393 @@
/*************************************************************************
* *
* 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_OBJECTS_FLUID_DYNAMICS_H_
#define _ODE_OBJECTS_FLUID_DYNAMICS_H_
#include <ode/fluid_dynamics/common_fluid_dynamics.h>
#include <ode/fluid_dynamics/immersion.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup fluids Fluids
*
*
*
*
*
*
**/
/**
* @brief Applies fluid static and dynamics forces (Archimedean, forces, drag forces)
* to all bodies in the world according to the immersionLinks generated after collision detection
* @ingroup fluids
* @param world the simulated world
* @remarks this step requires that collision detection was performed
*/
ODE_API int dFluidDynamicsStep (dWorldID w);
/**
* @brief Retrieves the world attached to te given body.
* @remarks
*
* @ingroup fluids
*/
ODE_API dWorldID dFluidGetWorld (dFluidID);
/**
* @brief Create a body in given world.
* @remarks
* Default mass parameters are at position (0,0,0).
* @ingroup fluids
*/
ODE_API dFluidID dFluidCreate (dWorldID);
/**
* @brief Destroy a fluid.
* @remarks
* All immersion links that are attached to this fluid will be put into limbo:
* i.e. unattached and not affecting the simulation, but they will NOT be
* deleted.
* @ingroup fluids
*/
ODE_API void dFluidDestroy (dFluidID);
/**
* @brief Set the fluid's user-data pointer.
* @ingroup fluids
* @param data arbitraty pointer
*/
ODE_API void dFluidSetData (dFluidID, void *data);
/**
* @brief Get the fluid's user-data pointer.
* @ingroup fluids
* @return a pointer to the user's data.
*/
ODE_API void *dFluidGetData (dFluidID);
/**
* @brief Set the fluid's density.
* @ingroup fluids
* @param zero or positive number
*/
ODE_API void dFluidSetDensity (dFluidID, dReal density);
/**
* @brief Get the fluid's dynamic viscosity.
* @ingroup fluids
* @return the viscosity value.
*/
ODE_API dReal dFluidGetViscosity (dFluidID);
/**
* @brief Set the fluid's viscosity.
* @ingroup fluids
* @param zero or positive number
*/
ODE_API void dFluidSetViscosity (dFluidID, dReal viscosity);
/**
* @brief Get the fluid's density.
* @ingroup fluids
* @return the density value.
*/
ODE_API dReal dFluidGetDensity (dFluidID);
/**
* @brief Set the fluid's stream linear velocity.
* @ingroup fluids
*/
ODE_API void dFluidSetStreamVel (dFluidID, const dReal *velocity);
/**
* @brief Get the fluid's stream linear velocity.
* @ingroup fluids
* @return the stream linear velocity.
*/
ODE_API const dReal* dFluidGetStreamVel (dFluidID);
/**
* @brief Manually enable a fluid.
* @param dFluidID identification of fluid.
* @ingroup fluids
*/
ODE_API void dFluidEnable (dFluidID);
/**
* @brief Manually disable a fluid.
* @ingroup fluids
* @remarks
* A disabled fluid that is connected through a immersion link to an enabled fluid will
* be automatically re-enabled at the next simulation step.
*/
ODE_API void dFluidDisable (dFluidID);
/**
* @brief Check wether a fluid is enabled.
* @ingroup fluids
* @return 1 if a fluid is currently enabled or 0 if it is disabled.
*/
ODE_API int dFluidIsEnabled (dFluidID);
/**
* @brief Return the first geom associated with the fluid.
*
* You can traverse through the geoms by repeatedly calling
* dFluidGetNextGeom().
*
* @return the first geom attached to this fluid, or 0.
* @ingroup fluids
*/
ODE_API dGeomID dFluidGetFirstGeom (dFluidID f);
/**
* @brief returns the next geom associated with the same fluid.
* @param g a geom attached to some fluid.
* @return the next geom attached to the same fluid, or 0.
* @sa dFluidGetFirstGeom
* @ingroup fluids
*/
ODE_API dGeomID dFluidGetNextGeom (dGeomID f);
/**
* @defgroup immersion links Immersion links
* An immersion link is structure that contains
* information about the (possibly partial) immersion of body into a fluid
*/
/**
* @brief Create a new immersion link.
* @ingroup immersion links
* @remarks
* The immersion link is initially in "limbo" (i.e. it has no effect on the simulation)
* because it does not connect to any bodies and fluids.
* @param dImmersionLinkGroupID set to 0 to allocate the immersion link normally.
* If it is nonzero the immersion link is allocated in the given immersion link group.
*/
ODE_API dImmersionLinkID dImmersionLinkCreate (dWorldID, dImmersionLinkGroupID, const dImmersion *);
/**
* @brief Destroy an immersion link.
* @ingroup immersion links
*
* disconnects it from its attached body and fluid and removing it from the world.
* However, if the immersion link is a member of a group then this function has no
* effect - to destroy that immersion link the group must be emptied or destroyed.
*/
ODE_API void dImmersionLinkDestroy (dImmersionLinkID);
/**
* @brief Create a immersion link group
* @ingroup immersion links
*/
ODE_API dImmersionLinkGroupID dImmersionLinkGroupCreate ();
/**
* @brief Destroy a immersion link group.
* @ingroup immersion links
*
* All immersion links in the immersion link group will be destroyed.
*/
ODE_API void dImmersionLinkGroupDestroy (dImmersionLinkGroupID);
/**
* @brief Empty a immersion link group.
* @ingroup immersion links
*
* All immersion links in the immersion link group will be destroyed,
* but the immersion link group itself will not be destroyed.
*/
ODE_API void dImmersionLinkGroupEmpty (dImmersionLinkGroupID);
/**
* @brief Attach the immersion link to some new body and fluid.
* @ingroup immersion links
*
* If the immersion link is already attached, it will be detached from the old bodies
* first.
* Setting either the body or the fluid to zero puts the immersion link into "limbo", i.e. it will
* have no effect on the simulation.
*/
ODE_API void dImmersionLinkAttach (dImmersionLinkID, dBodyID, dFluidID);
/**
* @brief Manually enable a immersion link.
* @param dImmersionLinkID identification of immersion link.
* @ingroup immersion links
*/
ODE_API void dImmersionLinkEnable (dImmersionLinkID);
/**
* @brief Manually disable a immersion link.
* @ingroup immersion links
* @remarks
* A disabled immersion link will not affect the simulation
*/
ODE_API void dImmersionLinkDisable (dImmersionLinkID);
/**
* @brief Check wether a immersion link is enabled.
* @ingroup immersion links
* @return 1 if a immersion link is currently enabled or 0 if it is disabled.
*/
ODE_API int dImmersionLinkIsEnabled (const dImmersionLinkID);
/**
* @brief Set the user-data pointer
* @ingroup immersion links
*/
ODE_API void dImmersionLinkSetData (dImmersionLinkID, void *data);
/**
* @brief Get the user-data pointer
* @ingroup immersion links
*/
ODE_API void *dImmersionLinkGetData (const dImmersionLinkID);
/**
* @brief Return the body that this immersion link connects.
* @ingroup immersion links
* @remarks
* If the body IDs is zero, the immersion link is in ``limbo'' and has no effect on
* the simulation.
*/
ODE_API dBodyID dImmersionLinkGetBody (const dImmersionLinkID);
/**
* @brief Return the fluid that this immersion link connects.
* @ingroup immersion links
* @remarks
* If the fluid ID is zero, the immersion link is in ``limbo'' and has no effect on
* the simulation.
*/
ODE_API dBodyID dImmersionLinkGetFluid (const dImmersionLinkID);
/**
* @ingroup immersion links
*/
ODE_API dImmersionLinkID dLinkingImmersionLink (const dBodyID, const dFluidID);
/**
* @brief Utility function
* @return 1 if the the body and the fluid are connected together by
* a immersion link, otherwise return 0.
* @ingroup immersion links
*/
ODE_API int dAreLinked (const dBodyID, const dFluidID);
/**
* @brief Get the number of immersion links that are attached to this body.
* @ingroup bodies
* @return number of immersion links
*/
ODE_API int dBodyGetNumImmersionLinks (dBodyID b);
/**
* @brief Return an immersion link attached to this body, given by index.
* @ingroup bodies
* @param index valid range is 0 to n-1 where n is the value returned by
* dBodyGetNumImmersionLinks().
*/
ODE_API dImmersionLinkID dBodyGetImmersionLink (dBodyID, int index);
/**
* @brief Get the number of immersion links that are attached to this fluid.
* @ingroup fluids
* @return number of immersion links
*/
ODE_API int dFluidGetNumImmersionLinks (dFluidID b);
/**
* @brief Return an immersion link attached to this fluid, given by index.
* @ingroup fluids
* @param index valid range is 0 to n-1 where n is the value returned by
* dFluidGetNumImmersionLinks().
*/
ODE_API dImmersionLinkID dFluidGetImmersionLink (dFluidID, int index);
/**
* @brief Return a pointer to an allocated immersion outline
* @ingroup fluids
*/
ODE_API dImmersionOutlineID dImmersionOutlineCreate ();
/**
* @brief Destroys an allocated immersion outline
* @ingroup fluids
*/
ODE_API void dImmersionOutlineDestroy (dImmersionOutlineID);
/**
* @brief Return the size of the straight edge array in the given immersion outline.
* @ingroup fluids
*/
ODE_API int dImmersionOutlineGetStraightEdgesSize (dImmersionOutlineID);
/**
* @brief Return a straight edge of the immersion outline, given by index.
* @ingroup fluids
* @param index valid range is 0 to n-1 where n is the value returned by
* dImmersionOutlineGetStraightEdgesSize().
*/
ODE_API void dImmersionOutlineGetStraightEdge (dImmersionOutlineID, int index, dStraightEdge *);
/**
* @brief Return the straight edge end of the immersion outline straight edge given by index.
* @ingroup fluids
* @param index valid range is 0 to n-1 where n is the value returned by
* dImmersionOutlineGetStraightEdgesSize().
*/
ODE_API const dReal *dImmersionOutlineGetStraightEdgeEnd (dImmersionOutlineID, int index);
/**
* @brief Return the straight edge origin of the immersion outline straight edge given by index.
* @ingroup fluids
* @param index valid range is 0 to n-1 where n is the value returned by
* dImmersionOutlineGetStraightEdgesSize().
*/
ODE_API const dReal *dImmersionOutlineGetStraightEdgeOrigin (dImmersionOutlineID, int index);
/**
* @brief Return the size of the curved edge array in the given immersion outline.
* @ingroup fluids
*/
ODE_API int dImmersionOutlineGetCurvedEdgesSize (dImmersionOutlineID);
/**
* @brief Return a curved edge of the immersion outline, given by index.
* @ingroup fluids
* @param index valid range is 0 to n-1 where n is the value returned by
* dImmersionOutlineGetCurvedEdgesSize().
*/
ODE_API void dImmersionOutlineGetCurvedEdge (dImmersionOutlineID, int index, dCurvedEdge *);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,34 @@
/*************************************************************************
* *
* 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. *
* 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_FLUID_DYNAMICS_H_
#define _ODE_ODE_FLUID_DYNAMICS_H_
/* include *everything* here */
#include <ode/fluid_dynamics/objects_fluid_dynamics.h>
#include <ode/fluid_dynamics/common_fluid_dynamics.h>
#include <ode/fluid_dynamics/immersion.h>
#include <ode/fluid_dynamics/fluid_dynamics.h>
#endif

View File

@ -0,0 +1,54 @@
/*************************************************************************
* *
* 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_FLUID_DYNAMICS_H_
#define _ODE_ODEMATH_FLUID_DYNAMICS_H_
#include <ode/common.h>
#include <ode/odemath.h>
ODE_PURE_INLINE bool dValidVector3(const dVector3 v) {
return !(isnan(v[0]) || isnan(v[1]) || isnan(v[2]));
}
ODE_PURE_INLINE void transformVectors3(dVector3 *array, int size, const dReal *rotation, const dReal *translation) {
for (int i = 0; i < size; ++i) {
dReal *const position = array[i];
dMultiplyHelper0_331(position, rotation, position);
dAddVectors3(position, position, translation);
}
}
template<class T, dReal (T::*integrand)(dReal) const>
dReal simpson(dReal start, dReal end, int numberOfSubdivisions, const T &object) {
const dReal stepSize = (end - start) / numberOfSubdivisions;
dReal a = stepSize + start;
const dReal halfStepSize = 0.5 * stepSize;
dReal m = start + halfStepSize;
dReal result = (object.*integrand)(start) + (object.*integrand)(end) + 4.0 * (object.*integrand)(end - halfStepSize);
for (int i = 1; i < numberOfSubdivisions; a += stepSize, m += stepSize, ++i)
result += 4.0 * (object.*integrand)(m) + 2.0 * (object.*integrand)(a);
return (1.0 / 6.0) * stepSize * result;
}
#endif

141
include/ode/ode/mass.h Normal file
View File

@ -0,0 +1,141 @@
/*************************************************************************
* *
* 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 dMassSetTrimeshTotal (dMass *m, dReal total_mass, 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 */
ODE_API ODE_API_DEPRECATED void dMassSetCappedCylinder(dMass *a, dReal b, int c, dReal d, dReal e);
ODE_API ODE_API_DEPRECATED void dMassSetCappedCylinderTotal(dMass *a, dReal b, int c, dReal d, dReal e);
struct dMass {
dReal mass;
dVector3 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 setSphereTotal (dReal total, dReal radius)
{ dMassSetSphereTotal (this,total,radius); }
void setCapsule (dReal density, int direction, dReal radius, dReal length)
{ dMassSetCapsule (this,density,direction,radius,length); }
void setCapsuleTotal (dReal total, int direction, dReal radius, dReal length)
{ dMassSetCapsule (this,total,direction,radius,length); }
void setCylinder(dReal density, int direction, dReal radius, dReal length)
{ dMassSetCylinder (this,density,direction,radius,length); }
void setCylinderTotal(dReal total, int direction, dReal radius, dReal length)
{ dMassSetCylinderTotal (this,total,direction,radius,length); }
void setBox (dReal density, dReal lx, dReal ly, dReal lz)
{ dMassSetBox (this,density,lx,ly,lz); }
void setBoxTotal (dReal total, dReal lx, dReal ly, dReal lz)
{ dMassSetBoxTotal (this,total,lx,ly,lz); }
void setTrimesh(dReal density, dGeomID g)
{ dMassSetTrimesh (this, density, g); }
void setTrimeshTotal(dReal total, dGeomID g)
{ dMassSetTrimeshTotal (this, total, g); }
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

176
include/ode/ode/matrix.h Normal file
View File

@ -0,0 +1,176 @@
/*************************************************************************
* *
* 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
include/ode/ode/memory.h Normal file
View 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/odeconfig.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

82
include/ode/ode/misc.h Normal file
View File

@ -0,0 +1,82 @@
/*************************************************************************
* *
* 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, const char *fmt = "%10.4f ",
FILE *f=stdout);
#else
ODE_API void dPrintMatrix (const dReal *A, int n, int m, const 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

3327
include/ode/ode/objects.h Normal file

File diff suppressed because it is too large Load Diff

52
include/ode/ode/ode.h Normal file
View File

@ -0,0 +1,52 @@
/*************************************************************************
* *
* 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/odeconfig.h>
#include <ode/compatibility.h>
#include <ode/common.h>
#include <ode/odeinit.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/collision_space.h>
#include <ode/collision.h>
#include <ode/export-dif.h>
#include <ode/version.h>
#ifdef __cplusplus
# include <ode/odecpp.h>
# include <ode/odecpp_collision.h>
#endif
#endif

71
include/ode/ode/ode_MT.h Normal file
View File

@ -0,0 +1,71 @@
#ifndef _ODE_ODE_MT_H_
#define _ODE_ODE_MT_H_
#include <ode/common.h>
#ifdef __cplusplus
extern "C" {
#endif
// an axis aligned bounding box in the hash table
struct dxClusterAABB {
dxClusterAABB *next; // next in the list of all AABBs (list not related to clusters)
int level; // the level this is stored in (cell size = 2^level)
int dbounds[6]; // AABB bounds, discretized to cell size
dGeomID geom; // corresponding geometry object (AABB stored here)
dBodyID body; // body to which this geom is attached
int index; // index of this AABB, starting from 0
float cellsize;
bool tag;
// tracker is used to split nodes in different clusters (declustering).
// While traversing the hashspace cells looking for crossover conditions,
// we mark the cells with a tracker in a fashion similar to the original cluster creation
// algorithm, i.e. neighboring hashspace cells containing geoms are marked with the same id.
// If we detect that the tracker id needs to be incremented within the same cluster, this is a
// sufficient condition for declustering.
int tracker;
struct ClusterNode *cluster;
int clusterID;
// Pointer to cluster AABB which contains this dxClusterAABB
// i.e., clusterNode->next->aabb->node == clusterNode
struct dxClusterNode *node;
};
struct dxClusterNode {
dxClusterAABB *aabb; // axis aligned bounding box that intersects this cell
int x,y,z; // cell position in space, discretized to cell size
int count;
struct ClusterNode *cluster;
bool tagged;
dxClusterNode *next; // next node in hash table collision list, NULL if none
dxClusterNode *nextFreeNode;
bool isStatic;
// For debugging purposes
dWorldID world;
dSpaceID space;
};
struct ClusterNode {
dxClusterNode *node;
dVector3 color;
bool tagged;
int count;
ClusterNode *next;
};
ODE_API int dClusterGetCount(dWorldID _world, dSpaceID _space);
ODE_API float dClusterGetGridStep(dWorldID _world, dSpaceID _space);
ODE_API void dClusterGetCenter(dWorldID _world, dSpaceID _space, float &_x, float &_y, float &_z);
ODE_API dxClusterNode** dClusterGetClusterAABBs(dWorldID _world, dSpaceID _space);
ODE_API int dThreadGetSpacesCount(int threadID);
ODE_API dSpaceID dThreadGetSpaceID(int threadID, int index);
#ifdef __cplusplus
}
#endif
#endif

157
include/ode/ode/odeconfig.h Normal file
View File

@ -0,0 +1,157 @@
/*************************************************************************
* *
* 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_ODECONFIG_H_
#define _ODE_ODECONFIG_H_
/* Pull in the standard headers */
#include <stddef.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <math.h>
#include <string.h>
#include <float.h>
#include <ode/precision.h>
#if defined(ODE_DLL) || defined(ODE_LIB)
#define __ODE__
#endif
/* Define a DLL export symbol for those platforms that need it */
#if defined(_MSC_VER) || (defined(__GNUC__) && defined(_WIN32))
#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
#if defined(_MSC_VER)
# define ODE_API_DEPRECATED __declspec(deprecated)
#elif defined (__GNUC__) && ( (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)) )
# define ODE_API_DEPRECATED __attribute__((__deprecated__))
#else
# define ODE_API_DEPRECATED
#endif
#define ODE_PURE_INLINE static __inline
#define ODE_INLINE __inline
#if defined(__cplusplus)
#define ODE_EXTERN_C extern "C"
#else
#define ODE_EXTERN_C
#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
#if defined(_MSC_VER)
typedef __int64 dint64;
typedef unsigned __int64 duint64;
#else
typedef long long dint64;
typedef unsigned long long duint64;
#endif
typedef int dint32;
typedef unsigned int duint32;
typedef short dint16;
typedef unsigned short duint16;
typedef signed char dint8;
typedef unsigned char duint8;
#else
#if defined(_MSC_VER)
typedef __int64 dint64;
typedef unsigned __int64 duint64;
#else
typedef long long dint64;
typedef unsigned long long duint64;
#endif
typedef int dint32;
typedef unsigned int duint32;
typedef short dint16;
typedef unsigned short duint16;
typedef signed char dint8;
typedef unsigned char duint8;
#endif
/* Define the dInfinity macro */
#ifdef INFINITY
#ifdef dSINGLE
#define dInfinity ((float)INFINITY)
#else
#define dInfinity ((double)INFINITY)
#endif
#elif defined(HUGE_VAL)
#ifdef dSINGLE
#ifdef HUGE_VALF
#define dInfinity HUGE_VALF
#else
#define dInfinity ((float)HUGE_VAL)
#endif
#else
#define dInfinity HUGE_VAL
#endif
#else
#ifdef dSINGLE
#define dInfinity ((float)(1.0/0.0))
#else
#define dInfinity (1.0/0.0)
#endif
#endif
/* Define the dNaN macro */
#ifdef NAN
#define dNaN NAN
#else
#ifdef dSINGLE
#define dNaN ((float)(dInfinity - dInfinity))
#else
#define dNaN (dInfinity - dInfinity)
#endif
#endif
/* Visual C does not define these functions */
#if defined(_MSC_VER)
#define _ode_copysignf(x, y) ((float)_copysign(x, y))
#define _ode_copysign(x, y) _copysign(x, y)
#define _ode_nextafterf(x, y) _nextafterf(x, y)
#define _ode_nextafter(x, y) _nextafter(x, y)
#if !defined(_WIN64) && defined(dSINGLE)
#define _ODE__NEXTAFTERF_REQUIRED
ODE_EXTERN_C float _nextafterf(float x, float y);
#endif
#else
#define _ode_copysignf(x, y) copysignf(x, y)
#define _ode_copysign(x, y) copysign(x, y)
#define _ode_nextafterf(x, y) nextafterf(x, y)
#define _ode_nextafter(x, y) nextafter(x, y)
#endif
#endif

1325
include/ode/ode/odecpp.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,438 @@
/*************************************************************************
* *
* 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>
//namespace ode {
class dGeom {
// intentionally undefined, don't use these
dGeom (dGeom &);
void operator= (dGeom &);
protected:
dGeomID _id;
dGeom()
{ _id = 0; }
public:
~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 getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomGetRelPointPos (_id, px, py, pz, result); }
void getRelPointPos (const dVector3 p, dVector3 result) const
{ getRelPointPos (p[0], p[1], p[2], result); }
void getPosRelPoint (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomGetPosRelPoint (_id, px, py, pz, result); }
void getPosRelPoint (const dVector3 p, dVector3 result) const
{ getPosRelPoint (p[0], p[1], p[2], result); }
void vectorToWorld (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomVectorToWorld (_id, px, py, pz, result); }
void vectorToWorld (const dVector3 p, dVector3 result) const
{ vectorToWorld (p[0], p[1], p[2], result); }
void vectorFromWorld (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomVectorFromWorld (_id, px, py, pz, result); }
void vectorFromWorld (const dVector3 p, dVector3 result) const
{ vectorFromWorld (p[0], p[1], p[2], result); }
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) const
{ dSpaceSetCleanup (id(), mode); }
int getCleanup() const
{ return dSpaceGetCleanup (id()); }
void add (dGeomID x) const
{ dSpaceAdd (id(), x); }
void remove (dGeomID x) const
{ dSpaceRemove (id(), x); }
int query (dGeomID x) const
{ return dSpaceQuery (id(),x); }
int getNumGeoms() const
{ return dSpaceGetNumGeoms (id()); }
dGeomID getGeom (int i)
{ return dSpaceGetGeom (id(),i); }
void collide (void *data, dNearCallback *callback) const
{ dSpaceCollide (id(),data,callback); }
};
class dSimpleSpace : public dSpace {
// intentionally undefined, don't use these
dSimpleSpace (dSimpleSpace &);
void operator= (dSimpleSpace &);
public:
dSimpleSpace ()
{ _id = (dGeomID) dSimpleSpaceCreate (0); }
explicit dSimpleSpace (dSpace &space)
{ _id = (dGeomID) dSimpleSpaceCreate (space.id()); }
explicit dSimpleSpace (dSpaceID space)
{ _id = (dGeomID) dSimpleSpaceCreate (space); }
};
class dHashSpace : public dSpace {
// intentionally undefined, don't use these
dHashSpace (dHashSpace &);
void operator= (dHashSpace &);
public:
dHashSpace ()
{ _id = (dGeomID) dHashSpaceCreate (0); }
explicit dHashSpace (dSpace &space)
{ _id = (dGeomID) dHashSpaceCreate (space.id()); }
explicit dHashSpace (dSpaceID space)
{ _id = (dGeomID) dHashSpaceCreate (space); }
void setLevels (int minlevel, int maxlevel) const
{ dHashSpaceSetLevels (id(),minlevel,maxlevel); }
};
class dQuadTreeSpace : public dSpace {
// intentionally undefined, don't use these
dQuadTreeSpace (dQuadTreeSpace &);
void operator= (dQuadTreeSpace &);
public:
dQuadTreeSpace (const dVector3 center, const dVector3 extents, int depth)
{ _id = (dGeomID) dQuadTreeSpaceCreate (0,center,extents,depth); }
dQuadTreeSpace (dSpace &space, const dVector3 center, const dVector3 extents, int depth)
{ _id = (dGeomID) dQuadTreeSpaceCreate (space.id(),center,extents,depth); }
dQuadTreeSpace (dSpaceID space, const dVector3 center, const 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 () { }
explicit dSphere (dReal radius)
{ _id = dCreateSphere (0, radius); }
dSphere (dSpace &space, dReal radius)
{ _id = dCreateSphere (space.id(), radius); }
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 (dReal lx, dReal ly, dReal lz)
{ _id = dCreateBox (0,lx,ly,lz); }
dBox (dSpace &space, dReal lx, dReal ly, dReal lz)
{ _id = dCreateBox (space,lx,ly,lz); }
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 (dReal a, dReal b, dReal c, dReal d)
{ _id = dCreatePlane (0,a,b,c,d); }
dPlane (dSpace &space, dReal a, dReal b, dReal c, dReal d)
{ _id = dCreatePlane (space.id(),a,b,c,d); }
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 (dReal radius, dReal length)
{ _id = dCreateCapsule (0,radius,length); }
dCapsule (dSpace &space, dReal radius, dReal length)
{ _id = dCreateCapsule (space.id(),radius,length); }
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 dCylinder : public dGeom {
// intentionally undefined, don't use these
dCylinder (dCylinder &);
void operator= (dCylinder &);
public:
dCylinder() { }
dCylinder (dReal radius, dReal length)
{ _id = dCreateCylinder (0,radius,length); }
dCylinder (dSpace &space, dReal radius, dReal length)
{ _id = dCreateCylinder (space.id(),radius,length); }
dCylinder (dSpaceID space, dReal radius, dReal length)
{ _id = dCreateCylinder (space,radius,length); }
void create (dSpaceID space, dReal radius, dReal length) {
if (_id) dGeomDestroy (_id);
_id = dCreateCylinder (space,radius,length);
}
void setParams (dReal radius, dReal length)
{ dGeomCylinderSetParams (_id, radius, length); }
void getParams (dReal *radius, dReal *length) const
{ dGeomCylinderGetParams (_id,radius,length); }
};
class dRay : public dGeom {
// intentionally undefined, don't use these
dRay (dRay &);
void operator= (dRay &);
public:
dRay() { }
explicit dRay (dReal length)
{ _id = dCreateRay (0,length); }
dRay (dSpace &space, dReal length)
{ _id = dCreateRay (space.id(),length); }
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); }
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
ODE_API_DEPRECATED
void setParams (int firstContact, int backfaceCull)
{ dGeomRaySetParams (_id, firstContact, backfaceCull); }
ODE_API_DEPRECATED
void getParams (int *firstContact, int *backfaceCull)
{ dGeomRayGetParams (_id, firstContact, backfaceCull); }
#pragma GCC diagnostic pop
void setBackfaceCull (int backfaceCull)
{ dGeomRaySetBackfaceCull (_id, backfaceCull); }
int getBackfaceCull()
{ return dGeomRayGetBackfaceCull (_id); }
void setFirstContact (int firstContact)
{ dGeomRaySetFirstContact (_id, firstContact); }
int getFirstContact()
{ return dGeomRayGetFirstContact (_id); }
void setClosestHit (int closestHit)
{ dGeomRaySetClosestHit (_id, closestHit); }
int getClosestHit()
{ return dGeomRayGetClosestHit (_id); }
};
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
class dGeomTransform : public dGeom {
// intentionally undefined, don't use these
dGeomTransform (dGeomTransform &);
void operator= (dGeomTransform &);
public:
dGeomTransform() { }
explicit dGeomTransform (dSpace &space)
{ _id = dCreateGeomTransform (space.id()); }
explicit 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); }
};
#pragma GCC diagnostic pop
//}
#endif
#endif

228
include/ode/ode/odeinit.h Normal file
View File

@ -0,0 +1,228 @@
/*************************************************************************
* *
* 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. *
* *
*************************************************************************/
/* Library initialization/finalization functions. */
#ifndef _ODE_ODEINIT_H_
#define _ODE_ODEINIT_H_
#include <ode/common.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ************************************************************************ */
/* Library initialization */
/**
* @defgroup init Library Initialization
*
* Library initialization functions prepare ODE internal data structures for use
* and release allocated resources after ODE is not needed any more.
*/
/**
* @brief Library initialization flags.
*
* These flags define ODE library initialization options.
*
* @c dInitFlagManualThreadCleanup indicates that resources allocated in TLS for threads
* using ODE are to be cleared by library client with explicit call to @c dCleanupODEAllDataForThread.
* If this flag is not specified the automatic resource tracking algorithm is used.
*
* With automatic resource tracking, On Windows, memory allocated for a thread may
* remain not freed for some time after the thread exits. The resources may be
* released when one of other threads calls @c dAllocateODEDataForThread. Ultimately,
* the resources are released when library is closed with @c dCloseODE. On other
* operating systems resources are always released by the thread itself on its exit
* or on library closure with @c dCloseODE.
*
* With manual thread data cleanup mode every collision space object must be
* explicitly switched to manual cleanup mode with @c dSpaceSetManualCleanup
* after creation. See description of the function for more details.
*
* If @c dInitFlagManualThreadCleanup was not specified during initialization,
* calls to @c dCleanupODEAllDataForThread are not allowed.
*
* @see dInitODE2
* @see dAllocateODEDataForThread
* @see dSpaceSetManualCleanup
* @see dCloseODE
* @ingroup init
*/
enum dInitODEFlags {
dInitFlagManualThreadCleanup = 0x00000001 /*@< Thread local data is to be cleared explicitly on @c dCleanupODEAllDataForThread function call*/
};
/**
* @brief Initializes ODE library.
*
* @c dInitODE is obsolete. @c dInitODE2 is to be used for library initialization.
*
* A call to @c dInitODE is equal to the following initialization sequence
* @code
* dInitODE2(0);
* dAllocateODEDataForThread(dAllocateMaskAll);
* @endcode
*
* @see dInitODE2
* @see dAllocateODEDataForThread
* @ingroup init
*/
ODE_API void dInitODE(void);
/**
* @brief Initializes ODE library.
* @param uiInitFlags Initialization options bitmask
* @return A nonzero if initialization succeeded and zero otherwise.
*
* This function must be called to initialize ODE library before first use. If
* initialization succeeds the function may not be called again until library is
* closed with a call to @c dCloseODE.
*
* The @a uiInitFlags parameter specifies initialization options to be used. These
* can be combination of zero or more @c dInitODEFlags flags.
*
* @note
* If @c dInitFlagManualThreadCleanup flag is used for initialization,
* @c dSpaceSetManualCleanup must be called to set manual cleanup mode for every
* space object right after creation. Failure to do so may lead to resource leaks.
*
* @see dInitODEFlags
* @see dCloseODE
* @see dSpaceSetManualCleanup
* @ingroup init
*/
ODE_API int dInitODE2(unsigned int uiInitFlags/*=0*/);
/**
* @brief ODE data allocation flags.
*
* These flags are used to indicate which data is to be pre-allocated in call to
* @c dAllocateODEDataForThread.
*
* @c dAllocateFlagBasicData tells to allocate the basic data set required for
* normal library operation. This flag is equal to zero and is always implicitly
* included.
*
* @c dAllocateFlagCollisionData tells that collision detection data is to be allocated.
* Collision detection functions may not be called if the data has not be allocated
* in advance. If collision detection is not going to be used, it is not necessary
* to specify this flag.
*
* @c dAllocateMaskAll is a mask that can be used for for allocating all possible
* data in cases when it is not known what exactly features of ODE will be used.
* The mask may not be used in combination with other flags. It is guaranteed to
* include all the current and future legal allocation flags. However, mature
* applications should use explicit flags they need rather than allocating everything.
*
* @see dAllocateODEDataForThread
* @ingroup init
*/
enum dAllocateODEDataFlags {
dAllocateFlagBasicData = 0, /*@< Allocate basic data required for library to operate*/
dAllocateFlagCollisionData = 0x00000001, /*@< Allocate data for collision detection*/
dAllocateMaskAll = ~0 /*@< Allocate all the possible data that is currently defined or will be defined in the future.*/
};
/**
* @brief Allocate thread local data to allow the thread calling ODE.
* @param uiAllocateFlags Allocation options bitmask.
* @return A nonzero if allocation succeeded and zero otherwise.
*
* The function is required to be called for every thread that is going to use
* ODE. This function allocates the data that is required for accessing ODE from
* current thread along with optional data required for particular ODE subsystems.
*
* @a uiAllocateFlags parameter can contain zero or more flags from @c dAllocateODEDataFlags
* enumerated type. Multiple calls with different allocation flags are allowed.
* The flags that are already allocated are ignored in subsequent calls. If zero
* is passed as the parameter, it means to only allocate the set of most important
* data the library can not operate without.
*
* If the function returns failure status it means that none of the requested
* data has been allocated. The client may retry allocation attempt with the same
* flags when more system resources are available.
*
* @see dAllocateODEDataFlags
* @see dCleanupODEAllDataForThread
* @ingroup init
*/
ODE_API int dAllocateODEDataForThread(unsigned int uiAllocateFlags);
/**
* @brief Free thread local data that was allocated for current thread.
*
* If library was initialized with @c dInitFlagManualThreadCleanup flag the function
* is required to be called on exit of every thread that was calling @c dAllocateODEDataForThread.
* Failure to call @c dCleanupODEAllDataForThread may result in some resources remaining
* not freed until program exit. The function may also be called when ODE is still
* being used to release resources allocated for all the current subsystems and
* possibly proceed with data pre-allocation for other subsystems.
*
* The function can safely be called several times in a row. The function can be
* called without prior invocation of @c dAllocateODEDataForThread. The function
* may not be called before ODE is initialized with @c dInitODE2 or after library
* has been closed with @c dCloseODE. A call to @c dCloseODE implicitly releases
* all the thread local resources that might be allocated for all the threads that
* were using ODE.
*
* If library was initialized without @c dInitFlagManualThreadCleanup flag
* @c dCleanupODEAllDataForThread must not be called.
*
* @see dAllocateODEDataForThread
* @see dInitODE2
* @see dCloseODE
* @ingroup init
*/
ODE_API void dCleanupODEAllDataForThread();
/**
* @brief Close ODE after it is not needed any more.
*
* The function is required to be called when program does not need ODE features any more.
* The call to @c dCloseODE releases all the resources allocated for library
* including all the thread local data that might be allocated for all the threads
* that were using ODE.
*
* @c dCloseODE is a paired function for @c dInitODE2 and must only be called
* after successful library initialization.
*
* @note Important!
* Make sure that all the threads that were using ODE have already terminated
* before calling @c dCloseODE. In particular it is not allowed to call
* @c dCleanupODEAllDataForThread after @c dCloseODE.
*
* @see dInitODE2
* @see dCleanupODEAllDataForThread
* @ingroup init
*/
ODE_API void dCloseODE(void);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _ODE_ODEINIT_H_ */

504
include/ode/ode/odemath.h Normal file
View File

@ -0,0 +1,504 @@
/*************************************************************************
* *
* 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>
/*
* 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[1]) || 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]) ))
/* Some vector math */
ODE_PURE_INLINE void dAddVectors3(dReal *res, const dReal *a, const dReal *b)
{
const dReal res_0 = a[0] + b[0];
const dReal res_1 = a[1] + b[1];
const dReal res_2 = a[2] + b[2];
/* Only assign after all the calculations are over to avoid incurring memory aliasing*/
res[0] = res_0; res[1] = res_1; res[2] = res_2;
}
ODE_PURE_INLINE void dSubtractVectors3(dReal *res, const dReal *a, const dReal *b)
{
const dReal res_0 = a[0] - b[0];
const dReal res_1 = a[1] - b[1];
const dReal res_2 = a[2] - b[2];
/* Only assign after all the calculations are over to avoid incurring memory aliasing*/
res[0] = res_0; res[1] = res_1; res[2] = res_2;
}
ODE_PURE_INLINE void dAddScaledVectors3(dReal *res, const dReal *a, const dReal *b, dReal a_scale, dReal b_scale)
{
const dReal res_0 = a_scale * a[0] + b_scale * b[0];
const dReal res_1 = a_scale * a[1] + b_scale * b[1];
const dReal res_2 = a_scale * a[2] + b_scale * b[2];
/* Only assign after all the calculations are over to avoid incurring memory aliasing*/
res[0] = res_0; res[1] = res_1; res[2] = res_2;
}
ODE_PURE_INLINE void dScaleVector3(dReal *res, dReal nScale)
{
res[0] *= nScale ;
res[1] *= nScale ;
res[2] *= nScale ;
}
ODE_PURE_INLINE void dNegateVector3(dReal *res)
{
res[0] = -res[0];
res[1] = -res[1];
res[2] = -res[2];
}
ODE_PURE_INLINE void dCopyVector3(dReal *res, const dReal *a)
{
const dReal res_0 = a[0];
const dReal res_1 = a[1];
const dReal res_2 = a[2];
/* Only assign after all the calculations are over to avoid incurring memory aliasing*/
res[0] = res_0; res[1] = res_1; res[2] = res_2;
}
ODE_PURE_INLINE void dCopyScaledVector3(dReal *res, const dReal *a, dReal nScale)
{
const dReal res_0 = a[0] * nScale;
const dReal res_1 = a[1] * nScale;
const dReal res_2 = a[2] * nScale;
/* Only assign after all the calculations are over to avoid incurring memory aliasing*/
res[0] = res_0; res[1] = res_1; res[2] = res_2;
}
ODE_PURE_INLINE void dCopyNegatedVector3(dReal *res, const dReal *a)
{
const dReal res_0 = -a[0];
const dReal res_1 = -a[1];
const dReal res_2 = -a[2];
/* Only assign after all the calculations are over to avoid incurring memory aliasing*/
res[0] = res_0; res[1] = res_1; res[2] = res_2;
}
ODE_PURE_INLINE void dCopyVector4(dReal *res, const dReal *a)
{
const dReal res_0 = a[0];
const dReal res_1 = a[1];
const dReal res_2 = a[2];
const dReal res_3 = a[3];
/* Only assign after all the calculations are over to avoid incurring memory aliasing*/
res[0] = res_0; res[1] = res_1; res[2] = res_2; res[3] = res_3;
}
ODE_PURE_INLINE void dCopyMatrix4x4(dReal *res, const dReal *a)
{
dCopyVector4(res + 0, a + 0);
dCopyVector4(res + 4, a + 4);
dCopyVector4(res + 8, a + 8);
}
ODE_PURE_INLINE void dCopyMatrix4x3(dReal *res, const dReal *a)
{
dCopyVector3(res + 0, a + 0);
dCopyVector3(res + 4, a + 4);
dCopyVector3(res + 8, a + 8);
}
ODE_PURE_INLINE void dGetMatrixColumn3(dReal *res, const dReal *a, unsigned n)
{
const dReal res_0 = a[n + 0];
const dReal res_1 = a[n + 4];
const dReal res_2 = a[n + 8];
/* Only assign after all the calculations are over to avoid incurring memory aliasing*/
res[0] = res_0; res[1] = res_1; res[2] = res_2;
}
ODE_PURE_INLINE dReal dCalcVectorLength3(const dReal *a)
{
return dSqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]);
}
ODE_PURE_INLINE dReal dCalcVectorLengthSquare3(const dReal *a)
{
return (a[0] * a[0] + a[1] * a[1] + a[2] * a[2]);
}
ODE_PURE_INLINE dReal dCalcPointDepth3(const dReal *test_p, const dReal *plane_p, const dReal *plane_n)
{
return (plane_p[0] - test_p[0]) * plane_n[0] + (plane_p[1] - test_p[1]) * plane_n[1] + (plane_p[2] - test_p[2]) * plane_n[2];
}
ODE_PURE_INLINE void make_sure_plane_normal_has_unit_length(dReal *plane_p)
{
dReal l = plane_p[0]*plane_p[0] + plane_p[1]*plane_p[1] + plane_p[2]*plane_p[2];
if (l > 0) {
l = dRecipSqrt(l);
plane_p[0] *= l;
plane_p[1] *= l;
plane_p[2] *= l;
plane_p[3] *= l;
}
else {
plane_p[0] = 1;
plane_p[1] = 0;
plane_p[2] = 0;
plane_p[3] = 0;
}
}
/*
* 3-way dot product. _dCalcVectorDot3 means that elements of `a' and `b' are spaced
* step_a and step_b indexes apart respectively. dCalcVectorDot3() means dDot311.
*/
ODE_PURE_INLINE dReal _dCalcVectorDot3(const dReal *a, const dReal *b, unsigned step_a, unsigned step_b)
{
return a[0] * b[0] + a[step_a] * b[step_b] + a[2 * step_a] * b[2 * step_b];
}
ODE_PURE_INLINE dReal dCalcVectorDot3 (const dReal *a, const dReal *b) { return _dCalcVectorDot3(a,b,1,1); }
ODE_PURE_INLINE dReal dCalcVectorDot3_13 (const dReal *a, const dReal *b) { return _dCalcVectorDot3(a,b,1,3); }
ODE_PURE_INLINE dReal dCalcVectorDot3_31 (const dReal *a, const dReal *b) { return _dCalcVectorDot3(a,b,3,1); }
ODE_PURE_INLINE dReal dCalcVectorDot3_33 (const dReal *a, const dReal *b) { return _dCalcVectorDot3(a,b,3,3); }
ODE_PURE_INLINE dReal dCalcVectorDot3_14 (const dReal *a, const dReal *b) { return _dCalcVectorDot3(a,b,1,4); }
ODE_PURE_INLINE dReal dCalcVectorDot3_41 (const dReal *a, const dReal *b) { return _dCalcVectorDot3(a,b,4,1); }
ODE_PURE_INLINE dReal dCalcVectorDot3_44 (const dReal *a, const dReal *b) { return _dCalcVectorDot3(a,b,4,4); }
/*
* cross product, set res = a x b. _dCalcVectorCross3 means that elements of `res', `a'
* and `b' are spaced step_res, step_a and step_b indexes apart respectively.
* dCalcVectorCross3() means dCross3111.
*/
ODE_PURE_INLINE void _dCalcVectorCross3(dReal *res, const dReal *a, const dReal *b, unsigned step_res, unsigned step_a, unsigned step_b)
{
const dReal res_0 = a[ step_a]*b[2*step_b] - a[2*step_a]*b[ step_b];
const dReal res_1 = a[2*step_a]*b[ 0] - a[ 0]*b[2*step_b];
const dReal res_2 = a[ 0]*b[ step_b] - a[ step_a]*b[ 0];
/* Only assign after all the calculations are over to avoid incurring memory aliasing*/
res[ 0] = res_0;
res[ step_res] = res_1;
res[2*step_res] = res_2;
}
ODE_PURE_INLINE void dCalcVectorCross3 (dReal *res, const dReal *a, const dReal *b) { _dCalcVectorCross3(res, a, b, 1, 1, 1); }
ODE_PURE_INLINE void dCalcVectorCross3_114(dReal *res, const dReal *a, const dReal *b) { _dCalcVectorCross3(res, a, b, 1, 1, 4); }
ODE_PURE_INLINE void dCalcVectorCross3_141(dReal *res, const dReal *a, const dReal *b) { _dCalcVectorCross3(res, a, b, 1, 4, 1); }
ODE_PURE_INLINE void dCalcVectorCross3_144(dReal *res, const dReal *a, const dReal *b) { _dCalcVectorCross3(res, a, b, 1, 4, 4); }
ODE_PURE_INLINE void dCalcVectorCross3_411(dReal *res, const dReal *a, const dReal *b) { _dCalcVectorCross3(res, a, b, 4, 1, 1); }
ODE_PURE_INLINE void dCalcVectorCross3_414(dReal *res, const dReal *a, const dReal *b) { _dCalcVectorCross3(res, a, b, 4, 1, 4); }
ODE_PURE_INLINE void dCalcVectorCross3_441(dReal *res, const dReal *a, const dReal *b) { _dCalcVectorCross3(res, a, b, 4, 4, 1); }
ODE_PURE_INLINE void dCalcVectorCross3_444(dReal *res, const dReal *a, const dReal *b) { _dCalcVectorCross3(res, a, b, 4, 4, 4); }
ODE_PURE_INLINE void dAddVectorCross3(dReal *res, const dReal *a, const dReal *b)
{
dReal tmp[3];
dCalcVectorCross3(tmp, a, b);
dAddVectors3(res, res, tmp);
}
ODE_PURE_INLINE void dSubtractVectorCross3(dReal *res, const dReal *a, const dReal *b)
{
dReal tmp[3];
dCalcVectorCross3(tmp, a, b);
dSubtractVectors3(res, res, tmp);
}
/*
* 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.
*/
ODE_PURE_INLINE void dSetCrossMatrixPlus(dReal *res, const dReal *a, unsigned skip)
{
const dReal a_0 = a[0], a_1 = a[1], a_2 = a[2];
res[1] = -a_2;
res[2] = +a_1;
res[skip+0] = +a_2;
res[skip+2] = -a_0;
res[2*skip+0] = -a_1;
res[2*skip+1] = +a_0;
}
ODE_PURE_INLINE void dSetCrossMatrixMinus(dReal *res, const dReal *a, unsigned skip)
{
const dReal a_0 = a[0], a_1 = a[1], a_2 = a[2];
res[1] = +a_2;
res[2] = -a_1;
res[skip+0] = -a_2;
res[skip+2] = +a_0;
res[2*skip+0] = +a_1;
res[2*skip+1] = -a_0;
}
/*
* compute the distance between two 3D-vectors
*/
ODE_PURE_INLINE dReal dCalcPointsDistance3(const dReal *a, const dReal *b)
{
dReal res;
dReal tmp[3];
dSubtractVectors3(tmp, a, b);
res = dCalcVectorLength3(tmp);
return res;
}
/*
* special case matrix multiplication, with operator selection
*/
ODE_PURE_INLINE void dMultiplyHelper0_331(dReal *res, const dReal *a, const dReal *b)
{
const dReal res_0 = dCalcVectorDot3(a, b);
const dReal res_1 = dCalcVectorDot3(a + 4, b);
const dReal res_2 = dCalcVectorDot3(a + 8, b);
/* Only assign after all the calculations are over to avoid incurring memory aliasing*/
res[0] = res_0; res[1] = res_1; res[2] = res_2;
}
ODE_PURE_INLINE void dMultiplyHelper1_331(dReal *res, const dReal *a, const dReal *b)
{
const dReal res_0 = dCalcVectorDot3_41(a, b);
const dReal res_1 = dCalcVectorDot3_41(a + 1, b);
const dReal res_2 = dCalcVectorDot3_41(a + 2, b);
/* Only assign after all the calculations are over to avoid incurring memory aliasing*/
res[0] = res_0; res[1] = res_1; res[2] = res_2;
}
ODE_PURE_INLINE void dMultiplyHelper0_133(dReal *res, const dReal *a, const dReal *b)
{
dMultiplyHelper1_331(res, b, a);
}
ODE_PURE_INLINE void dMultiplyHelper1_133(dReal *res, const dReal *a, const dReal *b)
{
const dReal res_0 = dCalcVectorDot3_44(a, b);
const dReal res_1 = dCalcVectorDot3_44(a + 1, b);
const dReal res_2 = dCalcVectorDot3_44(a + 2, b);
/* Only assign after all the calculations are over to avoid incurring memory aliasing*/
res[0] = res_0; res[1] = res_1; res[2] = res_2;
}
/*
Note: NEVER call any of these functions/macros with the same variable for A and C,
it is not equivalent to A*=B.
*/
ODE_PURE_INLINE void dMultiply0_331(dReal *res, const dReal *a, const dReal *b)
{
dMultiplyHelper0_331(res, a, b);
}
ODE_PURE_INLINE void dMultiply1_331(dReal *res, const dReal *a, const dReal *b)
{
dMultiplyHelper1_331(res, a, b);
}
ODE_PURE_INLINE void dMultiply0_133(dReal *res, const dReal *a, const dReal *b)
{
dMultiplyHelper0_133(res, a, b);
}
ODE_PURE_INLINE void dMultiply0_333(dReal *res, const dReal *a, const dReal *b)
{
dMultiplyHelper0_133(res + 0, a + 0, b);
dMultiplyHelper0_133(res + 4, a + 4, b);
dMultiplyHelper0_133(res + 8, a + 8, b);
}
ODE_PURE_INLINE void dMultiply1_333(dReal *res, const dReal *a, const dReal *b)
{
dMultiplyHelper1_133(res + 0, b, a + 0);
dMultiplyHelper1_133(res + 4, b, a + 1);
dMultiplyHelper1_133(res + 8, b, a + 2);
}
ODE_PURE_INLINE void dMultiply2_333(dReal *res, const dReal *a, const dReal *b)
{
dMultiplyHelper0_331(res + 0, b, a + 0);
dMultiplyHelper0_331(res + 4, b, a + 4);
dMultiplyHelper0_331(res + 8, b, a + 8);
}
ODE_PURE_INLINE void dMultiplyAdd0_331(dReal *res, const dReal *a, const dReal *b)
{
dReal tmp[3];
dMultiplyHelper0_331(tmp, a, b);
dAddVectors3(res, res, tmp);
}
ODE_PURE_INLINE void dMultiplyAdd1_331(dReal *res, const dReal *a, const dReal *b)
{
dReal tmp[3];
dMultiplyHelper1_331(tmp, a, b);
dAddVectors3(res, res, tmp);
}
ODE_PURE_INLINE void dMultiplyAdd0_133(dReal *res, const dReal *a, const dReal *b)
{
dReal tmp[3];
dMultiplyHelper0_133(tmp, a, b);
dAddVectors3(res, res, tmp);
}
ODE_PURE_INLINE void dMultiplyAdd0_333(dReal *res, const dReal *a, const dReal *b)
{
dReal tmp[3];
dMultiplyHelper0_133(tmp, a + 0, b);
dAddVectors3(res+ 0, res + 0, tmp);
dMultiplyHelper0_133(tmp, a + 4, b);
dAddVectors3(res + 4, res + 4, tmp);
dMultiplyHelper0_133(tmp, a + 8, b);
dAddVectors3(res + 8, res + 8, tmp);
}
ODE_PURE_INLINE void dMultiplyAdd1_333(dReal *res, const dReal *a, const dReal *b)
{
dReal tmp[3];
dMultiplyHelper1_133(tmp, b, a + 0);
dAddVectors3(res + 0, res + 0, tmp);
dMultiplyHelper1_133(tmp, b, a + 1);
dAddVectors3(res + 4, res + 4, tmp);
dMultiplyHelper1_133(tmp, b, a + 2);
dAddVectors3(res + 8, res + 8, tmp);
}
ODE_PURE_INLINE void dMultiplyAdd2_333(dReal *res, const dReal *a, const dReal *b)
{
dReal tmp[3];
dMultiplyHelper0_331(tmp, b, a + 0);
dAddVectors3(res + 0, res + 0, tmp);
dMultiplyHelper0_331(tmp, b, a + 4);
dAddVectors3(res + 4, res + 4, tmp);
dMultiplyHelper0_331(tmp, b, a + 8);
dAddVectors3(res + 8, res + 8, tmp);
}
ODE_PURE_INLINE dReal dCalcMatrix3Det( const dReal* mat )
{
dReal det;
det = mat[0] * ( mat[5]*mat[10] - mat[9]*mat[6] )
- mat[1] * ( mat[4]*mat[10] - mat[8]*mat[6] )
+ mat[2] * ( mat[4]*mat[9] - mat[8]*mat[5] );
return( det );
}
/**
Closed form matrix inversion, copied from
collision_util.h for use in the stepper.
Returns the determinant.
returns 0 and does nothing
if the matrix is singular.
*/
ODE_PURE_INLINE dReal dInvertMatrix3(dReal *dst, const dReal *ma)
{
dReal det;
dReal detRecip;
det = dCalcMatrix3Det( ma );
/* Setting an arbitrary non-zero threshold
for the determinant doesn't do anyone
any favors. The condition number is the
important thing. If all the eigen-values
of the matrix are small, so is the
determinant, but it can still be well
conditioned.
A single extremely large eigen-value could
push the determinant over threshold, but
produce a very unstable result if the other
eigen-values are small. So we just say that
the determinant must be non-zero and trust the
caller to provide well-conditioned matrices.
*/
if ( det == 0 )
{
return 0;
}
detRecip = dRecip(det);
dst[0] = ( ma[5]*ma[10] - ma[6]*ma[9] ) * detRecip;
dst[1] = ( ma[9]*ma[2] - ma[1]*ma[10] ) * detRecip;
dst[2] = ( ma[1]*ma[6] - ma[5]*ma[2] ) * detRecip;
dst[4] = ( ma[6]*ma[8] - ma[4]*ma[10] ) * detRecip;
dst[5] = ( ma[0]*ma[10] - ma[8]*ma[2] ) * detRecip;
dst[6] = ( ma[4]*ma[2] - ma[0]*ma[6] ) * detRecip;
dst[8] = ( ma[4]*ma[9] - ma[8]*ma[5] ) * detRecip;
dst[9] = ( ma[8]*ma[1] - ma[0]*ma[9] ) * detRecip;
dst[10] = ( ma[0]*ma[5] - ma[1]*ma[4] ) * detRecip;
return det;
}
/* Include legacy macros here */
#include <ode/odemath_legacy.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* normalize 3x1 and 4x1 vectors (i.e. scale them to unit length)
*/
/* For DLL export*/
ODE_API int dSafeNormalize3 (dVector3 a);
ODE_API int dSafeNormalize4 (dVector4 a);
ODE_API void dNormalize3 (dVector3 a); /* Potentially asserts on zero vec*/
ODE_API void dNormalize4 (dVector4 a); /* Potentially asserts on zero vec*/
/*
* 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);
/* Makes sure the matrix is a proper rotation */
ODE_API void dOrthogonalizeR(dMatrix3 m);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,152 @@
/*************************************************************************
* *
* 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_LEGACY_H_
#define _ODE_ODEMATH_LEGACY_H_
/*
* These macros are not used any more inside of ODE
* They are kept for backward compatibility with external code that
* might still be using them.
*/
/*
* General purpose vector operations with other vectors or constants.
*/
#define dOP(a,op,b,c) do { \
(a)[0] = ((b)[0]) op ((c)[0]); \
(a)[1] = ((b)[1]) op ((c)[1]); \
(a)[2] = ((b)[2]) op ((c)[2]); \
} while (0)
#define dOPC(a,op,b,c) do { \
(a)[0] = ((b)[0]) op (c); \
(a)[1] = ((b)[1]) op (c); \
(a)[2] = ((b)[2]) op (c); \
} while (0)
#define dOPE(a,op,b) do {\
(a)[0] op ((b)[0]); \
(a)[1] op ((b)[1]); \
(a)[2] op ((b)[2]); \
} while (0)
#define dOPEC(a,op,c) do { \
(a)[0] op (c); \
(a)[1] op (c); \
(a)[2] op (c); \
} while (0)
/* Define an equation with operators
* For example this function can be used to replace
* <PRE>
* for (int i=0; i<3; ++i)
* a[i] += b[i] + c[i];
* </PRE>
*/
#define dOPE2(a,op1,b,op2,c) do { \
(a)[0] op1 ((b)[0]) op2 ((c)[0]); \
(a)[1] op1 ((b)[1]) op2 ((c)[1]); \
(a)[2] op1 ((b)[2]) op2 ((c)[2]); \
} while (0)
#define dLENGTHSQUARED(a) dCalcVectorLengthSquare3(a)
#define dLENGTH(a) dCalcVectorLength3(a)
#define dDISTANCE(a, b) dCalcPointsDistance3(a, b)
#define dDOT(a, b) dCalcVectorDot3(a, b)
#define dDOT13(a, b) dCalcVectorDot3_13(a, b)
#define dDOT31(a, b) dCalcVectorDot3_31(a, b)
#define dDOT33(a, b) dCalcVectorDot3_33(a, b)
#define dDOT14(a, b) dCalcVectorDot3_14(a, b)
#define dDOT41(a, b) dCalcVectorDot3_41(a, b)
#define dDOT44(a, b) dCalcVectorDot3_44(a, b)
/*
* 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)
/*
Note: NEVER call any of these functions/macros with the same variable for A and C,
it is not equivalent to A*=B.
*/
#define dMULTIPLY0_331(A, B, C) dMultiply0_331(A, B, C)
#define dMULTIPLY1_331(A, B, C) dMultiply1_331(A, B, C)
#define dMULTIPLY0_133(A, B, C) dMultiply0_133(A, B, C)
#define dMULTIPLY0_333(A, B, C) dMultiply0_333(A, B, C)
#define dMULTIPLY1_333(A, B, C) dMultiply1_333(A, B, C)
#define dMULTIPLY2_333(A, B, C) dMultiply2_333(A, B, C)
#define dMULTIPLYADD0_331(A, B, C) dMultiplyAdd0_331(A, B, C)
#define dMULTIPLYADD1_331(A, B, C) dMultiplyAdd1_331(A, B, C)
#define dMULTIPLYADD0_133(A, B, C) dMultiplyAdd0_133(A, B, C)
#define dMULTIPLYADD0_333(A, B, C) dMultiplyAdd0_333(A, B, C)
#define dMULTIPLYADD1_333(A, B, C) dMultiplyAdd1_333(A, B, C)
#define dMULTIPLYADD2_333(A, B, C) dMultiplyAdd2_333(A, B, C)
/*
* These macros are not used any more inside of ODE
* They are kept for backward compatibility with external code that
* might still be using them.
*/
#endif /* #ifndef _ODE_ODEMATH_LEGACY_H_ */

View File

@ -0,0 +1,10 @@
#ifndef _ODE_PRECISION_H_
#define _ODE_PRECISION_H_
/* Define dSINGLE for single precision, dDOUBLE for double precision,
* but never both!
*/
#define dDOUBLE
#endif

View File

@ -0,0 +1,16 @@
#ifndef _ODE_PRECISION_H_
#define _ODE_PRECISION_H_
/* Define dSINGLE for single precision, dDOUBLE for double precision,
* but never both!
*/
#if defined(dIDESINGLE)
#define dSINGLE
#elif defined(dIDEDOUBLE)
#define dDOUBLE
#else
#define @ODE_PRECISION@
#endif
#endif

View File

@ -0,0 +1,68 @@
/*************************************************************************
* *
* 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

72
include/ode/ode/timer.h Normal file
View File

@ -0,0 +1,72 @@
/*************************************************************************
* *
* 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/odeconfig.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

View File

@ -0,0 +1,6 @@
#ifndef _ODE_VERSION_H_
#define _ODE_VERSION_H_
#define dODE_VERSION "0.13.1"
#endif

View File

@ -0,0 +1,6 @@
#ifndef _ODE_VERSION_H_
#define _ODE_VERSION_H_
#define dODE_VERSION "@ODE_VERSION@"
#endif

76
include/plugins/physics.h Normal file
View File

@ -0,0 +1,76 @@
/*
* Copyright 1996-2024 Cyberbotics Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef PHYSICS_H
#define PHYSICS_H
#include <ode/ode.h>
#include <pthread.h>
#ifdef _WIN32
#include <windows.h>
#endif
/* callback functions to be implemented in your physics plugin */
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _MSC_VER
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT
#endif
DLLEXPORT void webots_physics_init();
DLLEXPORT int webots_physics_collide(dGeomID,dGeomID);
DLLEXPORT void webots_physics_step();
DLLEXPORT void webots_physics_step_end();
DLLEXPORT void webots_physics_cleanup();
DLLEXPORT void webots_physics_draw(int pass, const char *view);
/* utility functions to be used in your callback functions */
#ifndef __linux__
extern dGeomID (*dWebotsGetGeomFromDEFProc)(const char *);
extern dBodyID (*dWebotsGetBodyFromDEFProc)(const char *);
extern dJointGroupID (*dWebotsGetContactJointGroupProc)();
extern void (*dWebotsSendProc)(int,const void *,int);
extern void* (*dWebotsReceiveProc)(int *);
extern void (*dWebotsConsolePrintfProc)(const char *, ...);
extern double (*dWebotsGetTimeProc)();
#define dWebotsGetGeomFromDEF(defName) (*dWebotsGetGeomFromDEFProc)(defName)
#define dWebotsGetBodyFromDEF(defName) (*dWebotsGetBodyFromDEFProc)(defName)
#define dWebotsGetContactJointGroup() (*dWebotsGetContactJointGroupProc)()
#define dWebotsSend(channel,buff,size) (*dWebotsSendProc)(channel,buff,size)
#define dWebotsReceive(size_ptr) (*dWebotsReceiveProc)(size_ptr)
#if defined(__VISUALC__) || defined (_MSC_VER) || defined(__BORLANDC__)
#define dWebotsConsolePrintf(format, ...) (*dWebotsConsolePrintfProc)(format, __VA_ARGS__)
#else
#define dWebotsConsolePrintf(format, ...) (*dWebotsConsolePrintfProc)(format, ## __VA_ARGS__)
#endif
#define dWebotsGetTime() (*dWebotsGetTimeProc)()
#else
dGeomID dWebotsGetGeomFromDEF(const char *defName);
dBodyID dWebotsGetBodyFromDEF(const char *defName);
dJointGroupID dWebotsGetContactJointGroup();
void dWebotsSend(int channel,const void *buffer,int size);
const void *dWebotsReceive(int *size);
void dWebotsConsolePrintf(const char *format, ...);
double dWebotsGetTime();
#endif
#ifdef __cplusplus
}
#endif
#endif /* PHYSICS_H */

82
include/plugins/radio.h Normal file
View File

@ -0,0 +1,82 @@
/*
* Copyright 1996-2024 Cyberbotics Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef WEBOTS_RADIO_H
#define WEBOTS_RADIO_H
#ifdef __cplusplus
extern "C" {
#endif
/* event types for WebotsRadioEvent */
#define WEBOTS_RADIO_EVENT_RECEIVE 1
#define WEBOTS_RADIO_EVENT_NETWORK_DETECTED 2
#define WEBOTS_RADIO_EVENT_LOST_CONNECTION 3
struct WebotsRadioEvent {
int type; /* see above the WEBOTS_RADIO_EVENT_* type list */
const char *data; /* data chunk received by the radio */
int data_size; /* size of the data chunk */
const char *from; /* address of the emitter of the data */
double rssi; /* wireless networking parameter */
void *user_data; /* user pointer defined in radio_set_callback() */
};
void webots_radio_init(void); /* initialization routine, to be called
prior to any function call */
void webots_radio_cleanup(void); /* cleanup rountine, no further
webots_radio_xxx() function can be
called after this one */
int webots_radio_new(void); /* create a new radio node */
/* parameter setters */
void webots_radio_set_protocol(int radio,const char *protocol);
void webots_radio_set_address(int radio,const char *address);
void webots_radio_set_frequency(int radio,double frequency);
void webots_radio_set_channel(int radio,int channel);
void webots_radio_set_bitrate(int radio,double bitrate);
void webots_radio_set_rx_sensitivity(int radio,double rx_sensitivity);
void webots_radio_set_tx_power(int radio,double tx_power);
void webots_radio_set_callback(int radio,void *user_data,
void(*)(const int radio,const struct WebotsRadioEvent *));
/* move a radio node */
void webots_radio_move(int radio,double x,double y,double z);
void webots_radio_send(int radio,const void *dest,const char *data,int size,double delay);
void webots_radio_delete(int radio); /* delete a radio node */
void webots_radio_run(double seconds); /* run the network simulation for
a given number of seconds */
/* radio connected mode: to be implemented later on */
int webots_radio_connection_open(int radio,const char *destination);
int webots_radio_connection_send(int connection,const char *data,int size);
void webots_radio_connection_set_callback(int radio,void *ptr,
void(*receive_func)(void *ptr,
char *data,
int size));
void webots_radio_connection_close(int connection);
#ifdef __cplusplus
}
#endif
#endif /* WEBOTS_RADIO_H */

9
include/wren/CHANGES.md Normal file
View File

@ -0,0 +1,9 @@
### Differences between Webots and Wren
Here we try to document things that WREN does differently from Webots and that may require changes to existing worlds.
#### IndexedLineSet
Before, the IndexedLineSet was shaded in the same way as all other geometries. This often results in a different
color for the lines than the material's diffuse color.
In the WREN branch, the IndexedLineSet uses a separate shader that directly applies the material's diffuse color.

14
include/wren/README.md Normal file
View File

@ -0,0 +1,14 @@
### Minimal interface between Webots and Wren
Wren exposes its public interface through a series of C headers, found in the include/wren directory
#### Wren dependencies
Wren requires only on these 4 dependencies:
1. STL
2. glm
3. glade
4. siphash
In particular, the dependency on Qt has been removed.

43
include/wren/camera.h Normal file
View File

@ -0,0 +1,43 @@
#ifndef WR_CAMERA_H
#define WR_CAMERA_H
#ifdef __cplusplus
extern "C" {
#endif
/* Inheritance diagram: WrNode <- WrCamera */
struct WrCamera;
typedef struct WrCamera WrCamera;
typedef enum WrCameraProjectionMode {
WR_CAMERA_PROJECTION_MODE_PERSPECTIVE,
WR_CAMERA_PROJECTION_MODE_ORTHOGRAPHIC
} WrCameraProjectionMode;
/* Use wr_node_delete(WR_NODE(camera)) to delete an instance */
WrCamera *wr_camera_new();
void wr_camera_set_projection_mode(WrCamera *camera, WrCameraProjectionMode mode);
void wr_camera_set_aspect_ratio(WrCamera *camera, float ratio);
void wr_camera_set_near(WrCamera *camera, float near_distance);
void wr_camera_set_far(WrCamera *camera, float far_distance);
void wr_camera_set_fovy(WrCamera *camera, float fovy);
void wr_camera_set_height(WrCamera *camera, float height);
void wr_camera_set_position(WrCamera *camera, float *position);
void wr_camera_set_flip_y(WrCamera *camera, bool flip_y);
/* Expects a 4-component array */
void wr_camera_set_orientation(WrCamera *camera, float *angle_axis);
void wr_camera_apply_yaw(WrCamera *camera, float angle);
void wr_camera_apply_pitch(WrCamera *camera, float angle);
void wr_camera_apply_roll(WrCamera *camera, float angle);
float wr_camera_get_near(WrCamera *camera);
float wr_camera_get_far(WrCamera *camera);
float wr_camera_get_fovy(WrCamera *camera);
float wr_camera_get_height(WrCamera *camera);
#ifdef __cplusplus
}
#endif
#endif // WR_CAMERA_H

33
include/wren/config.h Normal file
View File

@ -0,0 +1,33 @@
#ifndef WR_CONFIG_H
#define WR_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
struct WrShaderProgram;
typedef struct WrShaderProgram WrShaderProgram;
void wr_config_enable_shadows(bool enable);
void wr_config_set_line_scale(float line_scale);
void wr_config_set_show_bounding_spheres(bool show);
void wr_config_set_show_axis_aligned_bounding_boxes(bool show);
void wr_config_set_show_shadow_axis_aligned_bounding_boxes(bool show);
void wr_config_set_show_frustums(bool show);
void wr_config_set_bounding_volume_program(WrShaderProgram *program);
void wr_config_set_requires_flush_after_draw(bool require);
void wr_config_set_requires_depth_buffer_distortion(bool require);
void wr_config_enable_point_size(bool enable);
int wr_config_get_max_active_spot_light_count();
int wr_config_get_max_active_point_light_count();
int wr_config_get_max_active_directional_light_count();
bool wr_config_are_shadows_enabled();
float wr_config_get_line_scale();
#ifdef __cplusplus
}
#endif
#endif // WR_CONFIG_H

View File

@ -0,0 +1,28 @@
#ifndef WR_DIRECTIONAL_LIGHT_H
#define WR_DIRECTIONAL_LIGHT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Inheritance diagram: WrNode <- WrDirectionalLight */
struct WrDirectionalLight;
typedef struct WrDirectionalLight WrDirectionalLight;
/* Use wr_node_delete(WR_NODE(light)) to delete an instance */
WrDirectionalLight *wr_directional_light_new();
/* Expects a 3-component array */
void wr_directional_light_set_color(WrDirectionalLight *light, const float *color);
void wr_directional_light_set_intensity(WrDirectionalLight *light, float intensity);
void wr_directional_light_set_ambient_intensity(WrDirectionalLight *light, float ambient_intensity);
void wr_directional_light_set_on(WrDirectionalLight *light, bool on);
void wr_directional_light_set_cast_shadows(WrDirectionalLight *light, bool cast_shadows);
void wr_directional_light_set_direction(WrDirectionalLight *light, float *direction);
#ifdef __cplusplus
}
#endif
#endif // WR_DIRECTIONAL_LIGHT_H

View File

@ -0,0 +1,30 @@
#ifndef WR_DRAWABLE_TEXTURE_H
#define WR_DRAWABLE_TEXTURE_H
#ifdef __cplusplus
extern "C" {
#endif
/* Inheritance diagram: WrTexture2d <- WrDrawableTexture */
struct WrDrawableTexture;
typedef struct WrDrawableTexture WrDrawableTexture;
struct WrFont;
typedef struct WrFont WrFont;
WrDrawableTexture *wr_drawable_texture_new();
void wr_drawable_texture_set_font(WrDrawableTexture *texture, WrFont *font);
void wr_drawable_texture_set_color(WrDrawableTexture *texture, const float *color);
void wr_drawable_texture_set_antialasing(WrDrawableTexture *texture, bool enabled);
void wr_drawable_texture_set_use_premultiplied_alpha(WrDrawableTexture *texture, bool premultipliedAlpha);
void wr_drawable_texture_draw_pixel(WrDrawableTexture *texture, int x, int y);
void wr_drawable_texture_draw_text(WrDrawableTexture *texture, const char *text, int x, int y);
void wr_drawable_texture_clear(WrDrawableTexture *texture);
#ifdef __cplusplus
}
#endif
#endif // WR_DRAWABLE_TEXTURE_H

View File

@ -0,0 +1,26 @@
#ifndef WR_DYNAMIC_MESH_H
#define WR_DYNAMIC_MESH_H
#ifdef __cplusplus
extern "C" {
#endif
struct WrDynamicMesh;
typedef struct WrDynamicMesh WrDynamicMesh;
WrDynamicMesh *wr_dynamic_mesh_new(bool normals, bool texture_coordinates, bool color_per_vertex);
void wr_dynamic_mesh_delete(WrDynamicMesh *mesh);
void wr_dynamic_mesh_clear(WrDynamicMesh *mesh);
void wr_dynamic_mesh_clear_selected(WrDynamicMesh *mesh, bool vertices, bool normals, bool texture_coordinates, bool colors);
void wr_dynamic_mesh_add_vertex(WrDynamicMesh *mesh, const float *vertex);
void wr_dynamic_mesh_add_normal(WrDynamicMesh *mesh, const float *normal);
void wr_dynamic_mesh_add_texture_coordinate(WrDynamicMesh *mesh, const float *texture_coordinate);
void wr_dynamic_mesh_add_index(WrDynamicMesh *mesh, unsigned int index);
void wr_dynamic_mesh_add_color(WrDynamicMesh *mesh, const float *color);
#ifdef __cplusplus
}
#endif
#endif // WR_MESH_H

View File

@ -0,0 +1,33 @@
#ifndef WR_FILE_LOADER
#define WR_FILE_LOADER
#ifdef __cplusplus
extern "C" {
#endif
struct WrSkeleton;
typedef struct WrSkeleton WrSkeleton;
struct WrStaticMesh;
typedef struct WrStaticMesh WrStaticMesh;
struct WrDynamicMesh;
typedef struct WrDynamicMesh WrDynamicMesh;
// Utility methods to load WREN objects from files.
// Return false in case of failure.
// Load static mesh from OBJ file
bool wr_import_static_mesh_from_obj(const char *fileName, WrStaticMesh **mesh);
// Load skeleton and dynamic meshes from FBX/Ogre file
const char *wr_import_skeleton_from_file(const char *fileName, WrSkeleton **skeleton, WrDynamicMesh ***meshes,
const char ***materials, int *count);
const char *wr_import_skeleton_from_memory(const char *data, int size, const char *hint, WrSkeleton **skeleton,
WrDynamicMesh ***meshes, const char ***materials, int *count);
#ifdef __cplusplus
}
#endif
#endif // WR_FILE_LOADER

34
include/wren/font.h Normal file
View File

@ -0,0 +1,34 @@
#ifndef WR_FONT_H
#define WR_FONT_H
#ifdef __cplusplus
extern "C" {
#endif
struct WrFont;
typedef struct WrFont WrFont;
typedef enum WrFontError {
WR_FONT_ERROR_NONE,
WR_FONT_ERROR_UNKNOWN_FILE_FORMAT,
WR_FONT_ERROR_FONT_LOADING,
WR_FONT_ERROR_FONT_SIZE,
WR_FONT_ERROR_CHARACTER_LOADING,
WR_FONT_ERROR_FREETYPE_LOADING
} WrFontError;
WrFont *wr_font_new();
void wr_font_delete(WrFont *font);
void wr_font_set_face(WrFont *font, const char *filename);
void wr_font_set_size(WrFont *font, unsigned int size);
void wr_font_get_bounding_box(WrFont *font, const char *text, int *width, int *height);
WrFontError wr_font_get_error(WrFont *font);
#ifdef __cplusplus
}
#endif
#endif // WR_FONT_H

View File

@ -0,0 +1,40 @@
#ifndef WR_FRAME_BUFFER_H
#define WR_FRAME_BUFFER_H
#ifdef __cplusplus
extern "C" {
#endif
struct WrFrameBuffer;
typedef struct WrFrameBuffer WrFrameBuffer;
struct WrTextureRtt;
typedef struct WrTextureRtt WrTextureRtt;
WrFrameBuffer *wr_frame_buffer_new();
void wr_frame_buffer_delete(WrFrameBuffer *frame_buffer);
void wr_frame_buffer_append_output_texture(WrFrameBuffer *frame_buffer, WrTextureRtt *texture);
void wr_frame_buffer_append_output_texture_disable(WrFrameBuffer *frame_buffer, WrTextureRtt *texture);
void wr_frame_buffer_set_depth_texture(WrFrameBuffer *frame_buffer, WrTextureRtt *texture);
void wr_frame_buffer_enable_depth_buffer(WrFrameBuffer *frame_buffer, bool enable);
/* OpenGL context must be active when calling this function */
void wr_frame_buffer_enable_copying(WrFrameBuffer *frame_buffer, int index, bool enable);
void wr_frame_buffer_set_size(WrFrameBuffer *frame_buffer, int width, int height);
WrTextureRtt *wr_frame_buffer_get_output_texture(WrFrameBuffer *frame_buffer, int index);
WrTextureRtt *wr_frame_buffer_get_depth_texture(WrFrameBuffer *frame_buffer);
void wr_frame_buffer_setup(WrFrameBuffer *frame_buffer);
void wr_frame_buffer_blit_to_screen(WrFrameBuffer *frame_buffer);
/* The data written to 'data' will be in the format of output texture number 'index' */
void wr_frame_buffer_copy_contents(WrFrameBuffer *frame_buffer, int index, void *data);
void wr_frame_buffer_copy_pixel(WrFrameBuffer *frame_buffer, int index, int x, int y, void *data, bool flip_y);
void wr_frame_buffer_copy_depth_pixel(WrFrameBuffer *frame_buffer, int x, int y, void *data, bool flip_y);
#ifdef __cplusplus
}
#endif
#endif // WR_FRAME_BUFFER_H

28
include/wren/gl_state.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef WR_GL_STATE_H
#define WR_GL_STATE_H
#ifdef __cplusplus
extern "C" {
#endif
bool wr_gl_state_is_initialized();
void wr_gl_state_set_context_active(bool active);
const char *wr_gl_state_get_vendor();
const char *wr_gl_state_get_renderer();
const char *wr_gl_state_get_version();
const char *wr_gl_state_get_glsl_version();
int wr_gl_state_get_gpu_memory();
bool wr_gl_state_is_anisotropic_texture_filtering_supported();
float wr_gl_state_max_texture_anisotropy();
void wr_gl_state_disable_check_error();
#ifdef __cplusplus
}
#endif
#endif // WR_GL_STATE_H

View File

@ -0,0 +1,52 @@
#ifndef WR_GLSL_LAYOUT_H
#define WR_GLSL_LAYOUT_H
#ifdef __cplusplus
extern "C" {
#endif
/* For indexing into gUniformNames */
typedef enum WrGlslLayoutUniform {
WR_GLSL_LAYOUT_UNIFORM_TEXTURE0,
WR_GLSL_LAYOUT_UNIFORM_TEXTURE1,
WR_GLSL_LAYOUT_UNIFORM_TEXTURE2,
WR_GLSL_LAYOUT_UNIFORM_TEXTURE3,
WR_GLSL_LAYOUT_UNIFORM_TEXTURE4,
WR_GLSL_LAYOUT_UNIFORM_TEXTURE5,
WR_GLSL_LAYOUT_UNIFORM_TEXTURE6,
WR_GLSL_LAYOUT_UNIFORM_TEXTURE7,
WR_GLSL_LAYOUT_UNIFORM_TEXTURE8,
WR_GLSL_LAYOUT_UNIFORM_TEXTURE9,
WR_GLSL_LAYOUT_UNIFORM_TEXTURE10,
WR_GLSL_LAYOUT_UNIFORM_TEXTURE11,
WR_GLSL_LAYOUT_UNIFORM_TEXTURE12,
WR_GLSL_LAYOUT_UNIFORM_TEXTURE_CUBE0,
WR_GLSL_LAYOUT_UNIFORM_TEXTURE_CUBE1,
WR_GLSL_LAYOUT_UNIFORM_ITERATION_NUMBER,
WR_GLSL_LAYOUT_UNIFORM_MODEL_TRANSFORM,
WR_GLSL_LAYOUT_UNIFORM_TEXTURE_TRANSFORM,
WR_GLSL_LAYOUT_UNIFORM_VIEWPORT_SIZE,
WR_GLSL_LAYOUT_UNIFORM_COLOR_PER_VERTEX,
WR_GLSL_LAYOUT_UNIFORM_POINT_SIZE,
WR_GLSL_LAYOUT_UNIFORM_CHANNEL_COUNT,
WR_GLSL_LAYOUT_UNIFORM_GTAO,
WR_GLSL_LAYOUT_UNIFORM_COUNT
} WrGlslLayoutUniform;
/* For indexing into gUniformBufferNames and gUniformBufferSizes */
typedef enum WrGlslLayoutUniformBuffer {
WR_GLSL_LAYOUT_UNIFORM_BUFFER_MATERIAL_PHONG,
WR_GLSL_LAYOUT_UNIFORM_BUFFER_MATERIAL_PBR,
WR_GLSL_LAYOUT_UNIFORM_BUFFER_LIGHTS,
WR_GLSL_LAYOUT_UNIFORM_BUFFER_LIGHT_RENDERABLE,
WR_GLSL_LAYOUT_UNIFORM_BUFFER_CAMERA_TRANSFORMS,
WR_GLSL_LAYOUT_UNIFORM_BUFFER_FOG,
WR_GLSL_LAYOUT_UNIFORM_BUFFER_OVERLAY,
WR_GLSL_LAYOUT_UNIFORM_BUFFER_COUNT
} WrGlslLayoutUniformBuffer;
#ifdef __cplusplus
}
#endif
#endif // WR_GLSL_LAYOUT_H

36
include/wren/js_helper.h Normal file
View File

@ -0,0 +1,36 @@
// Copyright 1996-2024 Cyberbotics Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef WR_JS_HELPER_H
#define WR_JS_HELPER_H
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif
float *wrjs_array3(float element0, float element1, float element2);
float *wrjs_array4(float element0, float element1, float element2, float element3);
int *wrjs_pointerOnInt(int number);
int *wrjs_pointerOnIntBis(int number);
char *wrjs_pointerOnFloat(float number);
void wrjs_init_context(int width, int height);
void wrjs_exit();
#ifdef __cplusplus
}
#endif
#endif // WR_JS_HELPER_H

99
include/wren/material.h Normal file
View File

@ -0,0 +1,99 @@
#ifndef WR_MATERIAL_H
#define WR_MATERIAL_H
#include <wren/texture.h>
#ifdef __cplusplus
extern "C" {
#endif
enum WrMaterialType { WR_MATERIAL_NONE, WR_MATERIAL_PHONG, WR_MATERIAL_PBR };
struct WrMaterial {
WrMaterialType type;
void *data;
};
typedef struct WrMaterial WrMaterial;
struct WrShaderProgram;
typedef struct WrShaderProgram WrShaderProgram;
struct WrTextureTransform;
typedef struct WrTextureTransform WrTextureTransform;
struct WrTextureCubeMap;
typedef struct WrTextureCubeMap WrTextureCubeMap;
void wr_material_delete(WrMaterial *material);
void wr_material_set_texture(WrMaterial *material, WrTexture *texture, int index);
void wr_material_set_texture_wrap_s(WrMaterial *material, WrTextureWrapMode mode, int index);
void wr_material_set_texture_wrap_t(WrMaterial *material, WrTextureWrapMode mode, int index);
void wr_material_set_texture_anisotropy(WrMaterial *material, float anisotropy, int index);
void wr_material_set_texture_enable_interpolation(WrMaterial *material, bool enable, int index);
void wr_material_set_texture_enable_mip_maps(WrMaterial *material, bool enable, int index);
void wr_material_set_texture_cubemap(WrMaterial *material, WrTextureCubeMap *texture, int index);
void wr_material_set_texture_cubemap_wrap_r(WrMaterial *material, WrTextureWrapMode mode, int index);
void wr_material_set_texture_cubemap_wrap_s(WrMaterial *material, WrTextureWrapMode mode, int index);
void wr_material_set_texture_cubemap_wrap_t(WrMaterial *material, WrTextureWrapMode mode, int index);
void wr_material_set_texture_cubemap_anisotropy(WrMaterial *material, float anisotropy, int index);
void wr_material_set_texture_cubemap_enable_interpolation(WrMaterial *material, bool enable, int index);
void wr_material_set_texture_cubemap_enable_mip_maps(WrMaterial *material, bool enable, int index);
void wr_material_set_texture_transform(WrMaterial *material, WrTextureTransform *transform);
void wr_material_set_default_program(WrMaterial *material, WrShaderProgram *program);
void wr_material_set_stencil_ambient_emissive_program(WrMaterial *material, WrShaderProgram *program);
void wr_material_set_stencil_diffuse_specular_program(WrMaterial *material, WrShaderProgram *program);
WrTexture *wr_material_get_texture(const WrMaterial *material, int index);
WrTextureWrapMode wr_material_get_texture_wrap_s(const WrMaterial *material, int index);
WrTextureWrapMode wr_material_get_texture_wrap_t(const WrMaterial *material, int index);
float wr_material_get_texture_anisotropy(const WrMaterial *material, int index);
bool wr_material_is_texture_interpolation_enabled(const WrMaterial *material, int index);
bool wr_material_are_texture_mip_maps_enabled(const WrMaterial *material, int index);
// Phong material-only functions
WrMaterial *wr_phong_material_new();
void wr_phong_material_clear(WrMaterial *material);
void wr_phong_material_set_color(WrMaterial *material, const float *color);
void wr_phong_material_set_ambient(WrMaterial *material, const float *ambient);
void wr_phong_material_set_diffuse(WrMaterial *material, const float *diffuse);
void wr_phong_material_set_linear_ambient(WrMaterial *material, const float *ambient);
void wr_phong_material_set_linear_diffuse(WrMaterial *material, const float *diffuse);
void wr_phong_material_set_specular(WrMaterial *material, const float *specular);
void wr_phong_material_set_emissive(WrMaterial *material, const float *emissive);
void wr_phong_material_set_shininess(WrMaterial *material, float shininess);
void wr_phong_material_set_transparency(WrMaterial *material, float transparency);
void wr_phong_material_set_all_parameters(WrMaterial *material, const float *ambient, const float *diffuse,
const float *specular, const float *emissive, float shininess, float transparency);
bool wr_phong_material_is_translucent(const WrMaterial *material);
void wr_phong_material_set_color_per_vertex(WrMaterial *material, bool enabled);
// PBR material-only functions
WrMaterial *wr_pbr_material_new();
void wr_pbr_material_clear(WrMaterial *material);
void wr_pbr_material_set_transparency(WrMaterial *material, float transparency);
void wr_pbr_material_set_background_color(WrMaterial *material, const float *background_color);
void wr_pbr_material_set_base_color(WrMaterial *material, const float *base_color);
void wr_pbr_material_set_emissive_color(WrMaterial *material, const float *emissive_color);
void wr_pbr_material_set_roughness(WrMaterial *material, float roughness);
void wr_pbr_material_set_metalness(WrMaterial *material, float metalness);
void wr_pbr_material_set_ibl_strength(WrMaterial *material, float ibl_strength);
void wr_pbr_material_set_normal_map_strength(WrMaterial *material, float normal_map_factor);
void wr_pbr_material_set_occlusion_map_strength(WrMaterial *material, float occlusion_map_strength);
void wr_pbr_material_set_emissive_intensity(WrMaterial *material, float emissive_intensity);
void wr_pbr_material_set_all_parameters(WrMaterial *material, const float *background_color, const float *base_color,
float transparency, float roughness, float metalness, float ibl_strength,
float normal_map_factor, float occlusion_map_strength, const float *emissive_color,
float emissive_intensity);
bool wr_pbr_material_is_translucent(const WrMaterial *material);
#ifdef __cplusplus
}
#endif
#endif // WR_MATERIAL_H

26
include/wren/node.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef WR_NODE_H
#define WR_NODE_H
#define WR_NODE(x) ((WrNode *)(x))
#ifdef __cplusplus
extern "C" {
#endif
struct WrNode;
typedef struct WrNode WrNode;
struct WrTransform;
typedef struct WrTransform WrTransform;
void wr_node_delete(WrNode *node);
WrTransform *wr_node_get_parent(WrNode *node);
void wr_node_set_visible(WrNode *node, bool is_visible);
bool wr_node_is_visible(WrNode *node);
#ifdef __cplusplus
}
#endif
#endif // WR_NODE_H

67
include/wren/overlay.h Normal file
View File

@ -0,0 +1,67 @@
#ifndef WR_OVERLAY_H
#define WR_OVERLAY_H
#ifdef __cplusplus
extern "C" {
#endif
struct WrOverlay;
typedef struct WrOverlay WrOverlay;
struct WrShaderProgram;
typedef struct WrShaderProgram WrShaderProgram;
struct WrTexture;
typedef struct WrTexture WrTexture;
void wr_overlay_set_screen_ratio(float ratio);
WrOverlay *wr_overlay_new();
void wr_overlay_delete(WrOverlay *overlay);
void wr_overlay_set_order(WrOverlay *overlay, int order);
void wr_overlay_put_on_top(WrOverlay *overlay);
void wr_overlay_set_visible(WrOverlay *overlay, bool visible);
void wr_overlay_show_default_size(WrOverlay *overlay, bool visible);
void wr_overlay_set_default_size(WrOverlay *overlay, float width, float height);
void wr_overlay_set_size(WrOverlay *overlay, float width, float height);
void wr_overlay_set_position(WrOverlay *overlay, float x, float y);
void wr_overlay_set_use_premultiplied_alpha_textures(WrOverlay *overlay, bool enabled);
void wr_overlay_set_anisotropy(WrOverlay *overlay, float anisotropy);
void wr_overlay_set_translucency(WrOverlay *overlay, bool enabled);
void wr_overlay_enable_interpolation(WrOverlay *overlay, bool enabled);
void wr_overlay_enable_mip_maps(WrOverlay *overlay, bool enable);
/* Expects a 4-component array */
void wr_overlay_set_background_color(WrOverlay *overlay, const float *color);
void wr_overlay_set_border_active(WrOverlay *overlay, bool active);
/* Expects a 4-component array */
void wr_overlay_set_border_color(WrOverlay *overlay, const float *color);
void wr_overlay_set_border_size(WrOverlay *overlay, float size_horizontal, float size_vertical);
void wr_overlay_set_texture(WrOverlay *overlay, WrTexture *texture);
void wr_overlay_set_texture_flip_vertical(WrOverlay *overlay, bool flip);
void wr_overlay_set_background_texture(WrOverlay *overlay, WrTexture *texture);
void wr_overlay_set_mask_texture(WrOverlay *overlay, WrTexture *texture);
void wr_overlay_set_foreground_texture(WrOverlay *overlay, WrTexture *texture);
void wr_overlay_add_additional_texture(WrOverlay *overlay, WrTexture *texture);
void wr_overlay_set_program(WrOverlay *overlay, WrShaderProgram *program);
void wr_overlay_set_default_size_program(WrOverlay *overlay, WrShaderProgram *program);
void wr_overlay_set_max_range(WrOverlay *overlay, float max_range);
bool wr_overlay_is_visible(WrOverlay *overlay);
int wr_overlay_get_order(WrOverlay *overlay);
float wr_overlay_get_x(WrOverlay *overlay);
float wr_overlay_get_y(WrOverlay *overlay);
float wr_overlay_get_width(WrOverlay *overlay);
float wr_overlay_get_height(WrOverlay *overlay);
/* allows this overlay to live in the cache even if the scene is reset */
void wr_overlay_set_cache_persistency(WrOverlay *overlay, bool is_persistent);
#ifdef __cplusplus
}
#endif
#endif // WR_OVERLAY_H

View File

@ -0,0 +1,31 @@
#ifndef WR_POINT_LIGHT_H
#define WR_POINT_LIGHT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Inheritance diagram: WrNode <- WrPointLight */
struct WrPointLight;
typedef struct WrPointLight WrPointLight;
/* Use wr_node_delete(WR_NODE(light)) to delete an instance */
WrPointLight *wr_point_light_new();
/* Expects a 3-component array */
void wr_point_light_set_color(WrPointLight *light, const float *color);
void wr_point_light_set_intensity(WrPointLight *light, float intensity);
void wr_point_light_set_ambient_intensity(WrPointLight *light, float ambient_intensity);
void wr_point_light_set_on(WrPointLight *light, bool on);
void wr_point_light_set_cast_shadows(WrPointLight *light, bool cast_shadows);
void wr_point_light_set_position_relative(WrPointLight *light, const float *position);
void wr_point_light_set_radius(WrPointLight *light, float radius);
void wr_point_light_set_attenuation(WrPointLight *light, float attenuation_constant, float attenuation_linear,
float attenuation_quadratic);
#ifdef __cplusplus
}
#endif
#endif // WR_POINT_LIGHT_H

View File

@ -0,0 +1,85 @@
#ifndef WR_POST_PROCESSING_EFFECT_H
#define WR_POST_PROCESSING_EFFECT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <wren/texture.h>
struct WrPostProcessingEffect;
typedef struct WrPostProcessingEffect WrPostProcessingEffect;
struct WrPostProcessingEffectPass;
typedef struct WrPostProcessingEffectPass WrPostProcessingEffectPass;
struct WrFrameBuffer;
typedef struct WrFrameBuffer WrFrameBuffer;
struct WrMesh;
typedef struct WrMesh WrMesh;
struct WrShaderProgram;
typedef struct WrShaderProgram WrShaderProgram;
struct WrTextureRtt;
typedef struct WrTextureRtt WrTextureRtt;
struct WrViewport;
typedef struct WrViewport WrViewport;
WrPostProcessingEffectPass *wr_post_processing_effect_pass_new();
void wr_post_processing_effect_pass_delete(WrPostProcessingEffectPass *pass);
void wr_post_processing_effect_pass_set_name(WrPostProcessingEffectPass *pass, const char *name);
void wr_post_processing_effect_pass_set_program(WrPostProcessingEffectPass *pass, WrShaderProgram *program);
/* This function requires a persistent pointer to the value (it is not copied from the source), otherwise WREN crashes here. */
void wr_post_processing_effect_pass_set_program_parameter(WrPostProcessingEffectPass *pass, const char *parameter_name,
const char *value);
void wr_post_processing_effect_pass_set_output_size(WrPostProcessingEffectPass *pass, int width, int height);
/* Texture counts needs to be specified before setting individual input textures or output formats */
void wr_post_processing_effect_pass_set_input_texture_count(WrPostProcessingEffectPass *pass, int count);
void wr_post_processing_effect_pass_set_output_texture_count(WrPostProcessingEffectPass *pass, int count);
void wr_post_processing_effect_pass_set_input_texture_wrap_mode(WrPostProcessingEffectPass *pass, int index,
WrTextureWrapMode mode);
void wr_post_processing_effect_pass_set_input_texture_interpolation(WrPostProcessingEffectPass *pass, int index, bool enable);
void wr_post_processing_effect_pass_set_output_texture_format(WrPostProcessingEffectPass *pass, int index,
WrTextureInternalFormat format);
void wr_post_processing_effect_pass_set_input_texture(WrPostProcessingEffectPass *pass, int index, WrTexture *texture);
/* The pass will be invoked 'count' times (1 by default) */
void wr_post_processing_effect_pass_set_iteration_count(WrPostProcessingEffectPass *pass, int count);
WrTextureRtt *wr_post_processing_effect_pass_get_output_texture(WrPostProcessingEffectPass *pass, int index);
void wr_post_processing_effect_pass_set_clear_before_draw(WrPostProcessingEffectPass *pass, bool enable);
void wr_post_processing_effect_pass_set_alpha_blending(WrPostProcessingEffectPass *pass, bool enable);
WrPostProcessingEffect *wr_post_processing_effect_new();
void wr_post_processing_effect_delete(WrPostProcessingEffect *post_processing_effect);
/* Specifying an input framebuffer is optional. If available, its first output texture will be used as
the first input texture of the effect's first pass */
void wr_post_processing_effect_set_input_frame_buffer(WrPostProcessingEffect *post_processing_effect,
WrFrameBuffer *frame_buffer);
/* At a minimum, one pass needs to be specified */
void wr_post_processing_effect_append_pass(WrPostProcessingEffect *post_processing_effect, WrPostProcessingEffectPass *pass);
/* Sets output texture 'output_index' of pass 'from' as input texture 'input_index' of pass 'to' */
void wr_post_processing_effect_connect(WrPostProcessingEffect *post_processing_effect, WrPostProcessingEffectPass *from,
int output_index, WrPostProcessingEffectPass *to, int input_index);
/* Will usually be a pass-through shader, but can be any shader with only one input */
void wr_post_processing_effect_set_result_program(WrPostProcessingEffect *post_processing_effect, WrShaderProgram *program);
/* Will hold the result of applying the result program to the first output texture of the last pass */
void wr_post_processing_effect_set_result_frame_buffer(WrPostProcessingEffect *post_processing_effect,
WrFrameBuffer *frame_buffer);
WrPostProcessingEffectPass *wr_post_processing_effect_get_first_pass(WrPostProcessingEffect *post_processing_effect);
WrPostProcessingEffectPass *wr_post_processing_effect_get_last_pass(WrPostProcessingEffect *post_processing_effect);
WrPostProcessingEffectPass *wr_post_processing_effect_get_pass(WrPostProcessingEffect *post_processing_effect,
const char *name);
void wr_post_processing_effect_set_drawing_index(WrPostProcessingEffect *post_processing_effect, unsigned int index);
void wr_post_processing_effect_setup(WrPostProcessingEffect *post_processing_effect);
void wr_post_processing_effect_apply(WrPostProcessingEffect *post_processing_effect);
#ifdef __cplusplus
}
#endif
#endif // WR_POST_PROCESSING_EFFECT_H

67
include/wren/renderable.h Normal file
View File

@ -0,0 +1,67 @@
#ifndef WR_RENDERABLE_H
#define WR_RENDERABLE_H
#define WR_MESH(x) ((WrMesh *)(x))
#ifdef __cplusplus
extern "C" {
#endif
/* Inheritance diagram: WrNode <- WrRenderable */
struct WrRenderable;
typedef struct WrRenderable WrRenderable;
struct WrMesh;
typedef struct WrMesh WrMesh;
struct WrMaterial;
typedef struct WrMaterial WrMaterial;
typedef enum WrRenderableDrawingMode {
WR_RENDERABLE_DRAWING_MODE_TRIANGLES = 0x4, // GL_TRIANGLES
WR_RENDERABLE_DRAWING_MODE_TRIANGLE_FAN = 0x6, // GL_TRIANGLE_FAN
WR_RENDERABLE_DRAWING_MODE_LINES = 0x1, // GL_LINES
WR_RENDERABLE_DRAWING_MODE_LINE_STRIP = 0x3, // GL_LINE_STRIP
WR_RENDERABLE_DRAWING_MODE_POINTS = 0x0 // GL_POINTS
} WrRenderableDrawingMode;
typedef enum WrRenderableDrawingOrder {
WR_RENDERABLE_DRAWING_ORDER_MAIN,
WR_RENDERABLE_DRAWING_ORDER_AFTER_0,
WR_RENDERABLE_DRAWING_ORDER_AFTER_1,
WR_RENDERABLE_DRAWING_ORDER_AFTER_2,
WR_RENDERABLE_DRAWING_ORDER_AFTER_3,
WR_RENDERABLE_DRAWING_ORDER_COUNT
} WrRenderableDrawingOrder;
/* Use wr_node_delete(WR_NODE(renderable)) to delete an instance */
WrRenderable *wr_renderable_new();
void wr_renderable_set_mesh(WrRenderable *renderable, WrMesh *mesh);
/* Set a material to this renderable, the 'name' parameter is optional and can be set to NULL
to set the default material */
void wr_renderable_set_material(WrRenderable *renderable, WrMaterial *material, const char *name);
void wr_renderable_set_drawing_mode(WrRenderable *renderable, WrRenderableDrawingMode drawing_mode);
void wr_renderable_set_visibility_flags(WrRenderable *renderable, int flags);
void wr_renderable_invert_front_face(WrRenderable *renderable, bool invert_front_face);
void wr_renderable_set_cast_shadows(WrRenderable *renderable, bool cast_shadows);
void wr_renderable_set_receive_shadows(WrRenderable *renderable, bool receive_shadows);
void wr_renderable_set_scene_culling(WrRenderable *renderable, bool culling);
void wr_renderable_set_face_culling(WrRenderable *renderable, bool face_culling);
void wr_renderable_set_drawing_order(WrRenderable *renderable, WrRenderableDrawingOrder order);
void wr_renderable_set_in_view_space(WrRenderable *renderable, bool in_view_space);
void wr_renderable_set_z_sorted_rendering(WrRenderable *renderable, bool z_sorted);
void wr_renderable_set_point_size(WrRenderable *renderable, float point_size);
/* Returns the material associated to the 'name' parameter. Default material is returned if 'name' is set to NULL */
WrMaterial *wr_renderable_get_material(WrRenderable *renderable, const char *name);
/* Returns the bounding sphere in world space.
sphere[0]..[2] = center, sphere[3] = radius */
void wr_renderable_get_bounding_sphere(WrRenderable *renderable, float *sphere);
#ifdef __cplusplus
}
#endif
#endif // WR_RENDERABLE_H

88
include/wren/scene.h Normal file
View File

@ -0,0 +1,88 @@
#ifndef WR_SCENE_H
#define WR_SCENE_H
#ifdef __cplusplus
extern "C" {
#endif
struct WrScene;
typedef struct WrScene WrScene;
struct WrTransform;
typedef struct WrTransform WrTransform;
struct WrViewport;
typedef struct WrViewport WrViewport;
struct WrRenderable;
typedef struct WrRenderable WrRenderable;
struct WrShaderProgram;
typedef struct WrShaderProgram WrShaderProgram;
typedef enum WrSceneFogType {
WR_SCENE_FOG_TYPE_NONE,
WR_SCENE_FOG_TYPE_EXPONENTIAL,
WR_SCENE_FOG_TYPE_EXPONENTIAL2,
WR_SCENE_FOG_TYPE_LINEAR
} WrSceneFogType;
/* Defines the basis for the fog distance computation */
typedef enum WrSceneFogDepthType { WR_SCENE_FOG_DEPTH_TYPE_PLANE, WR_SCENE_FOG_DEPTH_TYPE_POINT } WrSceneFogDepthType;
WrScene *wr_scene_get_instance();
void wr_scene_destroy();
// The OpenGL context must be active when calling these functions
void wr_scene_init(WrScene *scene);
void wr_scene_reset(WrScene *scene);
// Apply pending OpenGL state changes
void wr_scene_apply_pending_updates(WrScene *scene);
/* The 'materialName' parameter is optional (can be set to NULL for default), and if set, force
the renderables to use the named material */
void wr_scene_render(WrScene *scene, const char *material_name, bool culling, bool offScreen);
void wr_scene_render_to_viewports(WrScene *scene, int count, WrViewport **viewports, const char *material_name, bool culling,
bool offScreen);
void wr_scene_set_ambient_light(const float *ambient_light);
int wr_scene_get_active_spot_light_count(WrScene *scene);
int wr_scene_get_active_point_light_count(WrScene *scene);
int wr_scene_get_active_directional_light_count(WrScene *scene);
/* Expects a 3-component array for 'color' */
void wr_scene_set_fog(WrScene *scene, WrSceneFogType fogType, WrSceneFogDepthType depthType, const float *color, float density,
float start, float end);
void wr_scene_set_skybox(WrScene *scene, WrRenderable *renderable);
void wr_scene_set_hdr_clear_quad(WrScene *scene, WrRenderable *renderable);
void wr_scene_set_fog_program(WrScene *scene, WrShaderProgram *program);
void wr_scene_set_shadow_volume_program(WrScene *scene, WrShaderProgram *program);
void wr_scene_enable_skybox(WrScene *scene, bool enable);
void wr_scene_enable_hdr_clear(WrScene *scene, bool enable);
void wr_scene_enable_translucence(WrScene *scene, bool enable);
void wr_scene_enable_depth_reset(WrScene *scene, bool enable);
void wr_scene_add_frame_listener(WrScene *scene, void (*listener)());
void wr_scene_remove_frame_listener(WrScene *scene, void (*listener)());
void wr_scene_get_main_buffer(int width, int height, unsigned int format, unsigned int data_type, void *buffer);
void wr_scene_init_frame_capture(WrScene *scene, int pixel_buffer_count, unsigned int *pixel_buffer_ids, int frame_size);
void wr_scene_bind_pixel_buffer(WrScene *scene, int buffer);
void *wr_scene_map_pixel_buffer(WrScene *scene, unsigned int access_mode);
void wr_scene_unmap_pixel_buffer(WrScene *scene);
void wr_scene_terminate_frame_capture(WrScene *scene);
int wr_scene_compute_node_count(WrScene *scene);
WrTransform *wr_scene_get_root(WrScene *scene);
WrViewport *wr_scene_get_viewport(WrScene *scene);
#ifdef __cplusplus
}
#endif
#endif // WR_SCENE_H

View File

@ -0,0 +1,46 @@
#ifndef WR_SHADER_PROGRAM_H
#define WR_SHADER_PROGRAM_H
#include <wren/glsl_layout.h>
#ifdef __cplusplus
extern "C" {
#endif
struct WrShaderProgram;
typedef struct WrShaderProgram WrShaderProgram;
typedef enum WrShaderProgramUniformType {
WR_SHADER_PROGRAM_UNIFORM_TYPE_BOOL,
WR_SHADER_PROGRAM_UNIFORM_TYPE_INT,
WR_SHADER_PROGRAM_UNIFORM_TYPE_FLOAT,
WR_SHADER_PROGRAM_UNIFORM_TYPE_VEC2F,
WR_SHADER_PROGRAM_UNIFORM_TYPE_VEC3F,
WR_SHADER_PROGRAM_UNIFORM_TYPE_VEC4F,
WR_SHADER_PROGRAM_UNIFORM_TYPE_MAT4F
} WrShaderProgramUniformType;
WrShaderProgram *wr_shader_program_new();
void wr_shader_program_delete(WrShaderProgram *program);
void wr_shader_program_set_vertex_shader_path(WrShaderProgram *program, const char *path);
void wr_shader_program_set_fragment_shader_path(WrShaderProgram *program, const char *path);
void wr_shader_program_use_uniform(WrShaderProgram *program, WrGlslLayoutUniform uniform);
void wr_shader_program_use_uniform_buffer(WrShaderProgram *program, WrGlslLayoutUniformBuffer uniform_buffer);
void wr_shader_program_create_custom_uniform(WrShaderProgram *program, const char *name, WrShaderProgramUniformType type,
const char *initial_value);
void wr_shader_program_set_custom_uniform_value(WrShaderProgram *program, const char *name, WrShaderProgramUniformType type,
const char *value);
unsigned int wr_shader_program_get_gl_name(WrShaderProgram *program);
bool wr_shader_program_has_vertex_shader_compilation_failed(WrShaderProgram *program);
bool wr_shader_program_has_fragment_shader_compilation_failed(WrShaderProgram *program);
const char *wr_shader_program_get_compilation_log(WrShaderProgram *program);
/* Setup must be called after all parameters have been specified */
void wr_shader_program_setup(WrShaderProgram *program);
#ifdef __cplusplus
}
#endif
#endif // WR_SHADER_PROGRAM_H

34
include/wren/skeleton.h Normal file
View File

@ -0,0 +1,34 @@
#ifndef WR_SKELETON_H
#define WR_SKELETON_H
#ifdef __cplusplus
extern "C" {
#endif
struct WrDynamicMesh;
typedef struct WrDynamicMesh WrDynamicMesh;
struct WrSkeleton;
typedef struct WrSkeleton WrSkeleton;
struct WrSkeletonBone;
typedef struct WrSkeletonBone WrSkeletonBone;
WrSkeleton *wr_skeleton_new();
int wr_skeleton_get_bone_count(WrSkeleton *skeleton);
WrSkeletonBone *wr_skeleton_get_bone_by_index(WrSkeleton *skeleton, int index);
WrSkeletonBone *wr_skeleton_get_bone_by_name(WrSkeleton *skeleton, const char *name);
void wr_skeleton_apply_binding_pose(WrSkeleton *skeleton);
// Only suitable when skeleton is attached to another transform
void wr_skeleton_update_offset(WrSkeleton *skeleton);
float *wr_skeleton_compute_bounding_spheres(WrSkeleton *skeleton, int &count);
#ifdef __cplusplus
}
#endif
#endif // WR_SKELETON_H

View File

@ -0,0 +1,23 @@
#ifndef WR_SKELETON_BONE_H
#define WR_SKELETON_BONE_H
#ifdef __cplusplus
extern "C" {
#endif
struct WrSkeleton;
typedef struct WrSkeleton WrSkeleton;
struct WrSkeletonBone;
typedef struct WrSkeletonBone WrSkeletonBone;
const char *wr_skeleton_bone_get_name(WrSkeletonBone *bone);
void wr_skeleton_bone_get_position(const WrSkeletonBone *bone, bool absolute, float *position);
void wr_skeleton_bone_get_orientation(const WrSkeletonBone *bone, bool absolute, float *orientation);
#ifdef __cplusplus
}
#endif
#endif // WR_SKELETON_BONE_H

37
include/wren/spot_light.h Normal file
View File

@ -0,0 +1,37 @@
#ifndef WR_SPOT_LIGHT_H
#define WR_SPOT_LIGHT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Inheritance diagram: WrNode <- WrSpotLight */
struct WrSpotLight;
typedef struct WrSpotLight WrSpotLight;
/* Use wr_node_delete(WR_NODE(light)) to delete an instance */
WrSpotLight *wr_spot_light_new();
/* Expects a 3-component array */
void wr_spot_light_set_color(WrSpotLight *light, const float *color);
void wr_spot_light_set_intensity(WrSpotLight *light, float intensity);
void wr_spot_light_set_ambient_intensity(WrSpotLight *light, float ambient_intensity);
void wr_spot_light_set_on(WrSpotLight *light, bool on);
void wr_spot_light_set_cast_shadows(WrSpotLight *light, bool cast_shadows);
/* Expects a 3-component array */
void wr_spot_light_set_position_relative(WrSpotLight *light, const float *position);
void wr_spot_light_set_radius(WrSpotLight *light, float radius);
void wr_spot_light_set_attenuation(WrSpotLight *light, float attenuation_constant, float attenuation_linear,
float attenuation_quadratic);
/* Expects a 3-component array */
void wr_spot_light_set_direction(WrSpotLight *light, const float *direction);
void wr_spot_light_set_beam_width(WrSpotLight *light, float beam_width);
void wr_spot_light_set_cutoff_angle(WrSpotLight *light, float cutoff_angle);
#ifdef __cplusplus
}
#endif
#endif // WR_SPOT_LIGHT_H

View File

@ -0,0 +1,56 @@
#ifndef WR_STATIC_MESH_H
#define WR_STATIC_MESH_H
#ifdef __cplusplus
extern "C" {
#endif
struct WrStaticMesh;
typedef struct WrStaticMesh WrStaticMesh;
/* Creates an axis-aligned box mesh with edge length 1.0f, centered on the origin. */
WrStaticMesh *wr_static_mesh_unit_box_new(bool outline);
/* Creates a cone with radius 1.0f and height 1.0f, centered on the origin with its main axis on +Y. */
WrStaticMesh *wr_static_mesh_unit_cone_new(int subdivision, bool has_side, bool has_bottom);
/* Creates a cylinder mesh with radius 1.0f and height 1.0f, centered on the origin with its main axis on +Y. */
WrStaticMesh *wr_static_mesh_unit_cylinder_new(int subdivision, bool has_side, bool has_top, bool has_bottom, bool outline);
/* Creates a elevation grid mesh with specified dimension, heights and unit spacing, starting at the origin and extending in +X
* and +Z. */
WrStaticMesh *wr_static_mesh_unit_elevation_grid_new(int dimension_x, int dimension_y, const float *height_data,
float thickness, bool outline);
/* Creates a rectangle mesh with an edge length of 1.0f, centered on the origin and perpendicular to +Y. */
WrStaticMesh *wr_static_mesh_unit_rectangle_new(bool outline);
/* Creates a screen-sized quad useful for post-processing */
WrStaticMesh *wr_static_mesh_quad_new();
/* Creates a sphere mesh with a radius of 1.0f, centered on the origin. */
WrStaticMesh *wr_static_mesh_unit_sphere_new(int subdivision, bool ico, bool outline);
/* Creates a capsule with given radius and height, centered on the origin with its main axis on +Y.
Since a capsule cannot simply be scaled when its radius or height changes, they have to be passed as parameters. */
WrStaticMesh *wr_static_mesh_capsule_new(int subdivision, float radius, float height, bool has_side, bool has_top,
bool has_bottom, bool outline);
/* Creates a line set. Each pair of coordinates defines a line. */
WrStaticMesh *wr_static_mesh_line_set_new(int coord_count, const float *coord_data, const float *color_data);
/* Creates a point set. Each coordinate defines a point. */
WrStaticMesh *wr_static_mesh_point_set_new(int coord_count, const float *coord_data, const float *color_data);
/* Creates a triangle mesh using the provided vertex and index data. */
WrStaticMesh *wr_static_mesh_new(int vertex_count, int index_count, const float *coord_data, const float *normal_data,
const float *tex_coord_data, const float *unwrapped_tex_coord_data,
const unsigned int *index_data, bool outline);
void wr_static_mesh_delete(WrStaticMesh *mesh);
/* Returns the bounding sphere in mesh space.
sphere[0]..[2] = center, sphere[3] = radius */
void wr_static_mesh_get_bounding_sphere(WrStaticMesh *mesh, float *sphere);
/* Returns mesh data, NULL can be passed for unwanted data.
This function should be avoided in performance sensitive code as it involves heavy memory operations. */
void wr_static_mesh_read_data(WrStaticMesh *mesh, float *coord_data, float *normal_data, float *tex_coord_data,
unsigned int *index_data);
int wr_static_mesh_get_vertex_count(WrStaticMesh *mesh);
int wr_static_mesh_get_index_count(WrStaticMesh *mesh);
#ifdef __cplusplus
}
#endif
#endif // WR_STATIC_MESH_H

63
include/wren/texture.h Normal file
View File

@ -0,0 +1,63 @@
#ifndef WR_TEXTURE_H
#define WR_TEXTURE_H
#define WR_TEXTURE(x) ((WrTexture *)(x))
#ifdef __cplusplus
extern "C" {
#endif
struct WrTexture;
typedef struct WrTexture WrTexture;
typedef enum WrTextureType {
WR_TEXTURE_TYPE_2D,
WR_TEXTURE_TYPE_RTT,
WR_TEXTURE_TYPE_CUBEMAP,
WR_TEXTURE_TYPE_DRAWABLE
} WrTextureType;
typedef enum WrTextureInternalFormat {
WR_TEXTURE_INTERNAL_FORMAT_RED,
WR_TEXTURE_INTERNAL_FORMAT_RG8,
WR_TEXTURE_INTERNAL_FORMAT_RGB8,
WR_TEXTURE_INTERNAL_FORMAT_RGBA8,
WR_TEXTURE_INTERNAL_FORMAT_R16F,
WR_TEXTURE_INTERNAL_FORMAT_RGB16F,
WR_TEXTURE_INTERNAL_FORMAT_RGBA16F,
WR_TEXTURE_INTERNAL_FORMAT_R32F,
WR_TEXTURE_INTERNAL_FORMAT_RG32F,
WR_TEXTURE_INTERNAL_FORMAT_RGB32F,
WR_TEXTURE_INTERNAL_FORMAT_RGBA32F,
WR_TEXTURE_INTERNAL_FORMAT_DEPTH24_STENCIL8,
WR_TEXTURE_INTERNAL_FORMAT_DEPTH_COMPONENT32F,
WR_TEXTURE_INTERNAL_FORMAT_COUNT
} WrTextureInternalFormat;
typedef enum WrTextureWrapMode {
WR_TEXTURE_WRAP_MODE_REPEAT = 0x2901, // GL_REPEAT
WR_TEXTURE_WRAP_MODE_CLAMP_TO_EDGE = 0x812F, // GL_CLAMP_TO_EDGE
WR_TEXTURE_WRAP_MODE_CLAMP_TO_BORDER = 0x812D // GL_CLAMP_TO_BORDER
} WrTextureWrapMode;
void wr_texture_delete(WrTexture *texture);
void wr_texture_set_internal_format(WrTexture *texture, WrTextureInternalFormat format);
void wr_texture_set_texture_unit(WrTexture *texture, unsigned int unit);
void wr_texture_set_size(WrTexture *texture, int width, int height);
void wr_texture_set_translucent(WrTexture *texture, bool translucent);
void wr_texture_change_data(WrTexture *texture, void *data, int x, int y, int width, int height);
void wr_texture_setup(WrTexture *texture);
int wr_texture_get_width(const WrTexture *texture);
int wr_texture_get_height(const WrTexture *texture);
bool wr_texture_is_translucent(const WrTexture *texture);
WrTextureType wr_texture_get_type(const WrTexture *texture);
unsigned int wr_texture_get_gl_name(const WrTexture *texture);
#ifdef __cplusplus
}
#endif
#endif // WR_TEXTURE_H

31
include/wren/texture_2d.h Normal file
View File

@ -0,0 +1,31 @@
#ifndef WR_TEXTURE_2D_H
#define WR_TEXTURE_2D_H
#ifdef __cplusplus
extern "C" {
#endif
/* Inheritance diagram: WrTexture <- WrTexture2d */
struct WrTexture2d;
typedef struct WrTexture2d WrTexture2d;
/* Use wr_texture_delete(WR_TEXTURE(texture)) to delete an instance */
WrTexture2d *wr_texture_2d_new();
/* This function creates and returns a WrTexture2d instance if a texture with
the given path exists in the cache, or NULL if none is found. */
WrTexture2d *wr_texture_2d_copy_from_cache(const char *file_path);
void wr_texture_2d_set_data(WrTexture2d *texture, const char *data);
/* The file path is used to produce a hash for the texture cache.
If none is provided, a unique string will be generated and used instead. */
void wr_texture_2d_set_file_path(WrTexture2d *texture, const char *file_path);
/* allows this texture to live in the cache even if the scene is reset */
void wr_texture_2d_set_cache_persistency(WrTexture2d *texture, bool is_persistent);
#ifdef __cplusplus
}
#endif
#endif // WR_TEXTURE_2D_H

View File

@ -0,0 +1,34 @@
#ifndef WR_TEXTURE_CUBEMAP_H
#define WR_TEXTURE_CUBEMAP_H
#ifdef __cplusplus
extern "C" {
#endif
#include <wren/texture.h>
/* Inheritance diagram: WrTexture <- WrTextureCubeMap */
struct WrTextureCubeMap;
typedef struct WrTextureCubeMap WrTextureCubeMap;
typedef enum WrTextureOrientation {
WR_TEXTURE_CUBEMAP_RIGHT = 0,
WR_TEXTURE_CUBEMAP_LEFT,
WR_TEXTURE_CUBEMAP_TOP,
WR_TEXTURE_CUBEMAP_BOTTOM,
WR_TEXTURE_CUBEMAP_BACK,
WR_TEXTURE_CUBEMAP_FRONT,
WR_TEXTURE_CUBEMAP_COUNT
} WrTextureOrientation;
/* Use wr_texture_delete(WR_TEXTURE(texture)) to delete an instance */
WrTextureCubeMap *wr_texture_cubemap_new();
void wr_texture_cubemap_set_data(WrTextureCubeMap *texture, const char *data, WrTextureOrientation orientation);
void wr_texture_cubemap_disable_automatic_mip_map_generation(WrTextureCubeMap *texture);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,22 @@
#ifndef WR_TEXTURE_CUBEMAP_BAKER_H
#define WR_TEXTURE_CUBEMAP_BAKER_H
#ifdef __cplusplus
extern "C" {
#endif
#include <wren/texture_2d.h>
#include <wren/texture_cubemap.h>
#include <wren/texture_rtt.h>
WrTextureCubeMap *wr_texture_cubemap_bake_diffuse_irradiance(WrTextureCubeMap *input_cubemap, WrShaderProgram *shader,
unsigned int size);
WrTextureCubeMap *wr_texture_cubemap_bake_specular_irradiance(WrTextureCubeMap *input_cubemap, WrShaderProgram *shader,
unsigned int size);
WrTextureRtt *wr_texture_cubemap_bake_brdf(WrShaderProgram *shader, unsigned int size);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,19 @@
#ifndef WR_TEXTURE_RTT_H
#define WR_TEXTURE_RTT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Inheritance diagram: WrTexture <- WrTextureRtt */
struct WrTextureRtt;
typedef struct WrTextureRtt WrTextureRtt;
WrTextureRtt *wr_texture_rtt_new();
void wr_texture_rtt_enable_initialize_data(WrTextureRtt *texture, bool enable);
#ifdef __cplusplus
}
#endif
#endif // WR_TEXTURE_RTT_H

View File

@ -0,0 +1,25 @@
#ifndef WR_TEXTURE_TRANSFORM_H
#define WR_TEXTURE_TRANSFORM_H
#ifdef __cplusplus
extern "C" {
#endif
struct WrTextureTransform;
typedef struct WrTextureTransform WrTextureTransform;
WrTextureTransform *wr_texture_transform_new();
void wr_texture_transform_delete(WrTextureTransform *transform);
void wr_texture_transform_set_center(WrTextureTransform *transform, float center_x, float center_y);
void wr_texture_transform_set_position(WrTextureTransform *transform, float position_x, float position_y);
void wr_texture_transform_set_rotation(WrTextureTransform *transform, float rotation);
void wr_texture_transform_set_scale(WrTextureTransform *transform, float scale_x, float scale_y);
/* Expects a 2-component array */
void wr_texture_transform_apply_to_uv_coordinate(WrTextureTransform *transform, float *coord);
#ifdef __cplusplus
}
#endif
#endif // WR_TEXTURE_TRANSFORM_H

41
include/wren/transform.h Normal file
View File

@ -0,0 +1,41 @@
#ifndef WR_TRANSFORM_H
#define WR_TRANSFORM_H
#define WR_TRANSFORM(x) ((WrTransform *)(x))
#ifdef __cplusplus
extern "C" {
#endif
/* Inheritance diagram: WrNode <- WrTransform */
struct WrTransform;
typedef struct WrTransform WrTransform;
struct WrNode;
typedef struct WrNode WrNode;
/* Use wr_node_delete(WR_NODE(transform)) to delete an instance */
WrTransform *wr_transform_new();
/* Returns a copy of 'transform' (without children & parent, parent matrices are applied at copy) */
WrTransform *wr_transform_copy(WrTransform *transform);
/* Returns the matrix equivalent to this transformation (column major, parent transforms included) */
const float *wr_transform_get_matrix(WrTransform *transform);
void wr_transform_attach_child(WrTransform *transform, WrNode *child);
void wr_transform_detach_child(WrTransform *transform, WrNode *child);
/* Expects a 3-component array */
void wr_transform_set_position(WrTransform *transform, const float *position);
void wr_transform_set_absolute_position(WrTransform *transform, const float *position);
/* Expects a 4-component array */
void wr_transform_set_orientation(WrTransform *transform, const float *angle_axis);
void wr_transform_set_absolute_orientation(WrTransform *transform, const float *angle_axis);
/* Expects a 3-component array */
void wr_transform_set_scale(WrTransform *transform, const float *scale);
/* Optimization to set both position and orientation of a transform */
void wr_transform_set_position_and_orientation(WrTransform *transform, const float *position, const float *angle_axis);
#ifdef __cplusplus
}
#endif
#endif // WR_TRANSFORM_H

69
include/wren/viewport.h Normal file
View File

@ -0,0 +1,69 @@
#ifndef WR_VIEWPORT_H
#define WR_VIEWPORT_H
#ifdef __cplusplus
extern "C" {
#endif
struct WrViewport;
typedef struct WrViewport WrViewport;
struct WrCamera;
typedef struct WrCamera WrCamera;
struct WrFrameBuffer;
typedef struct WrFrameBuffer WrFrameBuffer;
struct WrOverlay;
typedef struct WrOverlay WrOverlay;
struct WrPostProcessingEffect;
typedef struct WrPostProcessingEffect WrPostProcessingEffect;
typedef enum WrViewportPolygonMode {
WR_VIEWPORT_POLYGON_MODE_POINT = 0x1B00, // GL_POINT
WR_VIEWPORT_POLYGON_MODE_LINE = 0x1B01, // GL_LINE
WR_VIEWPORT_POLYGON_MODE_FILL = 0x1B02 // GL_FILL
} WrViewportPolygonMode;
WrViewport *wr_viewport_new();
void wr_viewport_delete(WrViewport *viewport);
/* Expects a 3-component array */
void wr_viewport_set_clear_color_rgb(WrViewport *viewport, const float *color);
/* Expects a 4-component array */
void wr_viewport_set_clear_color_rgba(WrViewport *viewport, const float *color);
void wr_viewport_set_polygon_mode(WrViewport *viewport, WrViewportPolygonMode mode);
void wr_viewport_set_visibility_mask(WrViewport *viewport, int mask);
void wr_viewport_set_size(WrViewport *viewport, int width, int height);
void wr_viewport_set_pixel_ratio(WrViewport *viewport, int ratio);
void wr_viewport_set_camera(WrViewport *viewport, WrCamera *camera);
void wr_viewport_set_frame_buffer(WrViewport *viewport, WrFrameBuffer *frame_buffer);
void wr_viewport_enable_shadows(WrViewport *viewport, bool enable);
void wr_viewport_enable_skybox(WrViewport *viewport, bool enable);
/* Allows or not the viewport to modify the camera aspect ratio when its size changes */
void wr_viewport_sync_aspect_ratio_with_camera(WrViewport *viewport, bool enable);
void wr_viewport_attach_overlay(WrViewport *viewport, WrOverlay *overlay);
void wr_viewport_detach_overlay(WrViewport *viewport, WrOverlay *overlay);
/* Use these functions only if you are not re-rendering the viewport but you want to force the overlay(s) to be repainted */
void wr_viewport_render_overlay(WrViewport *viewport, WrOverlay *overlay);
void wr_viewport_render_overlays(WrViewport *viewport);
void wr_viewport_add_post_processing_effect(WrViewport *viewport, WrPostProcessingEffect *post_processing_effect);
void wr_viewport_remove_post_processing_effect(WrViewport *viewport, WrPostProcessingEffect *post_processing_effect);
void wr_viewport_set_ambient_occlusion_effect(WrViewport *viewport, WrPostProcessingEffect *ambient_occlusion_effect);
void wr_viewport_set_anti_aliasing_effect(WrViewport *viewport, WrPostProcessingEffect *anti_aliasing_effect);
int wr_viewport_get_width(WrViewport *viewport);
int wr_viewport_get_height(WrViewport *viewport);
WrCamera *wr_viewport_get_camera(WrViewport *viewport);
WrFrameBuffer *wr_viewport_get_frame_buffer(WrViewport *viewport);
#ifdef __cplusplus
}
#endif
#endif // WR_VIEWPORT_H