Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

BaseObject

Description

In Orxonox, there are some classes refered to be "objects". In this context an object is not an instance of a class, but a class beeing relevant to the game-logic. Examples of objects are: A ship (but not the model), a particle effect (but not the particles themselfes), a trigger (which might be totally abstract like "finish the game after 20 minutes"), a HUD (but not the graphics). Examples of classes not beeing objects are: Interfaces (but objects might inherit from them), graphical components (meshes, textures, sprites, billboards, …), helper classes (Timer, …), classes in external libraries (network, audio, core, …).

To differ objects from other classes, they all derive from BaseObject. They might have other parents like interfaces or listeners, but they must inherit from BaseObject. The other way round you can cast every object to BaseObject, even if the only thing you know is it's a derivative of an interface like Tickable or Synchronisable.

The BaseObject itself inherits from OrxonoxClass.

Functions

The BaseObject provides several functions and states:

XMLPort

  • XMLPort(element, mode) is a virtual function defining rules to parse an xml element and assign values and subobjects to the object. This is used by the Loader?. See XMLPort for more information.

Name

  • setName(name): Sets the name of the object. This involves a call to changedName() (see below).
  • getName(): Returns the name of the object (if set).
  • changedName(): A virtual function which gets called if the name of the object changes. Can be changed by a subclass if the name is somehow important and changes have to be tracked.

Activity

  • setActive(bActive): Changes the activity of the object. Every object may define it's own definition of "activity" (see changedActivity).
  • isActive(): Returns true if the object is active.
  • changedActivity(): A virtual function which gets called if the activity of the object changes. This allows the class to implement it's own definition of "activity".

Visibility

  • setVisible(bVisible): Changes the visibility of the object. Every object may define it's own definition of "visibility" (see changedVisibility).
  • isVisible(): Returns true if the object is visiblee.
  • changedVisibility(): A virtual function which gets called if the visibility of the object changes. This allows the class to implement it's own definition of "visibility".

Loader

There are a few functions only relevant to the Loader? and Namespaces?:

  • setLevel(level)
  • getLevel()
  • setNamespace(namespace)
  • getNamespace()

Illustration

In this illustration of a class-tree (Test.h), the classes A1, A2 and A3 (and all derivatives) are "objects", because they inherit from BaseObject. As you can see, there are some Interfaces. Interfaces aren't connected with the BaseObject, they're on the same level. They all inherit from OrxonoxClass, but this isn't relevant to the game-logic.

Last modified 8 years ago Last modified on Apr 12, 2017, 10:34:04 PM