![]() |
Advanced Graphics TutorialThis chapter contains tutorials that deal with advanced graphics development in the Dynamic Markup Language. You will find it easier if you have reached a reasonable level of skill before attempting to follow this chapter. Rendering 101In this section we'll look at the art of creating render layers, which is basically a way of grouping your graphics into their own individual drawing spaces, or 'rendering areas'. Each rendered area that you create is independent of the others, allowing you to keep your graphics organised, which is especially important once you want to start moving them around. You'll also need to know how layering works the moment you start developing DML based applications and interactive components. Here's a list of features provided by the rendering system:
In an earlier chapter we mentioned that the DML plugin will automatically create a default rendering area called the "SystemDisplay" which is attached to the embedded graphics area. The SystemDisplay is the 'root' of the drawing hierarchy, which means that as the top-most object it is not contained by anything, but it can hold lots of smaller drawing spaces within it. In previous chapters we have limited ourselves to using graphical operations and interactive objects within the root area. To only use these types of objects is rather limiting and we need to be able to group our objects within drawing spaces so that we can manage more complex interfaces. In order to create these drawing spaces, we need to use the render tag. Let's start with a quick illustration. Run this script and then try dragging the red and blue squares around in the available space:
<dml>
<box colour="#000000"/>
<render colour="#ff0000" x="20" y="20" height="100" width="100" leftlimit="-10"
rightlimit="-10" toplimit="-10" bottomlimit="-10" drag="[self]">
<text face="arial:12" align="center" colour="#ffffff" string="Hello"/>
<action static monitor="[container]" call="focus">
<action static object="[[container].container]" call="movetofront"/>
</action>
</render>
<render colour="#0000ff" xoffset="20" y="20" height="100" width="100" leftlimit="-10"
rightlimit="-10" toplimit="-10" bottomlimit="-10" drag="[self]">
<text face="arial:12" align="center" colour="#ffffff" string="World"/>
<action static monitor="[container]" call="focus">
<action static object="[[container].container]" call="movetofront"/>
</action>
</text>
</dml>
You will notice that as you drag each square, the text that is contained within them is also dragged along. This is because each text object has been contained by its respective rendered area, effectively creating a 'group' of graphics that carry along with the parent. Also, notice that when you click on any area it is moved in front of the other - this demonstrates the ability to arrange graphics in layers. While the render object is the most complex type in the GUI system, it is simple to use if you only need its basic features. To get extended information on the Render class, please refer to its official render documentation. To help get you started, the following table describes the most commonly used fields:
Special EffectsIf you have used Athene before then you may have noticed that some special effect classes are distributed as standard. These include a starfield generator, flame effect, forest fractals, rotating 3D objects and others. Here are some effect examples:
The available special effects are extremely easy to use - simply specify the name of the effect in a tag, e.g. <starfield/> and you're done. The real question is, what do you need to do to create customised graphics like this? Due to the speed required to achieve these effects, the only option is to write them in C as DML plugins. This involves downloading the Pandora Engine SDK and retrieving the source code to the effects so that you can learn how to create them. If you have the C programming skills, creating new effects for DML is straight-forward and rewarding. The details for developing them is outside the scope of these tutorials, but you will find all of the necessary information in the SDK.
Copyright Rocklyte Ltd © 2002-2007. |