Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Initial Version and Version 1 of code/doc/HUD


Ignore:
Timestamp:
Sep 22, 2008, 11:05:28 PM (16 years ago)
Author:
rgrieder
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/HUD

    v1 v1  
     1= Head-Up Display =
     2When rendering a scene you usually want to overlay them with useful information about the player status like how fast you're going or how well your health is doing. This is basically the job of a HUD. [[br]]
     3In Orxonox we have a base class for all HUD objects that makes life a lot easier. There is also a class to group multiple HUD elements together. More information about that can be found in the framework section. [[br]]
     4
     5== Elements ==
     6This table lists all currently available HUD elements and gives a short description.
     7|| Name || Description ||
     8||      ||             ||
     9|| SpeedBar || Shows a value between 0 and 1 as a bar. Supports colouring. ||
     10
     11== Framework ==
     12We like to keep things as generic as possible. So we naturally have a HUD that can be loaded per XML. In order to achieve that, every HUD element derives from [wiki:OrxonoxOverlay]. This allows to configure basic parameters. Element specific values can also be loaded from XML, but have to be written by hand. To get more information about how to load with XML in Orxonox, visit [wiki:XMLPort this] page. In short, loading an entire HUD group could look like this (incomplete example!):
     13{{{
     14<OverlayGroup name = "HUD" scale = "1, 1">
     15
     16  <HUDSpeedBar
     17   name       = "SpeedBar1"
     18   size       = "0.35, 0.05"
     19   position   = "0.0 , 1.0 "
     20   value      = 0
     21  />
     22
     23  <HUDRadar
     24   name          = "Radar"
     25   size          = "0.17, 0.17"
     26   position      = "0.5, 1.0"
     27  />
     28
     29</OverlayGroup>
     30}}}
     31
     32Pretty self-explanatory, right? The OverlayGroup represents a collection of elements that derive from OrxonoxOverlay. Such a group can be transformed with limited capabilities. [[br]]
     33
     34=== OrxonoxOverlay ===
     35This is the very base class. Always derive from this and try to embrace it ;) [[br]]
     36It supports the following basic transformations:
     37 * setPosition/scroll (absolute/relative)
     38 * setRotation/rotate
     39 * setSize/scale
     40 * hide/show
     41The relative versions are implemented as [wiki:ConsoleCommand] too so you can use them in the Shell. [[br]][[br]]
     42
     43There is something very important to notice: When changing the resolution of your screen, the OrxonoxOverlay scales with it, so relatively speaking it doesn't scale at all. This is however a problem for round objects like the HUDRadar, which get egg like. To prevent this, there is an XML parameter called 'correctAspect'. If this is set, the OrxonoxOverlay will keep the a round thing round, but the scaling will of course not anymore be exactly as you tell (an average value is computed). getActualSize() will return the real, corrected size. [[br]][[br]]
     44
     45The following XML parameters can be used when loading:
     46 * size
     47 * pickPoint (explained below)
     48 * position
     49 * rotation
     50 * correctAspect
     51 * background (background material name)
     52The transformation order is unfortunately fixed by the underlaying Ogre::Overlay:
     53 * 1. Scale
     54 * 2. Rotate
     55 * 3. Translate
     56This implies that you cannot use correctAspect in any way when a rotation other than a multiple of 90° is applied (it simply gets deactivated otherwise). [[br]]
     57About ''pickPoint'': This parameter helps you aligning an element. The coordinate you supply here are relative to the element itself and they serve as the the reference point when setting ''position''. Example: You want to put your element in the middle of your screen at the right border. You will have to set ''pickPoint'' to "1,0.5" and ''position'' to "1,0.5" too. In most cases the values will equal.
     58
     59=== OverlayGroup ===
     60Very simple container that can group multiple OrxonoxOverlays to hide/show them at once. It implements the following transition methods:
     61 * hide/show
     62 * scale/setScale
     63 * scroll/setScroll
     64setScroll only uses relative coordinates because you cannot actually position an OverlayGroup since it doesn't really have an origin at all. You have to image it only as grouping operator. That also means calling ''scale'' will scale each element for itself!
     65[wiki:ConsoleCommand ConsoleCommands]: toggleVisibility, scaleGroup, scrollGroup
     66
     67=== Screen Coordinates ===
     68The OrxonoxOverlay uses very simple screen coordinates: "0,0" is the upper left corner, "1,1" the lower right one. Any coordinate outside this system is considered ''valid'' too and will behave as expected.