phyobject.h
1 /********************************************************************************
2  * WorldSim -- library for robot simulations *
3  * Copyright (C) 2008-2011 Gianluca Massera <emmegian@yahoo.it> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the Free Software *
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
18  ********************************************************************************/
19 
20 #ifndef PHYOBJECT_H
21 #define PHYOBJECT_H
22 
23 #include "worldsimconfig.h"
24 #include "wvector.h"
25 #include "wmatrix.h"
26 #include "wquaternion.h"
27 #include "world.h"
28 
29 namespace farsa {
30 
31 class PhyJoint;
32 class PhyObjectPrivate;
33 class WorldPrivate;
34 class PhyCompoundObject;
35 
46 class FARSA_WSIM_API PhyObject : public WObject {
47  Q_OBJECT
48 public:
54  PhyObject( World* world, QString name="unamed", const wMatrix& tm = wMatrix::identity(), bool cp = true );
56  virtual ~PhyObject();
57 
67  void setKinematic(bool b, bool c = false);
68 
72  bool getKinematic() const
73  {
74  return isKinematic;
75  }
76 
82  void setStatic(bool b);
83 
87  bool getStatic() const
88  {
89  return isStatic;
90  }
91 
98  void reset();
99 
100  void addForce( const wVector& force );
101  void setForce( const wVector& force);
102  wVector force();
103 
104  void addTorque( const wVector& torque );
105  void setTorque( const wVector& torque );
106  wVector torque();
107 
109  void setMassInertiaVec( const wVector& );
111  wVector massInertiaVec() const;
112  wVector inertiaVec() const;
113  wVector invMassInertiaVec() const;
115  wVector invInertiaVec() const;
117  void setMass( real );
119  real mass();
120 
121  void setOmega( const wVector& omega );
122  wVector omega();
123  void setVelocity( const wVector& velocity );
124  wVector velocity();
125  void addImpulse( const wVector& pointDeltaVeloc, const wVector& pointPosit );
126  void setMaterial( QString material );
127  QString material() const;
128 private:
130  QString materialv;
132  wVector forceAcc;
134  wVector torqueAcc;
136  bool isKinematic;
138  bool isStatic;
140  wVector objInertiaVec;
142  wVector objInvInertiaVec;
143 protected:
145  virtual void changedMatrix();
147  PhyObjectPrivate* priv;
148  WorldPrivate* worldpriv;
149  friend class PhyObjectPrivate;
150  friend class WorldPrivate;
151  friend class PhyJoint;
152  friend class World;
153  friend class PhyCompoundObject;
154  void createPrivateObject();
155 };
156 
157 } // end namespace farsa
158 
159 #endif