OpenMW
Public Types | Public Member Functions | Public Attributes
OEngine::Physic::PhysicEngine Class Reference

#include <physic.hpp>

List of all members.

Public Types

typedef std::map< std::string,
HeightField
HeightFieldContainer
typedef std::map< std::string,
RigidBody * > 
RigidBodyContainer
typedef std::map< std::string,
PhysicActor * > 
PhysicActorContainer

Public Member Functions

 PhysicEngine (BulletShapeLoader *shapeLoader)
 ~PhysicEngine ()
RigidBodycreateAndAdjustRigidBody (const std::string &mesh, const std::string &name, float scale, const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, Ogre::Vector3 *scaledBoxTranslation=0, Ogre::Quaternion *boxRotation=0, bool raycasting=false, bool placeable=false)
void adjustRigidBody (RigidBody *body, const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, const Ogre::Vector3 &scaledBoxTranslation=Ogre::Vector3::ZERO, const Ogre::Quaternion &boxRotation=Ogre::Quaternion::IDENTITY)
void boxAdjustExternal (const std::string &mesh, RigidBody *body, float scale, const Ogre::Vector3 &position, const Ogre::Quaternion &rotation)
void addHeightField (float *heights, int x, int y, float yoffset, float triSize, float sqrtVerts)
void removeHeightField (int x, int y)
void addRigidBody (RigidBody *body, bool addToMap=true, RigidBody *raycastingBody=NULL, bool actor=false)
void removeRigidBody (const std::string &name)
void deleteRigidBody (const std::string &name)
RigidBodygetRigidBody (const std::string &name, bool raycasting=false)
void addCharacter (const std::string &name, const std::string &mesh, const Ogre::Vector3 &position, float scale, const Ogre::Quaternion &rotation)
void removeCharacter (const std::string &name)
PhysicActorgetCharacter (const std::string &name)
void stepSimulation (double deltaT)
void emptyEventLists (void)
void createDebugRendering ()
void setDebugRenderingMode (int mode)
bool toggleDebugRendering ()
void getObjectAABB (const std::string &mesh, float scale, btVector3 &min, btVector3 &max)
void setSceneManager (Ogre::SceneManager *sceneMgr)
bool isAnyActorStandingOn (const std::string &objectName)
std::pair< std::string, float > rayTest (btVector3 &from, btVector3 &to, bool raycastingObjectOnly=true, bool ignoreHeightMap=false)
std::vector< std::pair< float,
std::string > > 
rayTest2 (btVector3 &from, btVector3 &to)
std::pair< bool, float > sphereCast (float radius, btVector3 &from, btVector3 &to)
std::vector< std::string > getCollisions (const std::string &name)
std::pair< const RigidBody
*, btVector3 > 
getFilteredContact (const std::string &filter, const btVector3 &origin, btCollisionObject *object)

Public Attributes

btOverlappingPairCache * pairCache
btBroadphaseInterface * broadphase
btDefaultCollisionConfiguration * collisionConfiguration
btSequentialImpulseConstraintSolver * solver
btCollisionDispatcher * dispatcher
btDiscreteDynamicsWorld * dynamicsWorld
BulletShapeLoadermShapeLoader
HeightFieldContainer mHeightFieldMap
RigidBodyContainer mCollisionObjectMap
RigidBodyContainer mRaycastingObjectMap
PhysicActorContainer mActorMap
Ogre::SceneManager * mSceneMgr
BtOgre::DebugDrawermDebugDrawer
bool isDebugCreated
bool mDebugActive

Detailed Description

The PhysicEngine class contain everything which is needed for Physic. It's needed that Ogre Resources are set up before the PhysicEngine is created. Note:deleting it WILL NOT delete the RigidBody! TODO:unload unused resources?


Member Typedef Documentation


Constructor & Destructor Documentation

Note that the shapeLoader IS destroyed by the phyic Engine!!

It DOES destroy the shape loader!


Member Function Documentation

void OEngine::Physic::PhysicEngine::addCharacter ( const std::string &  name,
const std::string &  mesh,
const Ogre::Vector3 &  position,
float  scale,
const Ogre::Quaternion &  rotation 
)

Create and add a character to the scene, and add it to the ActorMap.

