23 #include "worldsimconfig.h"
25 #include "wquaternion.h"
30 #include <QLinkedList>
34 #include <QTimerEvent>
43 class MotorController;
46 inline uint qHash(
const QPair<PhyObject*, PhyObject*>& pair ) {
48 return ( ::qHash( (
long int)(pair.first) ) );
50 return ( ::qHash( (
int)(pair.first) ) );
72 bool createMaterial( QString name );
79 void setFrictions( QString mat1, QString mat2, real st, real kn );
84 void setElasticity( QString mat1, QString mat2, real );
89 void setSoftness( QString mat1, QString mat2, real );
93 void setGravityForce( QString mat, real force );
96 real gravityForce( QString mat );
102 void enableCollision( QString mat1, QString mat2,
bool enable =
true );
111 void setProperties( QString mat1, QString mat2, real fs, real fk, real el, real sf,
bool en =
true );
117 class materialPairInfo {
120 real dynamicFriction;
128 QMap<QString, real> gravities;
140 QHash<QString, materialPairInfo> pmap;
143 QString createKey( QString mat1, QString mat2 );
176 typedef QVector<Contact> contactVec;
178 typedef QHash<PhyObject*, contactVec> contactMap;
180 typedef QHashIterator<PhyObject*, contactVec> contactMapIterator;
210 typedef QVector<RayCastHit> rayCastHitVector;
222 class FARSA_WSIM_API
World :
public QObject {
230 World( QString worldname,
bool LocalYarpPorts=
false );
234 QString name()
const;
236 real elapsedTime()
const;
238 void resetElapsedTime();
240 void setTimeStep( real );
243 void setMinimumFrameRate(
unsigned int frames );
245 void setIsRealTime(
bool b );
247 bool isRealTime()
const;
249 real timeStep()
const;
251 void setGravityForce( real g );
253 real gravityForce()
const;
255 const QLinkedList<WObject*> objects();
257 WObject* getObject( QString name );
259 const QLinkedList<PhyJoint*> joints();
261 const QHash<WObject*, QList<PhyJoint*> > mapObjectsToJoints();
267 void advanceUntil( real time );
278 const contactMap& contacts();
297 bool checkContacts(
PhyObject* obj1,
PhyObject* obj2,
int maxContacts = 4, QVector<wVector>* contacts = NULL, QVector<wVector>* normals = NULL, QVector<real>* penetra = NULL );
308 bool smartCheckContacts(
PhyObject* obj1,
PhyObject* obj2,
int maxContacts = 4, QVector<wVector>* contacts = NULL );
332 rayCastHitVector worldRayCast(
wVector start,
wVector end,
bool onlyClosest,
const QSet<PhyObject*>& ignoredObjs = QSet<PhyObject*>() );
340 void setSolverModel( QString model );
342 void setFrictionModel( QString model );
344 void setMultiThread(
int numThreads );
378 void cleanUpMemory();
413 void removedObject(
WObject* );
445 void timerEvent( QTimerEvent* e );
447 void customEvent( QEvent* e );
450 enum { E_Advance = 1200, E_Play = 1201, E_Stop = 1202, E_Pause = 1203 };
459 typedef QPair<PhyObject*, PhyObject*> NObj;
478 unsigned int timerId;
484 friend class WorldPrivate;