Levels (Scene)

Mesh uses Trenchbroom to make the main parts of levels - the architecture, or structure of a level. On top of the structure of the level, many game elements (Entities) are built into the level.

At the minimum, a level must have a player_start and at least one dynamic light.

Here are the brush types and entities Mesh supports:

Brush Types (Geometry Pieces) Entities (Player Pieces)
Doors Player_Start
Triggers Camera
Actives Dynamic Light
Brush Model
Skybox Sound
Floor Script

Brush Types

Doors

You can create a door by right clicking on any brush and choosing Func then Door.

door brush

A door will have several base properties that can be adjusted in the Entity editor. The most important being the name of the door. You will use this to reference the door with a Buttons or a Trigger.

door props

The following are the basic properties:

Property Type Does
name string allows referencing from other brushes or behaviours
speed float the speed at which the door moves
lip float the amount the door should stick out when closed. 0 is flush
movedir int the axis the door should move towards. - being down + being up for example
target string object(s) to trigger when the door triggers
moveaxis int axis the door should operate on x,y or z
behaviours behaviour string script(s) this object should use for custom behaviour (space separated)
shader shader string a custom shader (must be loaded in the engine)

Triggers

To make triggers the player can activate by colliding with it:

trigger active

  • Create a new brush where you want the trigger to be.
  • Right click on the brush and select Create Brush Entity then Trigger then active
  • You can then modify the trigger by editing the Entity property page
Property Type Does
name string allows referencing from other brushes or behaviours
behaviours behaviour string script(s) this object should use for custom behaviour (space separated)
target string object(s) to trigger when the trigger triggers
shader shader string a custom shader (must be loaded in the engine)
affects string the game object’s name who can trigger this (‘player’ for example)
requires string an inventory item that must be non-zero for this trigger to work (see Pickup)
activate_count int the number of times this trigger can work

Actives

Another special type of brush are the Actives. These are created similarly to the triggers above, but instead of right clicking Trigger, you selected Func.

trigger active

This setting will also allow you to set behaviours and custom shaders on brushes.

The difference between the Actives and the Triggers is: triggers are not meant to be seen whereas actives are. A Trigger can be used to make a door open, or kick off a sound, where as an Active is used for a button, an elevator, or to create a pool of water with a special shader.

Property Type Does
name string allows referencing from other brushes or behaviours
behaviours behaviour string script(s) this object should use for custom behaviour (space separated)
target string object(s) to target (used within custom behaviours)
shader shader string a custom shader (must be loaded in the engine)
affects string the game object’s name who can trigger this (‘player’ for example)
requires string an inventory item that must be non-zero for this trigger to work (see Pickup)
activate_count int the number of times this trigger can work

Behaviour: button

To create a button use an Active, and attach a behaviour of a button.

The target property of the active will be where the message ‘the button got pressed’ gets sent.

For example, here is a screen shot of a button that when pressed opens two doors at the same time:

button

Brush

Brush types are used to optimise a level. They can be used to make a brush invisible, or to create an invisible wall the player can not pass through.

Brush

Right click on any brush and select Create Brush Entity then Func then brush

Property Type Does
rendermode int sets if this brush should be rendered / drawn to the screen
solid int sets if this brush is within the physic system. E.g. can a player bump into it
name string allows referencing from other brushes or behaviours
shader shader string a custom shader (must be loaded in the engine)
target string object(s) to trigger when the object does something (used with a custom behaviour)
behaviours behaviour string script(s) this object should use for custom behaviour (space separated)

Behaviour: teleport

To create a teleport you start by creating the teleport destination. Create a Brush, give it a name, and attach a behaviour of a teleport. It is also useful to set rendermode to Don’t Render and solid to None.

With the teleport defined, you can then make a Trigger with a target of the newly created teleport destination. When the player trips the trigger they will be teleported ot the destination.

Skybox

To create a skybox you need to create a skybox set; four images that make up each side of a box facing inward. These files need to be in the textures/_box hive directory, and they must have a name in the following format:

  • <name>_nx.png (negative x)
  • <name>_ny.png (negative y)
  • <name>_nz.png (negative z)
  • <name>_px.png (positive x)
  • <name>_py.png (positive y)
  • <name>_pz.png (positive z)

