Below is a sample
with links to documentation for every attribute.
<?xml version="1.0"?> <level name="required_level_name" type="Level" scene="required_scene_file_name_or_url.x3d" title="Required Level Title" number="0" demo="False" title_hint="" default_played="False" placeholders="x3dshape" loading_image="" loading_bar_y_position="0.5" placeholder_reference_direction="1 0 0" music_sound=""> <!-- prepare_resources is an optional element. It should contain a list of resources (creatures; no need to list items, as they are always prepared (by default), see T3DResource.AlwaysPrepare) used by the level. Every <resource> element should refer to the resource name, that is you should have resource.xml file with name="TestCreature" in your data. --> <prepare_resources> <resource name="TestCreature" /> <!-- And more <resource> elements... --> </prepare_resources> </level>
A major feature of loading level through TGameSceneManager.LoadLevel is that you can put "placeholders" on your level 3D model. These are 3D shapes with special names that will be recognized by the engine:
Initial creatures / items are indicated by placeholders named
+ resource name.
CasRes is short for Castle Game Engine Resource.
The resource name refers to
it much match one of
name="ResourceName" declarations in your
CasRes<resource-name>[<optional-initial-life>][_<ignored>]. By default (if not explicitly specified), the initial creature life is taken from
resource.xml. It is possible to place a creature corpse on the level this way, by specifying life as 0. Initial creature looking direction is determined by the transformation of the placeholder object, see PlaceholderReferenceDirection, in short: look at where local +X of the placeholder is pointing.
CasRes<resource-name>[<optional-item-quantity>][_<ignored>]. By default (if not explicitly specified), item quantity is 1.
Anything after underscore is ignored. You can use this to make placeholder name unique, e.g. all objects in Blender must be unique. Note that Blender exporter changes the "dot" inside object names to an underscore when exporting, so everything in Blender object name after dot is ignored too.
Water volume by placeholder "CasWater" (see TCastleSceneManager.Water).
Move limit by placeholder "CasMoveLimit" (see TCastleSceneManager.MoveLimit).
Sectors / waypoints to improve creature AI moving. Each sector occupies some volume in 3D (like a room). Each waypoint indicates a point to pass when moving from one sector to another (like a narrow door between two rooms). Sectors create a graph, with waypoints indicating the graph connections. If the creature is in a different sector then it's target, it walks through appropriate waypoints.
CasWaypoint[_<ignored>] define waypoints.
Sectors of waypoints (and reverse property, waypoints of sectors) are automatically calculated, by looking how waypoints bounding boxes collide with sectors. This is the only moment when waypoints bounding volumes are considered, for all other purposes waypoints are simply 3D points. You should place boxes that indicate waypoints between two neighboring sectors, such that the bounding box of the waypoint is partially inside both sectors.
Sectors boxes need not be strictly separated. When 3D object, like player or a creature, is within two sectors, it's arbitrarily assigned to any of the possible sectors. However, for creature AI, this may cause some awkward movement (when the creature goes to a waypoint, instead of directly to the target), so try to set sectors that don't overlap (much).
You don't have to cover whole level with sectors. If a creature (or it's target) is not inside any sector, then the move direction is simply set to go to the target directly.
See TGameSceneManager.LoadLevel documentation for full list of placeholders.
The "placeholders" attribute in level.xml determines how we derive "placeholder name" from a VRML/X3D shape.
"x3dshape"(default) means that the placeholder name comes from VRML 2.0/X3D Shape node name (set using "DEF" in VRML/X3D).
"blender"means that the placeholder name is detected following standard Blender VRML/X3D exporters behavior. This allows you to set the placeholder name easily in Blender, just set the Blender object name.
Copyright Michalis Kamburelis. Thanks go to Paweł Wojciechowicz from Cat-astrophe Games for various graphics. Even this documentation is open-source, you can redistribute it on terms of the GNU General Public License.