Pogosim
Loading...
Searching...
No Matches
Object Class Referenceabstract

Base class of any object contained within the simulation. More...

#include <objects.h>

Inheritance diagram for Object:
AlternatingDualRayOfLightObject PhysicalObject RotatingRayOfLightObject StaticLightObject PassiveObject PogobotObject ActiveObject PogobjectObject Pogowall MembraneObject RectMembraneObject

Public Member Functions

 Object (float _x, float _y, ObjectGeometry &_geom, std::string const &_category="objects")
 Constructs an Object.
 Object (Simulation *simulation, float _x, float _y, Configuration const &config, std::string const &_category="objects")
 Constructs an Object from a configuration entry.
virtual ~Object ()
 Destructor.
void init (b2WorldId world_id)
 Launch virtual function 'do_init' that will perform base initialization (e.g. create Box2D objects).
bool is_initialized () const noexcept
 Check if the object was correctly initialized yet.
virtual void render (SDL_Renderer *renderer, b2WorldId world_id) const =0
 Renders the object on the given SDL renderer.
virtual void launch_user_step (float f)
 Launches the user-defined step function.
ObjectGeometryget_geometry ()
 Return the object's geometry.
virtual void move (float x, float y, float theta=NAN)
 Move the object to a given coordinate.
virtual bool is_tangible () const
 Returns whether this object is tangible (e.g. collisions, etc) or not.
virtual void serialize_base_values (DataLogger *data_logger, double t)
 Save base values of the object into a data logger row.
virtual void create_serialization_fields (DataLogger *data_logger)
 Create serialization fields of the data logger.
virtual arena_polygons_t generate_contours (std::size_t points_per_contour=0) const
 Return one or more polygonal contours that represent the geometry of the object.

Public Attributes

float x
 X position.
float y
 Y position.
float theta
 Orientation (in rad).
std::string category
 Category of the object.

Protected Member Functions

virtual void do_init (b2WorldId world_id)
 Perform the base initialization (e.g. create Box2D objects). Called once by init(world_id).
virtual void parse_configuration (Configuration const &config, Simulation *simulation)
 Parse a provided configuration and set associated members values.

Protected Attributes

ObjectGeometrygeom
 Geometry of the object.

Detailed Description

Base class of any object contained within the simulation.

Constructor & Destructor Documentation

◆ Object() [1/2]

Object::Object ( float _x,
float _y,
ObjectGeometry & _geom,
std::string const & _category = "objects" )

Constructs an Object.

Parameters
xInitial x-coordinate in the simulation.
yInitial y-coordinate in the simulation.
geomObject's geometry.
categoryName of the category of the object.

◆ Object() [2/2]

Object::Object ( Simulation * simulation,
float _x,
float _y,
Configuration const & config,
std::string const & _category = "objects" )

Constructs an Object from a configuration entry.

Parameters
simulationPointer to the underlying simulation.
xInitial x-coordinate in the simulation.
yInitial y-coordinate in the simulation.
configConfiguration entry describing the object properties.
categoryName of the category of the object.

◆ ~Object()

Object::~Object ( )
virtual

Destructor.

Member Function Documentation

◆ create_serialization_fields()

void Object::create_serialization_fields ( DataLogger * data_logger)
virtual

Create serialization fields of the data logger.

Parameters
data_loggerPointer to a DataLogger used for serialization

Reimplemented in MembraneObject, PhysicalObject, and PogobotObject.

◆ do_init()

virtual void Object::do_init ( b2WorldId world_id)
inlineprotectedvirtual

Perform the base initialization (e.g. create Box2D objects). Called once by init(world_id).

Parameters
world_idThe Box2D world identifier.

Reimplemented in MembraneObject, PhysicalObject, PogobjectObject, PogobotObject, Pogowall, and RectMembraneObject.

◆ generate_contours()

arena_polygons_t Object::generate_contours ( std::size_t points_per_contour = 0) const
virtual

Return one or more polygonal contours that represent the geometry of the object.

Parameters
points_per_contourDesired number of vertices for each contour (a rectangle has one contour, a disk has one, an arena may have many – one per wall).
Returns
arena_polygons_t A vector of closed polygons (counter‑clockwise, last vertex different from the first – the caller may close the loop if needed).

Reimplemented in MembraneObject, PhysicalObject, and RectMembraneObject.

◆ get_geometry()

ObjectGeometry * Object::get_geometry ( )
inline

Return the object's geometry.

◆ init()

void Object::init ( b2WorldId world_id)
inline

Launch virtual function 'do_init' that will perform base initialization (e.g. create Box2D objects).

◆ is_initialized()

bool Object::is_initialized ( ) const
inlinenoexcept

Check if the object was correctly initialized yet.

◆ is_tangible()

virtual bool Object::is_tangible ( ) const
inlinevirtual

Returns whether this object is tangible (e.g. collisions, etc) or not.

Reimplemented in MembraneObject, PhysicalObject, and Pogowall.

◆ launch_user_step()

void Object::launch_user_step ( float f)
virtual

Launches the user-defined step function.

Parameters
tcurrent simulation time

Reimplemented in AlternatingDualRayOfLightObject, PhysicalObject, PogobotObject, RotatingRayOfLightObject, and StaticLightObject.

◆ move()

void Object::move ( float x,
float y,
float theta = NAN )
virtual

Move the object to a given coordinate.

Parameters
xX coordinate.
yY coordinate.
thetaOrientation, in rad.

Reimplemented in MembraneObject, PhysicalObject, Pogowall, and RectMembraneObject.

◆ parse_configuration()

void Object::parse_configuration ( Configuration const & config,
Simulation * simulation )
protectedvirtual

Parse a provided configuration and set associated members values.

Parameters
configConfiguration entry describing the object properties.

Reimplemented in ActiveObject, AlternatingDualRayOfLightObject, MembraneObject, PassiveObject, PhysicalObject, PogobotObject, RectMembraneObject, RotatingRayOfLightObject, and StaticLightObject.

◆ render()

virtual void Object::render ( SDL_Renderer * renderer,
b2WorldId world_id ) const
pure virtual

Renders the object on the given SDL renderer.

Parameters
rendererPointer to the SDL_Renderer.
world_idThe Box2D world identifier (unused in rendering).

Implemented in ActiveObject, AlternatingDualRayOfLightObject, MembraneObject, PassiveObject, PhysicalObject, PogobjectObject, PogobotObject, Pogowall, RectMembraneObject, RotatingRayOfLightObject, and StaticLightObject.

◆ serialize_base_values()

void Object::serialize_base_values ( DataLogger * data_logger,
double t )
virtual

Save base values of the object into a data logger row.

Parameters
data_loggerPointer to a DataLogger used to serialize base values

Reimplemented in MembraneObject, PhysicalObject, PogobotObject, and RectMembraneObject.

Member Data Documentation

◆ category

std::string Object::category

Category of the object.

◆ geom

ObjectGeometry* Object::geom
protected

Geometry of the object.

◆ theta

float Object::theta

Orientation (in rad).

◆ x

float Object::x

X position.

◆ y

float Object::y

Y position.


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