Layer (Overlays) _ Script

Source: Internet
Author: User
From OGRE 3D Chinese Jump to:navigation, search

Layer (overlays) allows you to draw 2D or 3D elements on general scene content, such as hint information (heads-up displays (HUDs)), menu system, status bar, etc. The frame status bar in the Ogre system (frame Rate Statistics Panel) is an example of a layer (overlays). Layer (overlays) can be a 2D element or 3D element. The 2d element is usually used in the hint message (HUDs), and the 3D element is used in a similar cockpit to a 3D object that is the top element of the scene (on the Rest of the Scene).

You can create layers (overlays) by calling the Scenemanager::createoverlay method, or you can define layers (overlays) by creating a ". Overlay" script. In fact, the latter approach is more common (because you do not need to recompile the code after modifying the script). Note: You can define as many layers as you need (overlays), which are not displayed at first unless you call the show () method. You can also display multiple layers (overlays) at the same time, and the occlusion relationship between them can be achieved by calling the Overlay::setzorder () method to resize their z. Creating 2D Elements

The Overlayelement class is an abstraction of the 2D element that is added to the layer (overlays). Therefore, objects of the classes inherited through this class can be added to the layer (overlays). The ogre system encourages users to provide their own interface controls by defining subclasses of the Overlayelement class. The key attributes of a layer element (overlayelements) include attributes such as size, location, material (Material) name, and so on. Subclasses of the Overlayelement class extend more complex properties and behaviors.

A very important subclass of the Overlayelement class is the Overlaycontainer class. In addition to being able to contain other layer elements (overlayelements), the Overlaycontainer class has the same characteristics as the Overlayelement class. The Overlaycontainer class also provides native coordinates (local coordinate) for the layer elements (overlayelements) it contains, so that they can be easily placed together.

Another important class is the Overlaymanager class, which can be implemented by calling the Overlaymanager::createoverlayelement method, regardless of when the application wants to create a 2D element that is added to the layer (or container). The type of element you want to create is identified by a string, because you can register your custom layer element (overlayelement) type in Overlaymanager. For example, if you want to create a panel (a quadrilateral that can hold other layer elements (overlayelements), you can call Overlaymanager::getsingleton (). Createoverlayelement (" Panel "," Mynewpanel "). Add a 2D element to the layer (overlays)

The elements that can be added directly in a layer (overlays) are only layer containers (overlaycontainers). The reason is that each level of the container for the elements of their own container zorder, so if you put a few containers in the same layer, the container elements can be based on their zorder, and then according to the arrangement of the container normal display. To add a container (such as a panel) to a layer (overlays), call the Overlay::add2d method.

If you want to add a child element to the container, call the Overlaycontainer::addchild method. A child element can be either a layer element (overlayelements) or a layer container (overlaycontainer). Remember that the coordinate positions of the child elements are positioned according to the upper-left corner of their parent container. About 2D coordinates

The ogre system allows you to position elements by absolute coordinates (pixel) or relative coordinates (relative). Absolute coordinate mode (Pixel mode)

This is useful when you want to specify the exact size of your layer elements. The size of the layer element that specifies the dimension will never change, regardless of the size of the other elements on the screen. In this way, you want to put an element on the right or bottom of the screen to be computed by pixel, and if the relative coordinate mode (relative mode) is much simpler. However, this approach is relatively simple, the upper-left corner of the screen coordinates (0,0), the lower right corner of the coordinates by your screen settings (640*480,800*600,1024*768, etc.) determined. Again, if you want to position an element in the middle or bottom of the screen, it's best to use the relative coordinate method (relative mode). relative coordinate mode (relative mode)

You should use this method if you want the elements you create to maintain a fixed proportion of your screen settings. In the relative coordinate mode (relative mode), the coordinates of the upper-left corner of the screen are (0,0) and the lower-right corner coordinates (1,1). So if you put an element in (0.5,0.5), it's right in the middle of the screen. This rule is equally valid for setting dimensions. If you set the width of an element to 0.5, it is exactly half the width of the screen. Note that because the screen's aspect ratio is generally 1.3333:1, an element cannot be square if it is set to (0.25,0.25). But its size is exactly 1/16 of the size of the entire screen. If you want to set the shape of an element to a square, you can set its size to (0.1875,0.25). Layer (overlays) conversion

Another feature of the layer (overlays) is that it can be rotated, scrolled (Scroll), scaled proportionally. You can use these features in the menu system, you can achieve the menu system scaling, dragging or other effects. See Overlay::scroll,overlay::rotate and Overlay::scale methods. Layer (overlays) scripting

Layer (overlays) can also be defined by a script, see Layer 3.4 scripting (Overlay Scripts). GUI system

Layer (overlays) is only for screen users who do not interact, and if you need more complex GUI solutions, we recommend Cegui (HTTP://WWW.CEGUI.ORG.HK). You can see a demo of it in the Demo_gui example.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.