1 | <HTML> |
---|
2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
3 | <!-- Created on , 12 2006 by texi2html 1.64 --> |
---|
4 | <!-- |
---|
5 | Written 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. |
---|
9 | Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de> |
---|
10 | Send bugs and suggestions to <texi2html@mathematik.uni-kl.de> |
---|
11 | |
---|
12 | --> |
---|
13 | <HEAD> |
---|
14 | <TITLE>OGRE Manual v1.2.0 ('Dagon'): Overlays</TITLE> |
---|
15 | |
---|
16 | <META NAME="description" CONTENT="OGRE Manual v1.2.0 ('Dagon'): Overlays"> |
---|
17 | <META NAME="keywords" CONTENT="OGRE Manual v1.2.0 ('Dagon'): Overlays"> |
---|
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="SEC15"></A> |
---|
27 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> |
---|
28 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_11.html#SEC14"> < </A>]</TD> |
---|
29 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_4.html#SEC4"> Up </A>]</TD> |
---|
30 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_13.html#SEC22"> > </A>]</TD> |
---|
31 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <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> 2.8 Overlays </H2> |
---|
38 | <!--docid::SEC15::--> |
---|
39 | <P> |
---|
40 | |
---|
41 | Overlays allow you to render 2D and 3D elements on top of the normal scene contents to create effects like heads-up displays (HUDs), menu systems, status panels etc. The frame rate statistics panel which comes as standard with OGRE is an example of an overlay. Overlays can contain 2D or 3D elements. 2D elements are used for HUDs, and 3D elements can be used to create cockpits or any other 3D object which you wish to be rendered on top of the rest of the scene.<BR><BR> |
---|
42 | </P><P> |
---|
43 | |
---|
44 | You can create overlays either through the SceneManager::createOverlay method, or you can define them in an .overlay script. In reality the latter is likely to be the most practical because it is easier to tweak (without the need to recompile the code). Note that you can define as many overlays as you like: they all start off life hidden, and you display them by calling their 'show()' method. You can also show multiple overlays at once, and their Z order is determined by the Overlay::setZOrder() method.<BR><BR> |
---|
45 | </P><P> |
---|
46 | |
---|
47 | <A NAME="SEC16"></A> |
---|
48 | <H2> Creating 2D Elements </H2> |
---|
49 | <!--docid::SEC16::--> |
---|
50 | <P> |
---|
51 | |
---|
52 | The OverlayElement class abstracts the details of 2D elements which are added to overlays. All items which can be added to overlays are derived from this class. It is possible (and encouraged) for users of OGRE to define their own custom subclasses of OverlayElement in order to provide their own user controls. The key common features of all OverlayElements are things like size, position, basic material name etc. Subclasses extend this behaviour to include more complex properties and behaviour.<BR><BR> |
---|
53 | </P><P> |
---|
54 | |
---|
55 | An important built-in subclass of OverlayElement is OverlayContainer. OverlayContainer is the same as a OverlayElement, except that it can contain other OverlayElements, grouping them together (allowing them to be moved together for example) and providing them with a local coordinate origin for easier lineup.<BR><BR> |
---|
56 | </P><P> |
---|
57 | |
---|
58 | The third important class is OverlayManager. Whenever an application wishes to create a 2D element to add to an overlay (or a container), it should call OverlayManager::createOverlayElement. The type of element you wish to create is identified by a string, the reason being that it allows plugins to register new types of OverlayElement for you to create without you having to link specifically to those libraries. For example, to create a panel (a plain rectangular area which can contain other OverlayElements) you would call OverlayManager::getSingleton().createOverlayElement("Panel", "myNewPanel");<BR><BR> |
---|
59 | </P><P> |
---|
60 | |
---|
61 | <A NAME="SEC17"></A> |
---|
62 | <H2> Adding 2D Elements to the Overlay </H2> |
---|
63 | <!--docid::SEC17::--> |
---|
64 | <P> |
---|
65 | |
---|
66 | Only OverlayContainers can be added direct to an overlay. The reason is that each level of container establishes the Zorder of the elements contained within it, so if you nest several containers, inner containers have a higher zorder than outer ones to ensure they are displayed correctly. To add a container (such as a Panel) to the overlay, simply call Overlay::add2D.<BR><BR> |
---|
67 | </P><P> |
---|
68 | |
---|
69 | If you wish to add child elements to that container, call OverlayContainer::addChild. Child elements can be OverlayElements or OverlayContainer instances themselves. Remember that the position of a child element is relative to the top-left corner of it's parent.<BR><BR> |
---|
70 | </P><P> |
---|
71 | |
---|
72 | <A NAME="SEC18"></A> |
---|
73 | <H2> A word about 2D coordinates </H2> |
---|
74 | <!--docid::SEC18::--> |
---|
75 | <P> |
---|
76 | |
---|
77 | OGRE allows you to place and size elements based on 2 coordinate systems: <STRONG>relative</STRONG> and <STRONG>pixel</STRONG> based. |
---|
78 | <DL COMPACT> |
---|
79 | <DT>Pixel Mode |
---|
80 | <DD>This mode is useful when you want to specify an exact size for your overlay items, and you don't mind if those items get smaller on the screen if you increase the screen resolution (in fact you might want this). In this mode the only way to put something in the middle or at the right or bottom of the screen reliably in any resolution is to use the aligning options, whilst in relative mode you can do it just by using the right relative coordinates. This mode is very simple, the top-left of the screen is (0,0) and the bottom-right of the screen depends on the resolution. As mentioned above, you can use the aligning options to make the horizontal and vertical coordinate origins the right, bottom or center of the screen if you want to place pixel items in these locations without knowing the resolution. |
---|
81 | <DT>Relative Mode |
---|
82 | <DD>This mode is useful when you want items in the overlay to be the same size on the screen no matter what the resolution. In relative mode, the top-left of the screen is (0,0) and the bottom-right is (1,1). So if you place an element at (0.5, 0.5), it's top-left corner is placed exactly in the center of the screen, no matter what resolution the application is running in. The same principle applies to sizes; if you set the width of an element to 0.5, it covers half the width of the screen. Note that because the aspect ratio of the screen is typically 1.3333 : 1 (width : height), an element with dimensions (0.25, 0.25) will not be square, but it will take up exactly 1/16th of the screen in area terms. If you want square-looking areas you will have to compensate using the typical aspect ratio eg use (0.1875, 0.25) instead. |
---|
83 | </DL> |
---|
84 | <P> |
---|
85 | |
---|
86 | <A NAME="SEC19"></A> |
---|
87 | <H2> Transforming Overlays </H2> |
---|
88 | <!--docid::SEC19::--> |
---|
89 | <P> |
---|
90 | |
---|
91 | Another nice feature of overlays is being able to rotate, scroll and scale them as a whole. You can use this for zooming in / out menu systems, dropping them in from off screen and other nice effects. See the Overlay::scroll, Overlay::rotate and Overlay::scale methods for more information. |
---|
92 | </P><P> |
---|
93 | |
---|
94 | <A NAME="SEC20"></A> |
---|
95 | <H2> Scripting overlays </H2> |
---|
96 | <!--docid::SEC20::--> |
---|
97 | Overlays can also be defined in scripts. See section <A HREF="manual_33.html#SEC200">3.4 Overlay Scripts</A> for details. |
---|
98 | <P> |
---|
99 | |
---|
100 | <A NAME="SEC21"></A> |
---|
101 | <H2> GUI systems </H2> |
---|
102 | <!--docid::SEC21::--> |
---|
103 | Overlays are only really designed for non-interactive screen elements, although you can use them as a crude GUI. For a far more complete GUI solution, we recommend CEGui (<A HREF="http://www.cegui.org.uk">http://www.cegui.org.uk</A>), as demonstrated in the sample Demo_Gui. |
---|
104 | <P> |
---|
105 | |
---|
106 | <A NAME="Scripts"></A> |
---|
107 | <HR SIZE=1> |
---|
108 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> |
---|
109 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_11.html#SEC14"> < </A>]</TD> |
---|
110 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_4.html#SEC4"> Up </A>]</TD> |
---|
111 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_13.html#SEC22"> > </A>]</TD> |
---|
112 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD> |
---|
113 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_toc.html#SEC_Contents">Contents</A>]</TD> |
---|
114 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD> |
---|
115 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_abt.html#SEC_About"> ? </A>]</TD> |
---|
116 | </TR></TABLE> |
---|
117 | <BR> |
---|
118 | <FONT SIZE="-1"> |
---|
119 | This document was generated |
---|
120 | by <I>Steve Streeting</I> on <I>, 12 2006</I> |
---|
121 | using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html |
---|
122 | "><I>texi2html</I></A> |
---|
123 | |
---|
124 | </BODY> |
---|
125 | </HTML> |
---|