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
TLevel.Load 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>][.<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 or dot is ignored.
CasRedMedKit.123 is understood to include resource named
Water volume by placeholder "CasWater"
Move limit by placeholder "CasMoveLimit"
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.
TLevel.Load documentation for full list of placeholders.
And possibly your
TLevelLogic will define even more placeholders
and using your logic as
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 -> glTF and Blender -> X3D exporters behavior. This allows you to set the placeholder name easily in Blender. In case of exporting to glTF, just set the Blender mesh name. In case of exporting to X3D, just set the Blender object name.
TPlaceholderNamedocs. You can define and register your own functions there, to handle other 3D modelers, like 3ds Max or Maya or anything else (and you're welcome to contribute them to include them in engine code, of course!).