worldsim/include/phyobject.h

00001 /********************************************************************************
00002  *  WorldSim -- library for robot simulations                                   *
00003  *  Copyright (C) 2008-2011 Gianluca Massera <emmegian@yahoo.it>                *
00004  *                                                                              *
00005  *  This program is free software; you can redistribute it and/or modify        *
00006  *  it under the terms of the GNU General Public License as published by        *
00007  *  the Free Software Foundation; either version 2 of the License, or           *
00008  *  (at your option) any later version.                                         *
00009  *                                                                              *
00010  *  This program is distributed in the hope that it will be useful,             *
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of              *
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
00013  *  GNU General Public License for more details.                                *
00014  *                                                                              *
00015  *  You should have received a copy of the GNU General Public License           *
00016  *  along with this program; if not, write to the Free Software                 *
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA  *
00018  ********************************************************************************/
00019 
00020 #ifndef PHYOBJECT_H
00021 #define PHYOBJECT_H
00022 
00023 #include "worldsimconfig.h"
00024 #include "wvector.h"
00025 #include "wmatrix.h"
00026 #include "wquaternion.h"
00027 #include "world.h"
00028 
00029 namespace farsa {
00030 
00031 class PhyJoint;
00032 class PhyObjectPrivate;
00033 class WorldPrivate;
00034 class PhyCompoundObject;
00035 
00046 class FARSA_WSIM_API PhyObject : public WObject {
00047     Q_OBJECT
00048 public:
00054     PhyObject( World* world, QString name="unamed", const wMatrix& tm = wMatrix::identity(), bool cp = true );
00056     virtual ~PhyObject();
00057 
00067     void setKinematic(bool b, bool c = false);
00068 
00072     bool getKinematic() const
00073     {
00074         return isKinematic;
00075     }
00076 
00082     void setStatic(bool b);
00083 
00087     bool getStatic() const
00088     {
00089         return isStatic;
00090     }
00091     
00098     void reset();
00099     
00100     void addForce( const wVector& force );
00101     void setForce( const wVector& force);
00102     wVector force();
00103     
00104     void addTorque( const wVector& torque );
00105     void setTorque( const wVector& torque );
00106     wVector torque();
00107     
00109     void setMassInertiaVec( const wVector& );
00111     wVector massInertiaVec() const;
00112     wVector inertiaVec() const;
00113     wVector invMassInertiaVec() const;
00115     wVector invInertiaVec() const;
00117     void setMass( real );
00119     real mass();
00120 
00121     void setOmega( const wVector& omega );
00122     wVector omega();
00123     void setVelocity( const wVector& velocity );
00124     wVector velocity();
00125     void addImpulse( const wVector& pointDeltaVeloc, const wVector& pointPosit );
00126     void setMaterial( QString material );
00127     QString material() const;
00128 private:
00130     QString materialv;
00132     wVector forceAcc;
00134     wVector torqueAcc;
00136     bool isKinematic;
00138     bool isStatic;
00140     wVector objInertiaVec;
00142     wVector objInvInertiaVec;
00143 protected:
00145     virtual void changedMatrix();
00147     PhyObjectPrivate* priv;
00148     WorldPrivate* worldpriv;
00149     friend class PhyObjectPrivate;
00150     friend class WorldPrivate;
00151     friend class PhyJoint;
00152     friend class World;
00153     friend class PhyCompoundObject;
00154     void createPrivateObject();
00155 };
00156 
00157 } // end namespace farsa
00158 
00159 #endif