{"commit":"2f332b888c9e9ad67dbea1e05a8bf1fc0ec0cbd6","subject":"- max exporter fixes.","message":"- max exporter fixes.\n\ngit-svn-id: 28d9401aa571d5108e51b194aae6f24ca5964c06@32867 8cc4aa7f-3514-0410-904f-f2cc9021211c\n","repos":"crystalspace\/CS,crystalspace\/CS,crystalspace\/CS,crystalspace\/CS,crystalspace\/CS,crystalspace\/CS,crystalspace\/CS,crystalspace\/CS","old_file":"scripts\/max\/exportCS.mcr","new_file":"scripts\/max\/exportCS.mcr","new_contents":"------------------------------------------------------------\n-- Author: Luca Pancallo \n--\n-- Copyright (C) 2009 Atomic Blue (info@planeshift.it,\n-- http:\/\/www.atomicblue.org)\n--\n-- This program is free software; you can redistribute it and\/or\n-- modify it under the terms of the GNU General Public License\n-- as published by the Free Software Foundation (version 2 of the License)\n-- This program is distributed in the hope that it will be useful,\n-- but WITHOUT ANY WARRANTY; without even the implied warranty of\n-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n-- GNU General Public License for more details.\n-- You should have received a copy of the GNU General Public License\n-- along with this program; if not, write to the Free Software\n-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n--\n------------------------------------------------------------\n\n\n\nmacroScript Export_Level_CS\ncategory:\"PlaneShift\"\ninternalcategory:\"PlaneShift\"\nButtonText:\"Export Level to CS\" \ntooltip:\"Export Level to CS\" Icon:#(\"Maxscript\",1)\n(\n\nrollout Test1 \"Export Level to CS\" width:226 height:450\n(\n\tedittext edt3 \"\" pos:[17,32] width:192 height:21\n\tlabel lbl1 \"Export Level To:\" pos:[21,7] width:142 height:20\n\tbutton btn2 \"Export!\" pos:[37,110] width:152 height:24\n\tlabel lbl6 \"Scale:\" pos:[58,72] width:40 height:20\n\tedittext edtScale \"\" pos:[101,67] width:63 height:27\n\tcheckbox chkLights \"Generate Fake lights for walktest\" pos:[6,179] width:215 height:20 enabled:true\n\tlabel lbl3 \"Duration (msecs):\" pos:[16,207] width:108 height:20\n\tedittext edtDuration \"\" pos:[128,206] width:76 height:22\n\tcheckbox chk2 \"Copy textures to dest dir\" pos:[6,152] width:210 height:22\n\tGroupBox grp2 \"Sanity Check\" pos:[10,243] width:201 height:94\n\tcheckbox chkSanity \"Check Only, no Deletion\" pos:[22,267] width:159 height:23 enabled:true checked:true\n\tbutton sanity \"SanityCheck!\" pos:[32,297] width:145 height:31\n\tlabel lblVersion \"V.\" pos:[180,5] width:40 height:21\n\n\tgroupBox grp3 \"Terrain\" pos:[13,348] width:189 height:89\n\tcheckbox chkTerrain \"Export as Terrain Level\" pos:[22,372] width:168 height:26\n\ton Test1 open do\n\t(\n\t version = 52 as String\n\t lblVersion.text = \"V.\"+version\n\t \n\n\t\t-- get room name from custom property\n\t\tcustomPropNumber = fileProperties.findProperty #custom \"roomname\"\n\t\tif (customPropNumber==0) then (\n\t\t\tmessageBox \"Please click on File>File Properties and add a Custom Property called roomname with the name of the sector.\"\n\t\t\treturn 1\n\t\t)\n\t\troomName = fileProperties.getPropertyValue #custom customPropNumber \n\t\n\t\t-- get default scale from custom property\n\t\tcustomPropNumber = fileProperties.findProperty #custom \"scale\"\n\t\tif (customPropNumber==0) then (\n\t\t\tmessageBox \"Please click on File>File Properties and add a Custom Property called \\\"scale\\\" with the scale of the sector.\\n 1 generic unit=1 meter. You can model at higher scale, then specify scale=0.1 or 0.01\"\n\t\t\treturn 1\n\t\t)\n\t\tdefaultScale = fileProperties.getPropertyValue #custom customPropNumber \n\t\n\t edt3.text = \"D:\\Luca\\PS\\gfxpackage3.4\\levels\\\\\"+roomName+\"\\world\"\n\t edtScale.text = defaultScale\n\t)\n\n\ton btn2 pressed do\n\t(\n\t\n\t\t-- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\t\t-- Variables used in the program\n\t\t-- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\t\n\t\t-- get filename\n\t\tfilename = edt3.text\n\t\t-- set debug output\n\t\tdebug=false\n\t\tdebug2=false\n\n\t\t-- define if the program should combine 2 planar triangles into one polygon\n\t\tpolyCombine = true\n\t\n\t\t-- Define verbose output (that takes more space and memory)\n\t\tverboseMode = true\n\t\n\t\t-- parameters for scaling and relocation\n\t\tglobal xscale = edtScale.text as Float\n\t\tglobal yscale = edtScale.text as Float\n\t\tglobal zscale = edtScale.text as Float\n\t\n\t\tglobal xrelocate = 0\n\t\tglobal yrelocate = 0\n\t\tglobal zrelocate = 0\n\t\n\t\t-- functions declaration\n\t\tglobal tokenize\n\t\tglobal lowercase\n\t\tglobal getMatDiffuseMapFilename\n\t\tglobal getMatSpecMapFilename\n\t\tglobal getMatNormalMapFilename\n\t\tglobal getMatDispMapFilename\n\t\tglobal getMatDiffuseMapFullPath\n\t\tglobal getMatSpecMapFullPath\n\t\tglobal getMatNormalMapFullPath\n\t\tglobal getMatDispMapFullPath\n\t\tglobal OutputOldParticle\n\t\tglobal OutputNewParticle\n\t\n\t\t-- particle variables\n\t\tglobal fireNeeded = false\n\n\t\tglobal emitNeeded = false\n\t\tglobal particleNeeded = false\n\t\tglobal partMaterials = #()\n\t\t\n\t\t-- instanced materials\n\t\tglobal instancedMats = #()\n\t\t\n\t\t-- leaves materials\n\t\tglobal leavesMats = #()\n\n\t\t-- terrain\n\t\tglobal base_material = \"\"\n\n\t\t-- get room name from custom property\n\t\tcustomPropNumber = fileProperties.findProperty #custom \"roomname\"\n\t\tif (customPropNumber==0) then (\n\t\t\tmessageBox \"Please click on File>File Properties and add a Custom Property called roomname with the name of the sector.\"\n\t\t\treturn 1\n\t\t)\n\t\troomName = fileProperties.getPropertyValue #custom customPropNumber \n\n\t\n\t\t-- LowerCase utility function\n\t\tfn lowercase instring = \n\t\t(\n\t\t local upper, lower, outstring\n\t\t upper=\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\t\t lower=\"abcdefghijklmnopqrstuvwxyz\" \n\t\t\n\t\t outstring=copy instring \n\t\t\n\t\t for i=1 to outstring.count do \n\t\t ( j=findString upper outstring[i] \n\t\t if (j != undefined) do outstring[i]=lower[j] \n\t\t )\n\t\n\t\t outstring\n\t\t)\n\t\n\t\t-- Tokenize utility function\n\t\tfn tokenize instring sep = \n\t\t(\n\t\t outarray = #()\n\t\t temp=copy instring\n\t\t i = 1\n\t\t while (true) do (\n\t\t \tindex = findstring temp sep\n\t\t\tif (index==undefined) then\n\t\t\t(\n\t\t\t\toutarray[i]=temp\n\t\t\t\texit\n\t\t\t) else (\n\t\t\t\toutarray[i] = substring temp 1 (index-1)\n\t\t\t\ttemp = substring temp (index+1) -1\n\t\t\t)\n\t\t\ti = i +1\n\t\t )\n\t\t outarray\n\t\t)\n\t\n\t\t-- get filename from a material\n\t\tfn getMatDiffuseMapFilename m = \n\t\t(\n\t\t if (m==undefined) then\n\t\t\t\timage=\"materialnotdefined\"\n\t\t\telse (\n\t\t\t mat = m.diffuseMap\n\t\t\t\tif (mat!=undefined) then\n\t\t\t\t(\n\t\t\t\t\timage = mat.filename\n\t\t\t\t\tindx = tokenize image \"\\\\\"\n\t\t\t\t\timage = indx[indx.count]\n\t\t\t\t) else\n\t\t\t\t\timage=\"materialnotdefined\"\n\n\t\t\t\timage = lowercase(image)\n\t\t\t)\n\t\t)\n\n fn getMatSpecMapFilename m = \n\t\t(\n\t\t if (m==undefined) then\n\t\t\t\timage=\"materialnotdefined\"\n\t\t\telse (\n\t\t\t mat = m.specularMap\n\t\t\t\tif (mat!=undefined) then\n\t\t\t\t(\n\t\t\t\t\timage = mat.filename\n\t\t\t\t\tindx = tokenize image \"\\\\\"\n\t\t\t\t\timage = indx[indx.count]\n\t\t\t\t) else\n\t\t\t\t\timage=\"materialnotdefined\"\n\n\t\t\t\timage = lowercase(image)\n\t\t\t)\n\t\t)\n\t\t\n\t\tfn getMatNormalMapFilename m = \n\t\t(\n\t\t if (m==undefined) then\n\t\t\t\timage=\"materialnotdefined\"\n\t\t\telse (\n\t\t\t mat = m.bumpMap\n\t\t\t\tif (mat!=undefined) then\n\t\t\t\t(\n\t\t\t\t\timage = mat.filename\n\t\t\t\t\tindx = tokenize image \"\\\\\"\n\t\t\t\t\timage = indx[indx.count]\n\t\t\t\t) else\n\t\t\t\t\timage=\"materialnotdefined\"\n\n\t\t\t\timage = lowercase(image)\n\t\t\t)\n\t\t)\n\t\t\n\t fn getMatDispMapFilename m = \n\t\t(\n\t\t if (m==undefined) then\n\t\t\t\timage=\"materialnotdefined\"\n\t\t\telse (\n\t\t\t mat = m.displacementMap\n\t\t\t\tif (mat!=undefined) then\n\t\t\t\t(\n\t\t\t\t\timage = mat.filename\n\t\t\t\t\tindx = tokenize image \"\\\\\"\n\t\t\t\t\timage = indx[indx.count]\n\t\t\t\t) else\n\t\t\t\t\timage=\"materialnotdefined\"\n\n\t\t\t\timage = lowercase(image)\n\t\t\t)\n\t\t)\n\t\n\t\t-- get fullpath of materials\n\t\tfn getMatDiffuseMapFullPath m = \n\t\t(\n\t\t if (m==undefined) then\n\t\t\t\timage=\"materialnotdefined\"\n\t\t\telse (\n\t\t\t mat = m.diffuseMap\n\t\t\t\tif (mat!=undefined) then\n\t\t\t\t(\n\t\t\t\t\timage = mat.filename\n\t\t\t\t) else\n\t\t\t\t\timage=\"materialnotdefined\"\n\t\t\t image = lowercase(image)\n\t\t\t)\n\t\t)\n\n\t\tfn getMatSpecMapFullPath m = \n\t\t(\n\t\t if (m==undefined) then\n\t\t\t\timage=\"materialnotdefined\"\n\t\t\telse (\n\t\t\t mat = m.specularMap\n\t\t\t\tif (mat!=undefined) then\n\t\t\t\t(\n\t\t\t\t\timage = mat.filename\n\t\t\t\t) else\n\t\t\t\t\timage=\"materialnotdefined\"\n\t\t\t image = lowercase(image)\n\t\t\t)\n\t\t)\n\t\t\n\t\tfn getMatNormalMapFullPath m = \n\t\t(\n\t\t if (m==undefined) then\n\t\t\t\timage=\"materialnotdefined\"\n\t\t\telse (\n\t\t\t mat = m.bumpMap\n\t\t\t\tif (mat!=undefined) then\n\t\t\t\t(\n\t\t\t\t\timage = mat.normal_map.filename\n\t\t\t\t) else\n\t\t\t\t\timage=\"materialnotdefined\"\n\t\t\t image = lowercase(image)\n\t\t\t)\n\t\t)\n\t\t\n\t\tfn getMatDispMapFullPath m = \n\t\t(\n\t\t if (m==undefined) then\n\t\t\t\timage=\"materialnotdefined\"\n\t\t\telse (\n\t\t\t mat = m.displacementMap\n\t\t\t\tif (mat!=undefined) then\n\t\t\t\t(\n\t\t\t\t\timage = mat.filename\n\t\t\t\t) else\n\t\t\t\t\timage=\"materialnotdefined\"\n\t\t\t image = lowercase(image)\n\t\t\t)\n\t\t)\n\t\n\t\t-- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\t\t-- Write material function\n\t\t-- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\t\t\n\t\tfn WriteMaterials terrainobject outFile =\n\t\t(\n\t\t\n\t\t --\/\/\/ TEXTURES\n\t\t \n\t\t materialsWrittenToWorld=#()\n\t\t\n\t\t format \" \\n\" to:outFile\n\t\n\t\t for m in sceneMaterials do\n\t\t (\n\t\t -- handle Standardmaterials\n\t\t\tif ((classOf m)==Standardmaterial) then\n (\n\t\t\t -- For each material, if not written then add it.\t\t\t\t\n\t\t\t -- Diffuse Texture:\n\t\t\t diffuseImage = getMatDiffuseMapFilename m\t\t\t\n\t\t\t if (not m.mapEnables[10] and findItem materialsWrittenToWorld diffuseImage==0 and diffuseImage!=\"materialnotdefined\") then\n\t\t\t (\n\t\t\t format \"m: % \\n\" m\n\t\t\t\tformat \" \\n\" diffuseImage to:outFile\n\t\t\t\tformat \" %<\/file>\\n\" diffuseImage to:outFile\n\t\t\t\t-- handles transparent materials\t\t\t\t\t\n\t\t\t\tif (m.mapEnables[7]) then\n\t\t\t\t(\n\t\t\t\t format \" \\n\" to:outFile\n\t\t\t\t format \" \\n\" to:outFile\n\t\t\t\t format \" <\/alpha>\\n\" to:outFile\n\t\t\t\t)\n\t\t\t\tformat \" <\/texture>\\n\" to:outFile\n \n\t\t\t\tappend materialsWrittenToWorld diffuseImage\n\t\t\t )\n\n -- Reflection\/Environment Map Texture:\n if (m.mapEnables[10]) then\n (\n\t\t\t reflectionMap = m.reflectionMap\n\t\t\t\tif (reflectionMap!=undefined) then\n\t\t\t\t(\n if(classof reflectionMap == CompositeTexturemap) then\n (\n\t\t\t\t\t\tformat \" \\n\" m.name to:outFile\n\t\t\t \t\t\tformat \" crystalspace.texture.loader.cubemap<\/type>\\n\" to:outFile\n\t\t\t \t\t\tformat \" \\n\" to:outFile\n\n\t\t\t\t\t\tif(reflectionMap.mapList.count == 6) then\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tindx = tokenize reflectionMap.mapList[1].filename \"\\\\\"\n\t\t\t\t\t\t\tformat \" %<\/north>\\n\" indx[indx.count] to:outFile\n\n\t\t\t\t\t\t\tindx = tokenize reflectionMap.mapList[2].filename \"\\\\\"\n \t\t\t\t\t\tformat \" %<\/south>\\n\" indx[indx.count] to:outFile\n\n\t\t\t\t\t\t\tindx = tokenize reflectionMap.mapList[3].filename \"\\\\\"\n \t\t\t\t\t\t\tformat \" %<\/east>\\n\" indx[indx.count] to:outFile\n\n\t\t\t\t\t\t\tindx = tokenize reflectionMap.mapList[4].filename \"\\\\\"\n \t\t\t\t\t\t\tformat \" %<\/west>\\n\" indx[indx.count] to:outFile\n\n\t\t\t\t\t\t\tindx = tokenize reflectionMap.mapList[5].filename \"\\\\\"\n \t\t\t\t\t\tformat \" %<\/top>\\n\" indx[indx.count] to:outFile\n\n\t\t\t\t\t\t\tindx = tokenize reflectionMap.mapList[6].filename \"\\\\\"\n \t\t\t\t\t\tformat \" %<\/bottom>\\n\" indx[indx.count] to:outFile\n\t\t\t\t\t\t)\n\t\t\t\t\t\telse\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tmessage = \"ERROR: Reflection map must have six bitmaps.\"\n\t\t\t\t\t\t\tmessageBox message\n\t\t\t\t\t\t\treturn 1\n\t\t\t\t\t\t)\n\n\t\t\t \t\t\tformat \" <\/params>\\n\" to:outFile\n\t\t\t\t\t\tformat \" <\/texture>\\n\" to:outFile\n\t\t\t\t\t)\n else\n (\n indx = tokenize reflectionMap.filename \"\\\\\" \n \t\tformat \" \\n\" indx[indx.count] to:outFile\n\t\t\t\t\t\t\tformat \" %<\/file>\\n\" indx[indx.count] to:outFile\n\t\t\t\t\t\t\tformat \" <\/texture>\\n\" to:outFile\n\t\t\t\t\t\t\tappend materialsWrittenToWorld indx[indx.count]\n )\n\t\t\t\t)\n\n\t\t\t\t-- Normal Map Texture:\n\t\t\t \tnormalMapImage = getMatNormalMapFilename m\n\t\t\t \tif (findItem materialsWrittenToWorld normalMapImage==0 and normalMapImage!=\"materialnotdefined\") then\n\t\t\t \t(\n\t\t\t \t format \"m: % \\n\" m\n\t\t\t \t format \" \\n\" normalMapImage to:outFile\n\t\t\t \t format \" %<\/file>\\n\" normalMapImage to:outFile\n\t\t\t \t format \" normalmap<\/class>\\n\" to:outFile\n\t\t\t\t format \" no<\/mipmap>\\n\" to:outFile\n\t\t\t \t format \" <\/texture>\\n\" to:outFile\n\t\t\t\t\t\t\n\t\t\t\t append materialsWrittenToWorld normalMapImage\n\t\t\t\t)\n\n )\n\t\t\t else\n\t\t\t (\n\t\t\t \t-- Spec Map Texture:\n\t\t\t \tspecMapImage = getMatSpecMapFilename m\n\t\t\t \tif (findItem materialsWrittenToWorld specMapImage==0 and specMapImage!=\"materialnotdefined\") then\n\t\t\t \t(\n\t\t\t\t\t format \"m: % \\n\" m\n\t\t\t\t\t\tformat \" \\n\" specMapImage to:outFile\n\t\t\t\t\t\tformat \" %<\/file>\\n\" specMapImage to:outFile\n\t\t\t\t\t\tformat \" <\/texture>\\n\" to:outFile\n\t\t\t\t\t\n\t\t\t\t\tappend materialsWrittenToWorld dispMapImage\n\t\t\t \t)\n\t\t\t \t-- Normal Map Texture:\n\t\t\t \tnormalMapImage = getMatNormalMapFilename m\n\t\t\t \tif (findItem materialsWrittenToWorld normalMapImage==0 and normalMapImage!=\"materialnotdefined\") then\n\t\t\t \t(\n\t\t\t \t format \"m: % \\n\" m\n\t\t\t \t format \" \\n\" normalMapImage to:outFile\n\t\t\t \t format \" %<\/file>\\n\" normalMapImage to:outFile\n\t\t\t \t format \" normalmap<\/class>\\n\" to:outFile\n\t\t\t \t format \" <\/texture>\\n\" to:outFile\n\t\t\t\t\t\t\n\t\t\t\t append materialsWrittenToWorld normalMapImage\n\t\t\t\t )\n\t\t\t\t -- Displacement Map Texture:\n\t\t\t\t dispMapImage = getMatDispMapFilename m\n\t\t\t\t if (findItem materialsWrittenToWorld dispMapImage==0 and dispMapImage!=\"materialnotdefined\") then\n\t\t\t\t (\n\t\t\t\t format \"m: % \\n\" m\n\t\t\t\t\tformat \" \\n\" dispMapImage to:outFile\n\t\t\t\t\tformat \" %<\/file>\\n\" dispMapImage to:outFile\n\t\t\t\t\tformat \" <\/texture>\\n\" to:outFile\n\t\t\t\t\t\t\n\t\t\t\t\tappend materialsWrittenToWorld dispMapImage\n\t\t\t\t )\n\t\t\t )\n\t\t\t)\n\t\n\t\t -- handle Multi\/materials\n\t\t\tif ((classOf m)==Multimaterial) then\n (\n\t\t\t\tfor subm in m do\n (\n\t\t\t\t -- For each material, if not written then add it.\t\t\t\t\n\t\t\t\t -- Diffuse Texture:\n\t\t\t\t diffuseImage = getMatDiffuseMapFilename subm\t\t\t\t\n\t\t\t\t if (not subm.mapEnables[10] and findItem materialsWrittenToWorld diffuseImage==0 and diffuseImage!=\"materialnotdefined\") then\n\t\t\t\t (\n\t\t\t\t format \"m: % \\n\" m\n\t\t\t\t\tformat \" \\n\" diffuseImage to:outFile\n\t\t\t\t\tformat \" %<\/file>\\n\" diffuseImage to:outFile\n\t\t\t\t\t-- handles transparent materials\t\t\t\t\t\n\t\t\t\t\tif (subm.mapEnables[7]) then\n\t\t\t\t\t(\n\t\t\t\t\t format \" \\n\" to:outFile\n\t\t\t\t\t format \" \\n\" to:outFile\n\t\t\t\t\t format \" <\/alpha>\\n\" to:outFile\n\t\t\t\t\t)\n\t\t\t\t\tformat \" <\/texture>\\n\" to:outFile\n \t \n\t\t\t\t\tappend materialsWrittenToWorld diffuseImage\n\t\t\t\t )\n\n\t\t\t\t -- Reflection\/Environment Map Texture:\n \t if (subm.mapEnables[10]) then\n \t (\n\t\t\t \treflectionMap = subm.reflectionMap\n\t\t\t\t\tif (reflectionMap!=undefined) then\n\t\t\t\t\t(\n \tif(classof reflectionMap == CompositeTexturemap) then\n \t(\n\t\t\t\t\t\t\tformat \" \\n\" subm.name to:outFile\n\t\t\t \t\t\t\tformat \" crystalspace.texture.loader.cubemap<\/type>\\n\" to:outFile\n\t\t\t \t\t\t\tformat \" \\n\" to:outFile\n\t\n\t\t\t\t\t\t\tif(reflectionMap.mapList.count == 6) then\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tindx = tokenize reflectionMap.mapList[1].filename \"\\\\\"\n\t\t\t\t\t\t\t\tformat \" %<\/north>\\n\" indx[indx.count] to:outFile\n\t\n\t\t\t\t\t\t\t\tindx = tokenize reflectionMap.mapList[2].filename \"\\\\\"\n\t \t\t\t\t\t\tformat \" %<\/south>\\n\" indx[indx.count] to:outFile\n\t\n\t\t\t\t\t\t\t\tindx = tokenize reflectionMap.mapList[3].filename \"\\\\\"\n\t \t\t\t\t\t\t\tformat \" %<\/east>\\n\" indx[indx.count] to:outFile\n\t\n\t\t\t\t\t\t\t\tindx = tokenize reflectionMap.mapList[4].filename \"\\\\\"\n\t \t\t\t\t\t\t\tformat \" %<\/west>\\n\" indx[indx.count] to:outFile\n\t\n\t\t\t\t\t\t\t\tindx = tokenize reflectionMap.mapList[5].filename \"\\\\\"\n\t \t\t\t\t\t\tformat \" %<\/top>\\n\" indx[indx.count] to:outFile\n\t\n\t\t\t\t\t\t\t\tindx = tokenize reflectionMap.mapList[6].filename \"\\\\\"\n\t \t\t\t\t\t\tformat \" %<\/bottom>\\n\" indx[indx.count] to:outFile\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tmessage = \"ERROR: Reflection map must have six bitmaps.\"\n\t\t\t\t\t\t\t\tmessageBox message\n\t\t\t\t\t\t\t\treturn 1\n\t\t\t\t\t\t\t)\n\t\n\t\t\t\t \t\t\tformat \" <\/params>\\n\" to:outFile\n\t\t\t\t\t\t\tformat \" <\/texture>\\n\" to:outFile\n\t\t\t\t\t\t)\n\t else\n\t (\n indx = tokenize reflectionMap.filename \"\\\\\" \n \t\tformat \" \\n\" indx[indx.count] to:outFile\n\t\t\t\t\t\t\tformat \" %<\/file>\\n\" indx[indx.count] to:outFile\n\t\t\t\t\t\t\tformat \" <\/texture>\\n\" to:outFile\n append materialsWrittenToWorld indx[indx.count]\n \t )\n\t\t\t\t\t)\n\n\t\t\t\t\t-- Normal Map Texture:\n\t\t\t\t \tnormalMapImage = getMatNormalMapFilename subm\n\t\t\t\t \tif (findItem materialsWrittenToWorld normalMapImage==0 and normalMapImage!=\"materialnotdefined\") then\n\t\t\t\t \t(\n\t\t\t\t \t format \"m: % \\n\" subm\n\t\t\t\t \t format \" \\n\" normalMapImage to:outFile\n\t\t\t\t \t format \" %<\/file>\\n\" normalMapImage to:outFile\n\t\t\t\t \t format \" normalmap<\/class>\\n\" to:outFile\n\t\t\t\t\t format \" no<\/mipmap>\\n\" to:outFile\n\t\t\t\t \t format \" <\/texture>\\n\" to:outFile\n\t\t\t\t\t\t\t\n\t\t\t\t\t append materialsWrittenToWorld normalMapImage\n\t\t\t\t\t)\n \t )\n\t\t\t \t else\n\t\t\t \t (\n\t\t\t \t \t-- Spec Map Texture:\n\t\t\t \t \tspecMapImage = getMatSpecMapFilename subm\n\t\t\t \t \tif (findItem materialsWrittenToWorld specMapImage==0 and specMapImage!=\"materialnotdefined\") then\n\t\t\t \t \t(\n\t\t\t\t\t\t format \"m: % \\n\" subm\n\t\t\t\t\t\t\tformat \" \\n\" specMapImage to:outFile\n\t\t\t\t\t\t\tformat \" %<\/file>\\n\" specMapImage to:outFile\n\t\t\t\t\t\t\tformat \" <\/texture>\\n\" to:outFile\n\t\t\t\t\t\t\n\t\t\t\t\t\tappend materialsWrittenToWorld dispMapImage\n\t\t\t\t \t)\n\t\t\t\t \t-- Normal Map Texture:\n\t\t\t\t \tnormalMapImage = getMatNormalMapFilename subm\n\t\t\t\t \tif (findItem materialsWrittenToWorld normalMapImage==0 and normalMapImage!=\"materialnotdefined\") then\n\t\t\t\t \t(\n\t\t\t\t \t format \"m: % \\n\" subm\n\t\t\t\t \t format \" \\n\" normalMapImage to:outFile\n\t\t\t \t\t format \" %<\/file>\\n\" normalMapImage to:outFile\n\t\t\t \t\t format \" normalmap<\/class>\\n\" to:outFile\n\t\t\t \t\t format \" <\/texture>\\n\" to:outFile\n\t\t\t\t\t\t\t\n\t\t\t\t\t append materialsWrittenToWorld normalMapImage\n\t\t\t\t\t )\n\t\t\t\t\t -- Displacement Map Texture:\n\t\t\t\t\t dispMapImage = getMatDispMapFilename subm\n\t\t\t\t\t if (findItem materialsWrittenToWorld dispMapImage==0 and dispMapImage!=\"materialnotdefined\") then\n\t\t\t\t\t (\n\t\t\t\t\t format \"m: % \\n\" subm\n\t\t\t\t\t\tformat \" \\n\" dispMapImage to:outFile\n\t\t\t\t\t\tformat \" %<\/file>\\n\" dispMapImage to:outFile\n\t\t\t\t\t\tformat \" <\/texture>\\n\" to:outFile\n\t\t\t\t\t\t\t\n\t\t\t\t\t\tappend materialsWrittenToWorld dispMapImage\n\t\t\t\t\t )\n\t\t\t\t \t)\n\t\t\t )\n\t\t\t)\n\t\t\n\t\t )\n\t\t\n\t\t if (fireNeeded or emitNeeded) then (\n\t\t\t format \" \\n raindrop.png<\/file>\\n <\/texture>\\n\" to:outFile \n\t\t )\n\t\n\t\t -- handle additional textures for particles \n\t\t for m in partMaterials do\n\t\t (\n\t\t\t format \" \\n %<\/file>\\n <\/texture>\\n\" m m to:outFile\n\t\t )\n\n\n\t\t format \" <\/textures>\\n\" to:outFile\n\t\n\t\n\t\t --\/\/\/ MATERIALS\n\t\t\n\t\t materialsWrittenToWorld=#()\n\t\t\n\t\t format \" \\n\" to:outFile\n\t\t\n\t\t for m in sceneMaterials do\n\t\t (\n\t\t -- handle Standardmaterials\n\t\t\tif ((classOf m)==Standardmaterial) then\n (\n\t\t\t\t-- if material not written, add it\n\t\t\t\tdiffuseMapImage = getMatDiffuseMapFilename m\n\t\t\t\tif (findItem materialsWrittenToWorld diffuseMapImage==0) then\n (\n if(diffuseMapImage!=\"materialnotdefined\") then\n\t\t\t\t\t(\n \t\tformat \" \\n\" diffuseMapImage to:outFile\n\t\t\t\t\t)\n\t\t\t\t\telse if(m.mapEnables[10]) then\n\t\t\t\t\t(\n\t\t\t\t\t\tformat \" \\n\" m.name to:outFile\n\t\t\t\t\t)\n\t\t\t\t\telse\n\t\t\t\t\t(\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t)\n\t\t\t\t\t\n\t\t\t\t\t-- Find if it's an instanced mat\n\t\t\t\t\tlocal instancedMat = false\n\t\t\t\t\tif(findItem instancedMats m!=0) then\n\t\t\t\t\t(\n\t\t\t\t\t\tinstancedMat = true\n\t\t\t\t\t)\n\t\t\t\t\t\n\t\t\t\t\t-- Find if it's a leaves mat\n\t\t\t\t\tlocal leavesMat = false\n\t\t\t\t\tif(findItem leavesMats m!=0) then\n\t\t\t\t\t(\n\t\t\t\t\t\tleavesMat = true\n\t\t\t\t\t)\n\n\t\t\t\t\t-- handles transparent materials\n\t\t\t\t\tif (m.mapEnables[7]) then\n\t\t\t\t\t(\n\t\t\t\t\t\tformat \" *null<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\n\t\t\t\t\t if (leavesMat) then\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tformat \" foliage_tree_leaves<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\tformat \" foliage_tree_leaves<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t)\n\t\t\t\t\t\telse if (instancedMat) then\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tformat \" lighting_default_instance_binalpha<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\tformat \" lighting_default_instance_binalpha<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t)\n\t\t\t\t\t\telse\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tformat \" lighting_default_binalpha<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\tformat \" lighting_default_binalpha<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\telse\n\t\t\t\t\t(\n\t\t\t if (leavesMat) then\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tformat \" foliage_tree_leaves<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\tformat \" foliage_tree_leaves<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t)\n\t\t\t\t\t\telse if (instancedMat) then\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tformat \" lighting_default_instance<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\tformat \" lighting_default_instance<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\n\t\t\t\t\t-- handles reflection materials\n\t\t\t\t\tnormalMapImage = getMatNormalMapFilename m\n\t\t\t\t\tif (m.mapEnables[10]) then\n (\n\t\t\t\t\t\tformat \" reflect_water_plane<\/shader>\\n\" to:outFile\n\t\t\t\t\t\tformat \" reflect_water_plane<\/shader>\\n\" to:outFile\n\n\t\t\t\t\t\tif(normalMapImage!=\"materialnotdefined\") then\n (\n\t\t\t\t\t\t\tformat \" %<\/shadervar>\\n\" normalMapImage to:outFile\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\treflectionMap = m.reflectionMap\n\t\t\t\t\t\tif (reflectionMap!=undefined) then\n (\n\t\t\t\t\t\t\tif(classof reflectionMap == CompositeTexturemap) then\n \t\t(\n\t\t\t\t\t\t\t\tformat \" reflection_%<\/shadervar>\\n\" m.name to:outFile\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tindx = tokenize reflectionMap.filename \"\\\\\"\n\t\t\t\t\t\t\t\tformat \" %<\/shadervar>\\n\" indx[indx.count] to:outFile\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n else\n (\n \t-- handles diffuse maps\n \tformat \" %<\/shadervar>\\n\" diffuseMapImage to:outFile\n\n \t-- handles normal maps\n \tif(normalMapImage!=\"materialnotdefined\") then\n \t(\n \t format \" %<\/shadervar>\\n\" normalMapImage to:outFile\n \t)\n\n \t-- handles displacement(height) maps\n \tdispMapImage = getMatDispMapFilename m\n \tif(dispMapImage!=\"materialnotdefined\") then\n \t(\n \t format \" %<\/shadervar>\\n\" dispMapImage to:outFile\n \t)\n\n \t-- handles specular maps\n \tspecMapImage = getMatSpecMapFilename m\n \tif(specMapImage!=\"materialnotdefined\") then\n \t(\n \t format \" %<\/shadervar>\\n\" specMapImage to:outFile\n \t)\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\tformat \" 0,0,0<\/shadervar>\\n\" to:outFile\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t)\n \n format \" <\/material>\\n\" to:outFile\n\n\t\t\t\t\tif(diffuseMapImage!=\"materialnotdefined\") then\n\t\t\t\t\t(\n\t\t\t\t\t\tappend materialsWrittenToWorld diffuseMapImage\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\n\t\t -- handle Multi\/materials\n\t\t\tif ((classOf m)==Multimaterial) then (\n\t\t\t\tfor subm in m do (\n\t\t\t\t\tdiffuseMapImage = getMatDiffuseMapFilename subm\n\t\t\t\t\tisshader = false\n\n\t\t\t\t\t-- skip wrong materials\n\t\t\t\t\tif ( diffuseMapImage==\"materialnotdefined\" and not subm.mapEnables[10]) then\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\t-- determine if it's a shader material\n\t\t\t\t\tif (findString subm.name \"_shader_\"!=undefined) then\n\t\t\t\t\t\tisshader = true\n\n\t\t\t\t\t-- check if already written\n\t\t\t\t\tfound = false\n\t\t\t\t\timagetemp = diffuseMapImage\n\t\t\t\t\tif (isshader) then (\n\t\t\t\t\t\timagetemp = diffuseMapImage + \"sshhaaddeerr\"\n\t\t\t\t\t\tif(findItem materialsWrittenToWorld imagetemp!=0) then\n\t\t\t\t\t\t\tfound=true\n\t\t\t\t\t) else (\n\t\t\t\t\t\tif(findItem materialsWrittenToWorld diffuseMapImage!=0) then\n\t\t\t\t\t\t\tfound=true\n\t\t\t\t\t)\n\t\t\t\t\t\n\t\t\t\t\tif (not found) then\n (\n \t \t if(diffuseMapImage!=\"materialnotdefined\") then\n\t\t\t\t\t\t(\n \t\t\tformat \" \\n\" imagetemp to:outFile\n\t\t\t\t\t\t)\n\t\t\t\t\t\telse if(subm.mapEnables[10]) then\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tformat \" \\n\" subm.name to:outFile\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\n\t\t\t\t\t\t-- Find if it's an instanced mat\n\t\t\t\t\t\tlocal instancedMat = false\n\t\t\t\t\t\tif(findItem instancedMats subm!=0) then\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tinstancedMat = true\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\n\t\t\t\t\t\t-- Find if it's a leaves mat\n\t\t\t\t\t\tlocal leavesMat = false\n\t\t\t\t\t\tif(findItem leavesMats subm!=0) then\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tleavesMat = true\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\t-- handles transparent materials\n\t\t\t\t\t\tif (subm.mapEnables[7]) then\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tformat \" *null<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (leavesMat) then\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tformat \" foliage_tree_leaves<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\t\tformat \" foliage_tree_leaves<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\telse if (instancedMat) then\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tformat \" lighting_default_instance_binalpha<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\t\tformat \" lighting_default_instance_binalpha<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tformat \" lighting_default_binalpha<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\t\tformat \" lighting_default_binalpha<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t\telse\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tif (leavesMat) then\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tformat \" foliage_tree_leaves<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\t\tformat \" foliage_tree_leaves<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\telse if (instancedMat) then\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tformat \" lighting_default_instance<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\t\tformat \" lighting_default_instance<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\t-- manage shaders\n\t\t\t\t\t\tif (findString subm.name \"_shader_\" != undefined) then (\n\t\t\t\t\t\t\tif (findString subm.name \"_shader_terrain\" !=undefined) then (\n\t\t\t\t\t\t\t\tformat \" terrain_fixed_splatting<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\t\tformat \" 32,32<\/shadervar>\\n\" to:outFile\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\telse if (findString subm.name \"_shader_ambient\" !=undefined) then (\n\t\t\t\t\t\t\t\tformat \" terrain_fixed_base<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\t\tbase_material = imagetemp\n\t\t\t\t\t\t\t) else (\n\t\t\t\t\t\t\t\tmessage = \"ERROR: Found terrain's material \"+m.name+\" with submat \"+subm.name+\" defining a shader of unsupported type!\\n\"\n\t\t\t\t\t\t\t\tmessage = message + \"Supported types are: _shader_terrain , _shader_ambient\"\n\t\t\t\t\t\t\t\tmessageBox message\n\t\t\t\t\t\t\t\tformat \" <\/material>\\n\" to:outFile\n\t\t\t\t\t\t\t\treturn 1\n\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t) else if(imagetemp!=\"materialnotdefined\") then\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tappend materialsWrittenToWorld imagetemp\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\t-- handles reflection materials\n\t\t\t\t\t\tnormalMapImage = getMatNormalMapFilename subm\n\t\t\t\t\t\tif (subm.mapEnables[10]) then\n \t(\n\t\t\t\t\t\t\tformat \" reflect_water_plane<\/shader>\\n\" to:outFile\n\t\t\t\t\t\t\tformat \" reflect_water_plane<\/shader>\\n\" to:outFile\n\n\t\t\t\t\t\t\tif(normalMapImage!=\"materialnotdefined\") then\n \t\t(\n\t\t\t\t\t\t\t\tformat \" %<\/shadervar>\\n\" normalMapImage to:outFile\n\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\treflectionMap = subm.reflectionMap\n\t\t\t\t\t\t\tif (reflectionMap!=undefined) then\n \t(\n\t\t\t\t\t\t\t\tif(classof reflectionMap == CompositeTexturemap) then\n \t\t\t(\n\t\t\t\t\t\t\t\t\tformat \" reflection_%<\/shadervar>\\n\" subm.name to:outFile\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\tindx = tokenize reflectionMap.filename \"\\\\\"\n\t\t\t\t\t\t\t\t\tformat \" %<\/shadervar>\\n\" indx[indx.count] to:outFile\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n \telse\n \t(\n \t\t-- handles diffuse maps\n \t\tformat \" %<\/shadervar>\\n\" diffuseMapImage to:outFile\n\n \t\t-- handles normal maps\n \t\tif(normalMapImage!=\"materialnotdefined\") then\n \t\t(\n \t\t format \" %<\/shadervar>\\n\" normalMapImage to:outFile\n \t\t)\n\n \t\t-- handles displacement(height) maps\n \t\tdispMapImage = getMatDispMapFilename subm\n \t\tif(dispMapImage!=\"materialnotdefined\") then\n \t\t(\n \t\t format \" %<\/shadervar>\\n\" dispMapImage to:outFile\n \t\t)\n\n \t\t-- handles specular maps\n \t\tspecMapImage = getMatSpecMapFilename subm\n \t\tif(specMapImage!=\"materialnotdefined\") then\n \t\t(\n \t\t format \" %<\/shadervar>\\n\" specMapImage to:outFile\n \t\t)\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\tformat \" 0,0,0<\/shadervar>\\n\" to:outFile\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\tformat \" <\/material>\\n\" to:outFile\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t )\n\n\t\n\t\t if (fireNeeded or emitNeeded) then (\n\t\t\t format \" \\n\" to:outFile\n format \" raindrop<\/shadervar>\\n\" to:outFile\n format \" <\/material>\\n\" to:outFile\n\t\t )\n\t\n\t\t -- handle additional materials for particles\n\t\t for m in partMaterials do\n\t\t (\n\t\t format \" \\n\" m to:outFile\n\t\t\tformat \" *null<\/shader>\\n\" to:outFile\n format \" particles_basic<\/shader>\\n\" to:outFile\n\t\t\tformat \" particles_basic<\/shader>\\n\" to:outFile\n format \" %<\/shadervar>\\n\" m to:outFile\n\t\t\tformat \" <\/material>\\n\" to:outFile\n\t\t )\n\n\t\t format \" <\/materials>\\n\\n\" to:outFile\n\t\t\n\t\t)\n\n\t\t-- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\t\t-- Write shaders function\n\t\t-- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\t\t\n\t\tfn WriteShaders outFile =\n\t\t(\n\t\t format \"\\n\" to:outFile\n\n -- always write shader for alpha binary\n\t\t format \" \/shader\/lighting\/lighting_default_binalpha.xml<\/file><\/shader>\\n\" to:outFile\n\t\t\t\n\t\t\t-- instancing shaders\n\t\t\tformat \" \/shader\/lighting\/lighting_default_instance.xml<\/file><\/shader>\\n\" to:outFile\n\t\t\tformat \" \/shader\/lighting\/lighting_default_instance_binalpha.xml<\/file><\/shader>\\n\" to:outFile\n\t\t\t\n\t\t\t-- leaves shader\n\t\t\tformat \" \/shader\/foliage\/tree_leaves.xml<\/file><\/shader>\\n\" to:outFile\n\n\t\t -- shader for reflection\n format \" \/shader\/reflect\/water_plane.xml<\/file><\/shader>\\n\" to:outFile\n\n\t\t -- add shaders for particles\n\t\t format \" \/shader\/particles\/basic.xml<\/file><\/shader>\\n\" to:outFile\n\t\t format \" \/shader\/particles\/soft-alpha.xml<\/file><\/shader>\\n\" to:outFile\n\n\t\t -- add shaders needed for terrain\n\t\t if (chkTerrain.checked) then (\n\t\t filestr = openFile \"ps_terrain.shaders.txt\"\n\t\t if (filestr==undefined) then (\n\t\t\t\tmessage = \"ERROR: ps_terrain.shaders.txt not found!\"\n\t\t\t\tmessageBox message\n\t\t\t\treturn 1\n\t\t )\n\t\t while (not eof filestr) do\n\t\t (\n\t\t \tline = readLine filestr\n\t\t\tformat \"%\\n\" line to:outFile\n\t\t )\n\t\t )\n\n\t\t format \"<\/shaders>\\n\" to:outFile\n\t\t)\n\t\t\n\n\t\t-- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\t\t-- Output Particles function\n\t\t-- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\t\tfn OutputParticle obj allObjects meshfact outFile =\n\t\t(\n\t\t\t\ttype = getUserProp obj \"TYPE\"\n\t\t\t\tformat \"Exporting Particle: % % % % \\n\" obj.name meshfact type allObjects \n\t\t\t\tif ( type == \"hidden\") then\n\t\t\t\t\tcontinue;\n\t\t\t\telse if ( type == \"fire\" or type == \"emit\" ) then (\n\t\t\t\t if (not meshfact) then \n\t\t\t\t\t\tOutputOldParticle obj allObjects outFile\n\t\t\t\t) else\n\t\t\t\t\tOutputNewParticle obj allObjects meshfact outFile\n\t\t)\n\n\n\t\t-- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\t\t-- Output New Particles function\n\t\t-- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\t\tfn OutputNewParticle obj allObjects meshfact outFile =\n\t\t(\n\t\t format \"Exporting New Particle: % \\n\" obj.name\n\t\t\t\ttype = getUserProp obj \"TYPE\"\n\t\t\t\tpartMaterial = getUserProp obj \"MATERIAL\"\n\t\t\t\tmixmode = getUserProp obj \"MIXMODE\"\n\t\t\t\tif (mixmode==undefined) then (\n\t\t\t\t\tmixmode = \"add\"\n\t\t\t\t)\n\t\n\t\t\t\txpart = (obj.pos.x * xscale) + xrelocate\n\t\t\t\typart = (obj.pos.y * yscale) + yrelocate\n\t\t\t\tzpart = (obj.pos.z * zscale) + zrelocate\n\n\t\t\t\trenderorientation = getUserProp obj \"RENDERORIENTATION\"\n\t\t\t\trotationmode = getUserProp obj \"ROTATION\"\n\t\t\t\tsortmode = getUserProp obj \"SORT\"\n\t\t\t\tintegrationmode = getUserProp obj \"INTEGRATION\"\n\n\t\t\t\tparticlesize = getUserProp obj \"PARTICLESIZE\"\n\t\t\t\tparticlesize2 = tokenize particlesize \",\"\n\n\t\t\t\temittype = getUserProp obj \"EMITTYPE\"\n\t\t\t\t-- sphere\n\t\t\t\temissionrate = getUserProp obj \"EMISSIONRATE\"\n\t\t\t\tradius = getUserProp obj \"RADIUS\"\n\t\t\t\tvelocity = getUserProp obj \"VELOCITY\"\n\t\t\t\tvelocity2 = tokenize velocity \",\"\n\t\t\t\tmass = getUserProp obj \"MASS\"\n\t\t\t\tmass2 = tokenize mass \",\"\n\t\t\t\tttl = getUserProp obj \"TTL\"\n\t\t\t\tttl2 = tokenize ttl \",\"\n\t\t\t\tplacement = getUserProp obj \"PLACEMENT\"\n\t\t\t\teffectorforce = getUserProp obj \"EFFECTORFORCE\"\n\t\t\t\teffectorrandacc = getUserProp obj \"EFFECTORRANDACC\"\n\n\t\t\t\tuniformvel = getUserProp obj \"UNIFORMVEL\"\n\t\t\t\tif (uniformvel==undefined) then (\n\t\t\t\t\tuniformvel = \"yes\"\n\t\t\t\t)\n\n\t\t\t\tcolors = #()\n\t\t\t\tcolor0 = getUserProp obj \"COLOR0\"\n\t\t\t\tif (color0!=undefined) then (\n\t\t\t\t\tcolor0 = tokenize color0 \",\"\n\t\t\t\t\tappend colors color0\n\t\t\t\t)\n\t\t\t\tcolor1 = getUserProp obj \"COLOR1\"\n\t\t\t\tif (color1!=undefined) then (\n\t\t\t\t\tcolor1 = tokenize color1 \",\"\n\t\t\t\t\tappend colors color1\n\t\t\t\t)\n\t\t\t\tcolor2 = getUserProp obj \"COLOR2\"\n\t\t\t\tif (color2!=undefined) then (\n\t\t\t\t\tcolor2 = tokenize color2 \",\"\n\t\t\t\t\tappend colors color2\n\t\t\t\t)\n\t\t\t\tcolor3 = getUserProp obj \"COLOR3\"\n\t\t\t\tif (color3!=undefined) then (\n\t\t\t\t\tcolor3 = tokenize color3 \",\"\n\t\t\t\t\tappend colors color3\n\t\t\t\t)\n\t\t\t\tcolor4 = getUserProp obj \"COLOR4\"\n\t\t\t\tif (color4!=undefined) then (\n\t\t\t\t\tcolor4 = tokenize color4 \",\"\n\t\t\t\t\tappend colors color4\n\t\t\t\t)\n\t\t\t\t\t\n\t\t\t\tif (type == \"particle\" and meshfact) then (\n\t\t\t\t\tformat \" \\n\" (\"fact\"+obj.name) to:outFile\n\t\t\t\t\tformat \" crystalspace.mesh.loader.factory.particles<\/plugin> \\n\" to:outFile\n\t\t\t\t\tformat \" alpha<\/priority> \\n\" to:outFile\n\t\t\t\t\tformat \" \\n\" to:outFile\n\t\t\t\t\tformat \" \\n\" to:outFile\n\t\t\t\t\tformat \" <% \/><\/mixmode> \\n\" mixmode to:outFile\n\t\t\t\t\tformat \" %<\/material> \\n\" partMaterial to:outFile\n\t\t\t\t\tformat \" %<\/renderorientation> \\n\" renderorientation to:outFile\n\t\t\t\t\tformat \" %<\/rotationmode> \\n\" rotationmode to:outFile\n\t\t\t\t\tformat \" %<\/sortmode> \\n\" sortmode to:outFile\n\t\t\t\t\tformat \" %<\/integrationmode>\\n\" integrationmode to:outFile\n\t\t\t\t\tformat \" \\n\" particlesize2[1] particlesize2[2] to:outFile\n\t\t\t\t\tformat \" yes<\/individualsize>local<\/transformmode> \\n\" to:outFile\n\n\t\t\t\t\tif (emittype==\"sphere\") then (\n\t\t\t\t\t\tformat \" \\n\" to:outFile\n\t\t\t\t\t\tformat \" %<\/radius> \\n\" radius to:outFile\n\n\t\t\t\t\t) else if (emittype==\"box\") then (\n\t\t\t\t\t\temitbox = getUserProp obj \"EMITBOX\"\n\t\t\t\t\t\temitbox = tokenize emitbox \",\"\n\t\t\t\t\t\tformat \" \\n\" to:outFile\n\t\t\t\t\t\tformat \" <\/box> \\n\" emitbox[1] emitbox[2] emitbox[3] emitbox[4] emitbox[5] emitbox[6] to:outFile\n\t\t\t\t\t) else if (emittype==\"cone\") then (\n\t\t\t\t\t\temitcone = getUserProp obj \"EMITCONE\"\n\t\t\t\t\t\temitcone = tokenize emitcone \",\"\n\t\t\t\t\t\tformat \" \\n\" to:outFile\n\t\t\t\t\t\tformat \" %<\/coneangle> \\n\" emitcone[1] emitcone[2] emitcone[3] emitcone[4] emitcone[5] emitcone[6] to:outFile\n\t\t\t\t\t)\n\n\t\t\t\t\tformat \" yes<\/enabled> \\n\" to:outFile\n\t\t\t\t\tformat \" %<\/uniformvelocity> \\n\" uniformvel to:outFile\n\t\t\t\t\tformat \" %<\/emissionrate> \\n\" emissionrate to:outFile\n\t\t\t\t\tformat \" \\n\" to:outFile\n\t\t\t\t\tformat \" \\n\" velocity2[1] velocity2[2] velocity2[3] to:outFile\n\t\t\t\t\tformat \" \\n\" mass2[1] mass2[2] to:outFile\n\t\t\t\t\tformat \" \\n\" ttl2[1] ttl2[2] to:outFile\n\t\t\t\t\tformat \" %<\/placement> \\n\" placement to:outFile\n\t\t\t\t\tformat \" <\/emitter> \\n\" to:outFile\n\n\t\t\t\t\tif (effectorrandacc!=undefined) then (\n\t\t\t\t\t effectorrandacc = tokenize effectorrandacc \",\"\n\t\t\t\t\t\tformat \" \\n\" to:outFile\n\t\t\t\t\t\tformat \" \\n\" effectorrandacc[1] effectorrandacc[2] effectorrandacc[3] to:outFile\n\t\t\t\t\t\tformat \" <\/effector> \\n\" to:outFile\n\t\t\t\t\t)\n\n\t\t\t\t\tif (effectorforce!=undefined) then (\n\t\t\t\t\t\teffectorforce = tokenize effectorforce \",\"\n\t\t\t\t\t\tformat \" \\n\" to:outFile\n\t\t\t\t\t\tformat \" \\n\" effectorforce[1] effectorforce[2] effectorforce[3] to:outFile\n\t\t\t\t\t\tformat \" <\/effector> \\n\" to:outFile\n\t\t\t\t\t)\n\t\t\t\t\t\n\t\t\t\t\tvelocity = getUserProp obj \"VELOCITYFIELD\"\n\t\t\t\t\tif (velocity!=undefined) then (\n\t\t\t\t\t\tvelocity = tokenize velocity \",\"\n\t\t\t\t\t format \" \\n\" to:outFile\n\t \tformat \" radialpoint<\/type>\\n\" velocity[1] velocity[2] velocity[3] to:outFile\n \t\tformat \" %<\/fparam>\\n\" velocity[4] to:outFile\n \t\t\tformat \" <\/effector>\\n\" to:outFile\n\t\t\t\t\t)\n\t\t\t\t\tspiral = getUserProp obj \"SPIRALFIELD\"\n\t\t\t\t\tif (spiral!=undefined) then (\n\t\t\t\t\t\tspiral = tokenize spiral \",\"\n\t\t\t\t\t format \" \\n\" to:outFile\n\t \tformat \" spiral<\/type>\\n\" spiral[1] spiral[2] spiral[3] spiral[4] spiral[5] spiral[6] to:outFile\n \t\tformat \" %<\/fparam>\\n\" spiral[7] spiral[8] spiral[9] spiral[10] to:outFile\n \t\t\tformat \" <\/effector>\\n\" to:outFile\n\t\t\t\t\t)\n\n\t\t\t\t\tformat \" \\n\" to:outFile\n\t\t\t\t\tfor color in colors do (\n\t\t\t\t\t\tformat \" \\n\" color[1] to:outFile\n\t\t\t\t\t\tformat \" \\n \" color[2] color[3] color[4] to:outFile\n\t\t\t\t\t\tformat \" \\n\" color[5] color[6] to:outFile\n\t\t\t\t\t\tformat \" \\n\" color[7] to:outFile\n\t\t\t\t\t\tformat \" <\/param> \\n\" to:outFile\n\t\t\t\t\t)\n\n\t\t\t\t\tformat \" <\/effector> \\n\" to:outFile\n\n\t\t\t\t\tformat \" <\/params> \\n\" to:outFile\n\t\t\t\t\tformat \" <\/meshfact> \\n\" to:outFile\n\t\t\t\t) else if (type == \"particle\" and not meshfact) then (\n\t\t\t\t\tformat \" \\n\" obj.name to:outFile\n\t\t\t\t format \" particles<\/plugin>\\n\" to:outFile\n\t\t\t\t format \" alpha<\/priority>\\n\" to:outFile\n\t\t\t\t format \" \\n\" to:outFile\n\t\t\t\t format \" %<\/factory>\\n\" (\"fact\"+obj.name) to:outFile\n\t\t\t\t format \" %<\/material>\\n\" partMaterial to:outFile\n\t\t\t\t format \" <\/params>\\n\" to:outFile\n\t\t\t\t format \" shadows<\/id><\/trimesh>\\n\" to:outFile\n\t\t\t\t\tformat \" \\n\" to:outFile\n\t\t\t\t format \" <\/move>\\n\" xpart zpart ypart to:outFile\n\t\t\t\t format \" <\/meshobj>\\n\" to:outFile\n\t\t\t\t)\n\n\t\t)\n\n\n\t\t-- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\t\t-- Output Old Particle function\n\t\t-- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\t\tfn OutputOldParticle obj allObjects outFile =\n\t\t(\n\t\t format \"Exporting Old Particle: % \\n\" obj.name to:outFile\n\t\t\t\ttype = getUserProp obj \"TYPE\"\n\t\t\t\tpartMaterial = getUserProp obj \"MATERIAL\"\n\t\t\t\tmixmode = getUserProp obj \"MIXMODE\"\n\t\n\t\t\t\txpart = (obj.pos.x * xscale) + xrelocate\n\t\t\t\typart = (obj.pos.y * yscale) + yrelocate\n\t\t\t\tzpart = (obj.pos.z * zscale) + zrelocate\n\t\n\t\t --format \" ;Particle Name: % Type: %\\n\" obj.name type to:outFile\n\t\n\t\t\t\t-- \/\/\/\/\/\/\n\t\t\t\t-- Fire\n\t\t\t\t-- \/\/\/\/\/\/\n\t\t\t\tif (type == \"fire\") then (\n\n\t\t\t\t\tnumber = getUserProp obj \"NUMBER\"\n\t\t\t\t\tdropsize = getUserProp obj \"DROPSIZE\"\n\t\t\t\t\tlighting = getUserProp obj \"LIGHTING\"\n\t\t\t\t\tswirl = getUserProp obj \"SWIRL\"\n\t\t\t\t\tcolorscale = getUserProp obj \"COLORSCALE\"\n\n\t\t\t\t\tformat \" \\n\" to:outFile\n\t\t\t\t\tformat \" alpha<\/priority>\\n\" to:outFile\n\t\t\t\t\tformat \" emit<\/plugin>\\n\" to:outFile\n\t\t\t\t\tformat \" \\n\" to:outFile\n\t\t\t\t\tformat \" <\/move>\\n\" to:outFile\n\t\t\t\t\tformat \" \\n\" to:outFile\n\t\t\t\t\tformat \"\t emitFact<\/factory> \\n\" to:outFile\n\t\t\t\t\tformat \"\t <\/mixmode>\\n\" to:outFile\n\n\t\t\t\t\tif (partMaterial == undefined) then\n\t\t\t\t\t\tformat \"\t candleflame.png<\/material>\\n\" to:outFile\n\t\t\t\t\telse\n\t\t\t\t\t\tformat \"\t %<\/material>\\n\" partMaterial to:outFile\t\n\n\t\t\t\t\tformat \"\t %<\/number> \\n\" number to:outFile\n\t\t\t\t\tformat \"\t \\n\" to:outFile\n\t\t\t\t\tformat \"\t off<\/lighting> \\n\" to:outFile\n\t\t\t\t\tformat \"\t 1000<\/totaltime> \\n\" to:outFile\n\t\t\t\t\tformat \"\t <\/startpos> \\n\" xpart zpart ypart to:outFile\n\t\t\t\t\tformat \"\t \\n\" to:outFile\n\t\t\t\t\tformat \"\t <\/emitbox><\/startspeed> \\n\" to:outFile\n\t\t\t\t\tformat \"\t <\/startaccel>\\n\" to:outFile\n\t\t\t\t\tformat \"\t <\/attractor> \" xpart (zpart+0.2) ypart to:outFile\n\t\t\t\t\tformat \"\t 1<\/attractorforce>\\n\" to:outFile\n\t\t\t\t\tformat \"\t