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

4.16.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.

Crystal Space itself currently defines two addon loaders itself. The first one is useful for defining bezier templates that you can later use in a bezier curve. The second one is useful for creating named texture planes that can be used to define texture mapping for a number of polygons that are all on the same plane. Here is an example of both:

 
<addon>
    <plugin>crystalspace.mesh.loader.thing.bezier</plugin>
    <params>
        <name>b1</name>
        <material>mosaic</material>
        <v>0</v>
        <v>1</v>
        <v>2</v>
        <v>8</v>
        <v>9</v>
        <v>10</v>
        <v>16</v>
        <v>17</v>
        <v>18</v>
    </params>
</addon>

<addon>
    <plugin>crystalspace.mesh.loader.thing.plane</plugin>
    <params>
        <name>floor_plane</name>
        <orig x="-20" y="-1" z="20" />
        <first x="-19" y="-1" z="20" />
        <firstlen>5</firstlen>
        <second x="-20" y="-1" z="19" />
        <secondlen>5</secondlen>
    </params>
</addon>

I will only explain the second example here as bezier curves are likely to change in the not-too-distant future. Important in both examples is that the part inside the ‘params’ block is parsed by the addon itself. It is also possible to specify the parameters of a plugin in another XML file in which case you can use ‘paramsfile’.

The plane addon that is used above defines a horizontal texture plane at location y equal to ‘-1’. The dimension of the texture on that plane will be 5x5 units. This means that in the space of a 5x5 unit block the texture will be shown exactly one time. If the polygons are bigger then that then tiling will be used. When you define ‘thing’ mesh objects you can use this plane if the polygon happens to be at y equal to ‘-1’.

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.