[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ] [ Search: ]

5.4.2.2 World Element Section

This section describes the world element section.

Addon Section

Addons are loader plugins that can be used to extend the loading capabilities. Like keys, addons can also be loaded from almost any Crystal Space object. The difference is that the loaded information is not automatically attached to the object. Instead the object in which the addon is called is given as a context to the addon loader so that it can choose to do with it whatever it wants. For example, you could make an addon plugin for your own game that sets up a physics object for a mesh object. To do that you would have to create a plugin that implements the ‘iLoaderPlugin’ interface. In the plugin implementation you can examine the context and based on that create some information that you can attach to that context (if it is a mesh object for example). The addon plugin will also get an XML node that it can parse for additional parameters.

Mesh Factory Section

In a map file you can define zero or more mesh factories. A mesh factory itself is not an object that you can see. It only defines a blue-print for creating mesh objects later. How a mesh factory and mesh object interact depends on the specific type of mesh object. For some types factories are required but for others you can just define the object directly as a mesh object (see section Mesh Object Plug-In System).

Here is an example mesh factory:

 
<meshfact name="square">
    <plugin>crystalspace.mesh.loader.factory.genmesh</plugin>
    <params>
        <numvt>4</numvt>
        <numtri>4</numtri>
        <v x="-2" y="0" z="-2" u="0" v="0" />
        <v x="2" y="0" z="-2" u="1" v="0" />
        <v x="2" y="0" z="2" u="1" v="1" />
        <v x="-2" y="0" z="2" u="0" v="1" />
        <t v1="3" v2="0" v3="1" />
        <t v1="1" v2="2" v3="3" />
        <t v1="1" v2="0" v3="3" />
        <t v1="3" v2="2" v3="1" />
        <autonormals />
    </params>
</meshfact>

In the example above we use the ‘genmesh’ factory loader plugin. Everything inside the ‘params’ block is specific to that loader. If you use other loaders you will need other stuff in there. It is also possible to specify the parameters of a plugin in another XML file in which case you can use ‘paramsfile’. The use of ‘paramsfile’ is required if the other file is binary or not XML.

The example above defines a factory called ‘square’. When you later define mesh objects you can create them from that factory. In case of ‘genmesh’ which is used here you must use factories.

Mesh factories can contain keys and addons.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated using texi2html 1.76.