00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef OPAL_ODE_SIMULATOR_H
00029 #define OPAL_ODE_SIMULATOR_H
00030
00031
00032 #include "../Defines.h"
00033 #include "../Simulator.h"
00034 #include "../AccelerationSensor.h"
00035 #include "../InclineSensor.h"
00036 #include "../RaycastSensor.h"
00037 #include "../VolumeSensor.h"
00038 #include "ODESolid.h"
00039 #include "ODEJoint.h"
00040 #include "ODESpace.h"
00041
00042
00043 #include <ode/ode.h>
00044 #include <vector>
00045
00046 namespace opal
00047 {
00049 class ODESimulator : public Simulator
00050 {
00051 public:
00053 enum SolverType
00054 {
00057 SOLVER_WORLDSTEP,
00058
00061 SOLVER_QUICKSTEP };
00062
00064 ODESimulator( );
00065
00067 void initData( SimulatorData data );
00068
00069 virtual ~ODESimulator();
00070
00071 virtual void OPAL_CALL destroy();
00072
00073 virtual void OPAL_CALL setMaxCorrectingVel( real vel );
00074
00075
00076
00077 virtual Solid* OPAL_CALL createSolid();
00078
00079
00080
00081 virtual Joint* OPAL_CALL createJoint();
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 virtual Space* OPAL_CALL createSpace();
00094
00095 virtual void OPAL_CALL setGravity( const Vec3r& gravity );
00096
00097 virtual Vec3r OPAL_CALL getGravity() const;
00098
00099 virtual void OPAL_CALL setSolverAccuracy( SolverAccuracyLevel level );
00100
00101 virtual dWorldID OPAL_CALL internal_getWorldID() const;
00102
00103 virtual dSpaceID OPAL_CALL internal_getSpaceID() const;
00104
00105 virtual dJointGroupID OPAL_CALL internal_getJointGroupID() const;
00106
00107 virtual std::vector<RaycastResult> & OPAL_CALL internal_fireRay(
00108 const Rayr& r, real length, const Solid* attachedSolid,
00109 unsigned int rayContactGroup );
00110
00111 virtual const VolumeQueryResult& OPAL_CALL internal_queryVolume(
00112 const Solid* volume, const Solid* attachedSolid );
00113
00115
00118 void internal_addRaycastResult( Solid* solid,
00119 const Point3r& intersection, const Vec3r& normal, real depth );
00120
00122 void internal_addCollidedSolid( Solid* solid );
00123
00125 virtual unsigned int OPAL_CALL internal_getRayContactGroup();
00126
00127 protected:
00128 virtual void stepPhysics();
00129
00131 dWorldID mWorldID;
00132
00134 dSpaceID mRootSpaceID;
00135
00137 dJointGroupID mContactJointGroupID;
00138
00140 SolverType mSolverType;
00141
00143 long int mCollisionCount;
00144
00147 VolumeQueryResult mVolumeQueryResult;
00148
00153 const Solid* mSensorSolid;
00154
00157 unsigned int mRayContactGroup;
00158
00160 std::vector<RaycastResult> mRaycastResults;
00161 };
00162
00164 namespace ode_hidden
00165 {
00166
00167
00168
00169
00171 void internal_collisionCallback( void* data, dGeomID o0, dGeomID o1 );
00172
00176 Joint* internal_getCommonJoint( dBodyID body0, dBodyID body1 );
00177
00180 void internal_volumeCollisionCallback( void* data, dGeomID o0,
00181 dGeomID o1 );
00182
00185 void internal_raycastCollisionCallback( void* data, dGeomID o0,
00186 dGeomID o1 );
00187
00188
00189
00190
00191 }
00192 }
00193
00194 #endif