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  bool isCollidable() const
83  {
84  return !isKinematic || isKinematicCollidable;
85  }
86 
92  void setStatic(bool b);
93 
97  bool getStatic() const
98  {
99  return isStatic;
100  }
101 
108  void reset();
109 
110  void addForce( const wVector& force );
111  void setForce( const wVector& force);
112  wVector force();
113 
114  void addTorque( const wVector& torque );
115  void setTorque( const wVector& torque );
116  wVector torque();
117 
119  void setMassInertiaVec( const wVector& );
121  wVector massInertiaVec() const;
122  wVector inertiaVec() const;
123  wVector invMassInertiaVec() const;
125  wVector invInertiaVec() const;
127  void setMass( real );
129  real mass();
130 
131  void setOmega( const wVector& omega );
132  wVector omega();
133  void setVelocity( const wVector& velocity );
134  wVector velocity();
135  void addImpulse( const wVector& pointDeltaVeloc, const wVector& pointPosit );
136  void setMaterial( QString material );
137  QString material() const;
138 private:
140  QString materialv;
142  wVector forceAcc;
144  wVector torqueAcc;
146  bool isKinematic;
148  bool isKinematicCollidable;
150  bool isStatic;
152  wVector objInertiaVec;
154  wVector objInvInertiaVec;
155 protected:
157  virtual void changedMatrix();
159  PhyObjectPrivate* priv;
160  WorldPrivate* worldpriv;
161  friend class PhyObjectPrivate;
162  friend class WorldPrivate;
163  friend class PhyJoint;
164  friend class World;
165  friend class PhyCompoundObject;
166  void createPrivateObject();
167 };
168 
169 } // end namespace farsa
170 
171 #endif
bool getKinematic() const
Returns true if the object has kinematic behaviour.
Definition: phyobject.h:72
World's Object class.
Definition: wobject.h:39
static wMatrix identity()
create an identity matrix
Definition: wmatrix.h:460
bool isCollidable() const
Returns true if this object collides with other object.
Definition: phyobject.h:82
bool getStatic() const
Returns true if the object is static.
Definition: phyobject.h:97
World class.
Definition: world.h:223
PhyObjectPrivate * priv
Engine encapsulation.
Definition: phyobject.h:159
PhyJoint class.
Definition: phyjoint.h:359
wMatrix class
Definition: wmatrix.h:48
PhyCompoundObject class.
float real
PhyObject class.
Definition: phyobject.h:46