Landscape Collisions
Description
During the build-gamedata process, NeL patches automatically generate a collision layer.
To insert a mesh into your landscape and have your character collide it, you have to manually add collision information.
This document shows how to create this kind of collisions in 3DSMax and export / test them in the [SnowBalls] demo.
Requisites
You need the following configuration:
- 3DSMax and NeL plugins
- A working [SnowBalls] demo
- Snowballs 3DSMax .max source files
- The build_gamedata package, and especially :
- The /build_gamedata/bin/build_indoor_rbank.exe tool
- The /build_gamedata/processes/rbank/build_indoor_rbank.cfg configuration file with the following options
- Merge = 1;
- MergePath = "smooth/";
- MergeInputPrefix = "snowballs";
- OutputPath = "retrievers/";
- MergeOutputPrefix = "snowballs";
Backup your original [SnowBalls] files: some of them will be changed by this process. Copy the original snowball.gr and snowballs.rbank files from /snowballs/data/pacs/ into /build_gamedata/processes/rbank/smooth/
Overall process
- In 3DSMax
- Load a .max Zone file
- Create a mesh
- Export its .shape file in /snowballs/data/shapes
- Select the whole scenery objects and export the instance group file, replacing the old /snowballs/data/zone/<zone>.ig file
- Create an interior collision mesh (explained hereafter)
- Create an exterior collision mesh (explained hereafter)
- Select all the collision meshes and export the collisions (Utilities / NeL Export / Export collisions), point to the /build_gamedata/processes/rbank/cmb/ directory
- Launch /build_gamedata/processes/rbank/3_build.bat to build and merge the new collision data to the original Snowballs collision.
- Replace the files snowballs.gr and snowballs.rbank in /snowballs/data/pacs/ with the new ones from /build_gamedata/processes/rbank/retrievers/
- Launch Snowballs
Details on collisions
Pairs
In a landscape, every collision system is composed of two objects: an interior and an exterior mesh
- The interior mesh is a mesh on which the user can walk
- The exterior mesh acts as a collider in the landscape (visible open edges) and a bridge between the landscape and the interior collision mesh (invisible open edges (An 'open' edge is an edge that belongs to only one face) )
Even if there is no need for an interior collision mesh, this mesh must be present:
Here is a simple box placed on the landscape:

The 'exterior' collision mesh prevents the player from crossing the visible mesh The 'interior' collision mesh is in this case of no use, but it has to be present.
Frontiers
To have the character walk on a mesh, like a staircase or a ramp, the exterior and interior collision meshes must have overlapping invisible open edges.
Every invisible edge in the exterior mesh must have a corresponding 'snapped' edge in the interior mesh.

Ramp raising from the ground, the player cannot walk under it.

- The visible edges of the exterior mesh block the user coming from the landscape
- The visible edges of the interior mesh prevent the user from falling out of the ramp
- The superposed invisible edges of both the interior and the exterior meshes indicate a connection between the landscape and the ramp
Objects informations and constraints
- Node properties (Utilities / NeL Export / Node Properties / Instances Tab)
- The two collision meshes have the same non null Instance group name.
- The interior collision mesh has the 'Collision Mesh' property checked.
- The exterior collision mesh has both the 'Collision Mesh' and 'Collision Mesh Exterior' properties checked.
- Edges
- Both objects must have the same number of invisible open edges, the vertices of the interior mesh along these edges must be 'snapped' to those of the exterior mesh (same position).
- Material ID
- Exterior collision mesh: The faces must have the MatID 666.
- Interior collision mesh: Verify that the faces along the open edges have a unique material ID : Faces that have different matIDs are separated in different meshes at export time, this generates new 'open' edges that can't match a corresponding edge on the exterior collision mesh.
Complex collisions
The following example is composed of two collision systems:

A connection between the landscape and the ramp, but the exterior mesh only blocks the path around the start : the player can walk under the ramp:

A collision at the base of the ramp:

Remark
For now this system cannot create bridges. You can have a collision that has two or more distinct connections with the landscape, but the exterior mesh cannot be broken into multiple meshes, so you couldn't go onto and under a bridge.