CUGL 2.1
Cornell University Game Library
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cugl::physics2::WheelObstacle Class Reference

#include <CUWheelObstacle.h>

Inheritance diagram for cugl::physics2::WheelObstacle:
cugl::physics2::SimpleObstacle cugl::physics2::Obstacle

Public Member Functions

 WheelObstacle (void)
 
virtual ~WheelObstacle ()
 
virtual bool init () override
 
virtual bool init (const Vec2 pos) override
 
virtual bool init (const Vec2 pos, float radius)
 
float getRadius () const
 
void setRadius (float value)
 
virtual void createFixtures () override
 
virtual void releaseFixtures () override
 
- Public Member Functions inherited from cugl::physics2::SimpleObstacle
 SimpleObstacle ()
 
virtual ~SimpleObstacle ()
 
virtual b2BodyType getBodyType () const override
 
virtual void setBodyType (b2BodyType value) override
 
virtual Vec2 getPosition () const override
 
virtual void setPosition (const Vec2 value) override
 
virtual void setPosition (float x, float y) override
 
virtual float getX () const override
 
virtual void setX (float value) override
 
virtual float getY () const override
 
virtual void setY (float value) override
 
virtual float getAngle () const override
 
virtual void setAngle (float value) override
 
virtual Vec2 getLinearVelocity () const override
 
virtual void setLinearVelocity (const Vec2 value) override
 
virtual void setLinearVelocity (float x, float y) override
 
virtual float getVX () const override
 
virtual void setVX (float value) override
 
virtual float getVY () const override
 
virtual void setVY (float value) override
 
virtual float getAngularVelocity () const override
 
virtual void setAngularVelocity (float value) override
 
virtual bool isEnabled () const override
 
virtual void setEnabled (bool value) override
 
virtual bool isAwake () const override
 
virtual void setAwake (bool value) override
 
virtual bool isSleepingAllowed () const override
 
virtual void setSleepingAllowed (bool value) override
 
virtual bool isBullet () const override
 
virtual void setBullet (bool value) override
 
virtual bool isFixedRotation () const override
 
virtual void setFixedRotation (bool value) override
 
virtual float getGravityScale () const override
 
virtual void setGravityScale (float value) override
 
virtual float getLinearDamping () const override
 
virtual void setLinearDamping (float value) override
 
virtual float getAngularDamping () const override
 
virtual void setAngularDamping (float value) override
 
virtual void setDensity (float value) override
 
virtual void setFriction (float value) override
 
virtual void setRestitution (float value) override
 
virtual void setSensor (bool value) override
 
virtual void setFilterData (b2Filter value) override
 
virtual Vec2 getCentroid () const override
 
virtual void setCentroid (const Vec2 value) override
 
virtual void setCentroid (float x, float y) override
 
virtual float getInertia () const override
 
virtual void setInertia (float value) override
 
virtual float getMass () const override
 
virtual void setMass (float value) override
 
virtual void resetMass () override
 
virtual b2Body * getBody () override
 
virtual bool activatePhysics (b2World &world) override
 
virtual void deactivatePhysics (b2World &world) override
 
virtual void update (float delta) override
 
int getPositionSnap ()
 
void setPositionSnap (unsigned int snap)
 
int getAngleSnap ()
 
void setAngleSnap (unsigned int snap)
 
- Public Member Functions inherited from cugl::physics2::Obstacle
 Obstacle (void)
 
virtual ~Obstacle ()
 
void setBodyState (const b2Body &body)
 
float getDensity () const
 
float getFriction () const
 
float getRestitution () const
 
bool isSensor () const
 
b2Filter getFilterData () const
 
bool isRemoved () const
 
void markRemoved (bool value)
 
bool isDirty () const
 
void markDirty (bool value)
 
const std::function< void(Obstacle *obstacle)> & getListener () const
 
void setListener (const std::function< void(Obstacle *obstacle)> &listener)
 
std::string getName () const
 
void setName (std::string value)
 
std::string toString () const
 
Color4 getDebugColor () const
 
virtual void setDebugColor (Color4 color)
 
scene2::SceneNodegetDebugScene () const
 
scene2::WireNodegetDebugNode () const
 
virtual void setDebugScene (const std::shared_ptr< scene2::SceneNode > &node)
 
bool hasDebug ()
 

Static Public Member Functions

static std::shared_ptr< WheelObstaclealloc ()
 
static std::shared_ptr< WheelObstaclealloc (const Vec2 pos)
 
static std::shared_ptr< WheelObstaclealloc (const Vec2 pos, float radius)
 

Protected Member Functions

virtual void resetDebug () override
 
- Protected Member Functions inherited from cugl::physics2::SimpleObstacle
virtual void updateDebug () override
 

Protected Attributes

b2CircleShape _shape
 
b2Fixture * _geometry
 
- Protected Attributes inherited from cugl::physics2::SimpleObstacle
b2Body * _body
 
int _posSnap
 
unsigned long _posFact
 
int _angSnap
 
unsigned long _angFact
 
- Protected Attributes inherited from cugl::physics2::Obstacle
b2BodyDef _bodyinfo
 
b2FixtureDef _fixture
 
b2MassData _massdata
 
