From: Mike G. <xo...@gm...> - 2007-10-31 00:47:16
|
It's the same. I don't see the difference between merging and adding in this case. On 30/10/2007, Marten Svanfeldt (dev) <dev...@sv...> wrote: > > Is this script the same as the one in the trunk? Then the addition of > it to trunk should be merged over, not the script added directly. Can > you confirm its indeed the same and if so should you or I fix it? > > -Marten > > Quoting lpa...@us...: > > > Revision: 28038 > > http://crystal.svn.sourceforge.net/crystal/?rev=28038&view=rev > > Author: lpancallo > > Date: 2007-10-29 00:59:17 -0700 (Mon, 29 Oct 2007) > > > > Log Message: > > ----------- > > Added 3dsmax exporter for genmeshes (required by lighter2) > > > > Added Paths: > > ----------- > > CS/branches/release/V1.2/scripts/max/exportCS.mcr > > > > Added: CS/branches/release/V1.2/scripts/max/exportCS.mcr > > =================================================================== > > --- CS/branches/release/V1.2/scripts/max/exportCS.mcr > > (rev 0) > > +++ CS/branches/release/V1.2/scripts/max/exportCS.mcr 2007-10-29 > > 07:59:17 UTC (rev 28038) > > @@ -0,0 +1,2760 @@ > > +------------------------------------------------------------ > > +-- Author: Luca Pancallo <pan...@ne...> > > +-- > > +-- Copyright (C) 2002 PlaneShift Team (in...@pl..., > > +-- http://www.planeshift.it) > > +-- > > +-- This program is free software; you can redistribute it and/or > > +-- modify it under the terms of the GNU General Public License > > +-- as published by the Free Software Foundation (version 2 of the > License) > > +-- This program is distributed in the hope that it will be useful, > > +-- but WITHOUT ANY WARRANTY; without even the implied warranty of > > +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > +-- GNU General Public License for more details. > > +-- You should have received a copy of the GNU General Public License > > +-- along with this program; if not, write to the Free Software > > +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA > > 02111-1307, USA. > > +-- > > +------------------------------------------------------------ > > + > > + > > +macroScript Export_CS_GenMesh > > +category:"PlaneShift" > > +internalcategory:"PlaneShift" > > +ButtonText:"Export Level CS GenMesh" > > +tooltip:"Export Level CS GenMesh" Icon:#("Maxscript",1) > > +( > > + > > +rollout Test1 "Export Level to CS GenMesh" width:226 height:450 > > +( > > + edittext edt3 "" pos:[17,32] width:192 height:21 > > + label lbl1 "Export Level To:" pos:[21,7] width:142 height:20 > > + button btn2 "Export!" pos:[37,110] width:152 height:24 > > + label lbl6 "Scale:" pos:[58,72] width:40 height:20 > > + edittext edtScale "" pos:[101,67] width:63 height:27 > > + checkbox chkLights "Generate Fake lights for walktest" pos:[6,179] > > width:215 height:20 enabled:true > > + label lbl3 "Duration (msecs):" pos:[16,207] width:108 height:20 > > + edittext edtDuration "" pos:[128,206] width:76 height:22 > > + checkbox chk2 "Copy textures to dest dir" pos:[6,152] width:210 > height:22 > > + GroupBox grp2 "Sanity Check" pos:[10,243] width:201 height:94 > > + checkbox chkSanity "Check Only, no Deletion" pos:[22,267] > > width:159 height:23 enabled:true checked:true > > + button sanity "SanityCheck!" pos:[32,297] width:145 height:31 > > + label lblVersion "V." pos:[180,5] width:40 height:21 > > + > > + groupBox grp3 "Terrain" pos:[13,348] width:189 height:89 > > + checkbox chkTerrain "Export as Terrain Level" pos:[22,372] > > width:168 height:26 > > + on Test1 open do > > + ( > > + version = 50 as String > > + lblVersion.text = "V."+version > > + > > + -- get room name from custom property > > + customPropNumber = fileProperties.findProperty #custom > "roomname" > > + if (customPropNumber==0) then ( > > + messageBox "Please click on File>File Properties > and add a > > Custom Property called roomname with the name of the sector." > > + return 1 > > + ) > > + roomName = fileProperties.getPropertyValue #custom > customPropNumber > > + > > + -- get default scale from custom property > > + customPropNumber = fileProperties.findProperty #custom > "scale" > > + if (customPropNumber==0) then ( > > + messageBox "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" > > + return 1 > > + ) > > + defaultScale = fileProperties.getPropertyValue #custom > customPropNumber > > + > > + edt3.text = > "D:\Luca\PS\gfxpackage3.4\levels\\"+roomName+"\world" > > + edtScale.text = defaultScale > > + ) > > + on btn2 pressed do > > + ( > > + > > + -- //////////////////////// > > + -- Variables used in the program > > + -- //////////////////////// > > + > > + -- get filename > > + filename = edt3.text > > + -- set debug output > > + debug=false > > + debug2=false > > + > > + -- define if the program should combine 2 planar triangles > into > > one polygon > > + polyCombine = true > > + > > + -- Define verbose output (that takes more space and > memory) > > + verboseMode = true > > + > > + -- parameters for scaling and relocation > > + global xscale = edtScale.text as Float > > + global yscale = edtScale.text as Float > > + global zscale = edtScale.text as Float > > + > > + global xrelocate = 0 > > + global yrelocate = 0 > > + global zrelocate = 0 > > + > > + -- functions declaration > > + global tokenize > > + global lowercase > > + global getMatFilename > > + global getMatFullPath > > + > > + -- particle variables > > + global fireNeeded = false > > + > > + global emitNeeded = false > > + global partMaterials = #() > > + > > + -- get room name from custom property > > + customPropNumber = fileProperties.findProperty #custom > "roomname" > > + if (customPropNumber==0) then ( > > + messageBox "Please click on File>File Properties > and add a > > Custom Property called roomname with the name of the sector." > > + return 1 > > + ) > > + roomName = fileProperties.getPropertyValue #custom > customPropNumber > > + > > + > > + -- LowerCase utility function > > + fn lowercase instring = > > + ( > > + local upper, lower, outstring > > + upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ" > > + lower="abcdefghijklmnopqrstuvwxyz" > > + > > + outstring=copy instring > > + > > + for i=1 to outstring.count do > > + ( j=findString upper outstring[i] > > + if (j != undefined) do outstring[i]=lower[j] > > + ) > > + > > + outstring > > + ) > > + > > + -- Tokenize utility function > > + fn tokenize instring sep = > > + ( > > + outarray = #() > > + temp=copy instring > > + i = 1 > > + while (true) do ( > > + index = findstring temp sep > > + if (index==undefined) then > > + ( > > + outarray[i]=temp > > + exit > > + ) else ( > > + outarray[i] = substring temp 1 (index-1) > > + temp = substring temp (index+1) -1 > > + ) > > + i = i +1 > > + ) > > + outarray > > + ) > > + > > + -- get filename from a material > > + fn getMatFilename m = > > + ( > > + if (m==undefined) then > > + image="MATERIALNOTDEFINED" > > + else ( > > + mat = m.maps[2] > > + if (mat!=undefined) then > > + ( > > + image = mat.filename > > + indx = tokenize image "\\" > > + image = indx[indx.count] > > + ) else > > + image="MATERIALNOTDEFINED" > > + > > + image = lowercase(image) > > + ) > > + ) > > + > > + -- get fullpath of a material > > + fn getMatFullPath m = > > + ( > > + if (m==undefined) then > > + image="MATERIALNOTDEFINED" > > + else ( > > + mat = m.maps[2] > > + if (mat!=undefined) then > > + ( > > + image = mat.filename > > + ) else > > + image="MATERIALNOTDEFINED" > > + image = lowercase(image) > > + ) > > + ) > > + > > + -- //////////////////////// > > + -- Write material function > > + -- //////////////////////// > > + > > + fn WriteMaterials terrainobject outFile = > > + ( > > + > > + --/// TEXTURES > > + > > + materialsWrittenToWorld=#() > > + > > + format " <textures>\n" to:outFile > > + > > + for m in sceneMaterials do > > + ( > > + -- handle Standardmaterials > > + if ((classOf m)==Standardmaterial) then ( > > + -- if material not written, add it > > + image = getMatFilename m > > + if (findItem materialsWrittenToWorld > image==0 and > > image!="MATERIALNOTDEFINED") then ( > > + format "m: % \n" m > > + -- handles trasparent materials > > + if (m.mapEnables[7]) then > > + format " <texture > name=\"%\"> > > <file>%</file><alpha><binary/></alpha></texture>\n" image image > > to:outFile > > + else > > + format " <texture > name=\"%\"> <file>%</file></texture>\n" > > image image to:outFile > > + > > + append materialsWrittenToWorld > image > > + ) > > + ) > > + > > + -- handle Multi/materials > > + if ((classOf m)==Multimaterial) then ( > > + for subm in m do ( > > + image = getMatFilename subm > > + if (findItem > materialsWrittenToWorld image==0 and > > image!="MATERIALNOTDEFINED") then ( > > + format "m: % subm: % \n" m > subm > > + if (subm.mapEnables[7]) > then > > + format > " <texture name=\"%\"> > > <file>%</file><alpha><binary/></alpha></texture>\n" image image > > to:outFile > > + else > > + format > " <texture name=\"%\"> <file>%</file></texture>\n" > > image image to:outFile > > + append > materialsWrittenToWorld image > > + ) > > + ) > > + ) > > + > > + ) > > + > > + if (fireNeeded or emitNeeded) then ( > > + format " <texture name=\"raindrop\"> > > <file>raindrop.png</file></texture>\n" to:outFile > > + ) > > + > > + -- handle additional textures for particles > > + for m in partMaterials do > > + ( > > + format " <texture name=\"%\"> > <file>%</file></texture>\n" > > m m to:outFile > > + ) > > + > > + > > + format " </textures>\n" to:outFile > > + > > + > > + --/// MATERIALS > > + > > + materialsWrittenToWorld=#() > > + > > + format " <materials>\n" to:outFile > > + > > + for m in sceneMaterials do > > + ( > > + -- handle Standardmaterials > > + if ((classOf m)==Standardmaterial) then ( > > + -- if material not written, add it > > + image = getMatFilename m > > + if (findItem materialsWrittenToWorld > image==0 and > > image!="MATERIALNOTDEFINED") then ( > > + format " <material name=\"%\"> > > <texture>%</texture></material>\n" image image to:outFile > > + append materialsWrittenToWorld > image > > + ) > > + ) > > + > > + -- handle Multi/materials > > + if ((classOf m)==Multimaterial) then ( > > + for subm in m do ( > > + image = getMatFilename subm > > + isshader = false > > + > > + -- skip wrong materials > > + if ( image=="MATERIALNOTDEFINED") > then > > + continue; > > + > > + -- determine if it's a shader > material > > + if (findString subm.name"_shader_"!=undefined) then > > + isshader = true > > + > > + -- check if already written > > + found = false > > + imagetemp = image > > + if (isshader) then ( > > + imagetemp = image + > "sshhaaddeerr" > > + if(findItem > materialsWrittenToWorld imagetemp!=0) then > > + found=true > > + ) else ( > > + if(findItem > materialsWrittenToWorld image!=0) then > > + found=true > > + ) > > + > > + if (not found) then ( > > + > > + format " <material > name=\"%\"> <texture>%</texture>\n" > > imagetemp image to:outFile > > + -- manage shaders > > + if (findString subm.name"_shader_" != undefined) then ( > > + if (findString > subm.name "_shader_terrain" !=undefined) then ( > > + format > " <shadervar name=\"texture scale\" > > type=\"vector2\">32,32</shadervar>\n" to:outFile > > + format > " <shader type=\"terrain > > splat\">terrain_fixed_splatting</shader>\n" to:outFile > > + ) > > + else if > (findString subm.name "_shader_ambient" !=undefined) then ( > > + format > " <shader > > type=\"ambient\">terrain_fixed_base</shader>\n" to:outFile > > + ) else ( > > + message = > "ERROR: Found terrain's material "+m.name+" with > > submat "+subm.name+" defining a shader of unsupported type!\n" > > + message = > message + "Supported types are: _shader_terrain , > > _shader_ambient" > > + messageBox > message > > + format > " </material>\n" to:outFile > > + return 1 > > + ) > > + > > + ) else > > + append > materialsWrittenToWorld imagetemp > > + > > + format " </material>\n" > image image to:outFile > > + > > + ) > > + ) > > + ) > > + ) > > + > > + > > + if (fireNeeded or emitNeeded) then ( > > + format " <material name=\"raindrop\"> > > <texture>raindrop</texture></material>\n" to:outFile > > + ) > > + > > + -- handle additional materials for particles > > + for m in partMaterials do > > + ( > > + format " <material name=\"%\"> > > <texture>%</texture></material>\n" m m to:outFile > > + ) > > + > > + format " </materials>\n\n" to:outFile > > + > > + ) > > + > > + -- //////////////////////// > > + -- Write shaders function > > + -- //////////////////////// > > + > > + fn WriteShaders outFile = > > + ( > > + > > + -- add shaders needed for terrain > > + if (chkTerrain.checked) then ( > > + filestr = openFile "ps_terrain.shaders.txt" > > + if (filestr==undefined) then ( > > + message = "ERROR: ps_terrain.shaders.txt > not found!" > > + messageBox message > > + return 1 > > + ) > > + while (not eof filestr) do > > + ( > > + line = readLine filestr > > + format "%\n" line to:outFile > > + ) > > + ) > > + > > + ) > > + > > + > > + -- //////////////////////// > > + -- Output Particle function > > + -- //////////////////////// > > + fn OutputParticle obj allObjects outFile = > > + ( > > + type = getUserProp obj "TYPE" > > + partMaterial = getUserProp obj "MATERIAL" > > + mixmode = getUserProp obj "MIXMODE" > > + > > + xpart = (obj.pos.x * xscale) + xrelocate > > + ypart = (obj.pos.y * yscale) + yrelocate > > + zpart = (obj.pos.z * zscale) + zrelocate > > + > > + --format " ;Particle Name: % Type: %\n" > obj.name type > > to:outFile > > + > > + -- ////// > > + -- Fire > > + -- ////// > > + if (type == "fire") then ( > > + > > + number = getUserProp obj "NUMBER" > > + dropsize = getUserProp obj > "DROPSIZE" > > + lighting = getUserProp obj > "LIGHTING" > > + swirl = getUserProp obj "SWIRL" > > + colorscale = getUserProp obj > "COLORSCALE" > > + > > + format " <meshobj > name=\"Fire01\">\n" to:outFile > > + format > " <priority>alpha</priority>\n" to:outFile > > + format > " <plugin>emit</plugin>\n" to:outFile > > + format " <ztest />\n" > to:outFile > > + format " <move> <v x=\"0\" > y=\"0\" z=\"0\" /> </move>\n" > > to:outFile > > + format " <params>\n" > to:outFile > > + format > " <factory>emitFact</factory> \n" to:outFile > > + format " <mixmode><add > /></mixmode>\n" to:outFile > > + > > + if (partMaterial == undefined) > then > > + format > " <material>candleflame.png</material>\n" to:outFile > > + else > > + format > " <material>%</material>\n" partMaterial to:outFile > > + > > + format > " <number>%</number> \n" number to:outFile > > + format > " <regularparticles sides=\"4\" radius=\"0.1\" /> > > \n" to:outFile > > + format > " <lighting>off</lighting> \n" to:outFile > > + format > " <totaltime>1000</totaltime> \n" to:outFile > > + format > " <startpos><emitsphere x=\"%\" y=\"%\" z=\"%\" > > p=\"0\" q=\"0.03\" /></startpos> \n" xpart zpart ypart to:outFile > > + format > " <startspeed><emitbox><min x=\"0\" y=\"0\" z=\"0\" > > /> \n" to:outFile > > + format " <max x=\"0\" > y=\"0.3\" z=\"0\" > > /></emitbox></startspeed> \n" to:outFile > > + format > " <startaccel><emitfixed x=\"0\" y=\"0\" z=\"0\" > > /></startaccel>\n" to:outFile > > + format " <attractor> > <emitfixed x=\"%\" y=\"%\" z=\"%\" > > /> </attractor> " xpart (zpart+0.2) ypart to:outFile > > + format > " <attractorforce>1</attractorforce>\n" to:outFile > > + format " <aging> > <time>0</time><color red=\"0.7\" > > green=\"0.1\" blue=\"0.0\" /> \n" to:outFile > > + format " > > <alpha>0.2</alpha><swirl>0.01</swirl><rotspeed>0.0</rotspeed><scale>0.4 > </scale></aging>\n" > > to:outFile > > + format " <aging> > <time>250</time><color red=\"0.6\" > > green=\"0.1\" blue=\"0.05\" /> \n" to:outFile > > + format " > > <alpha>0.5</alpha><swirl>0.002</swirl><rotspeed>0.0</rotspeed><scale>0.4 > </scale></aging>\n" > > to:outFile > > + format " <aging> > <time>500</time><color red=\"0.8\" > > green=\"0.6\" blue=\"0.1\" /> \n" to:outFile > > + format " > > <alpha>0.8</alpha><swirl>0.01</swirl><rotspeed>0.0</rotspeed><scale>0.6 > </scale></aging>\n" > > to:outFile > > + format " <aging> > <time>750</time><color red=\"0.4\" > > green=\"0.2\" blue=\"0.05\" /> \n" to:outFile > > + format " > > <alpha>0.6</alpha><swirl>0.02</swirl><rotspeed>0.0</rotspeed><scale>0.4 > </scale></aging>\n" > > to:outFile > > + format " <aging> > <time>1000</time><color red=\"0.3\" > > green=\"0.1\" blue=\"0.02\" /> \n" to:outFile > > + format " > > <alpha>1</alpha><swirl>0.001</swirl><rotspeed>0.0</rotspeed><scale>0.2 > </scale></aging>\n" > > to:outFile > > + format " </params>\n" > to:outFile > > + format " </meshobj>\n" > to:outFile > > + > > + ) > > + -- ////// > > + -- Emit > > + -- ////// > > + else if (type == "emit") then ( > > + number = getUserProp obj "NUMBER" > > + regparticle = getUserProp obj > "REGULARPARTICLES" > > + if (regparticle==undefined) then > > + ( > > + rectparticle = getUserProp > obj "RECTPARTICLES" > > + rectparticle2 = tokenize > rectparticle "," > > + ) else ( > > + regparticle2 = tokenize > regparticle "," > > + ) > > + lighting = getUserProp obj > "LIGHTING" > > + totaltime = getUserProp obj > "TOTALTIME" > > + -- STARTPOS: > STARTPOS1=EMITSPHERE STARTPOS2=0,0.1 > > + startpostype = getUserProp obj > "STARTPOS1" > > + startpostype = lowercase > startpostype > > + startpos = getUserProp obj > "STARTPOS2" > > + index = findString startpos "," > > + startposarray = tokenize startpos > "," > > + -- > STARTSPEED=EMITBOX(-1,-1,-1,1,1,1) > > + startspeed = getUserProp obj > "STARTSPEED" > > + index = findString startspeed "(" > > + startspeedtype = lowercase > (substring startspeed 1 (index-1)) > > + startspeed = substring startspeed > (index+1) -1 > > + startspeed = substring startspeed > 1 ((startspeed.count)-1) > > + startspeedarray = tokenize > startspeed "," > > + -- STARTACCEL=EMITFIXED(0,0,0) > > + startaccel = getUserProp obj > "STARTACCEL" > > + index = findString startaccel "(" > > + startacctype = lowercase > (substring startaccel 1 (index-1)) > > + startaccel = substring startaccel > (index+1) -1 > > + startaccel = substring startaccel > 1 ((startaccel.count)-1) > > + startaccarray = tokenize > startaccel "," > > + attractorobj = obj.children[1] > > + if (attractorobj!=undefined) then > ( > > + xattractorobj = ( > attractorobj.pos.x * xscale) + xrelocate > > + yattractorobj = ( > attractorobj.pos.y * yscale) + yrelocate > > + zattractorobj = ( > attractorobj.pos.z * zscale) + zrelocate > > + typeattractor = > getUserProp attractorobj "TYPE" > > + attractorforce = > getUserProp obj "ATTRACTORFORCE" > > + ) > > + > > + -- fieldspeed > > + fieldspeed = getUserProp obj > "FIELDSPEED" > > + format "fieldspeed: % \n" > fieldspeed > > + if (fieldspeed!=undefined) then ( > > + index = findString > fieldspeed "(" > > + fieldspeedtype = lowercase > (substring fieldspeed 1 (index-1)) > > + format "fieldspeedtype: % > \n" fieldspeedtype > > + fieldspeed = substring > fieldspeed (index+1) -1 > > + fieldspeed = substring > fieldspeed 1 ((fieldspeed.count)-1) > > + fieldspeedarray = tokenize > fieldspeed "," > > + ) > > + > > + aging0 = getUserProp obj "AGING0" > > + if (aging0!=undefined) then > > + aging0 = tokenize aging0 > "," > > + aging1 = getUserProp obj "AGING1" > > + if (aging1!=undefined) then > > + aging1 = tokenize aging1 > "," > > + aging2 = getUserProp obj "AGING2" > > + if (aging2!=undefined) then > > + aging2 = tokenize aging2 > "," > > + aging3 = getUserProp obj "AGING3" > > + if (aging3!=undefined) then > > + aging3 = tokenize aging3 > "," > > + aging4 = getUserProp obj "AGING4" > > + if (aging4!=undefined) then > > + aging4 = tokenize aging4 > "," > > + > > + format " <meshobj > name=\"%\">\n" obj.name to:outFile > > + format > " <priority>alpha</priority>\n" to:outFile > > + format > " <plugin>emit</plugin>\n" to:outFile > > + format " <ztest />\n" > to:outFile > > + > > + if (attractorobj!=undefined) then > ( > > + movexpart = 0; moveypart = > 0; movezpart = 0 > > + startposxpart = xpart; > startposypart = ypart ; startposzpart = zpart > > + ) else ( > > + movexpart = xpart; > moveypart = ypart ; movezpart = zpart > > + startposxpart = 0; > startposypart = 0 ; startposzpart = 0 > > + ) > > + > > + format " <move> <v x=\"%\" > y=\"%\" z=\"%\" /> </move>\n" > > movexpart movezpart moveypart to:outFile > > + > > + format " <params>\n" > to:outFile > > + format > " <factory>emitFact</factory> \n" to:outFile > > + if (mixmode == undefined) then > > + format > " <mixmode><add /></mixmode>\n" to:outFile > > + else > > + format > " <mixmode><% /></mixmode>\n" mixmode to:outFile > > + if (partMaterial == undefined) > then > > + format > " <material>raindrop</material>\n" to:outFile > > + else > > + format > " <material>%</material>\n" partMaterial to:outFile > > + > > + format > " <number>%</number> \n" number to:outFile > > + if (regparticle==undefined) then > > + ( > > + format > " <rectparticles w=\"%\" h=\"%\" /> \n" > > rectparticle2[1] rectparticle2[2] to:outFile > > + ) else ( > > + format > " <regularparticles sides=\"%\" radius=\"%\" /> > > \n" regparticle2[1] regparticle2[2] to:outFile > > + ) > > + format > " <lighting>%</lighting> \n" lighting to:outFile > > + format > " <totaltime>%</totaltime> \n" totaltime to:outFile > > + -- STARTPOS > > + if (startpostype=="emitsphere") > then ( > > + --pscaled = > (startposarray[1] * xscale) + xrelocate > > + --qscaled = > (startposarray[2] * yscale) + yrelocate > > + format > " <startpos><% x=\"%\" y=\"%\" z=\"%\" p=\"%\" > > q=\"%\" /></startpos>\n" startpostype startposxpart startposzpart > > startposypart startposarray[1] startposarray[2] to:outFile > > + ) else if > (startpostype=="emitfixed") then > > + format > " <startpos><% x=\"%\" y=\"%\" z=\"%\" > > /></startpos>\n" startpostype startposxpart startposzpart > > startposypart to:outFile > > + else if (startpostype=="emitbox") > then > > + ( > > + format > " <startpos><%><min x=\"%\" y=\"%\" z=\"%\" /> \n" > > startpostype startposarray[1] startposarray[2] startposarray[3] > > to:outFile > > + format " <max > x=\"%\" y=\"%\" z=\"%\" /></%></startpos> > > \n" startposarray[4] startposarray[5] startposarray[6] startpostype > > to:outFile > > + ) > > + -- STARTSPEED > > + if (startspeedtype=="emitbox") > then > > + ( > > + > > + format > " <startspeed><%><min x=\"%\" y=\"%\" z=\"%\" /> > > \n" startspeedtype startspeedarray[1] startspeedarray[2] > > startspeedarray[3] to:outFile > > + format " <max > x=\"%\" y=\"%\" z=\"%\" /></%></startspeed> > > \n" startspeedarray[4] startspeedarray[5] startspeedarray[6] > > startspeedtype to:outFile > > + ) else if > (startspeedtype=="emitfixed") then > > + format > " <startspeed><% x=\"%\" y=\"%\" z=\"%\" /> > > </startspeed>\n" startspeedtype startspeedarray[1] > > startspeedarray[2] startspeedarray[3] to:outFile > > + format " <startaccel><% > x=\"%\" y=\"%\" z=\"%\" > > /></startaccel>\n" startacctype startaccarray[1] startaccarray[2] > > startaccarray[3] to:outFile > > + > > + -- ATTRACTOR > > + if (attractorobj!=undefined) then > ( > > + format > " <attractor> <emitfixed x=\"%\" y=\"%\" z=\"%\" > > /> </attractor>\n" xattractorobj zattractorobj yattractorobj > > to:outFile > > + format > " <attractorforce>%</attractorforce>\n" > > attractorforce to:outFile > > + ) > > + > > + -- FIELDSPEED > > + if (fieldspeedtype=="emitcylindertangent") then > > + ( > > + format > " <fieldspeed><% p=\"%\" q=\"%\">\n" > > fieldspeedtype fieldspeedarray[1] fieldspeedarray[2] to:outFile > > + format " <min > x=\"%\" y=\"%\" z=\"%\" /><max x=\"%\" > > y=\"%\" z=\"%\" /> \n" fieldspeedarray[3] fieldspeedarray[4] > > fieldspeedarray[5] fieldspeedarray[6] fieldspeedarray[7] > > fieldspeedarray[8] to:outFile > > + format > " </emitcylindertangent></fieldspeed>\n" to:outFile > > + ) > > + > > + if (aging0!=undefined) then > > + ( > > + format > " <aging> <time>%</time><color red=\"%\" > > green=\"%\" blue=\"%\" /> \n" aging0[1] aging0[2] aging0[3] > > aging0[4] to:outFile > > + format " > > > <alpha>%</alpha><swirl>%</swirl><rotspeed>%</rotspeed><scale>%</scale></aging>\n" > aging0[5] aging0[6] aging0[7] aging0[8] > > to:outFile > > + ) > > + if (aging1!=undefined) then > > + ( > > + format > " <aging> <time>%</time><color red=\"%\" > > green=\"%\" blue=\"%\" /> \n" aging1[1] aging1[2] aging1[3] > > aging1[4] to:outFile > > + format " > > > <alpha>%</alpha><swirl>%</swirl><rotspeed>%</rotspeed><scale>%</scale></aging>\n" > aging1[5] aging1[6] aging1[7] aging1[8] > > to:outFile > > + ) > > + if (aging2!=undefined) then > > + ( > > + format > " <aging> <time>%</time><color red=\"%\" > > green=\"%\" blue=\"%\" /> \n" aging2[1] aging2[2] aging2[3] > > aging2[4] to:outFile > > + format " > > > <alpha>%</alpha><swirl>%</swirl><rotspeed>%</rotspeed><scale>%</scale></aging>\n" > aging2[5] aging2[6] aging2[7] aging2[8] > > to:outFile > > + ) > > + if (aging3!=undefined) then > > + ( > > + format > " <aging> <time>%</time><color red=\"%\" > > green=\"%\" blue=\"%\" /> \n" aging3[1] aging3[2] aging3[3] > > aging3[4] to:outFile > > + format " > > > <alpha>%</alpha><swirl>%</swirl><rotspeed>%</rotspeed><scale>%</scale></aging>\n" > aging3[5] aging3[6] aging3[7] aging3[8] > > to:outFile > > + ) > > + if (aging4!=undefined) then > > + ( > > + format > " <aging> <time>%</time><color red=\"%\" > > green=\"%\" blue=\"%\" /> \n" aging4[1] aging4[2] aging4[3] > > aging4[4] to:outFile > > + format " > > > <alpha>%</alpha><swirl>%</swirl><rotspeed>%</rotspeed><scale>%</scale></aging>\n" > aging4[5] aging4[6] aging4[7] aging4[8] > > to:outFile > > + ) > > + format " </params>\n" > to:outFile > > + format " </meshobj>\n" > to:outFile > > + ) > > + ) > > + > > + -- //////////////////////// > > + -- copy textures to output dir > > + -- //////////////////////// > > + fn CopyTexturesToDir outFile = > > + ( > > + destDir = getFilenamePath edt3.text > > + destFile = filenameFromPath edt3.text > > + destDir = destDir + destFile + "textures" > > + format "makedir % \n" destDir > > + makeDir destDir > > + > > + materialsWrittenToWorld=#() > > + > > + for m in sceneMaterials do > > + ( > > + -- handle Standardmaterials > > + if ((classOf m)==Standardmaterial) then ( > > + -- if material not written, add it > > + image = getMatFullPath m > > + if (findItem materialsWrittenToWorld > image==0) then ( > > + destFile2 = filenameFromPath image > > + destFile2 = destDir + "\\" + > destFile2 > > + format "copy from % to % \n" image > destFile2 > > + copyFile image destFile2 > > + append materialsWrittenToWorld > image > > + ) > > + ) > > + > > + > > + -- handle Multi/materials > > + if ((classOf m)==Multimaterial) then ( > > + for subm in m do ( > > + image = getMatFullPath subm > > + if (findItem > materialsWrittenToWorld image==0) then ( > > + destFile2 = > filenameFromPath image > > + destFile2 = destDir + "\\" > + destFile2 > > + format "copy from % to % > \n" image destFile2 > > + copyFile image destFile2 > > + append > materialsWrittenToWorld image > > + ) > > + ) > > + ) > > + ) > > + ) > > + > > + > > + > > + -- //////////////////////// > > + -- Output a Portal object > > + -- //////////////////////// > > + fn OutputPortal obj debug outFile = > > + ( > > + format " <portals><portal name=\"%\">\n" > obj.name to:outFile > > + > > + -- all portals as autoresolve > > + format " <autoresolve />\n" to:outFile > > + > > + -- check if poly is valid: for now should be 2 > faces or have > > VERTS specified > > + faces = getNumFaces obj > > + vertsProp = getUserProp obj "VERTS" > > + if (faces!=2 and vertsProp==undefined) then ( > > + message = "ERROR: If you want to add a > portals with more than 2 > > triangles add a property called VERTS with list of verts clockwise." > > + messageBox message > > + return 1 > > + ) > > + > > + verts = #() > > + -- manage polygon portals > > + if (faces!=2) then ( > > + toks = tokenize vertsProp "," > > + for elem in toks do ( > > + vertPoly = getvert obj (elem as > Integer) > > + append verts (elem as Integer) > > + format "extracted %: % \n" elem > vertPoly > > + ) > > + > > + -- manage 2 faces portals > > + ) else ( > > + > > + -- checks if model has left-oriented > system or not > > + face = getface obj 1 > > + v1= getvert obj face[1] > > + v2 = getvert obj face[2] > > + v3 = getvert obj face[3] > > + > > + vect1 = v1-v2 > > + vect2 = v3-v2 > > + normal1 = cross vect1 vect2 > > + facenorm = normal1/(length normal1) > > + maxnorm = getfacenormal obj 1 > > + flipModel = false > > + > > + dotProd = dot facenorm maxnorm > > + if (dotProd>0) then ( > > + flipModel = true > > + ) > > + > > + -- get faces verts > > + vertsFace1=getface obj 1 > > + vertsFace2=getface obj 2 > > + > > + -- trasform to array (needed for findItem > func) > > + verts1 = #() > > + verts2 = #() > > + for h=1 to 3 do append verts1 > vertsFace1[h] > > + for h=1 to 3 do append verts2 > vertsFace2[h] > > + > > + additionalVertex = 0 > > + oppositeVertex = 0 > > + > > + if (debug) then format "Vertex of first > face: %\n" verts1 > > + > > + -- search non-common vertex on face2 > > + for h=1 to 3 do > > + ( > > + if (findItem verts1 verts2[h]==0) > then > > + additionalVertex = h > > + ) > > + if (debug) then format "Additional vertex: > % " verts2[additionalVertex] > > + > > + -- search opposite vertex > > + for h=1 to 3 do > > + ( > > + if (findItem verts2 verts1[h]==0) > then > > + oppositeVertex = h > > + ) > > + if (debug) then format "Opposite vertex: % > " verts1[oppositeVertex] > > + > > + -- list vertexes in right order for > resulting polygon > > + commonV = false > > + addedAdd = false > > + addedOpp = false > > + for h=1 to 3 do > > + ( > > + -- check next vertex > > + if (h!=3 and h!=oppositeVertex) > then ( > > + nextV = verts1[h+1] > > + -- first common vertex > > + if (nextV != > verts1[oppositeVertex]) then ( > > + append verts > verts1[h] > > + append verts > verts2[additionalVertex] > > + > > + addedAdd = true > > + > > + continue > > + ) > > + ) > > + > > + -- add vertex > > + append verts verts1[h] > > + > > + if (h==3 and (not addedAdd) ) then > ( > > + append verts > verts2[additionalVertex] > > + ) > > + ) > > + > > + -- clock-wise vertexes listing for CS > > + if (not flipModel) then ( > > + tmpVert = verts[2] > > + verts[2] = verts[4] > > + verts[4] = tmpVert > > + ) > > + > > + ) -- end if 2 faces > > + > > + -- export in XZY format > > + piv = obj.pos > > + for v in verts do > > + ( > > + currVert = getVert obj v > > + > > + --relocate in local pivot coords (needed for > > rotation of warping portals) > > + --currVert = currVert-piv > > + > > + --scale > > + scaledx = (currVert.x * xscale) + > xrelocate > > + scaledy = (currVert.y * yscale) + > yrelocate > > + scaledz = (currVert.z * zscale) + > zrelocate > > + format " <v x=\"%\" y=\"%\" z=\"%\" > /> \n" scaledx scaledz > > scaledy to:outFile > > + --format " <v x=\"%\" y=\"%\" z=\"%\" > /> \n" currVert.x > > currVert.z currVert.y to:outFile > > + ) > > + > > + -- search displacement target > > + warp = getUserProp obj "WARPTARGET" > > + if (warp!=undefined) then > > + ( > > + warptarget = getNodeByName warp > > + if (warptarget==undefined) then ( > > + message = "ERROR: WARP TARGET "+ > warp + " specified on object > > "+obj.name+" doesn't exist" > > + messageBox message > > + return 1 > > + ) > > + -- calcs distance from warptarget > > + warpx = obj.pos.x - warptarget.pos.x > > + warpy = obj.pos.y - warptarget.pos.y > > + warpz = obj.pos.z - warptarget.pos.z > > + warpx = (warpx * xscale) + xrelocate > > + warpy = (warpy * yscale) + yrelocate > > + warpz = (warpz * zscale) + zrelocate > > + > > + -- check portal rotation compared to target rotation > > + if (obj.rotation.x!=warptarget.rotation.x or > > obj.rotation.y!=warptarget.rotation.y or > > obj.rotation.z!=warptarget.rotation.z) then ( > > + -- move the target to 0,0,0 for a clean > rotation > > + format " <wv x=\"%\" y=\"%\" > z=\"%\" /> \n" > > warptarget.pos.x warptarget.pos.z warptarget.pos.y to:outFile > > + > > + -- rotate > > + rotmatrix = (warptarget.rotation - > obj.rotation) as eulerAngles > > + rotmatrixcs = (eulerAngles rotmatrix.x > rotmatrix.z > > rotmatrix.y) as matrix3 > > + format " <matrix>\n" to:outFile > > + format > " <m11>%</m11><m12>%</m12><m13>%</m13>\n" > > rotmatrixcs[1][1] rotmatrixcs[1][2] rotmatrixcs[1][3] to:outFile > > + format > " <m21>%</m21><m22>%</m22><m23>%</m23>\n" > > rotmatrixcs[2][1] rotmatrixcs[2][2] rotmatrixcs[2][3] to:outFile > > + format > " <m31>%</m31><m32>%</m32><m33>%</m33>\n" > > rotmatrixcs[3][1] rotmatrixcs[3][2] rotmatrixcs[3][3] to:outFile > > + format " </matrix> \n" to:outFile > > + > > + -- move it back in the right spot > > + format " <ww x=\"%\" y=\"%\" > z=\"%\" /> \n" obj.pos.x > > obj.pos.z obj.pos.y to:outFile > > + > > + ) else ( > > + format " <ww x=\"%\" y=\"%\" > z=\"%\" /> \n" warpx warpz > > warpy to:outFile > > + ) > > + ) > > + > > + arrives = getUserProp obj "ARRIVESINTHEMIDDLE" > > + if (arrives=="yes") then > > + format " <clip/>" to:outFile > > + > > + starts = getUserProp obj "STARTSINTHEMIDDLE" > > + if (starts=="yes") then > > + format " <zfill/>" to:outFile > > + > > + portalname = getUserProp obj "PORTAL" > > + if (portalname==undefined) then > > + ( > > + message = "ERROR: PORTAL WITH NO > DESTINATION % " obj.name > > + messageBox message > > + return 1 > > + ) > > + format " <sector>%</sector>\n" portalname > to:outFile > > + format " </portal>\n" to:outFile > > + > > + -- now displace by the pivot position > > + --format " <move><v x=\"%\" y=\"%\" z=\"%\" > /></move> \n" > > piv.x piv.z piv.y to:outFile > > + format " </portals>\n" to:outFile > > + > > + ) > > + > > + > > + -- //////////////////////// > > + -- Output culleronly trimesh > > + -- //////////////////////// > > + > > + fn OutputCullerOnly obj outFile verboseMode debug = > > + ( > > + > > + -- output vertexes of the object in XZY format > > + for v in obj.verts do > > + ( > > + xvert = (v.pos.x * xscale) + xrelocate > > + yvert = (v.pos.y * yscale) + yrelocate > > + zvert = (v.pos.z * zscale) + zrelocate > > + format " <v x=\"%\" y=\"%\" z=\"%\" > />\n" xvert zvert > > yvert to:outFile > > + ) > > + > > + format "\n" to:outFile > > + > > + -- cycle on all faces of object > > + for i =1 to obj.numFaces do > > + ( > > + -- get its 3 vertices as a point3 > > + -- export in XZY format > > + verts=getface obj i > > + a = verts[1] as Integer > > + b = verts[3] as Integer > > + c = verts[2] as Integer > > + > > + if (verboseMode) then > > + ( > > + format " <t v1=\"%\" v2=\"%\" > v3=\"%\" />\n" (a-1) > > (b-1) (c-1) to:outFile > > + ) else ( > > + format "<t v1=\"%\" > v2=\"%\" v3=\"%\" />\n" (a-1) (b-1) (c-1) > > to:outFile > > + ) > > + ) > > + ) > > + > > + -- //////////////////////// > > + -- Defines if an object should have <colldet> > > + -- //////////////////////// > > + fn doesCollide obj groupsInfo = > > + ( > > + > > + -- check for colldet setting > > + colldetProp = getUserProp obj "COLLDET" > > + > > + -- if it should not collide (e.g. water) > > + if (colldetProp=="no") then > > + return false; > > + > > + > > + -- if is not in a group by defaults it collides > > + if ( not isGroupMember obj) then > > + return true; > > + > > + -- check for colldet based on groups > > + > > + ) > > + > > + fn OutputGenMeshFactory obj outFile debug auto = > > + ( > > + format "auto setting is % for object %\n" auto > obj.name > > + if (auto==1) then ( > > + format "AUTO setting for object %\n" obj.name > > + factoryName = "_auto_" + obj.name > > + ) else ( > > + toks = tokenize obj.name "_" > > + factoryName = toks[3] > > + ) > > + > > + ------------------- > > + -- support for LOD. > > + -- it has to check all objects listed and export > each as a > > nested meshfact > > + ------------------- > > + lodlow = getUserProp obj "LODLOW" > > + if (lodlow!=undefined) then ( > > + format "FOUND LOD OBJECT: %" factoryName > > + > > + -- search low detail obj > > + lodobjects = #() > > + if (lodlow=="NULL") then > > + append lodobjects "null" > > + else > > + append lodobjects (getNodeByName > lodlow) > > + > > + -- search med detail obj > > + lodmed = getUserProp obj "LODMED" > > + if (lodmed=="NULL") then > > + append lodobjects "null" > > + else > > + append lodobjects (getNodeByName > lodmed) > > + > > + -- search high detail obj > > + append lodobjects obj > > + > > + ------------------------- > > + -- no LOD for this object > > + ------------------------- > > + ) else ( > > + lodobjects = #() > > + append lodobjects obj > > + ) > > + > > + -- export low, med and high > version > > + if (lodobjects.count!=1) then > > + ( > > + format "<meshfact name=\"%\">\n" > factoryName to:outFile > > + -- get proper nullmesh bbox size > > + rmin = [-1,-1,-1] > > + rmax = [1,1,1] > > + for k=1 to lodobjects.count do > > + ( > > + if (lodobjects[k]!="null") then > > + ( > > + tempmin = > lodobjects[k].min - lodobjects[k].center > > + tempmax = > lodobjects[k].max - lodobjects[k].center > > + if (tempmin.x<rmin.x) then > rmin.x=tempmin.x > > + if (tempmin.y<rmin.y) then > rmin.y=tempmin.y > > + if (tempmin.z<rmin.z) then > rmin.z=tempmin.z > > + if (tempmax.x>rmax.x) then > rmax.x=tempmax.x > > + if (tempmax.y>rmax.y) then > rmax.y=tempmax.y > > + if (tempmax.z>rmax.z) then > rmax.z=tempmax.z > > + ) > > + ) > > + rmin = (rmin * xscale) + xrelocate > > + rmax = (rmax * xscale) + xrelocate > > + format "<nullmesh><min x=\"%\" y=\"%\" > z=\"%\" /><max x=\"%\" > > y=\"%\" z=\"%\" /></nullmesh>\n" rmin.x ... [truncated message content] |