- Documentation
- Client functions
- engineGenerateCOL
Function
engineGenerateCOL
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, optionalmode("mesh","hull","boxes","box","sphere"),triangles(4-65535, alsomaxTriangles),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
engineReplaceCOLReplaces an object model's collision with one fromengineLoadCOLorengineGenerateCOL(also for map objects with that number and the day/night pair model). Objects only, not peds and vehicles. If the model does not exist in the game yet (a newengineRequestModelmodel while the player joins or a resource restarts), the collision waits and applies as soon as the model appears; a model number that does not exist givesfalse.engineLoadCOLLoads a collision from a resource file (COLL, COL2, COL3, COL4 formats; from an archive it takes the first model) or from file bytes.