NxOgre.org

Index

World and Params

shortguide

World is the top-most class of NxOgre; it is responsible for handling of all the Scenes and indirectly working with the PhysX library. It works in a kind of symbiosis with another class called PhysXDriver which is responsible for launching and configuring the PhysX Driver and libraries, investigating and reporting if something goes wrong, and shutting it all down properly when the World is destroyed.

Destroying the World (delete mWorld) will destroy all1 of the Scenes and the contents within. However, if you want to reuse NxOgre again you can, by destroying all the planets (mWorld->destroyAllScenes()) instead of being vengeful and eliminating all of creation. Besides, it’s easier to sweep up.

At this point we can introduce the highly versatile Params class. The purpose of this class is to specify arguments to Class constructors or other functions. These arguments can be given out of order, and it is also acceptable to leave some out.

There are two types of Params in NxOgre: String Params and Class Params. String-based Params are typed in shorthand within a string, and are useful for fast and short bits of code. The only drawback to this Param type is that they need functions to convert other types of data/classes into Strings and then concatenate them together. Class Params are used in two cases: when more than five string conversions would be necessary otherwise, or when the comparable string param would be several lines long or otherwise unmanageable.Class params always operate slightly faster than String Params but are less readable and take longer to write.

Param Examples

String-based
World* mWorld = new World("log: yes, time-controller: ogre);
Class-based
PhysXParams params;
params.mLog = true;
params.mTimeController = PhysXParams::TC_Ogre;
World* mWorld = new World(params);

The name of each String Param takes is a slight modification the name of its C++ equivalent: it is converted to lower-case, the “m” prefix is dropped, and the camel case of the name is split using a hyphen.

For example:

  • mLog -> "log"
  • mTimeController -> "time-controller"
  • mImplictSweepCacheSize -> "implicit-sweep-cache-size"

Passing on the value to a String Param is pretty much the same as in C++, as integers and other basic types all behave in the same way. The only restriction is that a comma cannot be part of the string, as it is regarded as the end of the previous param and the start of another.

  • "integer: 4"
  • "bool: true"
  • "bool: no"
  • "floating-point: 4.3"
  • "double: 4.4323"
  • "string: This is a string name."
  • "vector3: 1 2 3"
  • "quaternion: 1 0 0 0"

If you wish to use the Param system in your own application, you can by inheriting the Params class and overriding the virtual methods. Params can also use newlines instead of commas, allowing you to serialise and unserialise String Params to a file for use as a simple configuration file, or a complement to NxOgre in some way.

1 Destroying the World or a Scene will destroy only the classes “owned” by NxOgre. Chapter five describes this in great detail.