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

Geometry of an object. More...

#include <objects_geometry.h>

Inheritance diagram for ObjectGeometry:
ArenaGeometry DiskGeometry GlobalGeometry RectangleGeometry TriangleGeometry

Public Member Functions

 ObjectGeometry ()
 Construct an ObjectGeometry.
virtual ~ObjectGeometry ()
 Destructor.
virtual void create_box2d_shape (b2BodyId body_id, b2ShapeDef &shape_def)=0
 Create Box2D shape based on this geometry.
b2ShapeId get_shape_id () const
 Return Box2D shape_id.
virtual std::vector< std::vector< bool > > export_geometry_grid (size_t num_bins_x, size_t num_bins_y, float bin_width, float bin_height, float obj_x, float obj_y) const =0
 Exports a boolean 2D grid showing which bins are covered by the geometry.
virtual void render (SDL_Renderer *renderer, b2WorldId world_id, float x, float y, float theta, uint8_t r, uint8_t g, uint8_t b, uint8_t alpha=255) const =0
 Renders the object on the given SDL renderer.
virtual BoundingDisk compute_bounding_disk () const =0
 Computes the bounding disk that completely encloses the geometry.
virtual BoundingBox compute_bounding_box () const =0
 Computes the axis-aligned bounding box that completely encloses the geometry.
virtual float get_distance_to (b2Vec2 orig, b2Vec2 point) const
 Compute the distance from a given point to the geometry.
virtual arena_polygons_t generate_contours (std::size_t points_per_contour=0, b2Vec2 position={0.0f, 0.0f}) const =0
 Return one or more polygonal contours that approximate / represent this geometry.

Protected Attributes

bool shape_created = false
b2ShapeId shape_id
 Box2D shape identifier.

Detailed Description

Geometry of an object.

Constructor & Destructor Documentation

◆ ObjectGeometry()

ObjectGeometry::ObjectGeometry ( )
inline

Construct an ObjectGeometry.

◆ ~ObjectGeometry()

ObjectGeometry::~ObjectGeometry ( )
virtual

Destructor.

Member Function Documentation

◆ compute_bounding_box()

virtual BoundingBox ObjectGeometry::compute_bounding_box ( ) const
pure virtual

Computes the axis-aligned bounding box that completely encloses the geometry.

Returns
A BoundingBox with top-left corner (x,y) and width and height.

Implemented in ArenaGeometry, DiskGeometry, GlobalGeometry, RectangleGeometry, and TriangleGeometry.

◆ compute_bounding_disk()

virtual BoundingDisk ObjectGeometry::compute_bounding_disk ( ) const
pure virtual

Computes the bounding disk that completely encloses the geometry.

Returns
A BoundingDisk with center (x,y) and radius.

Implemented in ArenaGeometry, DiskGeometry, GlobalGeometry, RectangleGeometry, and TriangleGeometry.

◆ create_box2d_shape()

virtual void ObjectGeometry::create_box2d_shape ( b2BodyId body_id,
b2ShapeDef & shape_def )
pure virtual

Create Box2D shape based on this geometry.

Implemented in ArenaGeometry, DiskGeometry, GlobalGeometry, RectangleGeometry, and TriangleGeometry.

◆ export_geometry_grid()

virtual std::vector< std::vector< bool > > ObjectGeometry::export_geometry_grid ( size_t num_bins_x,
size_t num_bins_y,
float bin_width,
float bin_height,
float obj_x,
float obj_y ) const
pure virtual

Exports a boolean 2D grid showing which bins are covered by the geometry.

Parameters
num_bins_xNumber of bins along the X-axis.
num_bins_yNumber of bins along the Y-axis.
bin_widthWidth (size) of each bin.
bin_heightHeight (size) of each bin.
obj_xThe x-coordinate of the object (geometry center).
obj_yThe y-coordinate of the object (geometry center).
Returns
A 2D vector of booleans. True in a given cell indicates that the geometry covers that bin.

Implemented in DiskGeometry, GlobalGeometry, RectangleGeometry, and TriangleGeometry.

◆ generate_contours()

virtual arena_polygons_t ObjectGeometry::generate_contours ( std::size_t points_per_contour = 0,
b2Vec2 position = {0.0f, 0.0f} ) const
pure virtual

Return one or more polygonal contours that approximate / represent this geometry.

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).

Implemented in ArenaGeometry, DiskGeometry, GlobalGeometry, RectangleGeometry, and TriangleGeometry.

◆ get_distance_to()

float ObjectGeometry::get_distance_to ( b2Vec2 orig,
b2Vec2 point ) const
virtual

Compute the distance from a given point to the geometry.

Reimplemented in ArenaGeometry, and GlobalGeometry.

◆ get_shape_id()

b2ShapeId ObjectGeometry::get_shape_id ( ) const
inline

Return Box2D shape_id.

◆ render()

virtual void ObjectGeometry::render ( SDL_Renderer * renderer,
b2WorldId world_id,
float x,
float y,
float theta,
uint8_t r,
uint8_t g,
uint8_t b,
uint8_t alpha = 255 ) 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).
xX coordinate
yY coordinate
rRed color component
gGreen color component
bBlue color component
alphaAlpha color component

Implemented in ArenaGeometry, DiskGeometry, GlobalGeometry, RectangleGeometry, and TriangleGeometry.

Member Data Documentation

◆ shape_created

bool ObjectGeometry::shape_created = false
protected

◆ shape_id

b2ShapeId ObjectGeometry::shape_id
protected

Box2D shape identifier.


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