Elementary classes

The basic functionality of vrecko is provided by several elementary classes. All of them are located in namespace vrecko. Therefore, full identifier of e.g. EnvironmentObject class is vrecko::EnvironmentObject.

BaseClass

As the name suggests, BaseClass is the common ancestor of all vrecko classes. The most important aspects of BaseClass are methods related to Input/Output (see Messages) and several virtual methods which are supposed to be redefined by its descendants. These include

  • initialize (DOMNode *parameters)
  • update()

initialize(DOMNode *parameters)

This method is called right after object’s constructor. In case the scene is loaded from an XML file, all initialize() methods are called only after the abilities themselves have already been created. The single parameter contains pointer to the loaded XML node structure which contains all parameters of the given ability. In case the pointer is set to NULL, the ability should respond accordingly and set its properties to default values. The recommended approach to read values from XML nodes is to use methods from the ReaderWriter class. These methods ensure that in case of any problems with the XML node, given default value is assigned to the variable.

Example usage

iLength = ReaderWriter::getIntValue(parameters, "Length", 10);

update()

The update() method is periodically called during application’s runtime. Update frequency of these calls depends on internal setting of the given ability. For further details, see the Update article.

Ability

The Ability class is a common ancestor of all abilities created by vrecko developers. The majority of its methods is inherited from BaseClass.

Each ability may have an owner (which is usually an instance of EnvironmentObject) associated to it. The owner (if any) should be set during the initialization phase.

Abilities and their properties can be either created dynamically during runtime or loaded from a given XML file(s) during initialization.

EnvironmentObject

All objects in the scene which are managed by vrecko (using the Scene class) are instances of EnvironmentObject (sometimes shortened as EO). Internally, EO is inherited from osg::MatrixTransform and vrecko::BaseClass.

All objects which are created during loading the scene from XML file(s) are created as instances of EO. In general, environment objects may have a various number of abilities attached to them.

There should be no need to create any classes inherited from EnvironmentObject most of the time.

World

Base class which contains pointers to instances of other base classes. It is  directly accessible via global variable vrecko::world if the header file vrecko/World.h is properly included.

Scene

Contains structures and methods related to the management of virtual scene and environment objects within it such as:

  • getEORoot()
  • addEnvironmentObject()
  • removeEnvironmentObject()

Scene pointer to its instance is accessible via global variable vrecko::world.

world->getScenePtr();

EventDispatcher

Deals with events, messages and handles object interconnections for the purpose of message transfer. Interconnections may be easily added and during runtime using the appropriate methods, i.e.:

  • insertEventInterconnection()
  • deleteEventInterconnection()

To obtain the pointer to the instance of event dispatcher, use the global variable vrecko::world.

world->getEventDispatcherPtr();

Scheduler

Handles all events and operations (e.g. update() method of BaseClass) which are periodically called after the given time interval. If you wish to add new or remove  existing events, you may do so using methods

  • addEntity()
  • removeEntity()

To obtain pointer to the instance of scheduler, use the global variable vrecko::world.

vrecko::world->getSchedulerPtr();