bool _masseffect
 
std::shared_ptr< scene2::SceneNode_scene
 
std::shared_ptr< scene2::WireNode_debug
 
Color4 _dcolor
 
std::string _tag
 
std::function< void(Obstacle *obstacle)> _listener
 

Detailed Description

Circle-shaped model to support collisions.

Note that the shape must be circular, not elliptical. If you want to make an ellipse, you will need to use the PolygonObstacle class.

Unless otherwise specified, the center of mass is as the center.

Constructor & Destructor Documentation

◆ WheelObstacle()

cugl::physics2::WheelObstacle::WheelObstacle ( void  )
inline

Creates a new wheel object at the origin.

NEVER USE A CONSTRUCTOR WITH NEW. If you want to allocate an object on the heap, use one of the static constructors instead.

◆ ~WheelObstacle()

virtual cugl::physics2::WheelObstacle::~WheelObstacle ( )
inlinevirtual

Deletes this physics object and all of its resources.

We have to make the destructor public so that we can polymorphically delete physics objects.

A non-default destructor is necessary since we must release all claims on scene graph nodes.

Member Function Documentation

◆ alloc() [1/3]

static std::shared_ptr<WheelObstacle> cugl::physics2::WheelObstacle::alloc ( )
inlinestatic

Returns a new wheel object at the origin with no radius.

Returns
a new wheel object at the origin with no radius.

◆ alloc() [2/3]

static std::shared_ptr<WheelObstacle> cugl::physics2::WheelObstacle::alloc ( const Vec2  pos)
inlinestatic

Returns a new wheel object at the given point with no radius.

The scene graph is completely decoupled from the physics system. The node does not have to be the same size as the physics body. We only guarantee that the scene graph node is positioned correctly according to the drawing scale.

Parameters
posInitial position in world coordinates
Returns
a new wheel object at the given point with no radius.

◆ alloc() [3/3]

static std::shared_ptr<WheelObstacle> cugl::physics2::WheelObstacle::alloc ( const Vec2  pos,
float  radius 
)
inlinestatic

Returns a new wheel object of the given radius.

The scene graph is completely decoupled from the physics system. The node does not have to be the same size as the physics body. We only guarantee that the scene graph node is positioned correctly according to the drawing scale.

Parameters
posInitial position in world coordinates
radiusThe wheel radius
Returns
a new wheel object of the given radius.

◆ createFixtures()

virtual void cugl::physics2::WheelObstacle::createFixtures ( )
overridevirtual

Create new fixtures for this body, defining the shape

This is the primary method to override for custom physics objects

Reimplemented from cugl::physics2::SimpleObstacle.

◆ getRadius()

float cugl::physics2::WheelObstacle::getRadius ( ) const
inline

Returns the radius of this circle

Returns
the radius of this circle

◆ init() [1/3]

virtual bool cugl::physics2::WheelObstacle::init ( )
inlineoverridevirtual

Initializes a new wheel object at the origin with no size.

Returns
true if the obstacle is initialized properly, false otherwise.

Reimplemented from cugl::physics2::Obstacle.

◆ init() [2/3]

virtual bool cugl::physics2::WheelObstacle::init ( const Vec2  pos)
inlineoverridevirtual

Initializes a new wheel object at the given point with no size.

The scene graph is completely decoupled from the physics system. The node does not have to be the same size as the physics body. We only guarantee that the scene graph node is positioned correctly according to the drawing scale.

Parameters
posInitial position in world coordinates
Returns
true if the obstacle is initialized properly, false otherwise.

Reimplemented from cugl::physics2::Obstacle.

◆ init() [3/3]

virtual bool cugl::physics2::WheelObstacle::init ( const Vec2  pos,
float  radius 
)
virtual

Initializes a new wheel object of the given dimensions.

The scene graph is completely decoupled from the physics system. The node does not have to be the same size as the physics body. We only guarantee that the scene graph node is positioned correctly according to the drawing scale.

Parameters
posInitial position in world coordinates
radiusThe wheel radius
Returns
true if the obstacle is initialized properly, false otherwise.

◆ releaseFixtures()

virtual void cugl::physics2::WheelObstacle::releaseFixtures ( )
overridevirtual

Release the fixtures for this body, reseting the shape

This is the primary method to override for custom physics objects

Reimplemented from cugl::physics2::SimpleObstacle.

◆ resetDebug()

virtual void cugl::physics2::WheelObstacle::resetDebug ( )
overrideprotectedvirtual

Creates the outline of the physics fixtures in the debug node

The debug node is use to outline the fixtures attached to this object. This is very useful when the fixtures have a very different shape than the texture (e.g. a circular shape attached to a square texture).

Reimplemented from cugl::physics2::Obstacle.

◆ setRadius()

void cugl::physics2::WheelObstacle::setRadius ( float  value)
inline

Sets the radius of this circle

Parameters
valuethe radius of this circle

Member Data Documentation

◆ _geometry

b2Fixture* cugl::physics2::WheelObstacle::_geometry
protected

A cache value for the fixture (for resizing)

◆ _shape

b2CircleShape cugl::physics2::WheelObstacle::_shape
protected

Shape information for this box


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