Colobot
Models

Model formats and associated issues are described briefly for graphics designers and developers.

Model format

Todo:
Update for the new model format

Colobot models are basically a collection of triangles with some associated data. In the code, the class Gfx::CModel (src/graphics/model/model.h) is responsible for reading/writing model files. Each triangle of model contains the information as stored in Gfx::ModelTriangle struct defined in model_triangle.h header, that is:

Textures

1st texture is always static - the assigned image name.

2nd texture can be set explicitly in 2nd texture name, with variable flag set to false. It is then static as 1st texture.

But if variable flag is set, the texture will be applied dynamically by the graphics engine. It will be one of dirtyXX.png textures, depending on current setup.

Rendering states

Rendering state is one of Gfx::CEngine's rendering states, that is a mask of enum Gfx::EngineRenderState values from src/graphics/engine/engine.h.

For most purposes, the default render (Gfx::ENG_RSTATE_NORMAL = 0) state will be sufficient. This state enables regular one-texture rendering.

To use 2nd texture, set one of Gfx::ENG_RSTATE_DUAL_BLACK or Gfx::ENG_RSTATE_DUAL_WHITE states. Other states, enabling specific behavior may be used in rare cases.

Min and max LOD

LOD is used to display different model triangles based on distance to viewer. The given triangle will only be displayed if the distance is within bounds [min, max].

For now, use standard definitions of min and max which fall into 3 categories:

File formats

There are currently 3 file formats recognized by Gfx::ModelInput and Gfx::ModelOutput:

Import/export in Blender

The plugin to import and export models in Blender is contained in tools/blender-scipts.py. To use it, install it as per instructions on Blender wiki. It will register new menu entries under File -> Import and File -> Export. Import is always active, but to export, you have to select a mesh object first.

Textures are loaded from the same directory as the model file.

Additional data like state, variable texture flag and min and max LOD can be given as user attributes.

If you have any problems, please contact piotrdz on ICC forum or IRC channels.