23 #include "worldsimconfig.h"
25 #include "wquaternion.h"
30 #include <QLinkedList>
34 #include <QTimerEvent>
44 class MotorController;
47 inline uint qHash(
const QPair<PhyObject*, PhyObject*>& pair ) {
49 return ( ::qHash( (
long int)(pair.first) ) );
51 return ( ::qHash( (
int)(pair.first) ) );
73 bool createMaterial( QString name );
80 void setFrictions( QString mat1, QString mat2,
real st,
real kn );
85 void setElasticity( QString mat1, QString mat2,
real );
90 void setSoftness( QString mat1, QString mat2,
real );
94 void setGravityForce( QString mat,
real force );
97 real gravityForce( QString mat );
103 void enableCollision( QString mat1, QString mat2,
bool enable =
true );
112 void setProperties( QString mat1, QString mat2,
real fs,
real fk,
real el,
real sf,
bool en =
true );
118 class materialPairInfo {
121 real dynamicFriction;
129 QMap<QString, real> gravities;
141 QHash<QString, materialPairInfo> pmap;
144 QString createKey( QString mat1, QString mat2 );
177 typedef QVector<Contact> contactVec;
179 typedef QHash<PhyObject*, contactVec> contactMap;
181 typedef QHashIterator<PhyObject*, contactVec> contactMapIterator;
211 typedef QVector<RayCastHit> rayCastHitVector;
223 class FARSA_WSIM_API
World :
public QObject {
229 World( QString worldname );
233 QString name()
const;
235 real elapsedTime()
const;
237 void resetElapsedTime();
239 void setTimeStep(
real );
242 void setMinimumFrameRate(
unsigned int frames );
244 void setIsRealTime(
bool b );
246 bool isRealTime()
const;
248 real timeStep()
const;
250 void setGravityForce(
real g );
252 real gravityForce()
const;
254 const QLinkedList<WObject*> objects();
256 WObject* getObject( QString name );
258 const QLinkedList<PhyJoint*> joints();
260 const QHash<WObject*, QList<PhyJoint*> > mapObjectsToJoints();
266 void advanceUntil(
real time );
277 const contactMap& contacts();
296 bool checkContacts(
PhyObject* obj1,
PhyObject* obj2,
int maxContacts = 4, QVector<wVector>* contacts = NULL, QVector<wVector>* normals = NULL, QVector<real>* penetra = NULL );
307 bool smartCheckContacts(
PhyObject* obj1,
PhyObject* obj2,
int maxContacts = 4, QVector<wVector>* contacts = NULL );
331 rayCastHitVector worldRayCast(
wVector start,
wVector end,
bool onlyClosest,
const QSet<PhyObject*>& ignoredObjs = QSet<PhyObject*>() );
339 void setSolverModel( QString model );
341 void setFrictionModel( QString model );
343 void setMultiThread(
int numThreads );
377 void cleanUpMemory();
412 void removedObject(
WObject* );
444 void timerEvent( QTimerEvent* e );
446 void customEvent( QEvent* e );
449 enum { E_Advance = 1200, E_Play = 1201, E_Stop = 1202, E_Pause = 1203 };
458 typedef QPair<PhyObject*, PhyObject*> NObj;
477 unsigned int timerId;
483 friend class WorldPrivate;
Raycast intersection class.
the MaterialDB class managea the material properties
QHash< WObject *, QList< PhyJoint * > > mapObjJoints
Map object -> joints.
real timestepv
The time step.
real distance
The distance from start at which the ray intersects the object.
real time
The elapsed simulation-time from last calls of initialize()
wVector normal
The normal at the hit point in the global frame of reference.
real gforce
Gravity Force.
QLinkedList< WObject * > objs
Vector of WObject inside the World.
World * world()
return the world associate with these materials
w_state status()
return the actual state
wVector minP
Size of the Newton world.
w_state
define the state of the World
MaterialDB & materials()
return the MaterialDB object for managing World's materials
PhyObject * object
Object intersected by the ray.
wVector position
The actual point at which the ray intersects the object in the global frame of reference.
QLinkedList< PhyJoint * > jointsv
Vector of Joints inside the World.