Pogosim
Loading...
Searching...
No Matches
PassiveObject Class Reference

Physical object without user code (i.e. passive). Can still interact with other objects (e.g. collisions, etc). More...

#include <objects.h>

Inheritance diagram for PassiveObject:
PhysicalObject Object

Public Member Functions

 PassiveObject (uint16_t _id, float _x, float _y, ObjectGeometry &geom, b2WorldId world_id, float _linear_damping=0.0f, float _angular_damping=0.0f, float _density=10.0f, float _friction=0.3f, float _restitution=0.5f, std::string _colormap="rainbow", std::string const &_category="objects")
 Constructs a PassiveObject.
 PassiveObject (Simulation *simulation, uint16_t _id, float _x, float _y, b2WorldId world_id, Configuration const &config, std::string const &_category="objects")
 Constructs a PassiveObject from a configuration entry.
void render (SDL_Renderer *renderer, b2WorldId world_id) const override
 Renders the object on the given SDL renderer.
Public Member Functions inherited from PhysicalObject
 PhysicalObject (uint16_t _id, float _x, float _y, ObjectGeometry &geom, b2WorldId world_id, float _linear_damping=0.0f, float _angular_damping=0.0f, float _density=10.0f, float _friction=0.3f, float _restitution=0.5f, std::string const &_category="objects")
 Constructs a PhysicalObject.
 PhysicalObject (Simulation *simulation, uint16_t _id, float _x, float _y, b2WorldId world_id, Configuration const &config, std::string const &_category="objects")
 Constructs a PhysicalObject from a configuration entry.
virtual void launch_user_step (float t) override
 Launches the user-defined step function. For PhysicalObject, it is also used to compute acceleration statistics.
virtual b2Vec2 get_position () const
 Retrieves the object's current position.
float get_angle () const
 Retrieves the object's current orientation angle.
float get_angular_velocity () const
 Retrieves the object's current angular velocity.
b2Vec2 get_linear_acceleration () const
 Retrieves the object's current angular velocity.
virtual void move (float x, float y, float theta=NAN) override
 Move the object to a given coordinate.
virtual bool is_tangible () const override
 Returns whether this object is tangible (e.g. collisions, etc) or not.
virtual arena_polygons_t generate_contours (std::size_t points_per_contour=0) const override
 Return one or more polygonal contours that represent the geometry of the object.
Public Member Functions inherited from Object
 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.
ObjectGeometryget_geometry ()
 Return the object's geometry.

Protected Member Functions

virtual void parse_configuration (Configuration const &config, Simulation *simulation) override
 Parse a provided configuration and set associated members values.
Protected Member Functions inherited from PhysicalObject
virtual void create_body (b2WorldId world_id)
 Creates the object's physical body in the simulation.

Protected Attributes

std::string colormap
Protected Attributes inherited from PhysicalObject
float linear_damping
float angular_damping
float density
float friction
float restitution
b2BodyId body_id
 Box2D body identifier.
float _estimated_dt = 0.0f
float _last_time = 0.0f
b2Vec2 _prev_v = {NAN, NAN}
b2Vec2 _lin_acc = {NAN, NAN}
Protected Attributes inherited from Object
ObjectGeometrygeom
 Geometry of the object.

Additional Inherited Members

Public Attributes inherited from PhysicalObject
uint16_t id
 Object identifier.
Public Attributes inherited from Object
float x
 X position.
float y
 Y position.
float theta
 Orientation (in rad).
std::string category
 Category of the object.

Detailed Description

Physical object without user code (i.e. passive). Can still interact with other objects (e.g. collisions, etc).

Constructor & Destructor Documentation

◆ PassiveObject() [1/2]

PassiveObject::PassiveObject ( uint16_t _id,
float _x,
float _y,
ObjectGeometry & geom,
b2WorldId world_id,
float _linear_damping = 0.0f,
float _angular_damping = 0.0f,
float _density = 10.0f,
float _friction = 0.3f,
float _restitution = 0.5f,
std::string _colormap = "rainbow",
std::string const & _category = "objects" )

Constructs a PassiveObject.

Parameters
_idUnique object identifier.
xInitial x-coordinate in the simulation.
yInitial y-coordinate in the simulation.
geomObject's geometry.
world_idThe Box2D world identifier.
_linear_dampingLinear damping value for the physical body (default is 0.0f).
_angular_dampingAngular damping value for the physical body (default is 0.0f).
_densityDensity of the body shape (default is 10.0f).
_frictionFriction coefficient of the body shape (default is 0.3f).
_restitutionRestitution (bounciness) of the body shape (default is 0.5f).
_colormapName of the colormap to use to set the color of the object
categoryName of the category of the object.

◆ PassiveObject() [2/2]

PassiveObject::PassiveObject ( Simulation * simulation,
uint16_t _id,
float _x,
float _y,
b2WorldId world_id,
Configuration const & config,
std::string const & _category = "objects" )

Constructs a PassiveObject from a configuration entry.

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

Member Function Documentation

◆ parse_configuration()

void PassiveObject::parse_configuration ( Configuration const & config,
Simulation * simulation )
overrideprotectedvirtual

Parse a provided configuration and set associated members values.

Parameters
configConfiguration entry describing the object properties.

Reimplemented from PhysicalObject.

◆ render()

void PassiveObject::render ( SDL_Renderer * renderer,
b2WorldId world_id ) const
overridevirtual

Renders the object on the given SDL renderer.

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

Implements PhysicalObject.

Member Data Documentation

◆ colormap

std::string PassiveObject::colormap
protected

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