ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Client functions
  3. engineGenerateCOL

Function

engineGenerateCOL

ClientGame engineTrilogy Hub only

Creates a COL3 collision from a model from engineLoadMesh when the author did not supply a .col file. You set the triangle count (QEM simplification keeps the shape), the mode (mesh, convex hull, boxes, sphere) and the surface. Pass the result to engineReplaceCOL.

Syntax

col engineGenerateCOL(mesh mesh [, table options])

Arguments

meshmesh
The model.
optionstable, optional
mode ("mesh", "hull", "boxes", "box", "sphere"), triangles (4-65535, also maxTriangles), ratio (share of the model's triangles, e.g. 0.25), material (SA surface 0-178), maxBoxes (for "boxes", default 16), weld (metres, default 0.002), skipTransparent (no glass or leaves).

Returns

The collision with the fields mode, generatedFaces, originalFaces, simplified, deviation (largest shape error in metres) or false (the reason in the log).

Example

local mesh = engineLoadMesh("modele/dom.fbx")
local id = engineRequestModel("object")
engineReplaceModel(mesh, id)
local col = engineGenerateCOL(mesh, { triangles = 2500, material = 43, skipTransparent = true })
if col then engineReplaceCOL(col, id) end

Notes

A ready .col file with nothing computed in game: the collision generator on the website, same settings with a 3D preview.

See also