Once the images have been created, you can create a brush with it’s origin at (0, 0, 0) - it must be located in the middle of the map. You can then click on the box and choose skybox:

Skybox

Property Type Does
skybox string the name of the skybox set from within the hive
behaviours behaviour string script(s) this object should use for custom behaviour (space separated)
shader shader string a custom shader (must be loaded in the engine)
name string allows referencing from other brushes or behaviours

It is important to note that the skybox will follow the player around the level so you need to take care that the skybox encompasses the entire level, and that at no point would the skybox creep into the players view.

Floor

When the player is in VR, a floor will allow the user to use locomotion to move to that area (teleport to that location by using the VR controller, pointing at a location and pulling the trigger).

By default floors are not visible, and not sent to the physics engine. They are used to mark parts of the scene where the player is allowed move.

floor

Entities

Player_Start

This defines the player start position

Camera

This defines a static camera position. If you provide both a camera and a player_start, the player_start will be the default viewer when the scene starts.

Dynamic Light

Dynamic lights have some global settings as shown in the following table, and mesh had some built in behaviours you can apply (listed after the properties)

Property Type Does
light_color vector<float> the color of the light
light_type int specifies directional, point or spot light
angles vector<int> x, y and z angles of the light position
range float how far the light will reach (1 = 16tb units)
attenuation int constant, linear or quadratic - how the light “falls off”
cutoff float
intensity float how bright the light starts out
name string the name of the light used in behaviours
behaviours behaviour string script(s) this object should use for custom behaviour (space separated)

For more information see Lighting.

Behaviour: flicker

Adding the flicker behaviour will add the following properties

Property Type Does
_lowerBound float how low the intensity can get while pulsing / flickering (0 is completely off)
_style int 0 = pulse, 1 = flicker
_flickerRate float how fast it flickers (3 is a decent value)
_pulseRate float how fast the light pulses (.005 is a decent value)

Model

Models are used for static meshes, NPC, or animated models within a level.

Property Type Does
name string allows referencing from other brushes, models, scripts or behaviours
behaviours behaviour string script(s) this object should use for custom behaviour (space separated)
model string the file name (with extension) of the .obj or .mdl file to place in this location
material string the file name (with extension) of the material file (.mtl) to apply to the model
body int how this model should behave (dynamic, static, kinematic)
shape int the shape this object should have in the physics engine SPHERE, BOX, CONVEXPOLYHEDRON, ACTOR, etc
target string object(s) to trigger when the object does something (used with a custom behaviour)

Behaviour: pickup

Attaching the pickup behaviour will make it so the player can ‘pickup’ the object. Meaning when the player collides with the object, the object will be removed from the scene and any underscore property on the object will be added to the player’s inventory.

For example, if you add the custom underscore property _apple = 1 to the object, when the player collides with the object the players inventory will increase the player’s apple inventory by 1 (if it doesn’t exist it will create it and add one).

This could also be used to decrease a player’s health by using a negative value.

Property Type Does
_<name> int allows increasing or decreasing of any inventory item

Behaviour: spin

Spin will make the attached object slowly rotate.

Behaviour: chase

Chase will make the object try to follow the target. The “AI” behind this is quite dumb; currently only usable for testing.

Sound

Sounds are used to place sounds in the level

Property Type Does
name string allows referencing from other brushes, models, scripts or behaviours
behaviours behaviour string script(s) this object should use for custom behaviour (space separated)
sound string the file name (with extension) of the .m4a or .mp3 file to place in this location
autoplay int if the sound should start on scene load
loop int if the sound should loop

Script

A script is used to trigger several different entities or brushes at the same time, or in sequence with custom logic (assigned using the behaviour property)

Property Type Does
name string allows referencing from other brushes, models, scripts or behaviours
behaviours behaviour string script(s) this object should use for custom behaviour (space separated)
affects string space separated list of references for the script