- Main Page
- Modules
- Classes
- Files

- File List
- File Members

# D:/CHAI3D/build-2-0-0/2.0.0/win32/modules/ODE/CODEGenericBody.h

Go to the documentation of this file.

    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 CODEGenericBodyH
    00023 #define CODEGenericBodyH
    00024 //---------------------------------------------------------------------------
    00025 #include "ode/ode.h"
    00026 #include "chai3d.h"
    00027 //---------------------------------------------------------------------------
    00028
    00029 //===========================================================================
    00037 //===========================================================================
    00038
    00039 //---------------------------------------------------------------------------
    00040 class cODEWorld;
    00041 //---------------------------------------------------------------------------
    00043 enum cODEDynamicModelType
    00044 {
    00045     ODE_MODEL_BOX,
    00046     ODE_MODEL_SPHERE,
    00047     ODE_MODEL_CYLINDER,
    00048     ODE_MODEL_PLANE,
    00049     ODE_MODEL_TRIMESH
    00050 };
    00051 //---------------------------------------------------------------------------
    00052
    00053 //===========================================================================
    00061 //===========================================================================
    00062 class cODEGenericBody : public cGenericObject
    00063 {
    00064
    00065   public:
    00066
    00067     //-----------------------------------------------------------------------
    00068     // CONSTRUCTOR & DESTRUCTOR:
    00069     //-----------------------------------------------------------------------
    00070
    00072                 cODEGenericBody(cODEWorld* a_world) { initialize(a_world); }
    00073
    00075     virtual ~cODEGenericBody() {};
    00076
    00077
    00078         //-----------------------------------------------------------------------
    00079     // METHODS:
    00080     //-----------------------------------------------------------------------
    00081
    00083     void setPosition(cVector3d &a_position);
    00084
    00086     void setRotation(cMatrix3d &a_rotation);
    00087
    00089     void updateBodyPosition(void);
    00090
    00092     void addGlobalForceAtGlobalPos(cVector3d& a_force, cVector3d& a_pos);
    00093
    00095     void setMass(double a_mass);
    00096
    00098     double getMass() { return (m_mass); }
    00099
    00101     void setImageModel(cGenericObject* a_imageModel);
    00102
    00104     cGenericObject* getImageModel() { return (m_imageModel); }
    00105
    00107     void enableDynamics();
    00108
    00110     void disableDynamics();
    00111
    00113     bool isStatic() { return (m_static); }
    00114
    00116         virtual void buildDynamicModel() {};
    00117
    00119     void createDynamicBoundingBox(bool a_staticObject = false);
    00120
    00122         void createDynamicSphere(const double a_radius,
    00123                                                          bool a_staticObject = false,
    00124                              const cVector3d& a_offsetPos = cVector3d(0.0, 0.0, 0.0),
    00125                              const cMatrix3d& a_offsetRot = cIdentity3d());
    00126
    00128         void createDynamicBox(const double a_lengthX, const double a_lengthY, const double a_lengthZ,
    00129                           bool a_staticObject = false,
    00130                                                   const cVector3d& a_offsetPos = cVector3d(0.0, 0.0, 0.0),
    00131                           const cMatrix3d& a_offsetRot = cIdentity3d());
    00132
    00134         void createDynamicCapsule(const double a_radius, const double a_length,
    00135                               bool a_staticObject = false,
    00136                                                       const cVector3d& a_offsetPos = cVector3d(0.0, 0.0, 0.0),
    00137                               const cMatrix3d& a_offsetRot = cIdentity3d());
    00138
    00140         void createStaticPlane(const cVector3d& a_position,
    00141                            const cVector3d& a_normal);
    00142
    00144         void createDynamicMesh(bool a_staticObject = false,
    00145                            const cVector3d& a_offsetPos = cVector3d(0.0, 0.0, 0.0),
    00146                            const cMatrix3d& a_offsetRot = cIdentity3d());
    00147
    00149     void updateGlobalPositions(const bool a_frameOnly);
    00150
    00152     void render(const int a_renderMode);
    00153
    00155     void setShowDynamicCollisionModel(const bool a_show) { m_showDynamicCollisionModel = a_show; }
    00156
    00158     bool getShowDynamicCollisionModel() { return(m_showDynamicCollisionModel); }
    00159
    00161     cODEWorld* m_ODEWorld;
    00162
    00164     cGenericObject* m_imageModel;
    00165
    00166
    00167   private:
    00168
    00169         //-----------------------------------------------------------------------
    00170     // MEMBERS:
    00171     //-----------------------------------------------------------------------
    00172
    00174     bool m_static;
    00175
    00177     dBodyID m_ode_body;
    00178
    00180     dMass m_ode_mass;
    00181
    00183     double m_mass;
    00184
    00186     dGeomID m_ode_geom;
    00187
    00189     float* m_vertices;
    00190
    00192     int* m_vertexIndices;
    00193
    00195     double m_prevTransform[16];
    00196
    00198     dTriMeshDataID m_ode_triMeshDataID;
    00199
    00201     bool m_showDynamicCollisionModel;
    00202
    00204     cColorf m_colorDynamicCollisionModel;
    00205
    00207     cODEDynamicModelType m_typeDynamicCollisionModel;
    00208
    00214     double m_paramDynColModel0;
    00215     double m_paramDynColModel1;
    00216     double m_paramDynColModel2;
    00217     cVector3d m_posOffsetDynColModel;
    00218     cMatrix3d m_rotOffsetDynColModel;
    00219
    00221     int buildMeshTable(cMesh* a_mesh, int& a_indexOffset, int& a_verticesCount, int& a_indexCount);
    00222
    00224     void initialize(cODEWorld* a_world);
    00225
    00227     virtual bool computeOtherCollisionDetection(cVector3d& a_segmentPointA,
    00228                                                 cVector3d& a_segmentPointB,
    00229                                                 cCollisionRecorder& a_recorder,
    00230                                                 cCollisionSettings& a_settings);
    00231 };
    00232
    00233
    00234 //---------------------------------------------------------------------------
    00235 #endif
    00236 //---------------------------------------------------------------------------

CHAI3D 2.0.0 documentation
Please address any questions to support@chai3d.org
(C) 2003-2009 - CHAI 3D
All Rights Reserved.