fn DisplayGameToolsInfo = ( rollout GTInfo "" ( on GTInfo lbuttondown tmp do ( destroydialog GTInfo ) ) try ( createdialog GTInfo pos:((sysInfo.DesktopSize*[.25,.5])-[202,129]) width:404 height:258 style:#() bitmap:( openbitmap (ImageDir+"GameToolsTitle.bmp") ) bgcolor:(color 102 108 111) ) catch(messagebox "ERROR! Missing GameTools title bitmap") ) fn UpdateMaterialUI = ( local MatUI=GameToolsExecutiveRoll if MatUI == undefined then return false if UpDateError==1 then ( MatUI.MultiMatName.text="" MatUI.SubMatName.text="" MatUI.MultiMatName.enabled=false MatUI.SubMatName.enabled=false MatUI.SelfIllumVal.enabled=false MatUI.SelfIllumVal.value=0 MatUI.OpacityVal.enabled=false MatUI.OpacityVal.value=0 MatUI.MapColor.pos=[-100,0] MatUI.SubMatBit.enabled=true MatUI.SubMatBit.bitmap=copy EmptySlot MatUI.LevelVal.enabled=false MatUI.levelVal.value=0.0 MatUI.MapType.selection=1 MatUI.IDVal.value=0 ) else ( try ( local MatNode=$selection[1] local MatMaterial=MatNode.material local MatID=1 MatUI.MultiMatName.enabled=true MatUI.SubMatName.enabled=true MatUI.SelfIllumVal.enabled=true MatUI.OpacityVal.enabled=true case (classof MatNode.material) of ( Standardmaterial: ( MatID=1 MatUI.MultiMatName.text="" MatUI.MultiMatName.enabled=false MatUI.SubMatName.text=MatMaterial.name MatUI.SelfIllumVal.value=matMaterial.selfillumination MatUI.OpacityVal.value=matMaterial.Opacity MatUI.WireChk.state=matMaterial.wire MatUI.TwoSidedChk.state=matMaterial.twosided case MatUI.MapType.selected of ( "Ambient": ( MatUI.MapColor.pos=[196,140] MatUI.MapColor.color=matMaterial.Ambient MatUI.SubMatBit.enabled=false MatUI.SubMatBit.bitmap=copy (bitmap 52 49) MatUI.SubMatBit.pos=[-100,-100] MatUI.LevelVal.enabled=false MatUI.LevelVal.value=0.0 ) "Diffuse": ( MatUI.MapColor.pos=[196,140] MatUI.MapColor.color=matMaterial.diffuse MatUI.SubMatBit.enabled=true try ( MatUI.SubMatBit.bitmap=copy (matMaterial.diffusemap.bitmap) (bitmap 52 49) ) ; catch(MatUI.SubMatBit.bitmap=copy EmptySlot) MatUI.SubMatBit.pos=[196,83] MatUI.LevelVal.enabled=false MatUI.levelVal.value=0.0 ) "Specular": ( MatUI.MapColor.pos=[196,140] MatUI.MapColor.color=matMaterial.specular MatUI.SubMatBit.enabled=true try ( MatUI.SubMatBit.bitmap=copy (matMaterial.Specularlevelmap.bitmap) (bitmap 52 49) ) ; catch(MatUI.SubMatBit.bitmap=copy EmptySlot) MatUI.SubMatBit.pos=[196,83] MatUI.levelVal.enabled=true MatUI.levelVal.value=matMaterial.specularLevel ) "Opacity": ( MatUI.MapColor.pos=[-100,0] MatUI.SubMatBit.enabled=true try (MatUI.SubMatBit.bitmap=copy (matMaterial.opacitymap.bitmap) (bitmap 52 49) ) ; catch(MatUI.SubMatBit.bitmap=copy EmptySlot) MatUI.SubMatBit.pos=[196,83] MatUI.levelVal.enabled=true MatUI.levelVal.value=matMaterial.Opacity if MatUI.levelVal.value>100.0 do MatUI.levelVal.value=100 ) "Glossiness": ( MatUI.MapColor.pos=[-100,0] MatUI.SubMatBit.enabled=true try (MatUI.SubMatBit.bitmap=copy (matMaterial.glossinessmap.bitmap) (bitmap 52 49) ) ; catch(MatUI.SubMatBit.bitmap=copy EmptySlot) MatUI.SubMatBit.pos=[196,83] MatUI.LevelVal.enabled=true MatUI.levelVal.value=matMaterial.Glossiness if MatUI.levelVal.value>100.0 do MatUI.levelVal.value=100 ) "Soften": ( MatUI.MapColor.pos=[-100,0] MatUI.SubMatBit.enabled=false MatUI.SubMatBit.bitmap=copy (bitmap 52 49) MatUI.SubMatBit.pos=[196,83] MatUI.LevelVal.enabled=true MatUI.levelVal.value=matMaterial.Soften*100.0 if MatUI.levelVal.value>100.0 do MatUI.levelVal.value=100 ) "Bump": ( MatUI.MapColor.pos=[-100,0] MatUI.SubMatBit.enabled=true try (MatUI.SubMatBit.bitmap=copy (matMaterial.bumpmap.bitmap) (bitmap 52 49) ) ; catch(MatUI.SubMatBit.bitmap=copy EmptySlot) MatUI.SubMatBit.pos=[196,83] MatUI.LevelVal.enabled=true MatUI.levelVal.value=matMaterial.bumpMapAmount ) "Reflection": ( MatUI.MapColor.pos=[-100,0] MatUI.SubMatBit.enabled=true try (MatUI.SubMatBit.bitmap=copy (matMaterial.reflectionmap.bitmap) (bitmap 52 49) ) ; catch(MatUI.SubMatBit.bitmap=copy EmptySlot) MatUI.SubMatBit.pos=[196,83] MatUI.LevelVal.enabled=true MatUI.levelVal.value=matMaterial.ReflectionMapAmount ) )--case MatUI.MapType.selected of )--Standardmaterial... Multimaterial: ( case (classof MatNode) of ( Editable_mesh: (try(MatID=getfacematID MatNode MatNode.selectedfaces[1].index);catch()) Editable_Poly: (try(MatID=polyop.getfacematID MatNode MatNode.selectedfaces[1].index);catch()) ) MatUI.MultiMatName.text=MatMaterial.name MatID=mod MatID MatMaterial.count ; if MatID==0 do MatID=MatMaterial.count MatUI.SubMatName.text=MatMaterial[MatID].name if (classof MatMaterial[MatID])==Standardmaterial then ( MatUI.SelfIllumVal.value=matMaterial[MatID].selfillumination MatUI.OpacityVal.value=matMaterial[MatID].Opacity MatUI.WireChk.state=matMaterial[MatID].wire MatUI.TwoSidedChk.state=matMaterial[MatID].twosided case MatUI.MapType.selected of ( "Ambient": ( MatUI.MapColor.pos=[196,140] MatUI.MapColor.color=matMaterial[MatID].Ambient MatUI.SubMatBit.enabled=false MatUI.SubMatBit.bitmap=copy (bitmap 52 49) MatUI.SubMatBit.pos=[-100,-100] MatUI.LevelVal.enabled=false MatUI.LevelVal.value=0.0 ) "Diffuse": ( MatUI.MapColor.pos=[196,140] MatUI.MapColor.color=matMaterial[MatID].diffuse MatUI.SubMatBit.enabled=true try (MatUI.SubMatBit.bitmap=copy (matMaterial[MatID].diffusemap.bitmap) (bitmap 52 49) ) ; catch(MatUI.SubMatBit.bitmap=copy EmptySlot) MatUI.SubMatBit.pos=[196,83] MatUI.LevelVal.enabled=false MatUI.levelVal.value=0.0 ) "Specular": ( MatUI.MapColor.pos=[196,140] MatUI.MapColor.color=matMaterial[MatID].specular MatUI.SubMatBit.enabled=true try (MatUI.SubMatBit.bitmap=copy (matMaterial[MatID].specularlevelmap.bitmap) (bitmap 52 49) ) ; catch(MatUI.SubMatBit.bitmap=copy EmptySlot) MatUI.SubMatBit.pos=[196,83] MatUI.LevelVal.enabled=true MatUI.levelVal.value=matMaterial[MatID].specularLevel ) "Opacity": ( MatUI.MapColor.pos=[-100,0] MatUI.SubMatBit.enabled=true try (MatUI.SubMatBit.bitmap=copy (matMaterial[MatID].opacitymap.bitmap) (bitmap 52 49) ) ; catch(MatUI.SubMatBit.bitmap=copy EmptySlot) MatUI.SubMatBit.pos=[196,83] MatUI.LevelVal.enabled=true MatUI.levelVal.value=matMaterial[MatID].Opacity if MatUI.levelVal.value>100.0 do MatUI.levelVal.value=100 ) "Glossiness": ( MatUI.MapColor.pos=[-100,0] MatUI.SubMatBit.enabled=true try (MatUI.SubMatBit.bitmap=copy (matMaterial[MatID].glossinessmap.bitmap) (bitmap 52 49) ) ; catch(MatUI.SubMatBit.bitmap=copy EmptySlot) MatUI.SubMatBit.pos=[196,83] MatUI.LevelVal.enabled=true MatUI.levelVal.value=matMaterial[MatID].Glossiness if MatUI.levelVal.value>100.0 do MatUI.levelVal.value=100 ) "Soften": ( MatUI.MapColor.pos=[-100,0] MatUI.SubMatBit.enabled=false MatUI.SubMatBit.bitmap=copy (bitmap 52 49) MatUI.SubMatBit.pos=[-100,-100] MatUI.LevelVal.enabled=true MatUI.levelVal.value=matMaterial[MatID].Soften*100.0 if MatUI.levelVal.value>100.0 do MatUI.levelVal.value=100 ) "Bump": ( MatUI.MapColor.pos=[-100,0] MatUI.SubMatBit.enabled=true try (MatUI.SubMatBit.bitmap=copy (matMaterial[MatID].bumpmap.bitmap) (bitmap 52 49) ) ; catch(MatUI.SubMatBit.bitmap=copy EmptySlot) MatUI.SubMatBit.pos=[196,83] MatUI.LevelVal.enabled=true MatUI.levelVal.value=matMaterial[MatID].bumpMapAmount ) "Reflection": ( MatUI.MapColor.pos=[-100,0] MatUI.SubMatBit.enabled=true try (MatUI.SubMatBit.bitmap=copy (matMaterial[MatID].reflectionmap.bitmap) (bitmap 52 49) ) ; catch(MatUI.SubMatBit.bitmap=copy EmptySlot) MatUI.SubMatBit.pos=[196,83] MatUI.LevelVal.enabled=true MatUI.levelVal.value=matMaterial[MatID].ReflectionMapAmount ) )--case MatUI.MapType.selected of )--if (classof MatMaterial[MatID])==Standardmaterial then else ( MatUI.MultiMatName.text="" MatUI.SubMatName.text="" MatUI.MultiMatName.enabled=false MatUI.SubMatName.enabled=false MatUI.SelfIllumVal.enabled=false MatUI.SelfIllumVal.value=0 MatUI.OpacityVal.enabled=false MatUI.OpacityVal.value=0 MatUI.MapColor.pos=[-100,0] MatUI.SubMatBit.enabled=true MatUI.SubMatBit.bitmap=copy EmptySlot MatUI.LevelVal.enabled=false MatUI.levelVal.value=0.0 MatUI.MapType.selection=1 ) )--multimaterial default: ( MatUI.MultiMatName.text="" MatUI.SubMatName.text="" MatUI.MultiMatName.enabled=false MatUI.SubMatName.enabled=false MatUI.SelfIllumVal.enabled=false MatUI.SelfIllumVal.value=0 MatUI.OpacityVal.enabled=false MatUI.OpacityVal.value=0 MatUI.MapColor.pos=[-100,0] MatUI.SubMatBit.enabled=true MatUI.SubMatBit.bitmap=copy EmptySlot MatUI.LevelVal.enabled=false MatUI.levelVal.value=0.0 MatUI.MapType.selection=1 )--default )--case (classof MatNode.material) of... MatID ) catch ( MatUI.MultiMatName.text="" MatUI.SubMatName.text="" MatUI.MultiMatName.enabled=false MatUI.SubMatName.enabled=false MatUI.SelfIllumVal.enabled=false MatUI.SelfIllumVal.value=0 MatUI.OpacityVal.enabled=false MatUI.OpacityVal.value=0 MatUI.MapColor.pos=[-100,0] MatUI.SubMatBit.enabled=true MatUI.SubMatBit.bitmap=copy EmptySlot MatUI.LevelVal.enabled=false MatUI.levelVal.value=0.0 MatUI.MapType.selection=1 ) )--if UpDateError==1 then )--fn UpdateMaterial UI --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn TextMessage TM_Text TM_Color = ( local TM_Pos=(mouse.screenpos+[12,-2]) local TM_Size=(GetTextExtent TM_Text)+[6,6] if (TM_Pos.x+TM_Size.x)>sysinfo.desktopsize.x do ( TM_Pos.x=(TM_Pos.x-((TM_Pos.x+TM_Size.x)-sysinfo.desktopsize.x))-5.0 ) if (TM_Pos.y+TM_Size.y)>sysinfo.desktopsize.y do ( TM_Pos.y=(TM_Pos.y-((TM_Pos.y+TM_Size.y)-sysinfo.desktopsize.y))-5.0 ) try (destroydialog MessageRollout) ; catch() rollout MessageRollout "" ( label MessageTxt "" align:#left pos:[2,2] timer QuitMessage "" interval:100 on QuitMessage tick do ( if (distance MessageMousePos mouse.screenpos)>2 do (destroydialog MessageRollout) ) ) createdialog MessageRollout pos:TM_Pos width:TM_Size.x height:TM_Size.y bgcolor:TM_Color fgcolor:(color 255 255 255) style:#(#style_border) MessageRollout.MessageTxt.text=TM_Text MessageMousePos=mouse.screenpos ) --****************************************************************************************************** fn storeUVs = ( StoredObject=selection[1] StoredID=#() StoredUVCoords=#() StoredFaces=for gg=1 to selection[1].selectedfaces.count collect selection[1].selectedfaces[gg].index case (classof $) of ( Editable_mesh: ( StoredUVCount=selection[1].numtverts for FaceCount=1 to StoredFaces.count do ( StoredID[FaceCount]=getfacematid storedobject storedfaces[facecount] StoredUVCoords[FaceCount]=getTVface selection[1] Storedfaces[FaceCount] ) ) Editable_poly: ( StoredUVCount=polyop.getnummapverts selection[1] 1 for FaceCount=1 to StoredFaces.count do ( StoredID[FaceCount]=polyop.getfacematid storedobject storedfaces[facecount] StoredUVCoords[FaceCount]=polyop.getmapface selection[1] 1 Storedfaces[FaceCount] ) ) ) UndoNo=1 ) --************************************************************************************************** fn PolyFaceMap = ( local notallfaces=0 for gg=1 to $.selectedfaces.count do ( local tmpPol=polyop.getmapface $ 1 $.selectedfaces[gg].index local uvstart=(polyop.getnummapverts $ 1)+1 if tmpPol.count==4 then ( polyop.setnummapverts $ 1 ((polyop.getnummapverts $ 1)+4) keep:true polyop.setmapvert $ 1 (UVStart) [0,0,0] polyop.setmapvert $ 1 (UVStart+1) [1,0,0] polyop.setmapvert $ 1 (UVStart+2) [1,1,0] polyop.setmapvert $ 1 (UVStart+3) [0,1,0] polyop.setmapface $ 1 $.selectedfaces[gg].index #(UVStart,(UVStart+1),(UVStart+2),(UVStart+3)) ) else ( notallfaces=1 ) ) update $selection[1] if notallfaces==1 do (messagebox "WARNING: Some of the polys couldn't be face mapped as they contained more that 4 vertices. Deselect these faces and try again.") ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn FlattenViewVerts = ( local TempVertList=#() if (classof $)==Editable_Mesh do ( local TmpVerts=(meshop.getvertsusingface $ $.selectedfaces) as array ) if (classof $)==Editable_Poly do ( local TmpVerts=(Polyop.getvertsusingface $ $.selectedfaces) as array ) NodeCalc=Point Name:"Nodey" ishidden:true cross:off for PP=1 to TmpVerts.count do ( Mat=Matrix3 1 Mat.rotation=(viewport.getTM()).rotation Mat=orthogonalize (inverse Mat) if (classof $)==Editable_Mesh do (Mat.Translation=getvert $ TmpVerts[PP]) if (classof $)==Editable_Poly do (Mat.Translation=polyop.getvert $ TmpVerts[PP]) Rotate Mat (inverse Mat.rotation ) NodeCalc.transform=Mat Append TempVertList [NodeCalc.pos.x,NodeCalc.pos.y,0] ) delete NodeCalc --GC() return TempVertList ) fn PasteViewFacesExec VV = ( case (classof $selection[1]) of ( editable_mesh: ( if (meshop.getMapSupport $ 1)==false do (meshop.setMapSupport $ 1 true ; buildTVFaces $ true) ) editable_poly: ( if (polyop.getMapSupport $ 1)==false do (polyop.setMapSupport $ 1 true ; polyop.defaultmapfaces $ 1) ) ) StoreUVs() local CMinX=VXMin local CMaxX=VXmax local CMinY=VYMin local CMaxY=VYMax local OldTVerts local SelFaces local VertListIn VertList=VV local tmpVX=for gg=1 to Vertlist.count collect Vertlist[gg].x local tmpVY=for gg=1 to Vertlist.count collect Vertlist[gg].y case (classof $) of ( Editable_mesh: ( OldTVerts=$.numtverts SelFaces=for gg=1 to $.selectedfaces.count collect $.selectedfaces[gg].index VertListIn=(meshop.getvertsusingface $ $.selectedfaces) as array setnumTVerts $ ($.numtverts+VertList.count) true ) Editable_poly: ( OldTVerts=polyop.getNumMapVerts $ 1 SelFaces=(polyop.getfaceselection $) as array VertListIn=(polyop.getvertsusingface $ $.selectedfaces) as array polyop.setNumMapVerts $ 1 (OldTVerts+VertList.count) keep:true ) )--case (classof $)... local MinX=amin tmpVX local MaxX=amax tmpVX local MinY=amin tmpVY local MaxY=amax tmpVY local XScale=MaxX-MinX local YScale=MaxY-MinY local TmpTX=#() local TmpTY=#() for gg=1 to VertList.count do ( tmpV=VertList[gg] tmpV.x=CMinX+( ((tmpV.x-MinX)/XScale)*(CMaxX-CMinX) ) tmpV.y=CMinY+( ((tmpV.y-MinY)/YScale)*(CMaxY-CMinY) ) case (classof $) of ( Editable_mesh: (setTVert $ (OldTVerts+gg) tmpV) Editable_poly: (polyop.setmapVert $ 1 (OldTVerts+gg) tmpV) ) ) case (classof $) of ( Editable_mesh: ( for gg=1 to $.SelectedFaces.count do ( local TmpFace=getface $ $.SelectedFaces[gg].index local V1=OldTVerts+(finditem VertListIn TmpFace.x) local V2=OldTVerts+(finditem VertListIn TmpFace.y) local V3=OldTVerts+(finditem VertListIn TmpFace.z) setTVFace $ $.SelectedFaces[gg].index [V1,V2,V3] ) ) Editable_poly: ( for gg=1 to SelFaces.count do ( local TmpFace=polyop.getfaceverts $ SelFaces[gg] local VTable=#() for Loop=1 to TmpFace.count do ( append VTable (OldTVerts+(finditem VertListIn TmpFace[Loop])) ) polyop.setmapface $ 1 $.SelectedFaces[gg].index VTable ) ) )--case (classof $) of... update $ gc light:true ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn NormalAlignExec B = ( local Norm=[0,0,0] local GG=1, TT local TransFormMat if keyboard.controlpressed==true then ( if keyboard.altpressed==true then ( viewport.settm ( rotatez (viewport.gettm()) 45 ) ) else ( viewport.settm ( rotatez (viewport.gettm()) 90 ) ) ) else ( if (classof B)==Editable_Mesh do ( while GG<=B.selectedfaces.count do (Norm=Norm+(getfacenormal B B.selectedfaces[GG].index); GG+=1) Norm=Norm/[B.selectedfaces.count,B.selectedfaces.count,B.selectedfaces.count] TransFormMat=( MatrixFromNormal Norm ) tmpV=meshop.getvertsusingFace B(getfaceselection B); setvertselection B tmpV ) if (Classof B)==Editable_Poly do ( while GG<=B.selectedfaces.count do (Norm=Norm+(polyop.getfacenormal B B.selectedfaces[GG].index); GG+=1) Norm=Norm/[B.selectedfaces.count,B.selectedfaces.count,B.selectedfaces.count] TransFormMat=( MatrixFromNormal Norm ) tmpV=polyop.getvertsusingFace B(getfaceselection B); polyop.setvertselection B tmpV ) TransFormMat= orthogonalize TransFormMat GV=viewport.gettype() if GV==#view_Front or GV==#view_Back or GV==#view_Left or GV==#view_Right or GV==#view_Top or GV==#view_Bottom or GV==#view_iso_user then ( viewport.settype #view_iso_user ) else ( max vpt persp user ) viewport.setTM (inverse TransFormMat) max zoomext sel )--if keyboard.controlpressed do... gc light:true ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn ConformUVs UVPos UVScale = ( local UVMin=[999.0,999.0,0.0], UVMax=[0.0,0.0,0.0] local UVset=#() for gg=1 to $.selectedfaces.count do ( local TmpFce=getTVFace $ $.selectedfaces[gg].index local TmpVrt=getTVert $ TmpFce.x if TmpVrt.x<=UVMin.x do (UVMin.x=TmpVrt.x) if TmpVrt.y<=UVMin.y do (UVMin.y=TmpVrt.y) if TmpVrt.x>=UVMax.x do (UVMax.x=TmpVrt.x) if TmpVrt.y>=UVMax.y do (UVMax.y=TmpVrt.y) if (finditem UVSet TmpFce.x)==0 do (append UVSet TmpFce.x) local TmpVrt=getTVert $ TmpFce.y if TmpVrt.x<=UVMin.x do (UVMin.x=TmpVrt.x) if TmpVrt.y<=UVMin.y do (UVMin.y=TmpVrt.y) if TmpVrt.x>=UVMax.x do (UVMax.x=TmpVrt.x) if TmpVrt.y>=UVMax.y do (UVMax.y=TmpVrt.y) if (finditem UVSet TmpFce.y)==0 do (append UVSet TmpFce.y) local TmpVrt=getTVert $ TmpFce.z if TmpVrt.x<=UVMin.x do (UVMin.x=TmpVrt.x) if TmpVrt.y<=UVMin.y do (UVMin.y=TmpVrt.y) if TmpVrt.x>=UVMax.x do (UVMax.x=TmpVrt.x) if TmpVrt.y>=UVMax.y do (UVMax.y=TmpVrt.y) if (finditem UVSet TmpFce.z)==0 do (append UVSet TmpFce.z) ) --RESET UV POSITIONS UVMax=UVScale/(UVMax-UVMin) for gg=1 to UVSet.count do ( local tmpVrt=getTvert $ UVSet[gg] tmpVrt.x=UVPos.x+((TmpVrt.x-UVMin.x)*UVMax.x) tmpVrt.y=UVPos.y+((TmpVrt.y-UVMin.y)*UVMax.y) tmpVrt.z=0.0 setTvert $ UVSet[gg] tmpVrt ) update $ ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn QUADMapPro tmpp = ( local getQverts=#(), SetQverts=(), tmptri=#(), FaceA, FaceB, TFaceA, TFaceB, TVert=#(), TVertAdd=0 local bufcount=1, tt=1 try ( if tmpp==2 do ( case (classof $) of ( Editable_mesh: ( TVertAdd=($.numtverts+1) setnumtverts $ ($.numtverts+($.selectedfaces.count*3)) true for gg=1 to $.selectedfaces.count do ( settvert $ (TVertAdd ) (gettvert $ (getTVface $ facebuffer[bufcount]).x) settvert $ (TVertAdd+1) (gettvert $ (getTVface $ facebuffer[bufcount]).y) settvert $ (TVertAdd+2) (gettvert $ (getTVface $ facebuffer[bufcount]).z) setTVface $ $.selectedfaces[gg].index (TVertAdd ) (TVertAdd+1) (TVertAdd+2) setfacematId $ $.selectedfaces[gg].index (getfacematid $ facebuffer[bufcount]) bufcount +=1 ; if bufcount>facebuffer.count do (bufcount=1) TVertadd+=3 ) ) Editable_Poly: ( for gg=1 to $.selectedfaces.count do ( local TVs=polyop.getmapface $ 1 $.selectedfaces[gg].index local CopTVs=polyop.getmapface $ 1 facebuffer[bufcount] local CountTV=(polyop.getnummapverts $ 1)+1 local TVarray=#() tt=1 polyop.setnummapverts $ 1 (CountTV+TVs.count) keep:true for pp =1 to TVs.count do ( polyop.setmapvert $ 1 (CountTV+pp) (polyop.getmapvert $ 1 CopTVs[tt]) append TVarray (CountTV+pp) tt+=1 ; if tt>CopTVs.count do (tt=1) ) polyop.setmapface $ 1 $.selectedfaces[gg].index TVarray polyop.setFaceMatId $ $.selectedfaces[gg].index (polyop.getFaceMatId $ facebuffer[bufcount]) bufcount +=1 ; if bufcount>facebuffer.count do (bufcount=1) ) ) ) ) if facebuffer.count==2 or tmpp==1 do ( TVertAdd=($.numtverts+1) --*********************************************************************GETQVERTS 1-2=open 3-4=shared try ( FaceA=getface $ facebuffer[1] FaceB=getface $ facebuffer[2] TFaceA=getTVface $ facebuffer[1] TFaceB=getTVface $ facebuffer[2] Tvert[1]=gettvert $ TFaceB.x ; Tvert[2]=gettvert $ TFaceB.y ; Tvert[3]=gettvert $ TFaceB.z tmptri[1]=FaceA.x ; tmptri[2]=FaceA.y ; tmptri[3]=FaceA.z if (finditem tmptri FaceB.x)==0 do ( getQverts[1]=Tvert[1] ; getQverts[3]=Tvert[2] ; getQverts[4]=Tvert[3] ) if (finditem tmptri FaceB.y)==0 do ( getQverts[1]=Tvert[2] ; getQverts[3]=Tvert[1] ; getQverts[4]=Tvert[3] ) if (finditem tmptri FaceB.z)==0 do ( getQverts[1]=Tvert[3] ; getQverts[3]=Tvert[1] ; getQverts[4]=Tvert[2] ) Tvert[1]=gettvert $ TFaceA.x ; Tvert[2]=gettvert $ TFaceA.y ; Tvert[3]=gettvert $ TFaceA.z tmptri[1]=FaceB.x ; tmptri[2]=FaceB.y ; tmptri[3]=FaceB.z if (finditem tmptri FaceA.x)==0 do ( getQverts[2]=TVert[1] ) if (finditem tmptri FaceA.y)==0 do ( getQverts[2]=TVert[2] ) if (finditem tmptri FaceA.z)==0 do ( getQverts[2]=TVert[3] ) ) catch() --*********************************************************************SETQVERTS 1-2=open 3-4=shared setnumtverts $ ($.numtverts+($.selectedfaces.count*3)) true gg=1 while gg < $.selectedfaces.count do ( if tmpp==0 do ( settvert $ (TVertAdd ) getQverts[2] settvert $ (TVertAdd+1) getQverts[1] settvert $ (TVertAdd+2) getQverts[3] settvert $ (TVertAdd+3) getQverts[4] ) if tmpp==1 do ( settvert $ (TVertAdd+3) [1,1,0] settvert $ (TVertAdd+2) [0,0,0] settvert $ (TVertAdd+1) [1,0,0] settvert $ (TVertAdd+0) [0,1,0] ) if facebuffer.count==2 or tmpp==1 do ( try ( if tmpp==0 do ( setfacematId $ $.selectedfaces[gg].index (getfacematid $ facebuffer[1]) setfacematId $ $.selectedfaces[gg+1].index (getfacematid $ facebuffer[2]) ) FaceA=getface $ $.selectedfaces[gg].index FaceB=getface $ $.selectedfaces[gg+1].index tmptri[1]=FaceB.x ; tmptri[2]=FaceB.y ; tmptri[3]=FaceB.z if (finditem tmptri FaceA.x)==0 do ( settvface $ $.selectedfaces[gg].index (TVertAdd ) (TVertAdd+2) (TVertAdd+3) ) if (finditem tmptri FaceA.y)==0 do ( settvface $ $.selectedfaces[gg].index (TVertAdd+3) (TVertAdd ) (TVertAdd+2) ) if (finditem tmptri FaceA.z)==0 do ( settvface $ $.selectedfaces[gg].index (TVertAdd+2) (TVertAdd+3) (TVertAdd ) ) tmptri[1]=FaceA.x ; tmptri[2]=FaceA.y ; tmptri[3]=FaceA.z if (finditem tmptri FaceB.x)==0 do ( settvface $ $.selectedfaces[gg+1].index (TVertAdd+1) (TVertAdd+3) (TVertAdd+2) ) if (finditem tmptri FaceB.y)==0 do ( settvface $ $.selectedfaces[gg+1].index (TVertAdd+2) (TVertAdd+1) (TVertAdd+3) ) if (finditem tmptri FaceB.z)==0 do ( settvface $ $.selectedfaces[gg+1].index (TVertAdd+3) (TVertAdd+2) (TVertAdd+1) ) ) catch() ) gg +=2 ; TVertAdd +=4 ) --*********************************************************************SETQVERTS 1-2=open 3-4=shared ) update $ ) catch() ) --**************************************************************************************************QUAD MAP PRO --************************************************************************************************************** fn SelfIllum = ( for gg=1 to $geometry.count do ( if classof $geometry[gg]==editable_mesh do ( if classof $geometry[gg].material==standardmaterial do ( try ( $geometry[gg].material.useselfillumcolor=off $geometry[gg].material.selfIllumAmount = 100 ) catch() ) if classof $geometry[gg].material==multimaterial do ( for ff=1 to $geometry[gg].material.count do ( try ( $geometry[gg].material[ff].useselfillumcolor=off $geometry[gg].material[ff].selfIllumAmount = 100 ) catch() ) ) ) ) ) fn UndoTask UndoType = ( if UndoType==1 do ( --try --( case (classof $) of ( Editable_mesh: ( setnumtverts StoredObject StoredUVCount true for FaceCount=1 to StoredFaces.count do ( setfacematId storedobject StoredFaces[Facecount] StoredID[FaceCount] setTVface StoredObject StoredFaces[FaceCount] StoredUVCoords[FaceCount] ) ) Editable_poly: ( polyop.setnummapverts StoredObject 1 StoredUVCount keep:true for FaceCount=1 to StoredFaces.count do ( polyop.setFaceMatId storedobject StoredFaces[Facecount] StoredID[FaceCount] polyop.setmapface StoredObject 1 StoredFaces[FaceCount] StoredUVCoords[FaceCount] ) ) ) update StoredObject --) --catch() ) ) --************************************************************************************************** fn RemoveMatID Mat = ( local selfacetmp=#(), countup=1, aa, tmpID mat=mod mat $.material.count if mat==0 do (mat=$.material.count) try( if $.material.count>1 and Mat<=$.material.count do ( case (classof $) of ( Editable_mesh: ( for pp=1 to $.numfaces do ( tmpID=getfacematID $ pp tmpID=mod tmpID $.material.count if tmpID==0 do (tmpID=$.material.count) if tmpID==Mat do (selfacetmp[countup]=pp ; countup+=1 ; setfacematID $ pp 1) if tmpID > Mat do (setfacematID $ pp (tmpID-1)) ) ) Editable_poly: ( for pp=1 to $.numfaces do ( tmpID=polyop.getfacematID $ pp tmpID=mod tmpID $.material.count if tmpID==0 do (tmpID=$.material.count) if tmpID==Mat do (selfacetmp[countup]=pp ; countup+=1 ; polyop.setfacematID $ pp 1) if tmpID > Mat do (polyop.setfacematID $ pp (tmpID-1)) ) ) ) if countup>1 do (aa=querybox "Some faces contain the removed material ID. Do you wish me to select them?" if aa==true do (setfaceselection $ selfacetmp) ) for pp=(Mat+1) to $.material.count do ( selection[1].material[pp-1]=selection[1].material[pp] showTextureMap $.material[pp-1] on ) $.material.count -=1 showTextureMap $.material[$.material.count] $.material[$.material.count].diffuseMap on ) update $ ) catch() ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn RotateMultiFaces= ( local AxisPos=[0,0,0] , ang=90.0 , angcalc=rotateZmatrix ang local Xmin=9999999.0, Ymin=9999999.0, Xmax=0.0, Ymax=0.0, xratio, yratio,TVertadd, cpy local tt=1, bufcount=1 --****************************************************************************************** case (classof $) of ( Editable_mesh: ( TVertAdd=($.numtverts+1) setnumtverts $ ($.numtverts+($.selectedfaces.count*3)) true for gg=1 to $.selectedfaces.count do ( settvert $ (TVertAdd ) (gettvert $ (getTVface $ $.selectedfaces[gg].index).x) settvert $ (TVertAdd+1) (gettvert $ (getTVface $ $.selectedfaces[gg].index).y) settvert $ (TVertAdd+2) (gettvert $ (getTVface $ $.selectedfaces[gg].index).z) setTVface $ $.selectedfaces[gg].index (TVertAdd ) (TVertAdd+1) (TVertAdd+2) TVertadd+=3 ) ) Editable_Poly: ( for gg=1 to $.selectedfaces.count do ( local TVs=polyop.getmapface $ 1 $.selectedfaces[gg].index local CountTV=(polyop.getnummapverts $ 1)+1 local TVarray=#() tt=1 polyop.setnummapverts $ 1 (CountTV+TVs.count) keep:true for pp =1 to TVs.count do ( polyop.setmapvert $ 1 (CountTV+pp) (polyop.getmapvert $ 1 TVs[pp]) append TVarray (CountTV+pp) ) polyop.setmapface $ 1 $.selectedfaces[gg].index TVarray ) ) ) --****************************************************************************************** local tmpv=#() for gg=1 to $.selectedfaces.count do ( case (classof $) of ( editable_Mesh: ( append tmpv (getTvert $ (getTVface $ $.selectedfaces[gg].index).x) append tmpv (getTvert $ (getTVface $ $.selectedfaces[gg].index).y) append tmpv (getTvert $ (getTVface $ $.selectedfaces[gg].index).z) ) editable_poly: ( local faceverts=polyop.getmapface $ 1 $.selectedfaces[gg].index for zz=1 to faceverts.count do ( append tmpv (polyop.getmapvert $ 1 faceverts[zz]) ) ) ) for pp=1 to tmpv.count do ( if tmpv[PP].xXmax do (Xmax=tmpv[PP].x) ; if tmpv[PP].y>Ymax do (Ymax=tmpv[PP].y) ) ) yratio=(ymax-ymin)/(xmax-xmin) ; xratio=(xmax-xmin)/(ymax-ymin) AxisPos.x=(Xmin+((Xmax-Xmin)/2)) ; AxisPos.y=(Ymin+((Ymax-Ymin)/2)) case (classof $) of ( editable_mesh: ( for tt=1 to $.selectedfaces.count do ( Vertpos=getTvert $ (getTVface $ $.selectedfaces[tt].index).x Vertpos -=AxisPos ; Vertpos *=angcalc ; VertPos.x*=xratio ; VertPos.y*=yratio ; VertPos +=AxisPos setTvert $ (getTVface $ $.selectedfaces[tt].index).x Vertpos --******* Vertpos=getTvert $ (getTVface $ $.selectedfaces[tt].index).y Vertpos -=AxisPos ; Vertpos *=angcalc ; VertPos.x*=xratio ; VertPos.y*=yratio ; VertPos +=AxisPos setTvert $ (getTVface $ $.selectedfaces[tt].index).y Vertpos --******* Vertpos=getTvert $ (getTVface $ $.selectedfaces[tt].index).z Vertpos -=AxisPos ; Vertpos *=angcalc ; VertPos.x*=xratio ; VertPos.y*=yratio ; VertPos +=AxisPos setTvert $ (getTVface $ $.selectedfaces[tt].index).z Vertpos ) ) editable_poly: ( for tt=1 to $.selectedfaces.count do ( local faceverts=polyop.getmapface $ 1 $.selectedfaces[tt].index for zz=1 to faceverts.count do ( Vertpos=polyop.getmapvert $ 1 faceverts[zz] Vertpos -=AxisPos ; Vertpos *=angcalc ; VertPos.x*=xratio ; VertPos.y*=yratio ; VertPos +=AxisPos polyop.setmapvert $ 1 faceverts[zz] Vertpos ) ) ) ) update $ ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^POLY HERE fn FlippingPolys FlipStatus = ( try ( local TmpFaces=$.selectedfaces, TmpOrigin=[0,0,0] --, addon=1 local Xmin=9999999.0, Ymin=9999999.0, Xmax=0.0, Ymax=0.0 local tmpcount=1 --************************ PSTFACE=(Polyop.GetNumMapVerts $ 1)+1 for pp=1 to $.selectedfaces.count do tmpcount+=(polyop.getfaceverts $ $.selectedfaces[pp].index).count Polyop.setnumMapverts $ 1 ((Polyop.GetNumMapVerts $ 1)+tmpcount) keep:true for PSF=1 to $.selectedfaces.count do ( local tmparr=#(), OLDPST=PSTFACE cpy=Polyop.getMapface $ 1 $.selectedfaces[PSF].index for tt=1 to cpy.count do append tmparr (PSTFACE+tt) Polyop.setMapface $ 1 $.selectedfaces[PSF].index tmparr for tt=1 to cpy.count do ( Polyop.setMapvert $ 1 (PSTFACE+tt) (Polyop.getMapvert $ 1 cpy[tt]) ) PSTFACE+=cpy.count ) --************************ for gg=1 to TmpFaces.count do ( cpy=Polyop.getMapface $ 1 $.selectedfaces[gg].index for tt=1 to cpy.count do ( tmp=Polyop.getMapvert $ 1 cpy[tt] if tmp.xXmax do (Xmax=tmp.x) ; if tmp.y>Ymax do (Ymax=tmp.y) ) ) TmpOrigin.x=Xmin+((Xmax-Xmin)/2) ; TmpOrigin.y=Ymin+((Ymax-Ymin)/2) for gg=1 to TmpFaces.count do ( cpy=Polyop.getMapface $ 1 $.selectedfaces[gg].index local keytest=keyboard.controlpressed local normalflip=1 if keytest==true do NormalFlip=0 if NormalFlip==0 do ( if cpy.count==4 then ( case FlipStatus of ( 1:( tmpTVert=polyop.getMapvert $ 1 cpy[1] polyop.setMapvert $ 1 cpy[1] (polyop.getMapvert $ 1 cpy[2]) polyop.setMapvert $ 1 cpy[2] tmpTVert tmpTVert=polyop.getMapvert $ 1 cpy[3] polyop.setMapvert $ 1 cpy[3] (polyop.getMapvert $ 1 cpy[4]) polyop.setMapvert $ 1 cpy[4] tmpTVert ) 2:( tmpTVert=polyop.getMapvert $ 1 cpy[1] polyop.setMapvert $ 1 cpy[1] (polyop.getMapvert $ 1 cpy[4]) polyop.setMapvert $ 1 cpy[4] tmpTVert tmpTVert=polyop.getMapvert $ 1 cpy[2] polyop.setMapvert $ 1 cpy[2] (polyop.getMapvert $ 1 cpy[3]) polyop.setMapvert $ 1 cpy[3] tmpTVert ) ) ) else ( NormalFlip=1 ) ) if NormalFlip==1 do ( for tt=1 to cpy.count do ( tmpTVert=polyop.getMapvert $ 1 cpy[tt] case FlipStatus of ( 1: tmpTVert.x=TmpOrigin.x+(TmpOrigin.x-TmpTVert.x) 2: tmpTVert.y=TmpOrigin.y+(TmpOrigin.y-TmpTVert.y) ) polyop.setMapvert $ 1 cpy[tt] tmpTvert ) ) ) update $ ) catch() ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^POLY HERE fn FlippingFaces FlipStatus = ( try ( local TmpFaces=$.selectedfaces, TmpOrigin=[0,0,0], addon=1 local Xmin=9999999.0, Ymin=9999999.0, Xmax=0.0, Ymax=0.0 --************************ PSTFACE=(Meshop.GetNumMapVerts $ 1)+1 meshop.setnumMapverts $ 1 ((Meshop.GetNumMapVerts $ 1)+($.selectedfaces.count*3)) keep:true for PSF=1 to $.selectedfaces.count do ( cpy=meshop.getMapface $ 1 $.selectedfaces[PSF].index meshop.setMapvert $ 1 PSTFACE (meshop.getMapvert $ 1 cpy.x) meshop.setMapvert $ 1 (PSTFACE+1) (meshop.getMapvert $ 1 cpy.y) meshop.setMapvert $ 1 (PSTFACE+2) (meshop.getMapvert $ 1 cpy.z) meshop.setMapface $ 1 $.selectedfaces[PSF].index [PSTFACE, (PSTFACE+1), (PSTFACE+2)] PSTFACE=PSTFACE+3 ) --************************ for gg=1 to TmpFaces.count do ( tmpv1=meshop.getMapvert $ 1 (meshop.getMapface $ 1 TmpFaces[gg].index).x tmpv2=meshop.getMapvert $ 1 (meshop.getMapface $ 1 TmpFaces[gg].index).y tmpv3=meshop.getMapvert $ 1 (meshop.getMapface $ 1 TmpFaces[gg].index).z if tmpv1.xXmax do (Xmax=tmpv1.x) ; if tmpv1.y>Ymax do (Ymax=tmpv1.y) if tmpv2.x>Xmax do (Xmax=tmpv2.x) ; if tmpv2.y>Ymax do (Ymax=tmpv2.y) if tmpv3.x>Xmax do (Xmax=tmpv3.x) ; if tmpv3.y>Ymax do (Ymax=tmpv3.y) ) TmpOrigin.x=Xmin+((Xmax-Xmin)/2) ; TmpOrigin.y=Ymin+((Ymax-Ymin)/2) for gg=1 to TmpFaces.count do ( tmpTVert1=meshop.getMapvert $ 1 (meshop.getMapface $ 1 TmpFaces[addon].index).x tmpTVert2=meshop.getMapvert $ 1 (meshop.getMapface $ 1 TmpFaces[addon].index).y tmpTVert3=meshop.getMapvert $ 1 (meshop.getMapface $ 1 TmpFaces[addon].index).z if FlipStatus==1 do ( tmp=TmpOrigin.x+(TmpOrigin.x-TmpTvert1.x) tmpTvert1.x=tmp tmp=TmpOrigin.x+(TmpOrigin.x-TmpTvert2.x) tmpTvert2.x=tmp tmp=TmpOrigin.x+(TmpOrigin.x-TmpTvert3.x) tmpTvert3.x=tmp ) if FlipStatus==2 do ( tmp=TmpOrigin.y+(TmpOrigin.y-TmpTvert1.y) tmpTvert1.y=tmp tmp=TmpOrigin.y+(TmpOrigin.y-TmpTvert2.y) tmpTvert2.y=tmp tmp=TmpOrigin.y+(TmpOrigin.y-TmpTvert3.y) tmpTvert3.y=tmp ) meshop.setMapvert $ 1 (meshop.getMapface $ 1 TmpFaces[addon].index).x tmpTvert1 meshop.setMapvert $ 1 (meshop.getMapface $ 1 TmpFaces[addon].index).y tmpTvert2 meshop.setMapvert $ 1 (meshop.getMapface $ 1 TmpFaces[addon].index).z tmpTvert3 addon=addon+1 ) --update $ ) catch() ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn UVCopy = ( try ( OBJ=selection[1] local FceBffr=OBJ.selectedFaces FaceBuffer=for k=1 to OBJ.selectedFaces.count collect FceBffr[k].index case (classof $) of ( Editable_poly: (FaceIDs=for k=1 to OBJ.selectedFaces.count collect polyop.getfacematID OBJ FceBffr[k].index) Editable_mesh: (FaceIDs=for k=1 to OBJ.selectedFaces.count collect getfacematID OBJ FceBffr[k].index) ) ) catch() )--fn UVCopy... fn UVpaste = ( try ( StoreUVs() case (classof $) of ( Editable_mesh: ( if facebuffer.count==2 do ( QUADMapPro 0 ) if facebuffer.count!=2 do ( QUADMapPro 2 ) ) Editable_Poly: ( QUADMapPro 2 ) ) ) catch() )--fn UVPaste... --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn FlipX = ( try(OBJ2=selection[1]) ; catch() try ( StoreUVs() if (classof $)==editable_mesh do ( if $.selectedfaces.count<3 then ( norm=#() ; chk=0 if OBJ2.selectedfaces.count>=1 do ( FA=meshop.getMapface OBJ2 1 OBJ2.selectedfaces[1].index ) if OBJ2.selectedfaces.count==1 do (meshop.setMapface OBJ2 1 OBJ2.selectedfaces[1].index [FA.x, FA.z, FA.y] ; update OBJ2) if OBJ2.selectedfaces.count==2 do ( FB=meshop.getMapface OBJ2 1 OBJ2.selectedfaces[2].index VAx=meshop.getMapvert OBJ2 1 FA.x VAy=meshop.getMapvert OBJ2 1 FA.y VAz=meshop.getMapvert OBJ2 1 FA.z VBx=meshop.getMapvert OBJ2 1 FB.x VBy=meshop.getMapvert OBJ2 1 FB.y VBz=meshop.getMapvert OBJ2 1 FB.z if VAx!=VBx and VAx!=VBy and VAx!=VBz do (norm[1]=FA.x ; chk=chk+1) if VAy!=VBx and VAy!=VBy and VAy!=VBz do (norm[1]=FA.y ; chk=chk+1) if VAz!=VBx and VAz!=VBy and VAz!=VBz do (norm[1]=FA.z ; chk=chk+1) if chk >1 do (chk=3) if VBx!=VAx and VBx!=VAy and VBx!=VAz do (norm[2]=FB.x ; chk=chk+1) if VBy!=VAx and VBy!=VAy and VBy!=VAz do (norm[2]=FB.y ; chk=chk+1) if VBz!=VAx and VBz!=VAy and VBz!=VAz do (norm[2]=FB.z ; chk=chk+1) if chk==2 do ( if FA.x==norm[1] do (tmp=[FA.y,FA.x,norm[2]]) if FA.y==norm[1] do (tmp=[norm[2],FA.z,FA.y]) if FA.z==norm[1] do (tmp=[FA.z,norm[2],FA.x]) if FB.x==norm[2] do (meshop.setMapface OBJ2 1 OBJ2.selectedfaces[2].index [FB.y,FB.x,norm[1]]) if FB.y==norm[2] do (meshop.setMapface OBJ2 1 OBJ2.selectedfaces[2].index [norm[1],FB.z,FB.y]) if FB.z==norm[2] do (meshop.setMapface OBJ2 1 OBJ2.selectedfaces[2].index [FB.z,norm[1],FB.x]) meshop.setMapface OBJ2 1 OBJ2.selectedfaces[1].index tmp ) ) ) else ( FlippingFaces 1 ) ) if (classof $)==editable_poly do FlippingPolys 1 ) catch() try(update OBJ2) ; catch() )--FlipX pressed... --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn FlipY = ( try(OBJ2=selection[1]) ; catch() try ( StoreUVs() if (classof $)==editable_mesh then ( if $.selectedfaces.count<3 then ( norm=#() ; chk=0 if OBJ2.selectedfaces.count>=1 do ( FA=meshop.getMapface OBJ2 1 OBJ2.selectedfaces[1].index ) if OBJ2.selectedfaces.count==1 do (meshop.setMapface OBJ2 1 OBJ2.selectedfaces[1].index [FA.y, FA.x, FA.z] ; update OBJ2) if OBJ2.selectedfaces.count==2 do ( FB=meshop.getMapface OBJ2 1 OBJ2.selectedfaces[2].index VAx=meshop.getMapvert OBJ2 1 FA.x VAy=meshop.getMapvert OBJ2 1 FA.y VAz=meshop.getMapvert OBJ2 1 FA.z VBx=meshop.getMapvert OBJ2 1 FB.x VBy=meshop.getMapvert OBJ2 1 FB.y VBz=meshop.getMapvert OBJ2 1 FB.z if VAx!=VBx and VAx!=VBy and VAx!=VBz do (norm[1]=FA.x ; chk=chk+1) if VAy!=VBx and VAy!=VBy and VAy!=VBz do (norm[1]=FA.y ; chk=chk+1) if VAz!=VBx and VAz!=VBy and VAz!=VBz do (norm[1]=FA.z ; chk=chk+1) if chk >1 do (chk=3) if VBx!=VAx and VBx!=VAy and VBx!=VAz do (norm[2]=FB.x ; chk=chk+1) if VBy!=VAx and VBy!=VAy and VBy!=VAz do (norm[2]=FB.y ; chk=chk+1) if VBz!=VAx and VBz!=VAy and VBz!=VAz do (norm[2]=FB.z ; chk=chk+1) if chk==2 do ( if FA.x==norm[1] do (tmp=[FA.z,norm[2],FA.x]) if FA.y==norm[1] do (tmp=[FA.y,FA.x,norm[2]]) if FA.z==norm[1] do (tmp=[norm[2],FA.z,FA.y]) if FB.x==norm[2] do (meshop.setMapface OBJ2 1 OBJ2.selectedfaces[2].index [FB.z,norm[1],FB.x]) if FB.y==norm[2] do (meshop.setMapface OBJ2 1 OBJ2.selectedfaces[2].index [FB.y,FB.x,norm[1]]) if FB.z==norm[2] do (meshop.setMapface OBJ2 1 OBJ2.selectedfaces[2].index [norm[1],FB.z,FB.y]) meshop.setMapface OBJ2 1 OBJ2.selectedfaces[1].index tmp ) ) ) else ( flippingfaces 2 ) ) else ( if (classof $)==editable_poly do FlippingPolys 2 ) ) catch() try(update OBJ2) ; catch() )--FlipY pressed --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn Rotateit = ( try ( StoreUVs() OBJ2=selection[1] norm=#() ; chk=0 if (classof $)==editable_mesh do ( if OBJ2.selectedfaces.count>=1 do ( FA=getTVface OBJ2 OBJ2.selectedfaces[1].index ) if OBJ2.selectedfaces.count==1 do (setTVface OBJ2 OBJ2.selectedfaces[1].index [FA.z, FA.x, FA.y] ; update OBJ2) if OBJ2.selectedfaces.count==2 do ( FB=getTVface OBJ2 OBJ2.selectedfaces[2].index VAx=gettvert OBJ2 FA.x VAy=gettvert OBJ2 FA.y VAz=gettvert OBJ2 FA.z VBx=gettvert OBJ2 FB.x VBy=gettvert OBJ2 FB.y VBz=gettvert OBJ2 FB.z if VAx!=VBx and VAx!=VBy and VAx!=VBz do (norm[1]=FA.x ; chk=chk+1) if VAy!=VBx and VAy!=VBy and VAy!=VBz do (norm[1]=FA.y ; chk=chk+1) if VAz!=VBx and VAz!=VBy and VAz!=VBz do (norm[1]=FA.z ; chk=chk+1) if chk >1 do (chk=3) if VBx!=VAx and VBx!=VAy and VBx!=VAz do (norm[2]=FB.x ; chk=chk+1) if VBy!=VAx and VBy!=VAy and VBy!=VAz do (norm[2]=FB.y ; chk=chk+1) if VBz!=VAx and VBz!=VAy and VBz!=VAz do (norm[2]=FB.z ; chk=chk+1) if chk==2 do ( if FA.x==norm[1] do (setTVface OBJ2 OBJ2.selectedfaces[1].index [FA.z,FA.x,norm[2]]) if FA.y==norm[1] do (setTVface OBJ2 OBJ2.selectedfaces[1].index [norm[2],FA.x,FA.y]) if FA.z==norm[1] do (setTVface OBJ2 OBJ2.selectedfaces[1].index [FA.z,norm[2],FA.y]) if FB.x==norm[2] do (setTVface OBJ2 OBJ2.selectedfaces[2].index [FB.z,FB.x,norm[1]]) if FB.y==norm[2] do (setTVface OBJ2 OBJ2.selectedfaces[2].index [norm[1],FB.x,FB.y]) if FB.z==norm[2] do (setTVface OBJ2 OBJ2.selectedfaces[2].index [FB.z,norm[1],FB.y]) ) update OBJ2 ) ) if OBJ2.selectedfaces.count>2 or (classof $)==editable_poly do ( RotateMultiFaces() ) ) catch() ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn FaceMapit = ( case (classof $selection[1]) of ( editable_mesh: (if (meshop.getMapSupport $ 1)==false do (meshop.setMapSupport $ 1 true ; buildTVFaces $ true) ; StoreUVs() ; QUADmappro 1 ) editable_poly: (if (polyop.getMapSupport $ 1)==false do (polyop.setMapSupport $ 1 true ; polyop.defaultmapfaces $ 1) ; StoreUVs() ; POLYfacemap() ) ) update $ ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn UVOptimize = ( local tverttable=#(), FaceTable=#(), tmp, NewVCFace, OldCVertCount=0, tt=0 local prog, progadd=0.0 GameToolsExecutiveRoll.ProgressB.value=0.0 GameToolsExecutiveRoll.ProgressB.pos=[2,63] try ( if (classof $selection[1])==editable_poly then ( if (polyop.getnumMapverts $ 1)!=0 do ( FaceTable=#() ; OldCVertCount=0 ; tt=0 progadd=0.0 gc light:true prog=100.0/($.numfaces as float) OldCVertCount=(polyop.getnumMapverts $ 1) for gg=1 to $.numfaces do ( NewVCFace=polyop.getmapface $ 1 gg for tt=1 to NewVCFace.count do ( tvert=polyop.getmapvert $ 1 NewVCFace[tt] tmp=finditem tverttable tvert if tmp==0 do (append tverttable tvert ; NewVCFace[tt]=tverttable.count) if tmp!=0 do (NewVCFace[tt]=tmp) ) append FaceTable NewVCFace progadd+=prog GameToolsExecutiveRoll.ProgressB.value=Progadd if heapfree<1000000 do ( gc light:true ; heapsize+=10000000 ) ) polyop.setnumMapverts $ 1 tvertTable.count keep:true for gg=1 to tVertTable.count do (polyop.setmapvert $ 1 gg TVertTable[gg]) for gg=1 to FaceTable.count do (polyop.setmapface $ 1 gg FaceTable[gg]) update $ GameToolsExecutiveRoll.ProgressB.pos=[-100,0] GameToolsExecutiveRoll.UVInformation.text=((OldCVertCount-(polyop.getnummapverts $ 1)) as string)+" texture vertices removed" tverttable=#() ; FaceTable=#() ; OldCVertCount=0 ; tt=0 progadd=0.0 gc light:true GameToolsExecutiveRoll.ProgressB.value=0 ) )--if (classof $selection[1])==editable_poly else ( GameToolsExecutiveRoll.ProgressB.value=0 if (meshop.getnumMapverts $ 1)!=0 do ( FaceTable=#() ; OldCVertCount=0 ; tt=0 progadd=0.0 gc light:true prog=100.0/($.numfaces as float) OldCVertCount=(meshop.getnumMapverts $ 1) for gg=1 to $.numfaces do ( NewVCFace=meshop.getmapface $ 1 gg tvertX=meshop.getmapvert $ 1 (meshop.getmapface $ 1 gg).x tmp=finditem tverttable tvertX if tmp==0 do (append tverttable tvertX ; NewVCFace.x=tverttable.count) if tmp!=0 do (NewVCFace.x=tmp) tvertY=meshop.getmapvert $ 1 (meshop.getmapface $ 1 gg).y tmp=finditem tverttable tvertY if tmp==0 do (append tverttable tvertY ; NewVCFace.y=tverttable.count ) if tmp!=0 do (NewVCFace.y=tmp) tvertZ=meshop.getmapvert $ 1 (meshop.getmapface $ 1 gg).z tmp=finditem tverttable tvertZ if tmp==0 do (append tverttable tvertZ ; NewVCFace.z=tverttable.count ) if tmp!=0 do (NewVCFace.z=tmp) append FaceTable NewVCFace progadd+=prog GameToolsExecutiveRoll.ProgressB.value=Progadd if heapfree<1000000 do ( gc light:true ; heapsize+=10000000 ) ) meshop.setnumMapverts $ 1 tvertTable.count for gg=1 to tVertTable.count do (meshop.setmapvert $ 1 gg TVertTable[gg]) for gg=1 to FaceTable.count do (meshop.setmapface $ 1 gg FaceTable[gg]) update $ GameToolsExecutiveRoll.ProgressB.pos=[-100,0] GameToolsExecutiveRoll.UVInformation.text=((OldCVertCount-(meshop.getnummapverts $ 1)) as string)+" texture vertices removed" tverttable=#() ; FaceTable=#() ; OldCVertCount=0 ; tt=0 progadd=0.0 gc light:true GameToolsExecutiveRoll.ProgressB.value=0.0 )--if (meshop.getnumMapverts $ 1)!=0 )--else ) catch(GameToolsExecutiveRoll.UVInformation.text="UVToolsV3.0 - Written by A.Oakley") ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn VCOptimize = ( local tverttable=#(), FaceTable=#(), tmp, NewVCFace, OldCVertCount=0, tt=0 GameToolsExecutiveRoll.ProgressB.value=0.0 GameToolsExecutiveRoll.ProgressB.pos=[2,63] try ( if (classof $selection[1])==editable_poly then ( if (polyop.getnumMapverts $ 0)!=0 do ( FaceTable=#() ; OldCVertCount=0 ; tt=0 progadd=0.0 gc light:true prog=100.0/($.numfaces as float) OldCVertCount=(polyop.getnumMapverts $ 0) for gg=1 to $.numfaces do ( NewVCFace=polyop.getmapface $ 0 gg for tt=1 to NewVCFace.count do ( tvert=polyop.getmapvert $ 0 NewVCFace[tt] tmp=finditem tverttable tvert if tmp==0 do (append tverttable tvert ; NewVCFace[tt]=tverttable.count) if tmp!=0 do (NewVCFace[tt]=tmp) ) append FaceTable NewVCFace progadd+=prog GameToolsExecutiveRoll.ProgressB.value=ProgAdd if heapfree<1000000 do ( gc light:true ; heapsize+=10000000 ) ) polyop.setnumMapverts $ 0 tvertTable.count keep:true for gg=1 to tVertTable.count do (polyop.setmapvert $ 0 gg TVertTable[gg]) for gg=1 to FaceTable.count do (polyop.setmapface $ 0 gg FaceTable[gg]) update $ GameToolsExecutiveRoll.ProgressB.pos=[-100,0] GameToolsExecutiveRoll.UVInformation.text=((OldCVertCount-(polyop.getnummapverts $ 0)) as string)+" vertex colors removed" tverttable=#() ; FaceTable=#() ; OldCVertCount=0 ; tt=0 progadd=0.0 gc light:true ) ) else ( local prog, progadd=0.0 progadd=0.0 prog=50.0/((meshop.getnumMapverts $ 0) as float) OldCVertCount=(meshop.getnumMapverts $ 0) for gg=1 to (meshop.getnumMapverts $ 0) do ( VCol=(meshop.getmapvert $ 0 gg) as color if VCol.r>1.0 do (VCol.r=mod VCol.r 1.0 ; if VCol.r==0.0 do (VCol.r=1.0)) if VCol.g>1.0 do (VCol.g=mod VCol.g 1.0 ; if VCol.g==0.0 do (VCol.g=1.0)) if VCol.b>1.0 do (VCol.b=mod VCol.b 1.0 ; if VCol.b==0.0 do (VCol.b=1.0)) if VCol.r<0.0 do (VCol.r=0.0) if VCol.g<0.0 do (VCol.g=0.0) if VCol.b<0.0 do (VCol.b=0.0) meshop.setmapvert $ 0 gg VCol progadd+=prog GameToolsExecutiveRoll.ProgressB.value=ProgAdd ) if (meshop.getnumMapverts $ 0)!=0 do ( FaceTable=#() ; OldCVertCount=0 ; tt=0 progadd=50.0 gc light:true prog=50.0/($.numfaces as float) OldCVertCount=(meshop.getnumMapverts $ 0) for gg=1 to $.numfaces do ( NewVCFace=meshop.getmapface $ 0 gg tvertX=meshop.getmapvert $ 0 (meshop.getmapface $ 0 gg).x tmp=finditem tverttable tvertX if tmp==0 do (append tverttable tvertX ; NewVCFace.x=tverttable.count) if tmp!=0 do (NewVCFace.x=tmp) tvertY=meshop.getmapvert $ 0 (meshop.getmapface $ 0 gg).y tmp=finditem tverttable tvertY if tmp==0 do (append tverttable tvertY ; NewVCFace.y=tverttable.count ) if tmp!=0 do (NewVCFace.y=tmp) tvertZ=meshop.getmapvert $ 0 (meshop.getmapface $ 0 gg).z tmp=finditem tverttable tvertZ if tmp==0 do (append tverttable tvertZ ; NewVCFace.z=tverttable.count ) if tmp!=0 do (NewVCFace.z=tmp) append FaceTable NewVCFace progadd+=prog GameToolsExecutiveRoll.ProgressB.value=ProgAdd if heapfree<1000000 do ( gc light:true ; heapsize+=10000000 ) ) meshop.setnumMapverts $ 0 tvertTable.count for gg=1 to tVertTable.count do (meshop.setmapvert $ 0 gg TVertTable[gg]) for gg=1 to FaceTable.count do (meshop.setmapface $ 0 gg FaceTable[gg]) update $ GameToolsExecutiveRoll.ProgressB.pos=[-100,0] GameToolsExecutiveRoll.UVInformation.text=((OldCVertCount-(meshop.getnummapverts $ 0)) as string)+" vertex colors removed" tverttable=#() ; FaceTable=#() ; OldCVertCount=0 ; tt=0 progadd=0.0 gc light:true GameToolsExecutiveRoll.ProgressB.value=0.0 ) ) --else : end of ) catch(GameToolsExecutiveRoll.UVInformation.text="UVToolsV3.0 - Written by A.Oakley") ) --********************************************************************************** fn ShowBitmaps = ( local alphaview try ( if $selection.count!=0 do ( ShowTexTog=1-ShowTexTog if ShowTexTog==1 then ( Alphaview=querybox "Would you like textures displayed with alpha?" if Alphaview==false do ( for G=1 to selection[1].material.count do ( try (showtexturemap selection[1].material[G] selection[1].material[G].diffuseMap on ) ; catch() ) ) if Alphaview==true do ( for G=1 to selection[1].material.count do ( try (showTextureMap selection[1].material[G] on) ; catch() ) ) ) Else ( for G=1 to selection[1].material.count do ( try (showtexturemap selection[1].material[G] off ) ; catch() ) ) ) ) catch() ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn UndoTaskExec UndoType = ( if UndoType==1 do ( --try --( case (classof $) of ( Editable_mesh: ( setnumtverts StoredObject StoredUVCount true for FaceCount=1 to StoredFaces.count do ( setfacematId storedobject StoredFaces[Facecount] StoredID[FaceCount] setTVface StoredObject StoredFaces[FaceCount] StoredUVCoords[FaceCount] ) ) Editable_poly: ( polyop.setnummapverts StoredObject 1 StoredUVCount keep:true for FaceCount=1 to StoredFaces.count do ( polyop.setFaceMatId storedobject StoredFaces[Facecount] StoredID[FaceCount] polyop.setmapface StoredObject 1 StoredFaces[FaceCount] StoredUVCoords[FaceCount] ) ) ) update StoredObject --) --catch() ) ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn UnwrapUVCoords = ( local unwrapfaces=#() local faceid=#() local materiallist=#(), addmat=1, foundbitmap=0 try ( if classof $.material==multimaterial then ( case (classof $) of ( Editable_mesh: ( unwrapfaces=(for gg=1 to $.selectedfaces.count collect $.selectedfaces[gg].index) as bitarray ; faceid=mod (getfacematid $ $.selectedfaces[1].index) $.material.count) Editable_poly: ( unwrapfaces=polyop.getfaceselection $ ; faceid=mod (polyop.getfacematid $ (unwrapfaces as array)[1]) $.material.count) ) for pp=1 to $.material.count do ( foundbitmap=0 materiallist[pp]=addmat try(if (classof $.material[pp].diffuseMap.bitmap==bitmap) do (addmat=addmat+1 ; foundbitmap=1)) ; catch() try(if (classof $.material[pp].opacityMap.bitmap==bitmap) do (addmat=addmat+1 ; foundbitmap=1)) ; catch() ) if faceid==0 do (faceid=$.material.count) try ( $.modifiers[#unwrap_uvw].unwrap.setCurrentMap materiallist[faceid] ) catch() ) else ( case (classof $) of ( Editable_mesh: ( unwrapfaces=(for gg=1 to $.selectedfaces.count collect $.selectedfaces[gg].index) as bitarray) Editable_poly: ( unwrapfaces=polyop.getfaceselection $) ) faceid=1 materiallist[1]=1 ) try ( if modPanel.getCurrentObject()==$.baseobject and $.modifiers.count==0 do ( modPanel.setCurrentObject $.baseObject subobjectLevel = 0 modPanel.addModToSelection (Unwrap_UVW ()) ui:on modPanel.setCurrentObject $.modifiers[#Unwrap_UVW] $.modifiers[#unwrap_uvw].unwrap.selectPolygons unwrapfaces subobjectLevel = 1 $.modifiers[#unwrap_uvw].unwrap.move () $.modifiers[#unwrap_uvw].unwrap.edit () $.modifiers[#unwrap_uvw].unwrap.filterselected () $.modifiers[#unwrap_uvw].unwrap.setCurrentMap materiallist[faceid] ) ) catch() ) catch() ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn RemoveImage = ( try ( if $selection.count!=0 and GameToolsExecutiveRoll.SubMatName.enabled==true do ( local tm=querybox "This will remove the current texture.\nAre you sure?" if tm==true do ( RemoveMatID GameToolsExecutiveRoll.IDVal.value ) try(GameToolsExecutiveRoll.UVInformation.text="Number of materials now on object : "+($selection[1].material.count as string));catch() ) ) catch() OldFace=0 ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn AddImage = ( local dd, tmpit, FaceSel=#(), none=#() local text, bitmapfile local MatNode=$selection[1] disableSceneRedraw() if $selection.count!=0 do ( FaceSel=for gg=1 to $.selectedfaces.count collect $.selectedfaces[gg].index try ( if classof MatNode.material ==standardmaterial do ( MatNode.material=multimaterial numsubs:1 MatNode.material.count=1 ) if MatNode.material!=undefined then ( MatNode.material.count=MatNode.material.count+1 ) else ( setfaceselection MatNode none MatNode.material=multimaterial numsubs:0 MatNode.material.count=1 ) GameToolsExecutiveRoll.IDVal.value=MatNode.material.count local AddABitmap=querybox "Would you like to add a bitmap to the diffuse map slot?" if AddABitmap==true do ( NewMap=selectbitmap() if NewMap!=undefined do ( MatNode.material[MatNode.material.count].DiffuseMap = bitmaptexture filename:NewMap.filename ; MatNode.material[MatNode.material.count].name=(getfilenamefile NewMap.filename) ) showtexturemap MatNode.material[MatNode.material.count] on ) local ApplyToFaces=querybox "Do you want this new texture applied to the currently selected faces?" setfaceselection MatNode facesel try ( if ApplyToFaces==true do ( case (classof MatNode) of ( Editable_mesh: ( for ApplyMatId in FaceSel do (setfacematid MatNode ApplyMatId MatNode.material.count) ) Editable_poly: ( polyop.setFaceMatID MatNode FaceSel MatNode.material.count ) ) ) GameToolsExecutiveRoll.MultiMatName.text=(MatNode.material.name as string) GameToolsExecutiveRoll.SubMatName.text=""+(MatNode.material[MatNode.material.count].name as string) ) catch() GameToolsExecutiveRoll.UVInformation.text="Number of materials now on object : "+(MatNode.material.count as string) ) catch() ) enableSceneRedraw() oldFace=0 ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn CompressMaterials = ( local Prog=0.0 local ProgAdd=100.0/$selection.count GameToolsExecutiveRoll.UVInformation.text="Compressing MultiMaterials - please wait..." GameToolsExecutiveRoll.ProgressB.value=0.0 GameToolsExecutiveRoll.ProgressB.pos=[2,63] try ( if $selection.count==0 do GameToolsExecutiveRoll.UVInformation.text="ERROR! No models selected in scene" for ZZ=1 to $selection.count do ( Prog+=ProgAdd GameToolsExecutiveRoll.ProgressB.value=Prog try ( local OldSub=subobjectlevel subobjectlevel=0 local MatFaces=#(), NewMatFaces=#(), MatCount=0 local MatDiffuses=#() local newmat=multimaterial numsubs:0 local OldMatCount=$selection[ZZ].material.count local MatPos=#() newmat.name=$selection[ZZ].material.name for GG=1 to $selection[ZZ].numfaces do ( case (classof $selection[ZZ]) of ( Editable_mesh: ( tmp=(mod (getFacematID $selection[ZZ] GG) $selection[ZZ].material.count) ) Editable_poly: ( tmp=(mod (polyop.getFacematID $selection[ZZ] GG) $selection[ZZ].material.count) ) ) if tmp==0 do (tmp=$selection[ZZ].material.count) MatFaces[tmp]=true matpos[GG]=GG try(MatDiffuses[tmp]=$selection[ZZ].material[tmp].diffusemap.filename) ; catch(MatDiffuses[tmp]=undefined) ) tmpMat=#() for GG=1 to MatFaces.count do ( try (if $selection[ZZ].material[GG].diffusemap.filename!=undefined then (tmpfind=finditem MatDiffuses $selection[ZZ].material[GG].diffusemap.filename) else (tmpfind=0)) ; catch (tmpfind=0) if tmpfind!=GG and tmpfind!=0 do (MatFaces[GG]=undefined ; matpos[GG]=tmpfind) ) for GG=1 to MatFaces.count do ( if MatFaces[gg]==true do ( MatCount+=1 newmatFaces[GG]=MatCount newmat.material.count+=1 newmat.material[newmat.material.count]=$selection[ZZ].material[GG] ) ) for GG=1 to $selection[ZZ].numfaces do ( case (classof $selection[ZZ]) of ( Editable_mesh: ( tmp=(mod (getFacematID $selection[ZZ] GG) $selection[ZZ].material.count) if tmp==0 do (tmp= $selection[ZZ].material.count) setfacematID $selection[ZZ] GG NewMatFaces[MatPos[tmp]] ) Editable_poly: ( tmp=(mod (polyop.getFacematID $selection[ZZ] GG) $selection[ZZ].material.count) if tmp==0 do (tmp= $selection[ZZ].material.count) polyop.setfacematID $selection[ZZ] GG NewMatFaces[MatPos[tmp]] ) )--case... ) $.material=newmat GameToolsExecutiveRoll.UVInformation.text="Old: "+((OldMatCount as integer)as string)+" New: "+(($selection[ZZ].material.count as integer)as string)+" Removed: "+(((OldMatCount-$selection[ZZ].material.count) as integer)as string) oldface=0 if oldsub!=undefined do (subobjectlevel=OldSub) update $selection[ZZ] ForceUpdate=1 ) catch ( GameToolsExecutiveRoll.UVInformation.text="ERROR! Couldn't compress model" )--catch... )--for ZZ=1 to $selection.count do... )--try catch ( GameToolsExecutiveRoll.UVInformation.text="ERROR! Couldn't compress model" ) ProgressEnd() ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn SetSelectedID = ( local tmpfcesel=#() count=1 try ( case (classof $selection[1]) of ( Editable_mesh: ( for GG=1 to selection[1].numfaces do ( if (getfacematID selection[1] GG)==GameToolsExecutiveRoll.IDVal.value do (tmpfcesel[count]=GG ; count=count+1) ) setfaceselection $selection[1] tmpfcesel update $selection[1] ) Editable_Poly: ( for GG=1 to $selection[1].numfaces do ( if (polyop.getfacematID $selection[1] GG)==GameToolsExecutiveRoll.IDVal.value do (tmpfcesel[count]=GG ; count=count+1) ) polyop.setfaceselection $selection[1] tmpfcesel update $selection[1] ) ) )--try... catch() ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn CollectTextures = ( local SavePath=getsavepath "Output Texture Path" if SavePath!=undefined do ( local QBox=querybox "Do you want me to update the models material as well?" case (classof $.material) of ( Standardmaterial: ( try ( --"Opacity" try ( local FileAll=$.material.opacitymap.filename local Pth=getfilenamepath FileAll local Filenm=substring FileAll Pth.count FileAll.count Copyfile FileAll (SavePath+Filenm) if QBox==true do $.material.opacitymap.filename=(SavePath+Filenm) )--try... catch() --"Specular" try ( local FileAll=$.material.specularlevelmap.filename local Pth=getfilenamepath FileAll local Filenm=substring FileAll Pth.count FileAll.count copyfile FileAll (SavePath+Filenm) if QBox==true do $.material.specularlevelmap.filename=(SavePath+Filenm) )--try... catch() --"Glossiness" try ( local FileAll=$.material.glossinessmap.filename local Pth=getfilenamepath FileAll local Filenm=substring FileAll Pth.count FileAll.count copyfile FileAll (SavePath+Filenm) if QBox==true do $.material.glossinessmap.filename=(SavePath+Filenm) )--try... catch() --"Bump" try ( local FileAll=$.material.bumpmap.filename local Pth=getfilenamepath FileAll local Filenm=substring FileAll Pth.count FileAll.count copyfile FileAll (SavePath+Filenm) if QBox==true do $.material.bumpmap.filename=(SavePath+Filenm) )--try... catch() --"Reflection" try ( local FileAll=$.material.reflectionmap.filename local Pth=getfilenamepath FileAll local Filenm=substring FileAll Pth.count FileAll.count copyfile FileAll (SavePath+Filenm) if QBox==true do $.material.reflectionmap.filename=(SavePath+Filenm) )--try... catch() --"Diffuse" try ( local FileAll=$.material.diffusemap.filename local Pth=getfilenamepath FileAll local Filenm=substring FileAll Pth.count FileAll.count copyfile FileAll (SavePath+Filenm) if QBox==true do $.material.diffusemap.filename=(SavePath+Filenm) )--try... catch() ) catch() )--Standardmaterial... Multimaterial: ( for GG=1 to $.material.count do ( try ( --"Opacity" try ( local FileAll=$.material[GG].opacitymap.filename local Pth=getfilenamepath FileAll local Filenm=substring FileAll Pth.count FileAll.count copyfile FileAll (SavePath+Filenm) if QBox==true do $.material[GG].opacitymap.filename=(SavePath+Filenm) )--try... catch() --"Specular" try ( local FileAll=$.material[GG].specularlevelmap.filename local Pth=getfilenamepath FileAll local Filenm=substring FileAll Pth.count FileAll.count copyfile FileAll (SavePath+Filenm) if QBox==true do $.material[GG].specularlevelmap.filename=(SavePath+Filenm) )--try... catch() --"Glossiness" try ( local FileAll=$.material[GG].glossinessmap.filename local Pth=getfilenamepath FileAll local Filenm=substring FileAll Pth.count FileAll.count copyfile FileAll (SavePath+Filenm) if QBox==true do $.material[GG].glossinessmap.filename=(SavePath+Filenm) )--try... catch() --"Bump" try ( local FileAll=$.material[GG].bumpmap.filename local Pth=getfilenamepath FileAll local Filenm=substring FileAll Pth.count FileAll.count copyfile FileAll (SavePath+Filenm) if QBox==true do $.material[GG].bumpmap.filename=(SavePath+Filenm) )--try... catch() --"Reflection" try ( local FileAll=$.material[GG].reflectionmap.filename local Pth=getfilenamepath FileAll local Filenm=substring FileAll Pth.count FileAll.count copyfile FileAll (SavePath+Filenm) if QBox==true do $.material[GG].reflectionmap.filename=(SavePath+Filenm) )--try... catch() --"Diffuse" try ( local FileAll=$.material[GG].diffusemap.filename local Pth=getfilenamepath FileAll local Filenm=substring FileAll Pth.count FileAll.count copyfile FileAll (SavePath+Filenm) if QBox==true do $.material[GG].diffusemap.filename=(SavePath+Filenm) )--try... catch() ) catch() )--for GG... )--Multimaterial... )--case... messagebox "Textures successfully copied!" ) ) --^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fn ReRootTextures = ( local SrcPth=getsavepath "Select Source Directory" if SrcPth!=undefined do ( case (classof $.material) of ( Standardmaterial: ( try ( --"Opacity" try ( matname=$.material.opacitymap.filename bitm=getfilenamefile matname tpe=substring matname (matname.count-3) 4 allb=srcpth+"\\"+bitm+tpe $.material.opacitymap.filename=allb )--try... catch() --"Specular" try ( matname=$.material.specularlevelmap.filename bitm=getfilenamefile matname tpe=substring matname (matname.count-3) 4 allb=srcpth+"\\"+bitm+tpe $.material.specularlevelmap.filename=allb )--try... catch() --"Glossiness" try ( matname=$.material.glossinessmap.filename bitm=getfilenamefile matname tpe=substring matname (matname.count-3) 4 allb=srcpth+"\\"+bitm+tpe $.material.glossinessmap.filename=allb )--try... catch() --"Bump" try ( matname=$.material.bumpmap.filename bitm=getfilenamefile matname tpe=substring matname (matname.count-3) 4 allb=srcpth+"\\"+bitm+tpe $.material.bumpmap.filename=allb )--try... catch() --"Reflection" try ( matname=$.material.reflectionmap.filename bitm=getfilenamefile matname tpe=substring matname (matname.count-3) 4 allb=srcpth+"\\"+bitm+tpe $.material.reflectionmap.filename=allb )--try... catch() --"Diffuse" try ( matname=$.material.diffusemap.filename bitm=getfilenamefile matname tpe=substring matname (matname.count-3) 4 allb=srcpth+"\\"+bitm+tpe $.material.diffusemap.filename=allb )--try... catch() showtexturemap $.material $.material on ) catch() )--Standardmaterial... Multimaterial: ( for GG=1 to $.material.count do ( try ( --"Opacity" try ( matname=$.material[GG].opacitymap.filename bitm=getfilenamefile matname tpe=substring matname (matname.count-3) 4 allb=srcpth+"\\"+bitm+tpe $.material[GG].opacitymap.filename=allb )--try... catch() --"Specular" try ( matname=$.material[GG].specularlevelmap.filename bitm=getfilenamefile matname tpe=substring matname (matname.count-3) 4 allb=srcpth+"\\"+bitm+tpe $.material[GG].specularlevelmap.filename=allb )--try... catch() --"Glossiness" try ( matname=$.material[GG].glossinessmap.filename bitm=getfilenamefile matname tpe=substring matname (matname.count-3) 4 allb=srcpth+"\\"+bitm+tpe $.material[GG].glossinessmap.filename=allb )--try... catch() --"Bump" try ( matname=$.material[GG].bumpmap.filename bitm=getfilenamefile matname tpe=substring matname (matname.count-3) 4 allb=srcpth+"\\"+bitm+tpe $.material[GG].bumpmap.filename=allb )--try... catch() --"Reflection" try ( matname=$.material[GG].reflectionmap.filename bitm=getfilenamefile matname tpe=substring matname (matname.count-3) 4 allb=srcpth+"\\"+bitm+tpe $.material[GG].reflectionmap.filename=allb )--try... catch() --"Diffuse" try ( matname=$.material[GG].diffusemap.filename bitm=getfilenamefile matname tpe=substring matname (matname.count-3) 4 allb=srcpth+"\\"+bitm+tpe $.material[GG].diffusemap.filename=allb )--try... catch() showtexturemap $.material[GG] $.material[GG] on ) catch() )--for GG... )--Multimaterial... )--case... messagebox "Rerooting complete!" ) )