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

# OgreRefApp::World Class Reference

`#include <OgreRefAppWorld.h>`

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 Methods

| World (SceneManager *sceneMgr, WorldType worldType=WT_REFAPP_GENERIC)
| Creates an instance of the world.
| ~World ()
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)
| Create an OGRE head object.
FinitePlane * | createPlane (const String &name, Real width, Real height, const Vector3 &pos=Vector3::ZERO, const Quaternion &orientation=Quaternion::IDENTITY)
| Create a plane object.
Ball * | createBall (const String &name, Real radius, const Vector3 &pos=Vector3::ZERO, const Quaternion &orientation=Quaternion::IDENTITY)
| Create a ball object.
Box * | 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 * | createCamera (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 Vector3 & | getGravity (void)
| Gets the gravity vector.
Joint * | createJoint (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 Methods

World & | getSingleton (void)
| Override standard Singleton retrieval.
World * | getSingletonPtr (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

SceneManager * | mSceneMgr
| 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
IntersectionSceneQuery * | mIntersectionQuery
Real | mSimulationStepSize
| The step size of the collision / physics simulation.
WorldType | mWorldType
| The type of world we're dealing with.

## 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

Definition at line 47 of file OgreRefAppWorld.cpp.

References mIntersectionQuery, mOdeContactGroup, mOdeWorld, mSceneMgr, and mSimulationStepSize.

OgreRefApp::World::~World | ( |  | ) |

| Definition at line 69 of file OgreRefAppWorld.cpp. References clear(), mIntersectionQuery, mOdeContactGroup, and mOdeWorld.

## 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()

Definition at line 193 of file OgreRefAppWorld.cpp.

References mIntersectionQuery, and OgreRefApp::ApplicationObject::testCollide().

Referenced by simulationStep().

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

Updates the world simulation.

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

Definition at line 144 of file OgreRefAppWorld.cpp.

References mDynamicsObjects, mOdeContactGroup, mOdeWorld, and Ogre::Real.

Referenced by 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. Definition at line 164 of file OgreRefAppWorld.cpp. References mDynamicsObjects.

void OgreRefApp::World::clear | ( | void |  | ) |

| Clears the scene. Definition at line 122 of file OgreRefAppWorld.cpp. References mJoints, and mObjects. Referenced by ~World().

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

| Create a ball object. Definition at line 110 of file OgreRefAppWorld.cpp. References mObjects, Ogre::Real, OgreRefApp::ApplicationObject::setOrientation(), OgreRefApp::ApplicationObject::setPosition(), and Ogre::String.

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. Definition at line 308 of file OgreRefAppWorld.cpp. References mObjects, Ogre::Real, OgreRefApp::ApplicationObject::setOrientation(), OgreRefApp::ApplicationObject::setPosition(), and Ogre::String.

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. Definition at line 321 of file OgreRefAppWorld.cpp. References mObjects, OgreRefApp::CollideCamera::setOrientation(), OgreRefApp::ApplicationObject::setPosition(), and Ogre::String.

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.

Definition at line 249 of file OgreRefAppWorld.cpp.

References mJoints, and Ogre::String.

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

| Create an OGRE head object. Definition at line 86 of file OgreRefAppWorld.cpp. References mObjects, OgreRefApp::ApplicationObject::setOrientation(), OgreRefApp::ApplicationObject::setPosition(), and Ogre::String.

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. Definition at line 98 of file OgreRefAppWorld.cpp. References mObjects, Ogre::Real, OgreRefApp::ApplicationObject::setOrientation(), OgreRefApp::ApplicationObject::setPosition(), and Ogre::String.

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

| Gets the gravity vector. Definition at line 183 of file OgreRefAppWorld.cpp. References mGravity.

dJointGroup * OgreRefApp::World::getOdeContactJointGroup | ( | void |  | ) |

| Definition at line 188 of file OgreRefAppWorld.cpp. References mOdeContactGroup.

dWorld * OgreRefApp::World::getOdeWorld | ( | void |  | ) |

| Definition at line 139 of file OgreRefAppWorld.cpp. References mOdeWorld.

SceneManager * OgreRefApp::World::getSceneManager | ( | void |  | ) |

| Get the scene manager for this world. Definition at line 81 of file OgreRefAppWorld.cpp. References mSceneMgr.

Real OgreRefApp::World::getSimulationStepSize | ( | void |  | ) |

| Returns the size of the simulation step. Definition at line 282 of file OgreRefAppWorld.cpp. References mSimulationStepSize, and Ogre::Real.

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.

Definition at line 39 of file OgreRefAppWorld.cpp.

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.

Definition at line 35 of file OgreRefAppWorld.cpp.

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

Definition at line 177 of file OgreRefAppWorld.cpp.

References mGravity, and mOdeWorld.

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.

Definition at line 277 of file OgreRefAppWorld.cpp.

References mSimulationStepSize, and Ogre::Real.

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.

Definition at line 287 of file OgreRefAppWorld.cpp.

References _applyCollision(), _applyDynamics(), mSimulationStepSize, and Ogre::Real.

## 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. Referenced by _applyDynamics(), and _notifyDynamicsStateForObject().

Vector3 OgreRefApp::World::mGravity`[protected]`

| Definition at line 63 of file OgreRefAppWorld.h. Referenced by getGravity(), and setGravity().

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

| Definition at line 65 of file OgreRefAppWorld.h. Referenced by _applyCollision(), World(), and ~World().

JointMap OgreRefApp::World::mJoints`[protected]`

| Definition at line 51 of file OgreRefAppWorld.h. Referenced by clear(), and createJoint().

ObjectMap OgreRefApp::World::mObjects`[protected]`

| Main list of objects. Definition at line 48 of file OgreRefAppWorld.h. Referenced by clear(), createBall(), createBox(), createCamera(), createOgreHead(), and createPlane().

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

| Contact joint group. Definition at line 61 of file OgreRefAppWorld.h. Referenced by _applyDynamics(), getOdeContactJointGroup(), World(), and ~World().

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

| Definition at line 58 of file OgreRefAppWorld.h. Referenced by _applyDynamics(), getOdeWorld(), setGravity(), World(), and ~World().

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

| Pointer to OGRE's scene manager. Definition at line 44 of file OgreRefAppWorld.h. Referenced by getSceneManager(), and World().

Real OgreRefApp::World::mSimulationStepSize`[protected]`

| The step size of the collision / physics simulation. Definition at line 68 of file OgreRefAppWorld.h. Referenced by getSimulationStepSize(), setSimulationStepSize(), simulationStep(), and World().

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 files:

- OgreRefAppWorld.h
- OgreRefAppWorld.cpp

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:51:59 2004