LibreOffice Module slideshow (master) 1
Public Member Functions | Private Attributes | List of all members
box2d::utils::box2DBody Class Reference

Class that manages a single box2D Body. More...

#include <box2dtools.hxx>

Public Member Functions

 box2DBody (std::shared_ptr< b2Body > pBox2DBody, double fScaleFactor)
 
::basegfx::B2DPoint getPosition () const
 
void setPosition (const ::basegfx::B2DPoint &rPos)
 Set the position of box2d body. More...
 
void setPositionByLinearVelocity (const ::basegfx::B2DPoint &rDesiredPos, const double fPassedTime)
 Moves body to the specified position. More...
 
void setLinearVelocity (const ::basegfx::B2DVector &rVelocity)
 Sets linear velocity of the body. More...
 
void setAngleByAngularVelocity (const double fDesiredAngle, const double fPassedTime)
 Rotate body to specified angle of rotation. More...
 
void setAngularVelocity (const double fAngularVelocity)
 Sets angular velocity of the body. More...
 
void setCollision (const bool bCanCollide)
 Sets whether the body have collisions or not. More...
 
double getAngle () const
 
void setAngle (const double fAngle)
 Set angle of the box2d body. More...
 
void setDensityAndRestitution (const double fDensity, const double fRestitution)
 Set density and restitution of the box2d body. More...
 
void setRestitution (const double fRestitution)
 Set restitution of the box2d body. More...
 
void setType (box2DBodyType eType)
 Set type of the body. More...
 
box2DBodyType getType () const
 

Private Attributes

std::shared_ptr< b2Body > mpBox2DBody
 Pointer to the body that this class manages. More...
 
double mfScaleFactor
 Scale factor for conversions between LO user space coordinates to Box2D World coordinates. More...
 

Detailed Description

Class that manages a single box2D Body.

Definition at line 365 of file box2dtools.hxx.

Constructor & Destructor Documentation

◆ box2DBody()

box2d::utils::box2DBody::box2DBody ( std::shared_ptr< b2Body >  pBox2DBody,
double  fScaleFactor 
)

Definition at line 775 of file box2dtools.cxx.

Member Function Documentation

◆ getAngle()

double box2d::utils::box2DBody::getAngle ( ) const
Returns
current angle of rotation of the body

Definition at line 853 of file box2dtools.cxx.

References mpBox2DBody.

Referenced by setAngleByAngularVelocity().

◆ getPosition()

basegfx::B2DPoint box2d::utils::box2DBody::getPosition ( ) const
Returns
current position in LO user space coordinates

Definition at line 781 of file box2dtools.cxx.

References mfScaleFactor, and mpBox2DBody.

Referenced by setPositionByLinearVelocity().

◆ getType()

box2DBodyType box2d::utils::box2DBody::getType ( ) const
Returns
type of the body

Definition at line 891 of file box2dtools.cxx.

References mpBox2DBody.

◆ setAngle()

void box2d::utils::box2DBody::setAngle ( const double  fAngle)

Set angle of the box2d body.

Parameters
fAngleAngle in degrees

Definition at line 859 of file box2dtools.cxx.

References mpBox2DBody.

◆ setAngleByAngularVelocity()

void box2d::utils::box2DBody::setAngleByAngularVelocity ( const double  fDesiredAngle,
const double  fPassedTime 
)

Rotate body to specified angle of rotation.

Rotates body to specified rotation as if the body had angular velocity to reach that state in given time frame

Parameters
fDesiredAngleRotation angle in degrees to arrive in the time frame
fPassedTimeAmount of time for the movement to take place

Definition at line 809 of file box2dtools.cxx.

References getAngle(), mpBox2DBody, and setAngularVelocity().

◆ setAngularVelocity()

void box2d::utils::box2DBody::setAngularVelocity ( const double  fAngularVelocity)

Sets angular velocity of the body.

Parameters
fAngularVelocityAngular velocity in degrees per second

Definition at line 833 of file box2dtools.cxx.

References basegfx::deg2rad(), and mpBox2DBody.

Referenced by setAngleByAngularVelocity().

◆ setCollision()

void box2d::utils::box2DBody::setCollision ( const bool  bCanCollide)

Sets whether the body have collisions or not.

Definition at line 839 of file box2dtools.cxx.

References mpBox2DBody.

◆ setDensityAndRestitution()

void box2d::utils::box2DBody::setDensityAndRestitution ( const double  fDensity,
const double  fRestitution 
)

Set density and restitution of the box2d body.

Parameters
fDensityDensity in kg/m^2
fRestitutionRestitution (elasticity) coefficient, usually in the range [0,1]

Definition at line 864 of file box2dtools.cxx.

References mpBox2DBody.

◆ setLinearVelocity()

void box2d::utils::box2DBody::setLinearVelocity ( const ::basegfx::B2DVector rVelocity)

Sets linear velocity of the body.

Parameters
rVelocityVelocity vector in LO user space coordinates

Definition at line 826 of file box2dtools.cxx.

References mfScaleFactor, and mpBox2DBody.

Referenced by setPositionByLinearVelocity().

◆ setPosition()

void box2d::utils::box2DBody::setPosition ( const ::basegfx::B2DPoint rPos)

Set the position of box2d body.

Parameters
rPosPosition in LO user space coordinates

Definition at line 789 of file box2dtools.cxx.

References mfScaleFactor, and mpBox2DBody.

◆ setPositionByLinearVelocity()

void box2d::utils::box2DBody::setPositionByLinearVelocity ( const ::basegfx::B2DPoint rDesiredPos,
const double  fPassedTime 
)

Moves body to the specified position.

Moves body to the specified position by setting velocity of the body so that it reaches to rDesiredPos in given time fram

Parameters
rDesiredPosPosition to arrive in the time frame
fPassedTimeAmount of time for the movement to take place

Definition at line 795 of file box2dtools.cxx.

References getPosition(), mpBox2DBody, and setLinearVelocity().

◆ setRestitution()

void box2d::utils::box2DBody::setRestitution ( const double  fRestitution)

Set restitution of the box2d body.

Parameters
fRestitutionRestitution (elasticity) coefficient, usually in the range [0,1]

Definition at line 877 of file box2dtools.cxx.

References mpBox2DBody.

◆ setType()

void box2d::utils::box2DBody::setType ( box2DBodyType  eType)

Set type of the body.

Definition at line 886 of file box2dtools.cxx.

References eType, and mpBox2DBody.

Member Data Documentation

◆ mfScaleFactor

double box2d::utils::box2DBody::mfScaleFactor
private

Scale factor for conversions between LO user space coordinates to Box2D World coordinates.

Definition at line 371 of file box2dtools.hxx.

Referenced by getPosition(), setLinearVelocity(), and setPosition().

◆ mpBox2DBody

std::shared_ptr<b2Body> box2d::utils::box2DBody::mpBox2DBody
private

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