OgreRefApp::World Class Reference

Physics world definition. More...

#include <OgreRefAppWorld.h>

List of all members.

Public Types

enum  WorldType
 World type, you'll want to extend this for your own apps.

Public Member Functions

 World (SceneManager *sceneMgr, WorldType worldType=WT_REFAPP_GENERIC)
SceneManager * getSceneManager (void)
 Get the scene manager for this world.
OgreHead * createOgreHead (const String &name, const Vector3 &pos=Vector3::ZERO, const Quaternion &orientation=Quaternion::IDENTITY)
FinitePlane * createPlane (const String &name, Real width, Real height, const Vector3 &pos=Vector3::ZERO, const Quaternion &orientation=Quaternion::IDENTITY)
Ball * createBall (const String &name, Real radius, const Vector3 &pos=Vector3::ZERO, const Quaternion &orientation=Quaternion::IDENTITY)
Box * createBox (const String &name, Real width, Real height, Real depth, const Vector3 &pos=Vector3::ZERO, const Quaternion &orientation=Quaternion::IDENTITY)
CharactercreateCharacter (const String &name, const String &_meshName, const Vector3 &pos=Vector3::ZERO, const Quaternion &orientation=Quaternion::IDENTITY)
NPCcreateNPC (const String &name, const String &_meshName, const Vector3 &pos=Vector3::ZERO, const Quaternion &orientation=Quaternion::IDENTITY)
CollideCameracreateCamera (const String &name, const Vector3 &pos=Vector3::ZERO, const Quaternion &orientation=Quaternion::IDENTITY)
void clear (void)
void _applyCollision (void)
void _applyDynamics (Real timeElapsed)
void _notifyDynamicsStateForObject (ApplicationObject *obj, bool dynamicsEnabled)
void setGravity (const Vector3 &vec)
const Vector3 & getGravity (void)
JointcreateJoint (const String &name, Joint::JointType jtype, ApplicationObject *obj1, ApplicationObject *obj2)
void setSimulationStepSize (Real step)
Real getSimulationStepSize (void)
void simulationStep (Real timeElapsed)

Static Public Member Functions

static WorldgetSingleton (void)
static WorldgetSingletonPtr (void)

Protected Attributes

SceneManager * mSceneMgr
 Pointer to OGRE's scene manager.
ObjectMap mObjects
 Main list of objects.
ObjectSet mDynamicsObjects
 Set of dynamics objects (those to perform physics on).
dJointGroup * mOdeContactGroup
 Contact joint group.
Real mSimulationStepSize
 The step size of the collision / physics simulation.
WorldType mWorldType
 The type of world we're dealing with.


Detailed Description

Physics world definition.

Constructor & Destructor Documentation

OgreRefApp::World::World ( SceneManager *  sceneMgr,
WorldType  worldType = WT_REFAPP_GENERIC 
)

Creates an instance of the world.

Parameters:
sceneMgr Pointer to the scene manager which will manage the scene
worldType The type of world being used


Member Function Documentation

OgreHead * OgreRefApp::World::createOgreHead ( const String &  name,
const Vector3 &  pos = Vector3::ZERO,
const Quaternion &  orientation = Quaternion::IDENTITY 
)

Create an OGRE head object.

FinitePlane * OgreRefApp::World::createPlane ( const String &  name,
Real  width,
Real  height,
const Vector3 &  pos = Vector3::ZERO,
const Quaternion &  orientation = Quaternion::IDENTITY 
)

Create a plane object.

Ball * OgreRefApp::World::createBall ( const String &  name,
Real  radius,
const Vector3 &  pos = Vector3::ZERO,
const Quaternion &  orientation = Quaternion::IDENTITY 
)

Create a ball object.

OgreRefApp::Box * OgreRefApp::World::createBox ( const String &  name,
Real  width,
Real  height,
Real  depth,
const Vector3 &  pos = Vector3::ZERO,
const Quaternion &  orientation = Quaternion::IDENTITY 
)

Create a box object.

Character * OgreRefApp::World::createCharacter ( const String &  name,
const String &  _meshName,
const Vector3 &  pos = Vector3::ZERO,
const Quaternion &  orientation = Quaternion::IDENTITY 
)

Create a character object.

NPC * OgreRefApp::World::createNPC ( const String &  name,
const String &  _meshName,
const Vector3 &  pos = Vector3::ZERO,
const Quaternion &  orientation = Quaternion::IDENTITY 
)

Create a NPC object.

CollideCamera * OgreRefApp::World::createCamera ( const String &  name,
const Vector3 &  pos = Vector3::ZERO,
const Quaternion &  orientation = Quaternion::IDENTITY 
)

Create a camera which interacts with the world.

void OgreRefApp::World::clear ( void   ) 

Clears the scene.

void OgreRefApp::World::_applyCollision ( void   ) 

Detects all the collisions in the world and acts on them.

Remarks:
This method performs the appropriate queries to detect all the colliding objects in the world, tells the objects about it and adds the appropriate physical simulation constructs required to apply collision response when applyDynamics is called.
This method is called automatically by World::simulationStep()

void OgreRefApp::World::_applyDynamics ( Real  timeElapsed  ) 

Updates the world simulation.

This method is called automatically by World::simulationStep()

void OgreRefApp::World::_notifyDynamicsStateForObject ( ApplicationObject obj,
bool  dynamicsEnabled 
)

Internal method for notifying the world of a change in the dynamics status of an object.

void OgreRefApp::World::setGravity ( const Vector3 &  vec  ) 

Sets the gravity vector, units are in m/s^2.

Remarks:
The world defaults to no gravity. Tip: Earth gravity is Vector3(0, -9.81, 0);

const Vector3 & OgreRefApp::World::getGravity ( void   ) 

Gets the gravity vector.

Joint * OgreRefApp::World::createJoint ( const String &  name,
Joint::JointType  jtype,
ApplicationObject obj1,
ApplicationObject obj2 
)

Creates a Joint object for linking objects together in the world.

Parameters:
name The name of the Joint.
jtype The type of joint, see Joint::JointType.
obj1 The first object to attach, or NULL to attach to the static world.
obj2 The second object to attach, or NULL to attach to the static world.

void OgreRefApp::World::setSimulationStepSize ( Real  step  ) 

Sets the step size of the simulation.

Remarks:
This parameter allows you to alter the accuracy of the simulation. This is the interval at which collision and physics are performed, such that in high frame rate scenarios these operations are not done every single frame, and in low frame rate situations more steps are performed per frame to ensure the stability of the simulation.
The default value for this parameter is 0.01s.

Real OgreRefApp::World::getSimulationStepSize ( void   ) 

Returns the size of the simulation step.

void OgreRefApp::World::simulationStep ( Real  timeElapsed  ) 

Performs a simulation step, ie applies collision and physics.

Remarks:
Collision events will cause callbacks to your ApplicationObject instances to notify them of the collisions; this is for information, dynamics are applied automatically if turned on for the objects so you do not need to handle physics yourself if you do not wish to.
Note that if the timeElapsed parameter is greater than the simulation step size (as set using setSimulationStepSize), more than one collision and dynamics step will take place during this call. Similarly, no step may occur if the time elapsed has not reached the simulation step size yet.

OgreRefApp::World & OgreRefApp::World::getSingleton ( void   )  [static]

Override standard Singleton retrieval.

Remarks:
Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.
This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.

OgreRefApp::World * OgreRefApp::World::getSingletonPtr ( void   )  [static]

Override standard Singleton retrieval.

Remarks:
Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.
This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.


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

Generated on Sun Jun 15 18:43:30 2008 for SpadeShip Project by  doxygen 1.5.5