at the top of the file under the line:
global all_scene_maps = #()
add the following line:
global all_scene_maps_types = #()
under the line:
global All_Xref_objects = #()
add the following two lines:
-- collada names for the map types
global maptypes = #("AMBIENT","DIFFUSE","SPECULAR","","","","TRANSPARENCY","","BUMP","","","")
In function Write_DAE_TEXTURE_LIBRARY after the line which reads:
format " <texture id=\"%\" name=\"%\">
" name_string name_string to:file_ptr
add this line:
maptype = maptypes[all_scene_maps_types[i]]
and alter the line below with ‘<param name=“DIFFUSE”’ to:
format (" <param name=\""+maptype+"\" type=\"float3\" flow=\"OUT\"/>
") to:file_ptr
In the function Write_DAE_MATERIAL_LIBRARY, after the lines:
if ((isproperty this_mtl #diffusemap) and (this_mtl.diffusemap != undefined)) then
(
local texture_name_string = (DAE_Element_Name this_mtl.diffusemap)
format "<input semantic=\"TEXTURE\" source=\"#%\"/>
" texture_name_string to:file_ptr
)
add the following lines:
if ((isproperty this_mtl #specularmap) and (this_mtl.specularmap!= undefined)) then
(
local texture_name_string = (DAE_Element_Name this_mtl.specularmap)
format "<input semantic=\"TEXTURE\" source=\"#%\"/>
" texture_name_string to:file_ptr
)
if ((isproperty this_mtl #bumpmap) and (this_mtl.bumpmap!= undefined)) then
(
map = this_mtl.bumpmap
if ((classof map) == Normal_Bump) then
(
map = map.normal_map
)
local texture_name_string = (DAE_Element_Name map)
format "<input semantic=\"TEXTURE\" source=\"#%\"/>
" texture_name_string to:file_ptr
)
In function Collect_Material_Maps change the for map to mat.maps loop to:
for nmap = 1 to mat.maps.count do
(
map = mat.maps[nmap]
if (map != undefined) then
(
-- if normal map get the normal map itself
if ((classof map) == Normal_Bump) then
(
map = map.normal_map
)
-- if ((finditem all_scene_maps map) == 0) then -- don't add if already there
-- (
if (hasproperty map #filename) then -- this one references a file
(
if ((finditem all_map_filenames map.filename) == 0) then -- we have not collected this one yet
(
append all_map_filenames map.filename -- collect it
)
)
append all_scene_maps map -- add this map reference to the list
append all_scene_maps_types nmap -- add the type of this reference
-- )
)
)
You can now specify a map for the specular color of a material and it will be exported to Collada.
Also, You can use a Normal_Bump material in the bump channel of the material and it will export the normal map of the Normal_Bump as a ‘BUMP’ texture type in the Collada file.