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

4.3.5 Zone Manager

The zone manager is a useful property class for managing level loading.

Property Class Details

General Information

The zone manager is a powerful property class that manages dynamic loading (loading of the map files that are required at a given time in the game) but it can also be used for single map loading for simple games. A commonly used scenario is to setup the zone manager with a single map file for geometry and another file for entity descriptions.

Concepts

The following concepts are defined in the zone manager:

Loading A Simple Map File

The iPcZoneManager->Load() method which accepts a VFS `path' and a `file' accepts both normal Crystal Space world files or else an XML zone description file. In the first case the zone manager will automatically setup a region and a zone which are both called `main'.

Loading A Complex Level Set

The other case is where you pass a XML zone description file to the Load() method (of course you can also setup the zone manager purely with API calls but using an XML description file is more flexible and easier). Here is an example of such a description file:

 
<level name="SuperLevel" description="Super Complex Level">
    <mount vfs="/sl/part1" real="$*data$/levels$/part1.zip" />
    <mount vfs="/sl/part2" real="$*data$/levels$/part2.zip" />
    <mount vfs="/sl/part_trans" real="$*data$/levels$/part_trans.zip" />
    <mount vfs="/sl/textures" real="$*data$/levels$/textures.zip" />
    <region name="part1">
       <map
          name="part1_entities"
          path="/sl/part1"
          file="entities.xml" />
       <map
          name="part1_world"
          path="/sl/part1"
          file="world" />
    </region>
    <region name="part2">
       <map
          name="part2_entities"
          path="/sl/part2"
          file="entities.xml" />
       <map
          name="part2_world"
          path="/sl/part2"
          file="world" />
    </region>
    <region name="part_trans">
       <map
          name="part_trans_entities"
          path="/sl/part_trans"
          file="entities.xml" />
       <map
          name="part_trans_world"
          path="/sl/part_trans"
          file="world" />
    </region>
    <zone name="zone1">
       <region>part1</region>
       <region>part_trans</region>
    </zone>
    <zone name="zone2">
       <region>part2</region>
       <region>part_trans</region>
    </zone>
    <start>
       <region>part1</region>
       <name>Camera</name>
    </start>
</level>

In this example we have created three levels in our 3D modeller program: `part1', `part2', and `part_trans'. The last one is a transition level that connects `part1' and `part2'. Preferably this is a small level like a corridor which should ensure that from `part1' you can't see anything of `part2' by looking through `part_trans' (and vice versa). Every level zip files contains a `world' file with geometry and an `entities.xml' file for entity descriptions.

For every map file (geometry and entities) we have a region. Finally we create two zones. Both zones contain the transition map as that is always needed. As soon as the player enters the transition map both zones will be activated and everything will be in memory. If you want to avoid this then you need to define two transition maps.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated using texi2html 1.76.