void OEngine::Physic::PhysicEngine::addHeightField ( float *  heights,
int  x,
int  y,
float  yoffset,
float  triSize,
float  sqrtVerts 
)

Add a HeightField to the simulation

void OEngine::Physic::PhysicEngine::addRigidBody ( RigidBody body,
bool  addToMap = true,
RigidBody raycastingBody = NULL,
bool  actor = false 
)

Add a RigidBody to the simulation

void OEngine::Physic::PhysicEngine::adjustRigidBody ( RigidBody body,
const Ogre::Vector3 &  position,
const Ogre::Quaternion &  rotation,
const Ogre::Vector3 &  scaledBoxTranslation = Ogre::Vector3::ZERO,
const Ogre::Quaternion &  boxRotation = Ogre::Quaternion::IDENTITY 
)

Adjusts a rigid body to the right position and rotation

void OEngine::Physic::PhysicEngine::boxAdjustExternal ( const std::string &  mesh,
RigidBody body,
float  scale,
const Ogre::Vector3 &  position,
const Ogre::Quaternion &  rotation 
)

Mainly used to (but not limited to) adjust rigid bodies based on box shapes to the right position and rotation.

RigidBody * OEngine::Physic::PhysicEngine::createAndAdjustRigidBody ( const std::string &  mesh,
const std::string &  name,
float  scale,
const Ogre::Vector3 &  position,
const Ogre::Quaternion &  rotation,
Ogre::Vector3 *  scaledBoxTranslation = 0,
Ogre::Quaternion *  boxRotation = 0,
bool  raycasting = false,
bool  placeable = false 
)

Creates a RigidBody. It does not add it to the simulation. After created, the body is set to the correct rotation, position, and scale

Create a debug rendering. It is called by setDebgRenderingMode if it's not created yet. Important Note: this will crash if the Render is not yet initialise!

void OEngine::Physic::PhysicEngine::deleteRigidBody ( const std::string &  name)

Delete a RigidBody, and remove it from RigidBodyMap.

Empty events lists

Return a pointer to a character TODO:check if the actor exist...

std::vector< std::string > OEngine::Physic::PhysicEngine::getCollisions ( const std::string &  name)
std::pair< const RigidBody *, btVector3 > OEngine::Physic::PhysicEngine::getFilteredContact ( const std::string &  filter,
const btVector3 &  origin,
btCollisionObject *  object 
)
void OEngine::Physic::PhysicEngine::getObjectAABB ( const std::string &  mesh,
float  scale,
btVector3 &  min,
btVector3 &  max 
)
RigidBody * OEngine::Physic::PhysicEngine::getRigidBody ( const std::string &  name,
bool  raycasting = false 
)

Return a pointer to a given rigid body.

bool OEngine::Physic::PhysicEngine::isAnyActorStandingOn ( const std::string &  objectName)
std::pair< std::string, float > OEngine::Physic::PhysicEngine::rayTest ( btVector3 &  from,
btVector3 &  to,
bool  raycastingObjectOnly = true,
bool  ignoreHeightMap = false 
)

Return the closest object hit by a ray. If there are no objects, it will return ("",-1).

std::vector< std::pair< float, std::string > > OEngine::Physic::PhysicEngine::rayTest2 ( btVector3 &  from,
btVector3 &  to 
)

Return all objects hit by a ray.

void OEngine::Physic::PhysicEngine::removeCharacter ( const std::string &  name)

Remove a character from the scene. TODO:delete it! for now, a small memory leak^^ done?

Remove a HeightField from the simulation

void OEngine::Physic::PhysicEngine::removeRigidBody ( const std::string &  name)

Remove a RigidBody from the simulation. It does not delete it, and does not remove it from the RigidBodyMap.

Set the debug rendering mode. 0 to turn it off. Important Note: this will crash if the Render is not yet initialise!

void OEngine::Physic::PhysicEngine::setSceneManager ( Ogre::SceneManager *  sceneMgr)
std::pair< bool, float > OEngine::Physic::PhysicEngine::sphereCast ( float  radius,
btVector3 &  from,
btVector3 &  to 
)
Returns:
(hit, relative distance)

This step the simulation of a given time.


Member Data Documentation

btSequentialImpulseConstraintSolver* OEngine::Physic::PhysicEngine::solver

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