Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/data/levels/events.oxw @ 9664

Last change on this file since 9664 was 9348, checked in by landauf, 12 years ago

merged branch presentation2012merge back to trunk

  • Property svn:eol-style set to native
File size: 9.6 KB
Line 
1<LevelInfo
2  name = "Events showcase"
3  description = "Level to test and showcase events."
4  tags = "test, showcase"
5  screenshot = "eventsshowcase.png"
6/>
7
8<?lua
9  include("HUDTemplates3.oxo")
10  include("stats.oxo")
11  include("templates/spaceshipAssff.oxt")
12  include("templates/spaceshipH2.oxt")
13  include("templates/lodInformation.oxt")
14?>
15
16<Level>
17  <templates>
18    <Template link=lodtemplate_default />
19  </templates>
20  <?lua include("includes/notifications.oxi") ?>
21
22  <Scene
23   ambientlight = "0.5, 0.5, 0.5"
24   skybox       = "Orxonox/skyBoxBasic"
25  >
26    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
27
28    <SpawnPoint position="0,-100,0" lookat="0,0,0" roll=180 spawnclass=SpaceShip pawndesign=spaceshipassff />
29
30    <Billboard position=" 300,100,  0" material="Examples/Flare" colour="1.0, 0.0, 0.0" />
31    <Billboard position=" 200,100,  0" material="Examples/Flare" colour="1.0, 0.5, 0.0" />
32    <Billboard position=" 200,100,100" material="Examples/Flare" colour="1.0, 0.5, 0.0" />
33    <Billboard position=" 100,100,  0" material="Examples/Flare" colour="1.0, 1.0, 0.0" />
34    <Billboard position="   0,100,  0" material="Examples/Flare" colour="0.0, 1.0, 0.0" />
35    <Billboard position="-100,100,  0" material="Examples/Flare" colour="0.0, 1.0, 1.0" />
36    <Billboard position="-100,100,100" material="Examples/Flare" colour="0.0, 1.0, 1.0" />
37    <Billboard position="-200,100,  0" material="Examples/Flare" colour="0.0, 0.0, 1.0" />
38    <Billboard position="-300,100,  0" material="Examples/Flare" colour="1.0, 0.0, 1.0" />
39
40
41
42    <!--
43      Begin of the tutorial section.
44    -->
45
46
47
48    <!--
49      Note:
50      All following examples use only one subobject (in nested layouts). But of course you can add more
51      objects. They will all follow the same rules (depending on the example receive, send or pipe events).
52
53      Some examples address objects by name. Those methods always address ALL objects with this name, no
54      matter where they are in the XML-file (before or after the addressing object). Of course this also
55      works with all amounts of objects from zero to infinity. In the examples I used two objects each.
56    -->
57
58
59    <!-- red -->
60    <!--
61      Standard:
62      Direct event-connection between an event-listener (Billboard) and an event source (DistanceTrigger).
63      Every fired event of the source is mapped to the "visibility" state of the listener.
64
65      This is a 1:1 mapping between event-listener and event-source.
66    -->
67    <Billboard position="300,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0>
68      <events>
69        <visibility>
70          <DistanceTrigger position="300,100,0" distance=25 target="ControllableEntity" />
71        </visibility>
72      </events>
73    </Billboard>
74
75
76    <!-- orange -->
77    <!--
78      EventListener:
79      The EventListener object forwards all events from objects, whose names equal the "event" attribute
80      of the EventListener, to the enclosing object (Billboard).
81      In this case, both triggers have the name "trigger2" and thus both triggers send events to the Billboard.
82
83      The EventListener provides an 1:n mapping between one listener and multiple event-sources.
84    -->
85    <Billboard position="200,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0>
86      <events>
87        <visibility>
88          <EventListener event="trigger2" />
89        </visibility>
90      </events>
91    </Billboard>
92    <DistanceTrigger name="trigger2" position="200,100,0" distance=25 target="ControllableEntity" />
93    <DistanceTrigger name="trigger2" position="200,100,100" distance=25 target="ControllableEntity" />
94
95
96    <!-- yellow -->
97    <!--
98      EventTarget:
99      The EventTarget object forwards the events, received from objects whithin the "events" subsection,
100      to all  objects whose names equal the "name" attribute.
101      In this case, the EventTarget forwards the event from the DistanceTrigger to all listeners with
102      name "bb3".
103
104      The EventTarget provides an n:1 mapping between several listeners and one event-source.
105    -->
106    <Billboard name="bb3" position="100,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
107    <Billboard name="bb3" position="100,150,100" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
108    <EventTarget target="bb3">
109      <events>
110        <visibility>
111          <DistanceTrigger position="100,100,0" distance=25 target="ControllableEntity" />
112        </visibility>
113      </events>
114    </EventTarget>
115
116
117    <!-- green -->
118    <!--
119      EventDispatcher:
120      The EventDispatcher catches events from objects in its "events" subsection. Those events are forwared
121      to all objects in the "targets" subsection. The EventDispatcher resembles the EventTarget, but
122      doesn't address objects with the "name" attribute. It rather places them directly inside the "targets"
123      subsection.
124      In this case, the EventDispatcher receives events from the DistanceTrigger and forwards those events
125      to the Billboard object.
126
127      The EventDispatcher provides an n:1 mapping between several targets (listeners) and one event source.
128    -->
129    <EventDispatcher>
130      <targets>
131        <Billboard position="0,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
132      </targets>
133      <events>
134        <visibility>
135          <DistanceTrigger position="0,100,0" distance=25 target="ControllableEntity" />
136        </visibility>
137      </events>
138    </EventDispatcher>
139
140
141    <!-- turquoise -->
142    <!--
143      Combination:
144      By combinding the above three classes, namely EventDispatcher, EventTarget and EventListener, you can
145      extract the event logic completely from the actual objects (Billboards and DistanceTriggers).
146      In this case, both triggers (whith names "trigger5") send events to both Billboards (with names "bb5").
147
148      This combination allows an n:n mapping between event-listeners and event-sources.
149    -->
150    <Billboard name="bb5" position="-100,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
151    <Billboard name="bb5" position="-100,150,100" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
152    <DistanceTrigger name="trigger5" position="-100,100,0" distance=25 target="ControllableEntity" />
153    <DistanceTrigger name="trigger5" position="-100,100,100" distance=25 target="ControllableEntity" />
154    <EventDispatcher>
155      <targets>
156        <EventTarget target="bb5" />
157      </targets>
158      <events>
159        <visibility>
160          <EventListener event="trigger5" />
161        </visibility>
162      </events>
163    </EventDispatcher>
164
165
166    <!-- blue -->
167    <!--
168      Mainstate:
169      Apart from the standard states (like activity and visibility), each object can have a mainstate.
170      You can define the mainstate with an xml-attribute: mainstate="state". "state" must be one of the
171      supported states of the object (except states which need the originator as a second argument). If
172      the mainstate is set (by default that's not the case), you can send events to the "mainstate" state.
173      This allows you to hide the actually affected state in the event-listener, while the event-source
174      just sends events.
175      Note that this example is exactly like the standard case, but the event is sent to the main-state,
176      which in turn is set to "visibility".
177    -->
178    <Billboard position="-200,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 mainstate="visibility">
179      <events>
180        <mainstate>
181          <DistanceTrigger position="-200,100,0" distance=25 target="ControllableEntity" />
182        </mainstate>
183      </events>
184    </Billboard>
185
186
187    <!-- violet -->
188    <!--
189      Event forwarding:
190      As a consequence of the mainstate, events can also be sent without any explicit declaration of
191      the targets state. This allows us to forward events from an event-source directly to a bunch of
192      event-listeners. The events are automatically piped into the mainstate. Therefore the listeners
193      have to declare their main-state.
194      In this example, the DistanceTrigger forwards the events to the Billboards main-state (visibility).
195      This does the same like the example above, but instead of piping events backwards from the source
196      into the mainstate of the listener, we're forwarding the event implicitly to the mainstate.
197    -->
198    <DistanceTrigger position="-300,100,0" distance=25 target="ControllableEntity">
199      <eventlisteners>
200        <Billboard position="-300,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 mainstate="visibility" />
201      </eventlisteners>
202    </DistanceTrigger>
203
204
205
206    <!--
207      End of the tutorial section.
208    -->
209
210
211
212    <!--
213      The following example shows again the red (standard layout) and the violet (event forwarding) example,
214      but this time with a memoryless state (spawn) from the ParticleSpawner instead of the boolean state
215      (visibility) in the other examples.
216    -->
217    <Billboard position=" 300,100,300" material="Examples/Flare" colour="1.0, 0.0, 0.0" />
218    <Billboard position="-300,100,300" material="Examples/Flare" colour="1.0, 0.0, 1.0" />
219    <ParticleSpawner position="300,150,300" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0>
220      <events>
221        <spawn>
222          <DistanceTrigger position="300,100,300" distance=25 target="ControllableEntity" />
223        </spawn>
224      </events>
225    </ParticleSpawner>
226    <DistanceTrigger position="-300,100,300" distance=25 target="ControllableEntity">
227      <eventlisteners>
228        <ParticleSpawner position="-300,150,300" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0 mainstate="spawn" />
229      </eventlisteners>
230    </DistanceTrigger>
231
232  </Scene>
233</Level>
Note: See TracBrowser for help on using the repository browser.