YourGameLib
Loading...
Searching...
No Matches
Public Member Functions | List of all members
yourgame::util::PhysEnv Class Reference

Represents a Physical Environment. More...

#include <physenv.h>

Public Member Functions

 PhysEnv ()
 
 ~PhysEnv ()
 
void setGravity (float x, float y, float z)
 Set the Gravity of the physical world.
 
bool newBoxShape (const std::string &name, float halfX, float halfY, float halfZ)
 Creates and stores a new box shape to be referenced during rigid body creation.
 
bool newSphereShape (const std::string &name, float radius)
 Creates and stores a new sphere shape to be referenced during rigid body creation.
 
bool newCylinderShape (const std::string &name, float radius, float height)
 Creates and stores a new cylinder shape to be referenced during rigid body creation.
 
bool newConeShape (const std::string &name, float radius, float height)
 Creates and stores a new cone shape to be referenced during rigid body creation.
 
bool deleteShape (const std::string &name)
 Deletes a shape by name.
 
size_t clearShapes ()
 Deletes all shapes.
 
size_t numShapes ()
 Returns the number of present shapes.
 
bool newRigidBody (const std::string &name, const std::string &shapeName, const yourgame::math::Trafo &trafo, const RigidBodyInfo &info)
 Creates and stores a new rigid body.
 
bool deleteRigidBody (const std::string &name)
 Deletes rigid body by name.
 
yourgame::util::RigidBodygetRigidBody (const std::string &name)
 Returns rigid body by name.
 
std::vector< RigidBody * > getRigidBodiesStartingWith (const std::string &name)
 Returns rigid bodies with names starting with name.
 
size_t clearRigidBodies ()
 Deletes all rigid bodies.
 
size_t numRigidBodies ()
 Returns the number of present rigid bodies.
 
void tick (float dt)
 Advances the physical world dt seconds.
 
std::vector< CollisiongetCollisions ()
 Returns the collisions of rigid bodies since last tick()
 
RayTestResult rayTest (float eyeX, float eyeY, float eyeZ, float targetX, float targetY, float targetZ)
 Shoots a ray from eye to target into the world. Result contains first rigid body hit, if any.
 

Detailed Description

Represents a Physical Environment.

Constructor & Destructor Documentation

◆ PhysEnv()

yourgame::util::PhysEnv::PhysEnv ( )

◆ ~PhysEnv()

yourgame::util::PhysEnv::~PhysEnv ( )

Member Function Documentation

◆ clearRigidBodies()

size_t yourgame::util::PhysEnv::clearRigidBodies ( )

Deletes all rigid bodies.

Returns
number of rigid bodies deleted

◆ clearShapes()

size_t yourgame::util::PhysEnv::clearShapes ( )

Deletes all shapes.

Returns
number of shapes deleted

◆ deleteRigidBody()

bool yourgame::util::PhysEnv::deleteRigidBody ( const std::string &  name)

Deletes rigid body by name.

Parameters
namename of the rigidy body to delete
Returns
true if rigid body was deleted, false otherwise

◆ deleteShape()

bool yourgame::util::PhysEnv::deleteShape ( const std::string &  name)

Deletes a shape by name.

Parameters
namename of shape to delete
Returns
true if shape was deleted, false if no such shape

◆ getCollisions()

std::vector< Collision > yourgame::util::PhysEnv::getCollisions ( )

Returns the collisions of rigid bodies since last tick()

Returns
collisions

◆ getRigidBodiesStartingWith()

std::vector< RigidBody * > yourgame::util::PhysEnv::getRigidBodiesStartingWith ( const std::string &  name)

Returns rigid bodies with names starting with name.

Parameters
namename (prefix) of rigid bodies to get
Returns
matching rigid bodies

◆ getRigidBody()

yourgame::util::RigidBody * yourgame::util::PhysEnv::getRigidBody ( const std::string &  name)

Returns rigid body by name.

Parameters
namename of the rigid body
Returns
pointer to rigid body if it exists, nullptr otherwise

◆ newBoxShape()

bool yourgame::util::PhysEnv::newBoxShape ( const std::string &  name,
float  halfX,
float  halfY,
float  halfZ 
)

Creates and stores a new box shape to be referenced during rigid body creation.

Parameters
namename of the new box shape
halfXhalf extent in x dimension
halfYhalf extent in y dimension
halfZhalf extent in z dimension
Returns
true if new box shape was created, false if shape with this name existed before

◆ newConeShape()

bool yourgame::util::PhysEnv::newConeShape ( const std::string &  name,
float  radius,
float  height 
)

Creates and stores a new cone shape to be referenced during rigid body creation.

Parameters
namename of the new cone shape
radiusradius
heightheight
Returns
true if new cone shape was created, false if shape with this name existed before

◆ newCylinderShape()

bool yourgame::util::PhysEnv::newCylinderShape ( const std::string &  name,
float  radius,
float  height 
)

Creates and stores a new cylinder shape to be referenced during rigid body creation.

Parameters
namename of the new cylinder shape
radiusradius
heightheight
Returns
true if new cylinder shape was created, false if shape with this name existed before

◆ newRigidBody()

bool yourgame::util::PhysEnv::newRigidBody ( const std::string &  name,
const std::string &  shapeName,
const yourgame::math::Trafo trafo,
const RigidBodyInfo info 
)

Creates and stores a new rigid body.

Parameters
namename of the rigid body
shapeNamename of the shape to use for this rigid body
Returns
true if rigid body was added, false otherwise

◆ newSphereShape()

bool yourgame::util::PhysEnv::newSphereShape ( const std::string &  name,
float  radius 
)

Creates and stores a new sphere shape to be referenced during rigid body creation.

Parameters
namename of the new sphere shape
radiusradius
Returns
true if new sphere shape was created, false if shape with this name existed before

◆ numRigidBodies()

size_t yourgame::util::PhysEnv::numRigidBodies ( )

Returns the number of present rigid bodies.

Returns
number of present rigid bodies

◆ numShapes()

size_t yourgame::util::PhysEnv::numShapes ( )

Returns the number of present shapes.

Returns
number of present shapes

◆ rayTest()

RayTestResult yourgame::util::PhysEnv::rayTest ( float  eyeX,
float  eyeY,
float  eyeZ,
float  targetX,
float  targetY,
float  targetZ 
)

Shoots a ray from eye to target into the world. Result contains first rigid body hit, if any.

Returns
Result of the ray test

◆ setGravity()

void yourgame::util::PhysEnv::setGravity ( float  x,
float  y,
float  z 
)

Set the Gravity of the physical world.

Parameters
xx-component of gravity
yy-component of gravity
zz-component of gravity

◆ tick()

void yourgame::util::PhysEnv::tick ( float  dt)

Advances the physical world dt seconds.

Parameters
dttime [seconds] to advance the physical world

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