Light-emitting object with optional radial gradient. More...
#include <lights.h>
Public Types | |
| enum class | LightMode { STATIC , GRADIENT , PLANE } |
| Selects how intensity is distributed over the object geometry. More... | |
Public Member Functions | |
| StaticLightObject (float _x, float _y, ObjectGeometry &_geom, LightLevelMap *light_map, int16_t _value, LightMode _mode=LightMode::STATIC, int16_t _edge_value=0, float _gradient_radius=-1.0f, float _plane_angle=0.0f, float _plane_half_span=1000.0f, float _photo_start_at=-1.0f, float _photo_start_duration=1.0f, int16_t _photo_start_value=32767, std::string const &_category="objects") | |
| Construct a light object programmatically. | |
| StaticLightObject (Simulation *simulation, float _x, float _y, LightLevelMap *light_map, Configuration const &config, std::string const &_category="objects") | |
| Constructs a StaticLightObject object from a configuration entry. | |
| virtual void | render (SDL_Renderer *, b2WorldId) const override |
| Renders the object on the given SDL renderer. | |
| virtual void | update_light_map (LightLevelMap &l) |
| Updates the object's contribution to the light level map. | |
| virtual void | launch_user_step (float t) override |
| Launches the user-defined step function. | |
| 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. | |
| ObjectGeometry * | get_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 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. | |
Protected Member Functions | |
| virtual void | parse_configuration (Configuration const &config, Simulation *simulation) override |
| Parse a provided configuration and set associated members values. | |
Protected Attributes | |
| int16_t | value = 0 |
| int16_t | orig_value = 0 |
| int16_t | edge_value = 0 |
| float | gradient_radius = -1.0f |
| float | plane_angle = 0.0f |
| float | plane_half_span = 1000.0f |
| LightMode | mode = LightMode::STATIC |
| LightLevelMap * | light_map = nullptr |
| float | photo_start_at = -1.0f |
| start time (s), negative ⇒ off | |
| float | photo_start_duration = 1.0f |
| pulse width (s) | |
| int16_t | photo_start_value = 32767 |
| intensity during pulse | |
| bool | performing_photo_start = false |
| internal state flag | |
| Protected Attributes inherited from Object | |
| ObjectGeometry * | geom |
| Geometry of the object. | |
Additional Inherited Members | |
| 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. | |
Light-emitting object with optional radial gradient.
A StaticLightObject registers a callback on the global LightLevelMap given at construction time.
Once invoked, the callback iterates on every covered bin and calls LightLevelMap::add_light_level() with the intensity calculated according to the current LightMode.
The class is pod-friendly (all data members are trivially copyable / reset-able), yet provides high-level behaviour such as:
|
strong |
Selects how intensity is distributed over the object geometry.
| Enumerator | |
|---|---|
| STATIC | All bins receive an identical intensity = value. |
| GRADIENT | Bins receive an intensity that decays linearly with the distance from the geometrical centre (x,y). |
| PLANE | |
| StaticLightObject::StaticLightObject | ( | float | _x, |
| float | _y, | ||
| ObjectGeometry & | _geom, | ||
| LightLevelMap * | light_map, | ||
| int16_t | _value, | ||
| LightMode | _mode = LightMode::STATIC, | ||
| int16_t | _edge_value = 0, | ||
| float | _gradient_radius = -1.0f, | ||
| float | _plane_angle = 0.0f, | ||
| float | _plane_half_span = 1000.0f, | ||
| float | _photo_start_at = -1.0f, | ||
| float | _photo_start_duration = 1.0f, | ||
| int16_t | _photo_start_value = 32767, | ||
| std::string const & | _category = "objects" ) |
Construct a light object programmatically.
| _x | Initial x coordinate of the object centre (in world units, mm). |
| _y | Initial y coordinate of the object centre. |
| _geom | Reference to the geometry that delimits where the object exists in space. |
| light_map | Pointer to the global LightLevelMap (must remain valid for the lifetime of the object). |
| _value | Centre intensity in the range [0, 32767] (for STATIC this is also the only intensity). |
| _mode | Intensity distribution strategy (default =STATIC). |
| _edge_value | Intensity at gradient_radius (only meaningful in GRADIENT mode). |
| _gradient_radius | Radius, in mm, at which the intensity reaches _edge_value. If ≤ 0 the radius is computed automatically as the farthest covered bin centre. |
| _photo_start_at | Start time (seconds, simulation clock) of the optional photo-start pulse. Set to a negative value to disable. |
| _photo_start_duration | Duration (seconds) of the pulse. |
| _photo_start_value | Intensity during the pulse. After the pulse the object reverts to _value. |
| _category | Category name for profiling / filtering. |
light_map; do not call update_light_map() manually. | StaticLightObject::StaticLightObject | ( | Simulation * | simulation, |
| float | _x, | ||
| float | _y, | ||
| LightLevelMap * | light_map, | ||
| Configuration const & | config, | ||
| std::string const & | _category = "objects" ) |
Constructs a StaticLightObject object from a configuration entry.
| simulation | Pointer to the underlying simulation. |
| x | Initial x-coordinate in the simulation. |
| y | Initial y-coordinate in the simulation. |
| light_map | Pointer to the global light level map. |
| config | Configuration entry describing the object properties. |
| category | Name of the category of the object. |
|
overridevirtual |
Launches the user-defined step function.
Updates the object's time, enables all registered stop watches, executes the user step function via pogo_main_loop_step, and then disables the stop watches.
Reimplemented from Object.
|
overrideprotectedvirtual |
Parse a provided configuration and set associated members values.
| config | Configuration entry describing the object properties. |
Reimplemented from Object.
|
inlineoverridevirtual |
Renders the object on the given SDL renderer.
| renderer | Pointer to the SDL_Renderer. |
| world_id | The Box2D world identifier (unused in rendering). |
Implements Object.
|
virtual |
Updates the object's contribution to the light level map.
|
protected |
Intensity at gradient_radius (GRADIENT and PLANE modes only).
|
protected |
Radius (mm) used for linear fall-off in GRADIENT mode. A non-positive value means “compute automatically”.
|
protected |
Pointer to the light map this object contributes to.
|
protected |
Selected intensity distribution strategy.
|
protected |
Saved intensity for restoring after a photo-start pulse.
|
protected |
internal state flag
|
protected |
start time (s), negative ⇒ off
|
protected |
pulse width (s)
|
protected |
intensity during pulse
|
protected |
|
protected |
|
protected |
Centre intensity (also the uniform level for STATIC mode).