00001 //=========================================================================== 00002 /* 00003 This file is part of the CHAI 3D visualization and haptics libraries. 00004 Copyright (C) 2003-2009 by CHAI 3D. All rights reserved. 00005 00006 This library is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License("GPL") version 2 00008 as published by the Free Software Foundation. 00009 00010 For using the CHAI 3D libraries with software that can not be combined 00011 with the GNU GPL, and for taking advantage of the additional benefits 00012 of our support services, please contact CHAI 3D about acquiring a 00013 Professional Edition License. 00014 00015 \author <http://www.chai3d.org> 00016 \author Francois Conti 00017 \version 2.0.0 $Rev: 251 $ 00018 */ 00019 //=========================================================================== 00020 00021 //--------------------------------------------------------------------------- 00022 #ifndef CODEWorldH 00023 #define CODEWorldH 00024 //--------------------------------------------------------------------------- 00025 #include "chai3d.h" 00026 #include "CODEGenericBody.h" 00027 //--------------------------------------------------------------------------- 00028 00029 //=========================================================================== 00037 //=========================================================================== 00038 00039 00040 //=========================================================================== 00049 //=========================================================================== 00050 class cODEWorld : public cGenericObject 00051 { 00052 public: 00053 00054 //----------------------------------------------------------------------- 00055 // CONSTRUCTOR & DESTRUCTOR: 00056 //----------------------------------------------------------------------- 00057 00059 cODEWorld(cWorld* a_parentWorld); 00060 00062 ~cODEWorld(); 00063 00064 // PROPERTIES: 00066 list<cODEGenericBody*> m_bodies; 00067 00068 00069 //----------------------------------------------------------------------- 00070 // METHODS: 00071 //----------------------------------------------------------------------- 00072 00074 void setGravity(cVector3d a_gravity); 00075 00077 cVector3d getGravity(); 00078 00080 void setLinearDamping(double a_value) { dWorldSetLinearDamping(m_ode_world, a_value); } 00081 00083 void setAngularDamping(double a_value) { dWorldSetAngularDamping(m_ode_world, a_value); } 00084 00086 void setMaxAngularSpeed(double a_value) { dWorldSetMaxAngularSpeed(m_ode_world, a_value); } 00087 00089 void updateDynamics(double a_interval); 00090 00092 void updateBodyPositions(void); 00093 00094 // update global position frames. 00095 void updateGlobalPositions(const bool a_frameOnly); 00096 00097 00098 //----------------------------------------------------------------------- 00099 // MEMBERS: 00100 //----------------------------------------------------------------------- 00101 00103 dWorldID m_ode_world; 00104 00106 dSpaceID m_ode_space; 00107 00109 dJointGroupID m_ode_contactgroup; 00110 00111 00112 private: 00113 00114 //----------------------------------------------------------------------- 00115 // MEMBERS: 00116 //----------------------------------------------------------------------- 00117 00119 double m_simulationTime; 00120 00122 cWorld* m_parentWorld; 00123 00124 00125 //----------------------------------------------------------------------- 00126 // METHODS: 00127 //----------------------------------------------------------------------- 00128 00130 static void nearCallback (void *data, dGeomID o1, dGeomID o2); 00131 00133 virtual void render(const int a_renderMode=CHAI_RENDER_MODE_RENDER_ALL); 00134 }; 00135 00136 00137 //=========================================================================== 00143 //=========================================================================== 00144 class cODEWorldCollision : public cGenericCollision 00145 { 00146 public: 00147 00148 //----------------------------------------------------------------------- 00149 // CONSTRUCTOR & DESTRUCTOR: 00150 //----------------------------------------------------------------------- 00151 00153 cODEWorldCollision(cODEWorld* a_ODEWorld) {m_ODEWorld = a_ODEWorld;} 00154 00156 virtual ~cODEWorldCollision() {}; 00157 00158 00159 //----------------------------------------------------------------------- 00160 // METHODS: 00161 //----------------------------------------------------------------------- 00162 00164 virtual void initialize(double a_radius) {}; 00165 00167 virtual void render() {}; 00168 00170 virtual bool computeCollision(cVector3d& a_segmentPointA, 00171 cVector3d& a_segmentPointB, 00172 cCollisionRecorder& a_recorder, 00173 cCollisionSettings& a_settings); 00174 00175 00176 private: 00177 00178 //----------------------------------------------------------------------- 00179 // MEMBERS: 00180 //----------------------------------------------------------------------- 00181 00183 cODEWorld* m_ODEWorld; 00184 }; 00185 00186 00187 //--------------------------------------------------------------------------- 00188 #endif 00189 //---------------------------------------------------------------------------