Wartbed:Manual/Theatre of War

From Dark Omen Wiki

< Wartbed:Manual(Difference between revisions)
Jump to: navigation, search
(Created page with '{{stub}} <div style="margin:1em; border: 1px solid gray; background:lightgray;"><div style="background:gray;">'''This article discusses'''</div> <div style="padding:1em; "> * ''...')
(The Theatre and SceneElement classes)
 
(3 intermediate revisions not shown)
Line 4: Line 4:
<div style="padding:1em; ">
<div style="padding:1em; ">
* '''<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>Stage</tt>''': A class in Theatre containing all <tt>Terrain Prop</tt>s related to terrain and physical objects and their effects.  
+
* '''<tt>theatre::SceneElement</tt>''': The base class for all contents in a scene (all Props in a Theatre).
-
* '''<tt>Lighting</tt>''': A class in Theatre containing all non-effect lights affecting the Stage
+
<!--
-
* '''<tt>Backdrop</tt>''': A class in Theatre defining the backdrop (sky, clouds, etc) to the Stage.
+
* '''<tt>theatre::Light</tt>''': A class representing a non-effect light affecting the stage
-
* '''<tt>Weather</tt>''': A class in Theatre defining the weather conditions of the Scene
+
* '''<tt>theatre::Indicator</tt>''': A class used as an ersatz or indicator of something not visible
 +
-->
</div></div>
</div></div>
-
==Theatre, Scene, Lighting and Backdrop==
+
==The <tt>'''Theatre'''</tt> and <tt>'''SceneElement'''</tt> classes==
-
The Theatre class represents the world by containing all <tt>Prop</tt>s constituting it. It is used to generate Views that will represent it visually and auditory. 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 gathered under a histrionic nomenclature and contained in an instance of the <tt>Theatre</tt> class. The theatre metaphor was chosen because of its good fit and relevant separation of responsibilities for representing a WARTBED simulation universe. 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 a much wider concept and of broader usage than a "scene".  
-
This part of WARTBED intentionally uses the theatre metaphor because of its good fit and relevant separation of responsibilities.  
+
-
Stub:
+
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 <tt>SCENE_ELEMENT</tt> smart pointers nodes in a hierarchy, starting at <tt>Theatre::root</tt>. Note that unit movement and pathfinding does not primarily use the Theatre contents, but instead calls on a node-space representation of the map.
-
<div style="margin:1em; padding:1em; background:rgb(175,200,175);"><source lang="cpp">
+
 
-
class Stage;
+
===Scene elements===
-
class Lighting;
+
<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.
-
class Backdrop;
+
 
-
class Weather;
+
<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>
-
class Terrain;
+
<source lang="cpp">
 +
typedef shared_ptr<SceneElement *> SCENE_ELEMENT;
class Theatre
class Theatre
{
{
-
     Stage    stage;
+
     SCENE_ELEMENT root;
-
    Lighting  lighting;
+
-
    Backdrop  backdrop;
+
-
    Weather  weather;
+
     ...
     ...
};
};
-
class Terrain : public Prop
+
namespace theatre
{
{
-
     ...
+
     class SceneElement : public Prop { ... };
-
};
+
    class ElementGroup : SceneElement { ... };
 +
    class Light : SceneElement { ... };
 +
    class Indicator : SceneElement { ... };
 +
}
 +
</source></div>
-
class Stage
+
===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.
-
    typedef std::map<STRING, TERRAIN_PTR> TERRAIN;
+
 
-
    TERRAIN terrain;
+
<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 );
</source></div>
</source></div>
 +
 +
===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==
==Weather==

Current revision as of 17:01, 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 gathered under a histrionic nomenclature and contained in an instance of the Theatre class. The theatre metaphor was chosen because of its good fit and relevant separation of responsibilities for representing a WARTBED simulation universe. 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 a much wider concept and of broader usage than a "scene".

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