collisions_create - ryzom/ryzomcore GitHub Wiki


title: How to create collisions in a landscape description: published: true date: 2023-03-01T05:22:22.085Z tags: editor: markdown dateCreated: 2022-03-16T10:18:23.859Z

This piece of documentation is quite old. Please help review it! {.is-warning}

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 informations.

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:

  • NeL plugins for 3ds Max
  • A working Snowballs demo
  • Snowballs 3ds Max .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 3ds Max
    • 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.

missing image simple_cube_visible.jpg {.is-danger}

The 'exterior' collision mesh prevents the player from crossing the visible mesh. The 'interior' collision mesh is of no use, but it has to be present.

simple_cube_coll.jpg

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.

ramp_visible.jpg

  • 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

missing image ramp_coll.jpg {.is-danger}

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.

rampncollumn_0.jpg

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.

missing image rampncollumn_1.jpg {.is-danger}

A collision at the base of the ramp.

rampncollumn_2.jpg

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

Source

⚠️ **GitHub.com Fallback** ⚠️