Wartbed:Manual/Theatre of War

From Dark Omen Wiki

(Difference between revisions)
Jump to: navigation, search
(Theatre and SceneElements)
(Updated article, better examples)
Line 5: Line 5:
* '''<tt>Theatre</tt>''': The class encapsulating the entire set of constituent elements from which the game "map" or "level" is built and construed.  
* '''<tt>Theatre</tt>''': The class encapsulating the entire set of constituent elements from which the game "map" or "level" is built and construed.  
* '''<tt>theatre::SceneElement</tt>''': The base class for all contents in a scene (all Props in a Theatre).
* '''<tt>theatre::SceneElement</tt>''': The base class for all contents in a scene (all Props in a Theatre).
 +
<!--
* '''<tt>theatre::Light</tt>''': A class representing a non-effect light affecting the stage
* '''<tt>theatre::Light</tt>''': A class representing a non-effect light affecting the stage
-
* '''<tt>theatre::Indicator</tt>''': A class used as an ersatz or indicator of something not visible
+
* '''<tt>theatre::Indicator</tt>''': A class used as an ersatz or indicator of something not visible  
 +
-->
</div></div>
</div></div>
-
==Theatre and SceneElements==
+
==The <tt>Theatre</tt> and <tt>SceneElement</tt> classes==
-
The Theatre class represents the world by containing all <tt>SceneElement Prop</tt>s constituting it. Unit movement and pathfinding does not primarily use the Theatre contents, but instead calls on a node-space representation of the map.  
+
The world (or universe, scene, or many other synonymous words) of a WARTBED session is a collection of objects collected under a histrionic nomenclature. The theatre metaphor was chosen because of its good fit and relevant separation of responsibilities for representing a WARTBED simulation universe.  
-
<tt>SceneElement</tt>s are all specialisations of <tt>Prop</tt>, which in turn is a specialisation of <tt>mvc::Model</tt>. Thus, all scene elements can be used transparently with all other models inside the MVC architecture. Scene elements are not <tt>Actor</tt>s, though, and can't be issued <tt>Order</tt>s.
+
The <tt>Theatre</tt> class represents the world at large, and is composed of a hierarchically ordered collection of <tt>SceneElement</tt> instances. All scene elements contained are SCENE_ELEMENT smart pointers nodes in a hierarchy, starting at <tt>Theatre::root</tt>. The word "Theatre" is preferred over "Scene", since the latter tends to be strongly associated with rendering of 3D objects, while the WARTBED Theatre is also used in pure simulations without graphical representation. A "theatre" is therefore considered of much wider concept and usage than a "scene". Note that unit movement and pathfinding does not primarily use the Theatre contents, but instead calls on a node-space representation of the map.  
-
This part of WARTBED intentionally uses the theatre metaphor because of its good fit and relevant separation of responsibilities.  
+
===Scene elements===
 +
<tt>SceneElement</tt> is an abstract base class derived from the <tt>Prop</tt> class, which in turn extends <tt>mvc::Model</tt>. Thus, all elements of a theatre are also models and as such can be used transparently with all other models inside the MVC architecture. Scene elements are not <tt>Actor</tt>s, though, and can't be issued <tt>Order</tt>s.
-
Generic overview:
+
<div style="margin:1em; padding:1em; background:rgb(175,200,175);"><div style="margin-bottom:1em; color: green; border-bottom:1px solid green;">'''Generic overview:'''<br /></div>
-
<div style="margin:1em; padding:1em; background:rgb(175,200,175);"><source lang="cpp">
+
<source lang="cpp">
typedef shared_ptr<SceneElement *> SCENE_ELEMENT;
typedef shared_ptr<SceneElement *> SCENE_ELEMENT;
Line 28: Line 31:
namespace theatre
namespace theatre
{
{
-
     class SceneElement : public Prop
+
     class SceneElement : public Prop { ... };
-
     {
+
     class ElementGroup : SceneElement { ... };
-
        ...
+
    class Light : SceneElement { ... };
-
     };
+
     class Indicator : SceneElement { ... };
 +
}
 +
</source></div>
-
    class ElementGroup : SceneElement
+
===Accessing and changing elements after initial creation===
-
    {
+
A theatre takes exclusive responsibility for the scene elements it contains and keeps track internally of what data it contains. To this scene elements are categorised on two dimensions: by their ''scene element data type'' and ''prop type''. The data type corresponds to the data in general the object is containing or representing, f.i. 3D geometry, lights or audio. The prop type on the other hand reflects the scene object's actual (specific) use in the scene, f.i. terrain, water, weather or sound effects. Therefore, after having been added to a theatre, the data or prop types of a scene element can only be altered through setter methods of the theatre object containing the element.
-
        ...
+
-
    };
+
-
    class Light : SceneElement
+
<div style="margin:1em; padding:1em; background:rgb(175,200,175);"><div style="margin-bottom:1em; color: green; border-bottom:1px solid green;">'''Example usage:'''<br /></div><source lang="cpp">
-
    {
+
THEATRE pTheatre = DarkOmenSceneLoader().createScene( "c:/games/Dark Omen/gamedata/1pbat/B1_01" );
-
        ...
+
theatre::ELEMENTS audio_element = pTheatre->getByType( theatre::SET_audio );
-
    };
+
-
 
+
-
    class Indicator : SceneElement
+
-
    {
+
-
        ...
+
-
    };
+
-
}
+
</source></div>
</source></div>
-
The Theatre contains specialisations of SceneElement stored in SCENE_ELEMENT smart pointers. All elements are nodes in a hierarchy, starting at <tt>Theatre::root</tt>.
 
 +
