Gamedev Framework (gf)  0.11.0
A C++14 framework for 2D games
Public Types | Public Member Functions | List of all members
gf::PhysicsGeometry Class Referenceabstract

The geometry of a physics body. More...

#include <gf/PhysicsGeometry.h>

Inheritance diagram for gf::PhysicsGeometry:
Inheritance graph
[legend]

Public Types

enum  Type {
  Type::Circle,
  Type::Polygon
}
 The type of geometry. More...
 

Public Member Functions

 PhysicsGeometry (Type type)
 Constructor. More...
 
virtual ~PhysicsGeometry ()
 Destructor. More...
 
Type getType () const
 Get the type of the geometry. More...
 
virtual float getArea () const =0
 Compute the area of the geometry. More...
 
virtual CircF getBoundingCircle () const =0
 Get a bouding circle. More...
 
virtual void renderAt (RenderTarget &target, const RenderStates &states, Vector2f position, float angle) const =0
 Render the geometry. More...
 

Detailed Description

The geometry of a physics body.

The geometry is defined in model coordinates.

See also
gf::PhysicsBody

Member Enumeration Documentation

◆ Type

The type of geometry.

Enumerator
Circle 

A circle (see gf::CircleGeometry)

Polygon 

A polygon (see gf::PolygonGeometry)

Constructor & Destructor Documentation

◆ PhysicsGeometry()

gf::PhysicsGeometry::PhysicsGeometry ( Type  type)
inline

Constructor.

Parameters
typeThe type of the geometry

◆ ~PhysicsGeometry()

virtual gf::PhysicsGeometry::~PhysicsGeometry ( )
virtual

Destructor.

Member Function Documentation

◆ getArea()

virtual float gf::PhysicsGeometry::getArea ( ) const
pure virtual

Compute the area of the geometry.

Returns
The area in world units

Implemented in gf::PolygonGeometry, and gf::CircleGeometry.

◆ getBoundingCircle()

virtual CircF gf::PhysicsGeometry::getBoundingCircle ( ) const
pure virtual

Get a bouding circle.

The circle may not be the minimum bouding circle.

Returns
A bounding circle

Implemented in gf::PolygonGeometry, and gf::CircleGeometry.

◆ getType()

Type gf::PhysicsGeometry::getType ( ) const
inline

Get the type of the geometry.

◆ renderAt()

virtual void gf::PhysicsGeometry::renderAt ( RenderTarget target,
const RenderStates states,
Vector2f  position,
float  angle 
) const
pure virtual

Render the geometry.

Parameters
targetThe render target
statesThe render states to use for drawing
positionThe position of the geometry
angleThe angle of the geometry

Implemented in gf::PolygonGeometry, and gf::CircleGeometry.