ODESolid.h

Go to the documentation of this file.
00001 /*************************************************************************
00002  *                                                                       *
00003  * Open Physics Abstraction Layer                                        *
00004  * Copyright (C) 2004-2005                                               *
00005  * Alan Fischer  alan.fischer@gmail.com                                  *
00006  * Andres Reinot  andres@reinot.com                                      *
00007  * Tyler Streeter  tylerstreeter@gmail.com                               *
00008  * All rights reserved.                                                  *
00009  * Web: opal.sourceforge.net                                             *
00010  *                                                                       *
00011  * This library is free software; you can redistribute it and/or         *
00012  * modify it under the terms of EITHER:                                  *
00013  *   (1) The GNU Lesser General Public License as published by the Free  *
00014  *       Software Foundation; either version 2.1 of the License, or (at  *
00015  *       your option) any later version. The text of the GNU Lesser      *
00016  *       General Public License is included with this library in the     *
00017  *       file license-LGPL.txt.                                          *
00018  *   (2) The BSD-style license that is included with this library in     *
00019  *       the file license-BSD.txt.                                       *
00020  *                                                                       *
00021  * This library is distributed in the hope that it will be useful,       *
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files    *
00024  * license-LGPL.txt and license-BSD.txt for more details.                *
00025  *                                                                       *
00026  *************************************************************************/
00027 
00028 #ifndef OPAL_ODE_SOLID_H
00029 #define OPAL_ODE_SOLID_H
00030 
00031 #include <ode/ode.h>
00032 #include "../Defines.h"
00033 #include "../Solid.h"
00034 #include "../Blueprint.h"
00035 
00036 namespace opal
00037 {
00040         struct GeomData
00041         {
00042                 GeomData()
00043                 {
00044                         solid = NULL;
00045                         shape = NULL;
00046                         geomID = 0;
00047                         spaceID = 0;
00048                         transformID = 0;
00049                         trimeshDataID = 0;
00050                 }
00051 
00052                 Solid* solid;
00053                 ShapeData* shape;
00054                 dGeomID geomID;
00055                 dSpaceID spaceID;
00056                 dGeomID transformID;
00057                 dTriMeshDataID trimeshDataID; // only used for Solids with trimeshes
00058         };
00059 
00062         class ODESolid : public Solid
00063         {
00064         public:
00065                 ODESolid(dWorldID worldID, dSpaceID spaceID);
00066 
00067                 virtual ~ODESolid();
00068 
00069                 virtual void OPAL_CALL init(const SolidData& data);
00070 
00071                 virtual void OPAL_CALL setEnabled(bool e);
00072 
00073                 virtual void OPAL_CALL setSleeping(bool sleeping);
00074 
00075                 virtual void OPAL_CALL setSpace(Space* newSpace);
00076 
00077                 virtual bool OPAL_CALL isSleeping()const;
00078 
00079                 virtual void OPAL_CALL setSleepiness(real s);
00080 
00081                 virtual void OPAL_CALL setStatic(bool s);
00082 
00083                 virtual void OPAL_CALL clearShapes();
00084 
00085                 virtual void OPAL_CALL addShape(ShapeData& data);
00086 
00087                 virtual void OPAL_CALL setLocalLinearVel(const Vec3r& vel);
00088 
00089                 virtual Vec3r OPAL_CALL getLocalLinearVel()const;
00090 
00091                 virtual Vec3r OPAL_CALL getLocalLinearVelAtLocalPos(
00092                         const Point3r& p)const;
00093 
00094                 virtual void OPAL_CALL setLocalAngularVel(const Vec3r& vel);
00095 
00096                 virtual Vec3r OPAL_CALL getLocalAngularVel()const;
00097 
00098                 virtual void OPAL_CALL setGlobalLinearVel(const Vec3r& vel);
00099 
00100                 virtual Vec3r OPAL_CALL getGlobalLinearVel()const;
00101 
00102                 virtual Vec3r OPAL_CALL getGlobalLinearVelAtLocalPos(
00103                         const Point3r& p)const;
00104 
00105                 virtual void OPAL_CALL setGlobalAngularVel(const Vec3r& vel);
00106 
00107                 virtual Vec3r OPAL_CALL getGlobalAngularVel()const;
00108 
00109                 virtual void OPAL_CALL setMass( const Mass & newmass, const Matrix44r & offset );
00110 
00111                 virtual void OPAL_CALL translateMass(const Vec3r& offset);
00112 
00115                 //virtual void OPAL_CALL setFastRotation(bool fast);
00116 
00117                 //virtual bool OPAL_CALL getFastRotation()const;
00118 
00119                 //virtual void OPAL_CALL setFastRotationAxis(Vec3r axis);
00120 
00121                 virtual void OPAL_CALL zeroForces();
00122 
00123                 virtual real OPAL_CALL getMass()const;
00124 
00125                 virtual Matrix44r OPAL_CALL getInertiaTensor()const;
00126 
00127                 virtual void OPAL_CALL internal_updateOPALTransform();
00128 
00129                 virtual void OPAL_CALL internal_updateEngineTransform();
00130 
00132                 dBodyID OPAL_CALL internal_getBodyID()const;
00133 
00135                 void OPAL_CALL internal_setCollisionCount(long int count);
00136 
00138                 long int OPAL_CALL internal_getCollisionCount()const;
00139 
00141                 const std::vector<GeomData*>* OPAL_CALL internal_getGeomDataList()const;
00142 
00146                 void OPAL_CALL internal_doAngularVelFix();
00147 
00151                 void OPAL_CALL internal_setFreelySpinning(bool fs);
00152 
00153         protected:
00156                 void setupNewGeom(GeomData* newGeom);
00157 
00159                 void destroyGeoms();
00160 
00162                 void moveToSpace();
00163 
00164                 virtual void applyForce(const Force& f);
00165 
00169                 void addMass(dMass& newMass, const Matrix44r& offset);
00170 
00172                 void setMass(dMass& newMass, const Matrix44r& offset);
00173 
00175                 bool isInertiaNonSymmetric(const dMass& mass)const;
00176 
00178                 dBodyID mBodyID;
00179 
00182                 dWorldID mWorldID;
00183 
00185                 dSpaceID mSpaceID;
00186 
00188                 std::vector<GeomData*> mGeomDataList;
00189 
00191                 long int mCollisionCount;
00192 
00195                 bool mIsPlaceable;
00196 
00198                 bool mNonSymmetricInertia;
00199 
00202                 bool mIsFreelySpinning;
00203 
00206                 real mPrevAngVelMagSquared;
00207 
00208         private:
00209         };
00210 }
00211 
00212 #endif

Generated on Tue May 16 17:49:51 2006 for OPAL by  doxygen 1.4.6-NO