User Tools

Site Tools


This is an old revision of the document!


Using ASE Models

Most 3D modelling programs can export models to the ASE file format. As all Cafu programs directly support the ASE file format, using ASE models is straightforward.

This section explains the one-time adjustments required so that an ASE model works properly with the Cafu engine.

Saving the model

Saving the model Save or copy your model file and all related texture images somewhere into the Games/DeathMatch/Models subdirectory.

In the example at the right, we saved the ASE model file wbridge-1.ase of a wooden footbridge and the three texture images for its material in the Static subdirectory inside Models.

Setting the material names

Open the previously saved ASE model in a text editor like Notepad++ or UltraEdit. Use Notepad if you have nothing else.

In the file, find section *MATERIAL_LIST { … }. For example:

...
 
*MATERIAL_LIST	{
	*MATERIAL_COUNT	4
	*MATERIAL	0	{
		*MATERIAL_NAME	"textures/spkat3/cwood_mo5c"
		*MATERIAL_CLASS	"Standard"
		*MATERIAL_DIFFUSE	1.000000	1.000000	1.000000
		*MATERIAL_SHADING Phong
		...
	}
	...
}
 
...

In the *MATERIAL_LIST, for each listed *MATERIAL, you must replace the *MATERIAL_NAME string. The new *MATERIAL_NAME string can be anything you like, but:

  • you must be able to remember it or write it down for the next step,
  • it must not have whitespace (space or tab) characters,
  • it should be unique for all models known to the Cafu engine.

If there is more than one *MATERIAL in your *MATERIAL_LIST, you can initially use the same *MATERIAL_NAME string everywhere. When you later find out that you want to use different Cafu materials for different parts of the model, come back here and assign individual material names as required.

In the example, we have chosen Models/wbridge as the new material name, and our ASE file is saved like this:

...
 
*MATERIAL_LIST	{
	*MATERIAL_COUNT	4
	*MATERIAL	0	{
		*MATERIAL_NAME	"Models/wbridge"
		*MATERIAL_CLASS	"Standard"
		*MATERIAL_DIFFUSE	1.000000	1.000000	1.000000
		*MATERIAL_SHADING Phong
		...
	}
	*MATERIAL	1	{
		*MATERIAL_NAME	"Models/wbridge"
		...
	}
	...
}
 
...

Creating Cafu materials

We now add definitions for each material that we referenced above. Once more using the text editor, you can either create a new .cmat file somewhere inside the Games/DeathMatch/Materials folder, or just open one of the existing .cmat files and add your definitions there.

In our example, we just open Games/DeathMatch/Materials/Models/Static.cmat, and add at the end:

Models/wbridge
{
    diffusemap  Models/Static/wbridge_diff.png
 // normalmap   Models/Static/wbridge_norm.png
 // specularmap Models/Static/wbridge_spec.png
 
    red   ambientLightRed
    green ambientLightGreen
    blue  ambientLightBlue
 
    meta_editorImage noEditor
}

You can just copy and paste this example for your own materials.

  1. Edit the first line with the material name (Models/wbridge in the example) to match the name that was written into the ASE file in the previous step.
  2. Edit the three lines that define the diffuse, normal and specular map. The most difficult part of the job is to get the pathnames to the texture images right: They are relative to the DeathMatch directory and for the sake of Linux users, you should use forward () instead of backward (\**) slashes and make proper use of upper/lower case.
  3. Leave the last four lines alone.

Note that in the example, the normal and specular map lines are commented out. For your own use, remove the comment marker // as required. You can learn more about Cafu material definitions at The Cafu Material System.

If the *MATERIAL_NAME keyword occurred multiple times in the ASE file and you specified different names for them, you should repeat this step for every distinct material name.

Checking and using the model

Checking the ASE model in the ModelViewer You can check the result in the Cafu ModelViewer by running it from the command line with the model name as a parameter:

C:\Cafu-9.06> ModelViewer.exe Games\DeathMatch\Models\Static\wbridge-1.ase

(Use auto-completion also with Microsoft Windows for easily typing the path name.)

When you're satisfied with the result:

  • use the New Entity tool for placing your ASE model in CaWE,
  • watch the related “Placing a Model” tutorial – recommended! 8-)

If you want to make adjustments later, both the ASE model as well as the material definitions can be edited as shown above also after the model has been placed in a map or world file. The changes will take effect when the program is next restarted.

modelling/usingasemodels.1333530424.txt.gz · Last modified: 2013-01-07 12:07 (external edit)