# Introduction¶

Materials defines the visual aspect of an object in the 3D view, such as its color or which textures it uses.

Materials are defined in two places:

• 3D model (DAE file)
• Material file (materials.cs file)

## What is a DAE file?¶

A file with the DAE extension is a Digital Asset Exchange file and contains 3D models to be used in 3D applications. Objects must have at least one material assigned to them or they won’t be rendered in the game engine.

Materials system are mostly specific per program. For example, making a material glossy in your 3D program won’t make it appear glossy in the game engine, which will use its own material properties defined in the materials.cs files.

## What is a materials.cs file?¶

A file which is named materials.cs contains the properties that describes how a specific material will be rendered in the game engine. The name of these files are fixed.

The materials.cs are usually located in the same folder along with the DAE file it provides the material properties for. If two objects share the same material, but they are in separate folder, only one materials.cs with that material defined is needed (once it’s loaded, it will be in memory for all the other objects using it).

### Syntax¶

This is an example of a single material. A materials.cs file contain multiple materials (separated from a new line).

singleton Material(my_material_21)
{
mapTo = "my_material_21";
diffuseColor[0] = "1 1 1 1";
colorMap[0] = "levels/gridmap/art/shapes/buildings/tin-01_d.dds";
useAnisotropic[0] = "1";
materialTag0 = "mycustomtag";
groundType = "dirt_loose";
};

• The name of the material is my_material_21.
• The material is mapped to any object using the my_material_21 material. This option allows to assign a material to objects using a different material name in their DAE files.
• The diffuse color of the material is non trasparent white (Red Green Blue Alpha)
• The material has Anisotropic Filtering enabled (boolean)
• The material has a custom tag assigned. That will categorize the material in the in-game material library, to be found easily.
• The material has a groundmodel assigned, meaning that any objects using that material will physically act as ‘dirt_loose’ when a vehicle drives on it. If no groundType is specified, ‘asphalt’ is used as default.

More visual properties by using the in-game material editor (TODO - Add reference to material editor)

Because of the materials.cs file name is fixed, it’s not possible to have two of them in the same folder. In this case copy and paste the material from one onto the other, so that all the materials are defined in a single file.

## How materials.cs files are loaded¶

### Vehicles¶

Materials for vehicles are loaded from the folder of the vehicle in use, and the vehicle/common folder. The latter is used for parts that are shared between multiple vehicles (for example wheels and tires).

### Levels¶

Materials for levels are loaded from the folder of the level in use.