OpenMW
|
#include <physic.hpp>
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 () | |
RigidBody * | 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) |
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) |
RigidBody * | getRigidBody (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) |
PhysicActor * | getCharacter (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 |
BulletShapeLoader * | mShapeLoader |
HeightFieldContainer | mHeightFieldMap |
RigidBodyContainer | mCollisionObjectMap |
RigidBodyContainer | mRaycastingObjectMap |
PhysicActorContainer | mActorMap |
Ogre::SceneManager * | mSceneMgr |
BtOgre::DebugDrawer * | mDebugDrawer |
bool | isDebugCreated |
bool | mDebugActive |
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?
typedef std::map<std::string, HeightField> OEngine::Physic::PhysicEngine::HeightFieldContainer |
typedef std::map<std::string, PhysicActor*> OEngine::Physic::PhysicEngine::PhysicActorContainer |
typedef std::map<std::string,RigidBody*> OEngine::Physic::PhysicEngine::RigidBodyContainer |
OEngine::Physic::PhysicEngine::PhysicEngine | ( | BulletShapeLoader * | shapeLoader | ) |
Note that the shapeLoader IS destroyed by the phyic Engine!!
It DOES destroy the shape loader!
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.
void OEngine::Physic::PhysicEngine::emptyEventLists | ( | void | ) |
Empty events lists
PhysicActor * OEngine::Physic::PhysicEngine::getCharacter | ( | const std::string & | name | ) |
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?
void OEngine::Physic::PhysicEngine::removeHeightField | ( | int | x, |
int | y | ||
) |
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.
void OEngine::Physic::PhysicEngine::setDebugRenderingMode | ( | int | mode | ) |
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 | ||
) |
void OEngine::Physic::PhysicEngine::stepSimulation | ( | double | deltaT | ) |
This step the simulation of a given time.
btBroadphaseInterface* OEngine::Physic::PhysicEngine::broadphase |
btDefaultCollisionConfiguration* OEngine::Physic::PhysicEngine::collisionConfiguration |
btCollisionDispatcher* OEngine::Physic::PhysicEngine::dispatcher |
btDiscreteDynamicsWorld* OEngine::Physic::PhysicEngine::dynamicsWorld |
Ogre::SceneManager* OEngine::Physic::PhysicEngine::mSceneMgr |
btOverlappingPairCache* OEngine::Physic::PhysicEngine::pairCache |
btSequentialImpulseConstraintSolver* OEngine::Physic::PhysicEngine::solver |