Army ant simulation
Public Member Functions | Protected Attributes | List of all members
Terrain Class Reference
Inheritance diagram for Terrain:
Inheritance graph
[legend]
Collaboration diagram for Terrain:
Collaboration graph
[legend]

Public Member Functions

 Terrain (b2World *world, sf::RenderWindow &window, config::sTerrain terrainParam, int WINDOW_X_PX, double bodyLength=1)
 
virtual void create (b2World *world, sf::RenderWindow &window, config::sTerrain terrainParam, int WINDOW_X_PX, double bodyLength)
 
virtual void createBody (b2World *world)
 
virtual void drawBody (sf::RenderWindow &window)
 
virtual e_terrain_type getType ()
 
virtual b2Vec2 getTopLeftCorner ()
 
virtual b2Vec2 getTopRightCorner ()
 
virtual b2Vec2 getBottom ()
 
double getVLength ()
 
b2Body * getBody ()
 
const double getScale ()
 

Protected Attributes

b2Body * m_groundBody
 
double m_bodyLength
 
double m_M_TO_PX
 
double m_width
 
double m_height
 
double m_runaway
 
double m_angle
 
double m_posY =2.5
 
config::sTerrain m_terrainParam
 

Detailed Description

Definition at line 25 of file Terrain.h.

Member Function Documentation

◆ create()

void Terrain::create ( b2World *  world,
sf::RenderWindow &  window,
config::sTerrain  terrainParam,
int  WINDOW_X_PX,
double  bodyLength 
)
virtual

The function create MUST be called if the terrain object has been created via the default constructor (ex when created dynamically with new), otherwise no need to use it

Parameters
worldis a pointer on the Box2D world object
windowis the SFML window
terrainParamare the terrain parameters (cf Config.h)
WINDOW_X_PXis the x-size of the window. it is used to calculate the scale to convert from meters to pixels
bodylengthis the size of a robot. it is used to convert the dimension from body length to m

Reimplemented in Ramp, V2BLTerrain, Vterrain, BoxTerrain, and VStepper.

Definition at line 38 of file Terrain.cpp.

◆ createBody()

void Terrain::createBody ( b2World *  world)
virtual

Create the Box2D static body of the terrain

Parameters
worldis a pointer on the Box2D world

Reimplemented in Ramp, V2BLTerrain, Vterrain, BoxTerrain, and VStepper.

Definition at line 57 of file Terrain.cpp.

◆ drawBody()

void Terrain::drawBody ( sf::RenderWindow &  window)
virtual

Draw the body on the window using the SFML library

Parameters
windowis the SFML window where the terrain will be drawn

Reimplemented in Ramp, V2BLTerrain, Vterrain, BoxTerrain, and VStepper.

Definition at line 73 of file Terrain.cpp.

◆ getBody()

b2Body * Terrain::getBody ( )
Returns
a pointer on the Box2D body of the terrain

Definition at line 84 of file Terrain.cpp.

◆ getBottom()

b2Vec2 Terrain::getBottom ( )
virtual
Returns
the position of the bottom of the V in the box2D world coordinates [m]

Reimplemented in Ramp, V2BLTerrain, and Vterrain.

Definition at line 98 of file Terrain.cpp.

◆ getScale()

const double Terrain::getScale ( )

As the terrain is the first thing that has to be created in the world, this method allow to obtain a right scale factor to do the conversion between the real dimensions and the simulated ones based on and adapted to the terrain dimensions

Returns
the scale to do the conversion from real dimensions (m) to simulated ones (pixels)

Definition at line 88 of file Terrain.cpp.

Here is the caller graph for this function:

◆ getTopLeftCorner()

b2Vec2 Terrain::getTopLeftCorner ( )
virtual
Returns
the position of the Top left corner of the V in the box2D world coordinates [m]

Reimplemented in Ramp, V2BLTerrain, and Vterrain.

Definition at line 96 of file Terrain.cpp.

Here is the caller graph for this function:

◆ getTopRightCorner()

b2Vec2 Terrain::getTopRightCorner ( )
virtual
Returns
the position of the Top right corner of the V in the box2D world coordinates [m]

Reimplemented in Ramp, V2BLTerrain, and Vterrain.

Definition at line 97 of file Terrain.cpp.

◆ getType()

e_terrain_type Terrain::getType ( )
virtual
Returns
the type of the terrain. Can be DEFAULT, V_TERRAIN, V2BL_TERRAIN, RAMP, BOX or V_STEPPER

Reimplemented in Ramp, V2BLTerrain, Vterrain, BoxTerrain, and VStepper.

Definition at line 92 of file Terrain.cpp.

◆ getVLength()

double Terrain::getVLength ( )
inline
Returns
the length of the V when it makes sense, 0 otherwise [m]

Definition at line 67 of file Terrain.h.

Here is the caller graph for this function:

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