-
Notifications
You must be signed in to change notification settings - Fork 41
HowTo: Create mtl file for obj files ex post
To include reflectance values of different surfaces and to obtain data from full waveform HELIOS at all, an obj wavefront mesh model must be accompanied by a mtl (material) file.
In case no mtl file was created with the obj file, in the following you can find a work-around to re-construct an appropriate mtl file.
The work-around may be not very elegant, but the result works. The steps were necessary at the time of writing this wiki entry to provide HELIOS with appropriately formatted obj and mtl files.
Be aware that after the steps, you will have a mtl file and reflectance values, but it is assigned to all faces of your mesh.
The steps are:
- Import obj file to Blender (https://www.blender.org/)
- Don't change anything, only export the obj file again, using the obj exporter settings shown in the following screenshot:
- Blender will create a mtl file which is linked to the obj file
- The created mtl file may contain only one material, which is the default material 'None'
The content of the created mtl file may look like that:
# Blender MTL File: 'None'
# Material Count: 1
newmtl None
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
HELIOS uses the mtl file to read out the reflectance of the respective object surface mesh. Simply insert a line 'helios_reflectance' at the end of the mtl file:
# Generated by CloudCompare
newmtl None
Ka 0 0 1
Kd 0.8 0.8 0.8
Ks 0.8 0.8 0.8
Tr 1
illum 1
Ns 0
helios_reflectance 0.2
In case you are working with a mtl file which contains several material definitions, insert the 'helios_reflectance' line after each material definition and adjust the respective reflectance as considered appropriate.
That's it.
In case you have a bunch of similar obj files in your scene and you want to use the same mtl file for them (e.g. 'default.mtl')
- Insert the name of the mtl file at each occurrence of 'mtllib'
Example:
mtllib default.mtl
- Choose / set material at each occurrence of 'usemtl'
Example:
usemtl None
(Material definition 'None' will be applied)
Take care that when messing around with (1) names of materials in the mtl file, and (2) with mtl file names, the counterpart (the 'call' in the obj file) is adjusted accordingly.