LGW 3D model format

This file describes the file structure of the 3D models in UFO: Aftermath. You may need to convert the file from binary to text format (see UFObintxt) before viewing its contents.

Overall file structure

MODEL "01T01bicykle01"
  EXPORT_VERSION 4
  SOURCE_FILE "Q:\WorkData\Tactical\MaxModels\human\cars\01_kola-final_exp.max"
  MATERIAL_LIST
    MATERIAL 0 "1 - Default"
     ...                       
//material block
    END_OF_MATERIAL
    MATERIAL 1 "draty"
     ...
    END_OF_MATERIAL
    ...
  END_OF_MATERIAL_LIST
  MESH "Mesh01"
   ...                         
//mesh block
  END_OF_MESH "Mesh01"
  MESH "Mesh02"
   ...
  END_OF_MESH "Mesh02"
  ...
END_OF_MODEL

key + params required description
MODEL string yes model name
EXPORT_VERSION int yes format version (currently 4)
SOURCE_FILE string no name of source file from which was this model exported
MATERIAL_LIST yes opens the list of materials
END_OF_MATERIAL_LIST must be paired with the MATERIAL_LIST key closes the list of materials
MESH string yes opens mesh definition
END_OF_MESH string must be paired with the MESH key closes mesh definition
END_OF_MODEL yes closes the file

Actualy neither of the MATERIAL_LIST and MESH blocks are required but there is little point in having models without materials and/or without geometry.

Material block

MATERIAL 0 "1 - Default"
  DIFFUSE_COLOR 0.1843 0.4078 0.1725
  TEXTURE 0
   ...     
//texture descriptor
  END_OF_TEXTURE
  TEXTURE 1
   ...
  END_OF_TEXTURE
END_OF_MATERIAL

key + params description
MATERIAL int string material id and name
DIFFUSE_COLOR float float float not used
TEXTURE int texture number
END_OF_TEXTURE closes texture definition
END_OF_MATERIAL closes material definition

The texture number must be 0 if the material has only one texture. If the material has two textures then their numbers must be 0 and 1.

Texture descriptor

TEXTURE 0
  FILE_NAME "tactical/textures/human/cars/riksa+kolo.tga"
  U_WRAP V_WRAP
  ALPHA_MODE 1
END_OF_TEXTURE

key + params description
FILE_NAME string name of the file with the image
RAW_IMAGE alternative of FILE_NAME, the texture data are stored directly in the file
U_WRAP enables texture repeating in U axis
V_WRAP enables texture repeating in V axis
U_CLAMP disables texture repeating in U axis
V_CLAMP disables texture repeating in V axis
ALPHA_MODE int can be 0, 1 or 8 - inidicates how many bits of alpha should be used
MIPMAP_OFF turns mipmaps off for this texture
MIPMAP_ON turns mipmaps on for this texture
MUTABLE texture will be updated during then game
IMMUTABLE texture is never updated
TEX_GEN_[STR] key EYE_LINEAR, SPHERE_MAP, REFLECTION_MAP, NORMAL_MAP
TEX_GEN_[STR]_KOEF float koeficients for EYE_LINEAR
CUBE_MAP indicates that the texture should be used as cubemap
MODE key REPLACE, BLEND, DECAL, MODULATE, DOT3BUMP, ADD

PLEASE NOTE: Paths specified with the FILE_NAME key must be relative to the directory the game is installed to. Tga and DDS fileformats are supported. But no palleted images.

TEX_GEN_[STR] means TEX_GEN_S or TEX_GEN_T or TEX_GEN_R. The same goes for TEX_GEN_[STR]_KOE.

Actualy only the FILE_NAME key is required. All the other parametres have default values. Default setting are: U_CLAMP, V_CLAMP, ALPHA_MODE 0, MIPMAP_ON, IMMUTABLE, TEX_GEN_[STR] not present (which means off), CUBE_MAP not present (which means cubemapping off) and MODE MODULATE.

In case the key CUBE_MAP is present the key FILE_NAME must point to cubemap image in the dds format.

About texgen facility - see OpenGL specification for details (chapter 2.10.4 Generating Texture Coordinates). In case of EYE_LINEAR are the koeficients set in the following fashion:

coord p1, p2, p3, p4
GL_S TEX_GEN_S_KOEF, 0, 0, 0
GL_T 0, TEX_GEN_T_KOEF, 0, 0
GL_R 0, 0, TEX_GEN_R_KOEF, 0

In the other cases the koeficients doesn't matter.

Mesh block

MESH "Mesh01"
MATERIAL_REF 0
DEFAULT_COLOR 0.878 0.776 0.341
VERTS 238
-87.154137 83.603424 8.602158 0.498448 0.603164 -0.962625 0.257407 -0.084226
-87.154137 83.603424 8.602158 0.498448 0.603164 0.962625 -0.257407 0.084226
-86.991096 82.610558 3.704437 0.571406 0.603337 -0.962625 0.257407 -0.084226
-86.991096 82.610558 3.704437 0.571406 0.603337 0.962625 -0.257407 0.084226
-86.446823 82.922646 6.120047 0.581584 0.197750 -0.032608 0.198573 0.979544
...
PRIMITIVE_GEOMETRY_GROUPS 1
GROUP 0 TYPE_LIST
COUNT 702
0 2 8 0 8 6 1 7 9 1 9 3 6 8 23 6 23 19 7 21 25 7 25 9
12 2 0 12 14 2 13 1 3 13 3 15 18 22 79 18 79 77 20 76 78 20 78 24
...
END_OF_GROUP 0
END_OF_MESH "Mesh01"

key + params description
MATERIAL_REF int id of the material used on this mesh
DEFAULT_COLOR float float float not used
VERTS int count of vertices
PRIMITIVE_GEOMETRY_GROUPS int count of the geometry groups
GROUP int key start definition of a geometry group, the integer is id of the group and the key is type of the group
COUNT int count of indices in this geometry group
END_OF_GROUP int closes geometry group

The data for one vertex consists of 8 floats: 3 floats are coordinates, 2 floats are texture coordinates and last 3 floats are normal.
The geometry groups must be numbered consequently starting with 0. Each group can be one of the three types: TYPE_LIST, TYPE_STRIP, TYPE_FAN. The data of a geometry group consists of COUNT integers which are indices of vertices. The way indices forms triangles depends on the geometry group type, TYPE_LIST means that every three indices forms a triangle.
There can be only one group of type TYPE_LIST in a mesh.


Prev: Game Rules Next: Specification of Animation Up: Home