Enki  1.9
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Enki::World Class Reference

The world is the container of all objects and robots. More...

#include <PhysicalEngine.h>

Classes

struct  GroundTexture
 2-D Texture for ground More...
 

Public Types

enum  WallsType { WALLS_SQUARE = 0, WALLS_CIRCULAR, WALLS_NONE }
 Type of walls around the world. More...
 
typedef std::set< PhysicalObject * > Objects
 
typedef Objects::iterator ObjectsIterator
 

Public Member Functions

 World (double width, double height, const Color &wallsColor=Color::gray, const GroundTexture &groundTexture=GroundTexture())
 Construct a world with square walls, takes width and height of the world arena in cm.
 
 World (double r, const Color &wallsColor=Color::gray, const GroundTexture &groundTexture=GroundTexture())
 Construct a world with circle walls, takes radius of the world arena in cm.
 
 World ()
 Construct a world with no walls.
 
virtual ~World ()
 Destructor, destroy all objects.
 
bool hasGroundTexture () const
 Return whether the ground has a texture.
 
Color getGroundColor (const Point &p) const
 Return the color of the ground at a given point, or white.
 
virtual void step (double dt, unsigned physicsOversampling=1)
 Simulate a timestep of dt. dt should be below 1 (typically .02-.1); physicsOversampling is the amount of time the physics is run per step, as usual collisions require a more precise simulation than the sensor-motor loop frequency.
 
void addObject (PhysicalObject *o)
 Add an object to the world, simply add it to the vector. More...
 
void removeObject (PhysicalObject *o)
 Remove an object from the world and destroy it. If object is not in the world, do nothing.
 
void disconnectExternalObjectsUserData ()
 Set to 0 the userData member of all object whose value userData->deletedWithObject are false; call this before the creator of user data is destroyed, this method is typically called from a viewer just before its destruction.
 
void setRandomSeed (unsigned long seed)
 Set the seed of the random generator.
 
void initBluetoothBase ()
 Initialise and activate the Bluetooth base.
 
BluetoothBasegetBluetoothBase ()
 Return the address of the Bluetooth base.
 

Static Public Member Functions

static void takeObjectOwnership (bool doTake)
 Choose whether the world should take ownership of PhysicalObjects added, and delete them. Default is true.
 

Public Attributes

const WallsType wallsType
 type of walls this world is using
 
const double w
 The width of the world, if wallsType is WALLS_SQUARE.
 
const double h
 The height of the world, if wallsType is WALLS_SQUARE.
 
const double r
 The radius of the world, if wallsType is WALLS_CIRCLE.
 
const Color color
 The color of the world walls and ground.
 
const GroundTexture groundTexture
 Current ground texture.
 
Objects objects
 All the objects in the world.
 
BluetoothBasebluetoothBase
 Base for the Bluetooth connections between robots.
 

Protected Member Functions

void collideCircleWithShape (PhysicalObject *circularObject, PhysicalObject *shapedObject, const Polygone &shape)
 Do the collision of a circular object with one with a different shape (convex boundingsurface)
 
void collideObjects (PhysicalObject *object1, PhysicalObject *object2)
 Collide two objects. Correct functions will be called depending on type of object (circular or other shape).
 
void collideWithSquareWalls (PhysicalObject *object)
 Collide the object with square walls.
 
void collideWithCircularWalls (PhysicalObject *object)
 Collide the object with circular walls.
 
bool isPointInside (const Point &p, const Point &c, const Polygone &bs, Vector *distVector)
 Return true if point p of object of center c is inside polygone bs and return deinterlacement distVector.
 
virtual void controlStep (double dt)
 Can implement world specific control. By default do nothing.
 

Detailed Description

The world is the container of all objects and robots.

It is either a rectangular arena with walls at all sides, a circular area with walls, or an infinite surface.

Member Enumeration Documentation

Type of walls around the world.

Enumerator
WALLS_SQUARE 

square walls, use w and h for size

WALLS_CIRCULAR 

circle walls, use r for radius

WALLS_NONE 

no walls

Member Function Documentation

void Enki::World::addObject ( PhysicalObject o)

Add an object to the world, simply add it to the vector.

Object will be automatically deleted when world will be destroyed. If the object is already in the world, do nothing

References objects.


The documentation for this class was generated from the following files: