Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

OgreRefApp::World Class Reference

#include <OgreRefAppWorld.h>

Inheritance diagram for OgreRefApp::World:

Ogre::Singleton< World > List of all members.

Public Types

enum  WorldType { WT_REFAPP_GENERIC, WT_REFAPP_BSP }
 World type, you'll want to extend this for your own apps. More...


Public Member Functions

 World (SceneManager *sceneMgr, WorldType worldType=WT_REFAPP_GENERIC)
 Creates an instance of the world.

 ~World ()
SceneManagergetSceneManager (void)
 Get the scene manager for this world.

OgreHeadcreateOgreHead (const String &name, const Vector3 &pos=Vector3::ZERO, const Quaternion &orientation=Quaternion::IDENTITY)
 Create an OGRE head object.

FinitePlanecreatePlane (const String &name, Real width, Real height, const Vector3 &pos=Vector3::ZERO, const Quaternion &orientation=Quaternion::IDENTITY)
 Create a plane object.

BallcreateBall (const String &name, Real radius, const Vector3 &pos=Vector3::ZERO, const Quaternion &orientation=Quaternion::IDENTITY)
 Create a ball object.

BoxcreateBox (const String &name, Real width, Real height, Real depth, const Vector3 &pos=Vector3::ZERO, const Quaternion &orientation=Quaternion::IDENTITY)
 Create a box object.

CollideCameracreateCamera (const String &name, const Vector3 &pos=Vector3::ZERO, const Quaternion &orientation=Quaternion::IDENTITY)
 Create a camera which interacts with the world.

void clear (void)
 Clears the scene.

dWorld * getOdeWorld (void)
dJointGroup * getOdeContactJointGroup (void)
void _applyCollision (void)
 Detects all the collisions in the world and acts on them.

void _applyDynamics (Real timeElapsed)
 Updates the world simulation.

void _notifyDynamicsStateForObject (ApplicationObject *obj, bool dynamicsEnabled)
 Internal method for notifying the world of a change in the dynamics status of an object.

void setGravity (const Vector3 &vec)
 Sets the gravity vector, units are in m/s^2.

const Vector3getGravity (void)
 Gets the gravity vector.

JointcreateJoint (const String &name, Joint::JointType jtype, ApplicationObject *obj1, ApplicationObject *obj2)
 Creates a Joint object for linking objects together in the world.

void setSimulationStepSize (Real step)
 Sets the step size of the simulation.

Real getSimulationStepSize (void)
 Returns the size of the simulation step.

void simulationStep (Real timeElapsed)
 Performs a simulation step, ie applies collision and physics.


Static Public Member Functions

WorldgetSingleton (void)
 Override standard Singleton retrieval.

WorldgetSingletonPtr (void)
 Override standard Singleton retrieval.


Protected Types

typedef std::map< String,
ApplicationObject * > 
ObjectMap
typedef std::map< String,
Joint * > 
JointMap
typedef std::set< ApplicationObject * > ObjectSet

Protected Attributes

SceneManagermSceneMgr
 Pointer to OGRE's scene manager.

ObjectMap mObjects
 Main list of objects.

JointMap mJoints
ObjectSet mDynamicsObjects
 Set of dynamics objects (those to perform physics on).

dWorld * mOdeWorld
dJointGroup * mOdeContactGroup
 Contact joint group.

Vector3 mGravity
IntersectionSceneQuerymIntersectionQuery
Real mSimulationStepSize
 The step size of the collision / physics simulation.

WorldType mWorldType
 The type of world we're dealing with.


Static Protected Attributes

Worldms_Singleton

Member Typedef Documentation

typedef std::map<String, Joint*> OgreRefApp::World::JointMap [protected]
 

Definition at line 50 of file OgreRefAppWorld.h.

typedef std::map<String, ApplicationObject*> OgreRefApp::World::ObjectMap [protected]
 

Definition at line 46 of file OgreRefAppWorld.h.

typedef std::set<ApplicationObject*> OgreRefApp::World::ObjectSet [protected]
 

Definition at line 53 of file OgreRefAppWorld.h.


Member Enumeration Documentation

enum OgreRefApp::World::WorldType
 

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

Enumeration values:
WT_REFAPP_GENERIC 
WT_REFAPP_BSP 

Definition at line 38 of file OgreRefAppWorld.h.


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

OgreRefApp::World::~World  ) 
 


Member Function Documentation

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::clear void   ) 
 

Clears the scene.

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

Create a ball object.

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.

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.

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.

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.

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

Gets the gravity vector.

dJointGroup* OgreRefApp::World::getOdeContactJointGroup void   ) 
 

dWorld* OgreRefApp::World::getOdeWorld void   ) 
 

SceneManager* OgreRefApp::World::getSceneManager void   ) 
 

Get the scene manager for this world.

Real OgreRefApp::World::getSimulationStepSize void   ) 
 

Returns the size of the simulation step.

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.

Reimplemented from Ogre::Singleton< World >.

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.

Reimplemented from Ogre::Singleton< World >.

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);

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.

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.


Member Data Documentation

ObjectSet OgreRefApp::World::mDynamicsObjects [protected]
 

Set of dynamics objects (those to perform physics on).

Definition at line 55 of file OgreRefAppWorld.h.

Vector3 OgreRefApp::World::mGravity [protected]
 

Definition at line 63 of file OgreRefAppWorld.h.

IntersectionSceneQuery* OgreRefApp::World::mIntersectionQuery [protected]
 

Definition at line 65 of file OgreRefAppWorld.h.

JointMap OgreRefApp::World::mJoints [protected]
 

Definition at line 51 of file OgreRefAppWorld.h.

ObjectMap OgreRefApp::World::mObjects [protected]
 

Main list of objects.

Definition at line 48 of file OgreRefAppWorld.h.

dJointGroup* OgreRefApp::World::mOdeContactGroup [protected]
 

Contact joint group.

Definition at line 61 of file OgreRefAppWorld.h.

dWorld* OgreRefApp::World::mOdeWorld [protected]
 

Definition at line 58 of file OgreRefAppWorld.h.

World * Ogre::Singleton< World >::ms_Singleton [static, protected, inherited]
 

Definition at line 54 of file OgreSingleton.h.

SceneManager* OgreRefApp::World::mSceneMgr [protected]
 

Pointer to OGRE's scene manager.

Definition at line 44 of file OgreRefAppWorld.h.

Real OgreRefApp::World::mSimulationStepSize [protected]
 

The step size of the collision / physics simulation.

Definition at line 68 of file OgreRefAppWorld.h.

WorldType OgreRefApp::World::mWorldType [protected]
 

The type of world we're dealing with.

Definition at line 71 of file OgreRefAppWorld.h.


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

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:55:25 2006