source: OGRE/trunk/ogrenew/Docs/manual/manual_33.html @ 692

Revision 692, 11.6 KB checked in by mattausch, 18 years ago (diff)

adding ogre 1.2 and dependencies

Line 
1<HTML>
2<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
3<!-- Created on , 12 2006 by texi2html 1.64 -->
4<!--
5Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
6            Karl Berry  <karl@freefriends.org>
7            Olaf Bachmann <obachman@mathematik.uni-kl.de>
8            and many others.
9Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>
10Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
11 
12-->
13<HEAD>
14<TITLE>OGRE Manual v1.2.0 ('Dagon'): Overlay Scripts</TITLE>
15
16<META NAME="description" CONTENT="OGRE Manual v1.2.0 ('Dagon'): Overlay Scripts">
17<META NAME="keywords" CONTENT="OGRE Manual v1.2.0 ('Dagon'): Overlay Scripts">
18<META NAME="resource-type" CONTENT="document">
19<META NAME="distribution" CONTENT="global">
20<META NAME="Generator" CONTENT="texi2html 1.64">
21<LINK TYPE="text/css" rel="stylesheet" href="../style.css"> 
22</HEAD>
23
24<BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
25
26<A NAME="SEC200"></A>
27<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
28<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_32.html#SEC192"> &lt; </A>]</TD>
29<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_13.html#SEC22"> Up </A>]</TD>
30<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_34.html#SEC206"> &gt; </A>]</TD>
31<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD>
32<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_toc.html#SEC_Contents">Contents</A>]</TD>
33<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
34<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_abt.html#SEC_About"> ? </A>]</TD>
35</TR></TABLE>
36<HR SIZE=1>
37<H2> 3.4 Overlay Scripts </H2>
38<!--docid::SEC200::-->
39<P>
40
41Overlay scripts offer you the ability to define overlays in a script which can be reused easily. Whilst you could set up all overlays for a scene in code using the methods of the SceneManager, Overlay and OverlayElement classes, in practice it's a bit unwieldy. Instead you can store overlay definitions in text files which can then be loaded whenever required.<BR><BR>
42</P><P>
43
44<A NAME="SEC201"></A>
45<H2> Loading scripts    </H2>
46<!--docid::SEC201::-->
47<P>
48
49Overlay scripts are loaded at initialisation time by the system: by default it looks in all common resource locations (see Root::addResourceLocation) for files with the '.overlay' extension and parses them. If you want to parse files with a different extension, use the OverlayManager::getSingleton().parseAllSources method with your own extension, or if you want to parse an individual file, use OverlayManager::getSingleton().parseScript.<BR><BR>
50</P><P>
51
52<A NAME="SEC202"></A>
53<H2> Format    </H2>
54<!--docid::SEC202::-->
55<P>
56
57Several overlays may be defined in a single script. The script format is pseudo-C++, with sections delimited by curly braces ({}), comments indicated by starting a line with '//' (note, no nested form comments allowed), and inheritance through the use of templates. The general format is shown below in a typical example:
58<TABLE><tr><td>&nbsp;</td><td class=example><pre>// The name of the overlay comes first
59MyOverlays/ANewOverlay
60{
61    zorder 200
62
63    container Panel(MyOverlayElements/TestPanel)
64    {
65        // Center it horzontally, put it at the top
66        left 0.25
67        top 0
68        width 0.5
69        height 0.1
70        material MyMaterials/APanelMaterial
71
72        // Another panel nested in this one
73        container Panel(MyOverlayElements/AnotherPanel)
74        {
75             left 0
76             top 0
77             width 0.1
78             height 0.1
79             material MyMaterials/NestedPanel
80        }
81    }
82
83}
84</pre></td></tr></table></P><P>
85
86The above example defines a single overlay called 'MyOverlays/ANewOverlay', with 2 panels in it, one nested under the other. It uses relative metrics (the default if no metrics_mode option is found).<BR><BR>
87</P><P>
88
89Every overlay in the script must be given a name, which is the line before the first opening '{'. This name must be globally unique. It can include path characters (as in the example) to logically divide up your overlays, and also to avoid duplicate names, but the engine does not treat the name a hierarchical, just as a string. Within the braces are the properties of the overlay, and any nested elements. The overlay itself only has a single property 'zorder' which determines how'high' it is in the stack of overlays if more than one is displayed at the same time. Overlays with higher zorder values are displayed on top.<BR><BR>
90</P><P>
91
92<A NAME="SEC203"></A>
93<H2> Adding elements to the overlay </H2>
94<!--docid::SEC203::-->
95<P>
96
97Within an overlay, you can include any number of 2D or 3D elements. You do this by defining a nested block headed by:
98<DL COMPACT>
99<DT>'element'
100<DD>if you want to define a 2D element which cannot have children of it's own
101<DT>'container'
102<DD>if you want to define a 2D container object (which may itself have nested containers or elements)
103</DL>
104<BR>
105The element and container blocks are pretty identical apart from their ability to store nested blocks.
106<P>
107
108<A NAME="SEC204"></A>
109<H2> 'container' / 'element' blocks </H2>
110<!--docid::SEC204::-->
111<P>
112
113These are delimited by curly braces. The format for the header preceding the first brace is:<BR><BR>
114</P><P>
115
116[container | element] &#60;type_name&#62; ( &#60;instance_name&#62;) [: &#60;template_name&#62;]<BR>
117{ ...<BR><BR>
118<DL COMPACT>
119<DT>type_name
120<DD>Must resolve to the name of a OverlayElement type which has been registered with the OverlayManager. Plugins register with the OverlayManager to advertise their ability to create elements, and at this time advertise the name of the type. OGRE comes preconfigured with types 'Panel', 'BorderPanel' and 'TextArea'.
121<DT>instance_name
122<DD>Must be a name unique among all other elements / containers by which to identify the element. Note that you can obtain a pointer to any named element by calling OverlayManager::getSingleton().getOverlayElement(name).
123<DT>template_name
124<DD>Optional template on which to base this item. See templates.
125</DL>
126<P>
127
128The properties which can be included within the braces depend on the custom type. However the following are always valid:
129<UL>
130<LI>
131<A HREF="manual_34.html#SEC207">metrics_mode</A>
132<LI>
133<A HREF="manual_34.html#SEC208">horz_align</A>
134<LI>
135<A HREF="manual_34.html#SEC209">vert_align</A>
136<LI>
137<A HREF="manual_34.html#SEC210">left</A>
138<LI>
139<A HREF="manual_34.html#SEC211">top</A>
140<LI>
141<A HREF="manual_34.html#SEC212">width</A>
142<LI>
143<A HREF="manual_34.html#SEC213">height</A>
144<LI>
145<A HREF="manual_34.html#overlay_material">material</A>
146<LI>
147<A HREF="manual_34.html#SEC215">caption</A>
148</UL>
149<P>
150
151<A NAME="SEC205"></A>
152<H2> Templates </H2>
153<!--docid::SEC205::-->
154<P>
155
156You can use templates to create numerous elements with the same properties. A template is an abstract element and it is not added to an overlay. It acts as a base class that elements can inherit and get its default properties. To create a template, the keyword 'template' must be the first word in the element definition (before container or element). The template element is created in the topmost scope - it is NOT specified in an Overlay. It is recommended that you define templates in a separate overlay though this is not essential. Having templates defined in a separate file will allow different look &#38; feels to be easily substituted.<BR><BR>
157</P><P>
158
159Elements can inherit a template in a similar way to C++ inheritance - by using the : operator on the element definition. The : operator is placed after the closing bracket of the name (separated by a space). The name of the template to inherit is then placed after the : operator (also separated by a space).<BR><BR>
160</P><P>
161
162A template can contain template children which are created when the template is subclassed and instantiated. Using the template keyword for the children of a template is optional but recommended for clarity, as the children of a template are always going to be templates themselves.<BR><BR>
163<TABLE><tr><td>&nbsp;</td><td class=example><pre>template container BorderPanel(MyTemplates/BasicBorderPanel)
164{
165    left 0
166    top 0
167    width 1
168    height 1
169
170// setup the texture UVs for a borderpanel
171
172// do this in a template so it doesn't need to be redone everywhere
173    material Core/StatsBlockCenter
174    border_size 0.05 0.05 0.06665 0.06665
175    border_material Core/StatsBlockBorder
176    border_topleft_uv 0.0000 1.0000 0.1914 0.7969
177    border_top_uv 0.1914 1.0000 0.8086 0.7969
178    border_topright_uv 0.8086 1.0000 1.0000 0.7969
179    border_left_uv 0.0000 0.7969 0.1914 0.2148
180    border_right_uv 0.8086 0.7969 1.0000 0.2148
181    border_bottomleft_uv 0.0000 0.2148 0.1914 0.0000
182    border_bottom_uv 0.1914 0.2148 0.8086 0.0000
183    border_bottomright_uv 0.8086 0.2148 1.0000 0.0000
184}
185template container Button(MyTemplates/BasicButton) : MyTemplates/BasicBorderPanel
186{
187    left 0.82
188    top 0.45
189    width 0.16
190    height 0.13
191    material Core/StatsBlockCenter
192    border_up_material Core/StatsBlockBorder/Up
193    border_down_material Core/StatsBlockBorder/Down
194}
195template element TextArea(MyTemplates/BasicText)
196{
197    font_name Ogre
198    char_height 0.08
199    colour_top 1 1 0
200    colour_bottom 1 0.2 0.2
201    left 0.03
202    top 0.02
203    width 0.12
204    height 0.09
205}
206
207MyOverlays/AnotherOverlay
208{
209    zorder 490
210    container BorderPanel(MyElements/BackPanel) : MyTemplates/BasicBorderPanel
211    {
212        left 0
213        top 0
214        width 1
215        height 1
216
217        container Button(MyElements/HostButton) : MyTemplates/BasicButton
218        {
219            left 0.82
220            top 0.45
221            caption MyTemplates/BasicText HOST
222        }
223
224        container Button(MyElements/JoinButton) : MyTemplates/BasicButton
225        {
226            left 0.82
227            top 0.60
228            caption MyTemplates/BasicText JOIN
229        }
230    }
231}
232</pre></td></tr></table>The above example uses templates to define a button. Note that the button template inherits from the borderPanel template. This reduces the number of attributes needed to instantiate a button.<BR><BR>
233</P><P>
234
235Also note that the instantiate of a Button needs a template name for the caption attribute. So templates can also be used by elements that need dynamic creation of children elements (the button creates a TextAreaElement in this case for its caption).<BR><BR>
236</P><P>
237
238See section <A HREF="manual_34.html#SEC206">3.4.1 OverlayElement Attributes</A>, <A HREF="manual_35.html#SEC217">3.4.2 Standard OverlayElements</A>
239</P><P>
240
241<A NAME="OverlayElement Attributes"></A>
242<HR SIZE=1>
243<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
244<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_32.html#SEC192"> &lt; </A>]</TD>
245<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_13.html#SEC22"> Up </A>]</TD>
246<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_34.html#SEC206"> &gt; </A>]</TD>
247<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD>
248<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_toc.html#SEC_Contents">Contents</A>]</TD>
249<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
250<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_abt.html#SEC_About"> ? </A>]</TD>
251</TR></TABLE>
252<BR> 
253<FONT SIZE="-1">
254This document was generated
255by <I>Steve Streeting</I> on <I>, 12 2006</I>
256using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
257"><I>texi2html</I></A>
258
259</BODY>
260</HTML>
Note: See TracBrowser for help on using the repository browser.