23 #include "worldsimconfig.h"
26 #include "wquaternion.h"
32 #include <QLinkedList>
36 #include <QTimerEvent>
45 class MotorController;
48 inline uint qHash(
const QPair<PhyObject*, PhyObject*>& pair ) {
50 return ( ::qHash( (
long int)(pair.first) ) );
52 return ( ::qHash( (
int)(pair.first) ) );
109 texturev = textureName;
115 void setColor( QColor c ) {
118 void setAlpha(
int alpha ) {
119 colorv.setAlpha( alpha );
121 QColor color()
const {
126 return usecolortextureofowner;
130 usecolortextureofowner = b;
203 bool createMaterial( QString name );
210 void setFrictions( QString mat1, QString mat2, real st, real kn );
215 void setElasticity( QString mat1, QString mat2, real );
220 void setSoftness( QString mat1, QString mat2, real );
224 void setGravityForce( QString mat, real force );
227 real gravityForce( QString mat );
233 void enableCollision( QString mat1, QString mat2,
bool enable =
true );
242 void setProperties( QString mat1, QString mat2, real fs, real fk, real el, real sf,
bool en =
true );
248 class materialPairInfo {
251 real dynamicFriction;
259 QMap<QString, real> gravities;
271 QHash<QString, materialPairInfo> pmap;
274 QString createKey( QString mat1, QString mat2 );
305 typedef QVector<Contact> contactVec;
307 typedef QHash<PhyObject*, contactVec> contactMap;
309 typedef QHashIterator<PhyObject*, contactVec> contactMapIterator;
339 typedef QVector<RayCastHit> rayCastHitVector;
351 class FARSA_WSIM_API
World :
public QObject {
359 World( QString worldname,
bool LocalYarpPorts=
false );
363 QString name()
const;
365 real elapsedTime()
const;
367 void resetElapsedTime();
369 void setTimeStep( real );
372 void setMinimumFrameRate(
unsigned int frames );
374 void setIsRealTime(
bool b );
376 bool isRealTime()
const;
378 real timeStep()
const;
380 void setGravityForce( real g );
382 real gravityForce()
const;
384 const QLinkedList<WObject*> objects();
386 WObject* getObject( QString name );
388 const QLinkedList<PhyJoint*> joints();
390 const QHash<WObject*, QList<PhyJoint*> > mapObjectsToJoints();
396 void advanceUntil( real time );
407 const contactMap& contacts();
426 bool checkContacts(
PhyObject* obj1,
PhyObject* obj2,
int maxContacts = 4, QVector<wVector>* contacts = NULL, QVector<wVector>* normals = NULL, QVector<real>* penetra = NULL );
437 bool smartCheckContacts(
PhyObject* obj1,
PhyObject* obj2,
int maxContacts = 4, QVector<wVector>* contacts = NULL );
461 rayCastHitVector worldRayCast(
wVector start,
wVector end,
bool onlyClosest,
const QSet<PhyObject*>& ignoredObjs = QSet<PhyObject*>() );
469 void setSolverModel( QString model );
471 void setFrictionModel( QString model );
473 void setMultiThread(
int numThreads );
507 void cleanUpMemory();
542 void removedObject(
WObject* );
574 void timerEvent( QTimerEvent* e );
576 void customEvent( QEvent* e );
579 enum { E_Advance = 1200, E_Play = 1201, E_Stop = 1202, E_Pause = 1203 };
588 typedef QPair<PhyObject*, PhyObject*> NObj;
607 unsigned int timerId;
613 friend class WorldPrivate;