===Implementation notes===
All scene elements are Props, and all are created through an abstract factory. Thus, the Theatre class and subscribing code need not care about the underlying implementation of the scene components, which means that the same architecture can be used both for server and client modules.
All scene elements are Props, and all are created through an abstract factory. Thus, the Theatre class and subscribing code need not care about the underlying implementation of the scene components, which means that the same architecture can be used both for server and client modules.
 +
 +
Principally, clients will load level data through a factory specialised for OGRE 3D, which will generate scene elements prepared for rendering by OGRE (but also for audio etc), while a server application will generate its theatre through the same data parser populated by a factory specialised for generating data for an abstract simulation.
==Weather==
==Weather==

Revision as of 16:57, 24 March 2010


This article discusses
  • Theatre: The class encapsulating the entire set of constituent elements from which the game "map" or "level" is built and construed.
  • theatre::SceneElement: The base class for all contents in a scene (all Props in a Theatre).

Contents

The Theatre and SceneElement classes

The world (or universe, scene, or many other synonymous words) of a WARTBED session is a collection of objects collected under a histrionic nomenclature. The theatre metaphor was chosen because of its good fit and relevant separation of responsibilities for representing a WARTBED simulation universe.

The Theatre class represents the world at large, and is composed of a hierarchically ordered collection of SceneElement instances. All scene elements contained are SCENE_ELEMENT smart pointers nodes in a hierarchy, starting at Theatre::root. The word "Theatre" is preferred over "Scene", since the latter tends to be strongly associated with rendering of 3D objects, while the WARTBED Theatre is also used in pure simulations without graphical representation. A "theatre" is therefore considered of much wider concept and usage than a "scene". Note that unit movement and pathfinding does not primarily use the Theatre contents, but instead calls on a node-space representation of the map.

Scene elements

SceneElement is an abstract base class derived from the Prop class, which in turn extends mvc::Model. Thus, all elements of a theatre are also models and as such can be used transparently with all other models inside the MVC architecture. Scene elements are not Actors, though, and can't be issued Orders.

Generic overview:
typedef shared_ptr<SceneElement *> SCENE_ELEMENT;
 
class Theatre
{
    SCENE_ELEMENT root;
    ...
};
 
namespace theatre
{
    class SceneElement : public Prop { ... };
    class ElementGroup : SceneElement { ... };
    class Light : SceneElement { ... };
    class Indicator : SceneElement { ... };
}

Accessing and changing elements after initial creation

A theatre takes exclusive responsibility for the scene elements it contains and keeps track internally of what data it contains. To this scene elements are categorised on two dimensions: by their scene element data type and prop type. The data type corresponds to the data in general the object is containing or representing, f.i. 3D geometry, lights or audio. The prop type on the other hand reflects the scene object's actual (specific) use in the scene, f.i. terrain, water, weather or sound effects. Therefore, after having been added to a theatre, the data or prop types of a scene element can only be altered through setter methods of the theatre object containing the element.

Example usage:
THEATRE pTheatre = DarkOmenSceneLoader().createScene( "c:/games/Dark Omen/gamedata/1pbat/B1_01" );
theatre::ELEMENTS audio_element = pTheatre->getByType( theatre::SET_audio );

Implementation notes

All scene elements are Props, and all are created through an abstract factory. Thus, the Theatre class and subscribing code need not care about the underlying implementation of the scene components, which means that the same architecture can be used both for server and client modules.

Principally, clients will load level data through a factory specialised for OGRE 3D, which will generate scene elements prepared for rendering by OGRE (but also for audio etc), while a server application will generate its theatre through the same data parser populated by a factory specialised for generating data for an abstract simulation.

Weather

Placeholder

Personal tools
communication