Guest User

Untitled

a guest
Jun 13th, 2013
68
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --------------------------------------------------------------------
  2. -------------------------------Globals------------------------------
  3. --------------------------------------------------------------------
  4.  
  5. local Beveled = false
  6. local Conglomerate = false
  7. local Scale = 1/10
  8.  
  9. --------------------------------------------------------------------
  10. -----------------------Implementation Globals-----------------------
  11. --------------------------------------------------------------------
  12.  
  13. -- Not applicable
  14.  
  15. --------------------------------------------------------------------
  16. --------------------------Helper Functions--------------------------
  17. --------------------------------------------------------------------
  18.  
  19. function SaveLimitedString(Str,Nami)
  20.     local File = script:FindFirstChild(Nami)
  21.     if File == nil then
  22.         File = Instance.new("StringValue")
  23.         File.Name = Nami
  24.         File.Parent = script
  25.     end
  26.     File.Value = Str
  27. end
  28.  
  29. function SaveString(Str,Nami)
  30.     local Max = 128000
  31.     if string.len(Str) > Max then
  32.         for i=1,math.ceil(string.len(Str)/Max) do
  33.             if i == math.ceil(string.len(Str)/Max) then
  34.                 SaveLimitedString(string.sub(Str,(i-1)*Max+1,string.len(Str)),Nami.."(Part"..NumPrefix(i)..")")
  35.             else
  36.                 SaveLimitedString(string.sub(Str,(i-1)*Max+1,i*Max),Nami.."(Part"..NumPrefix(i)..")")
  37.             end
  38.         end
  39.     else
  40.         SaveLimitedString(Str,Nami)
  41.     end
  42. end
  43.  
  44. function PartsList(Par,List)
  45.     if List == nil then List = {} end
  46.    
  47.     local c = Par:GetChildren()
  48.     for i=1,#c do
  49.         if c[i]:IsA("BasePart") then
  50.             List[#List+1] = c[i]
  51.         end
  52.         List = PartsList(c[i],List)
  53.     end
  54.    
  55.     return List
  56. end
  57.  
  58. function Append(T1,T2)
  59.     for i=1,#T2 do
  60.         T1[#T1+1] = T2[i]
  61.     end
  62.     return T1
  63. end
  64.  
  65. function Vector3ToObjString(Vector)
  66.     return ""..Vector.x.." "..Vector.y.." "..Vector.z
  67. end
  68.  
  69. function TableToObjString(Table)
  70.     local Str = ""
  71.     for i=1,#Table do
  72.         if i == 1 then
  73.             Str = Str..Table[i]
  74.         else
  75.             Str = Str.." "..Table[i]
  76.         end
  77.     end
  78.     return Str
  79. end
  80.  
  81. function NumPrefix(Number)
  82.     if Number >= 99 then
  83.         return Number
  84.     elseif Number >= 9 then
  85.         return "0"..Number
  86.     else
  87.         return "00"..Number
  88.     end
  89. end
  90.  
  91. function OriginTag()
  92.     return "# Generated with Roblox BuildIn Plugin"
  93. end
  94.  
  95. function MtlLibTag(PlaceName)
  96.     return "mtllib "..PlaceName..".mtl"
  97. end
  98.  
  99. function ObjectTag(Type,MeshesMade)
  100.     return "g Mesh_"..Type.."."..NumPrefix(MeshesMade)
  101. end
  102.  
  103. function VertTag(Vector)
  104.     return "v "..Vector3ToObjString(Vector)
  105. end
  106.  
  107. function FaceTag(Vertlist)
  108.     return "f "..TableToObjString(Vertlist)
  109. end
  110.  
  111. function MaterialTag(MaterialV,Index)
  112.     return {"newmtl Material."..NumPrefix(Index),
  113.         "d "..1-MaterialV[2],
  114.         "Ns 96.0",
  115.         "Ka 0.3 0.3 0.3",
  116.         "Kd ".. MaterialV[1].r .." ".. MaterialV[1].g .." ".. MaterialV[1].b ,
  117.         "Ks 1.0 1.0 1.0",
  118.         "illum 2"}
  119. end
  120.  
  121. --------------------------------------------------------------------
  122. ---------------------------Basic Exporting--------------------------
  123. --------------------------------------------------------------------
  124. "Head""Sphere"
  125. end
  126.  
  127. function CylinderFaceList(CF,Size)
  128.     local Verts = {Vector3.new(0.000000,-1.000000,-1.000000),Vector3.new(0.000000,1.000000,-1.000000),Vector3.new(0.195090,-1.000000,-0.980785),Vector3.new(0.195090,1.000000,-0.980785),Vector3.new(0.382683,-1.000000,-0.923880),Vector3.new(0.382683,1.000000,-0.923880),Vector3.new(0.555570,-1.000000,-0.831470),Vector3.new(0.555570,1.000000,-0.831470),Vector3.new(0.707107,-1.000000,-0.707107),Vector3.new(0.707107,1.000000,-0.707107),Vector3.new(0.831470,-1.000000,-0.555570),Vector3.new(0.831470,1.000000,-0.555570),Vector3.new(0.923880,-1.000000,-0.382683),Vector3.new(0.923880,1.000000,-0.382683),Vector3.new(0.980785,-1.000000,-0.195090),Vector3.new(0.980785,1.000000,-0.195090),Vector3.new(1.000000,-1.000000,-0.000000),Vector3.new(1.000000,1.000000,-0.000000),Vector3.new(0.980785,-1.000000,0.195090),Vector3.new(0.980785,1.000000,0.195090),Vector3.new(0.923880,-1.000000,0.382683),Vector3.new(0.923880,1.000000,0.382683),Vector3.new(0.831470,-1.000000,0.555570),Vector3.new(0.831470,1.000000,0.555570),Vector3.new(0.707107,-1.000000,0.707107),Vector3.new(0.707107,1.000000,0.707107),Vector3.new(0.555570,-1.000000,0.831470),Vector3.new(0.555570,1.000000,0.831470),Vector3.new(0.382683,-1.000000,0.923880),Vector3.new(0.382683,1.000000,0.923880),Vector3.new(0.195090,-1.000000,0.980785),Vector3.new(0.195090,1.000000,0.980785),Vector3.new(-0.000000,-1.000000,1.000000),Vector3.new(-0.000000,1.000000,1.000000),Vector3.new(-0.195091,-1.000000,0.980785),Vector3.new(-0.195091,1.000000,0.980785),Vector3.new(-0.382684,-1.000000,0.923879),Vector3.new(-0.382684,1.000000,0.923879),Vector3.new(-0.555571,-1.000000,0.831469),Vector3.new(-0.555571,1.000000,0.831469),Vector3.new(-0.707107,-1.000000,0.707106),Vector3.new(-0.707107,1.000000,0.707106),Vector3.new(-0.831470,-1.000000,0.555570),Vector3.new(-0.831470,1.000000,0.555570),Vector3.new(-0.923880,-1.000000,0.382683),Vector3.new(-0.923880,1.000000,0.382683),Vector3.new(-0.980785,-1.000000,0.195089),Vector3.new(-0.980785,1.000000,0.195089),Vector3.new(-1.000000,-1.000000,-0.000001),Vector3.new(-1.000000,1.000000,-0.000001),Vector3.new(-0.980785,-1.000000,-0.195091),Vector3.new(-0.980785,1.000000,-0.195091),Vector3.new(-0.923879,-1.000000,-0.382684),Vector3.new(-0.923879,1.000000,-0.382684),Vector3.new(-0.831469,-1.000000,-0.555571),Vector3.new(-0.831469,1.000000,-0.555571),Vector3.new(-0.707106,-1.000000,-0.707108),Vector3.new(-0.707106,1.000000,-0.707108),Vector3.new(-0.555569,-1.000000,-0.831470),Vector3.new(-0.555569,1.000000,-0.831470),Vector3.new(-0.382682,-1.000000,-0.923880),Vector3.new(-0.382682,1.000000,-0.923880),Vector3.new(-0.195089,-1.000000,-0.980786),Vector3.new(-0.195089,1.000000,-0.980786),Vector3.new(0.000000,1.000000,-1.000000),Vector3.new(0.195090,1.000000,-0.980785),Vector3.new(0.382683,1.000000,-0.923880),Vector3.new(0.555570,1.000000,-0.831470),Vector3.new(0.707107,1.000000,-0.707107),Vector3.new(0.831470,1.000000,-0.555570),Vector3.new(0.923880,1.000000,-0.382683),Vector3.new(0.980785,1.000000,-0.195090),Vector3.new(1.000000,1.000000,-0.000000),Vector3.new(0.980785,1.000000,0.195090),Vector3.new(0.923880,1.000000,0.382683),Vector3.new(0.831470,1.000000,0.555570),Vector3.new(0.707107,1.000000,0.707107),Vector3.new(0.555570,1.000000,0.831470),Vector3.new(0.382683,1.000000,0.923880),Vector3.new(0.195090,1.000000,0.980785),Vector3.new(-0.000000,1.000000,1.000000),Vector3.new(-0.195091,1.000000,0.980785),Vector3.new(-0.382684,1.000000,0.923879),Vector3.new(-0.555571,1.000000,0.831469),Vector3.new(-0.707107,1.000000,0.707106),Vector3.new(-0.831470,1.000000,0.555570),Vector3.new(-0.923880,1.000000,0.382683),Vector3.new(-0.980785,1.000000,0.195089),Vector3.new(-1.000000,1.000000,-0.000001),Vector3.new(-0.980785,1.000000,-0.195091),Vector3.new(-0.923879,1.000000,-0.382684),Vector3.new(-0.831469,1.000000,-0.555571),Vector3.new(-0.707106,1.000000,-0.707108),Vector3.new(-0.555569,1.000000,-0.831470),Vector3.new(-0.382682,1.000000,-0.923880),Vector3.new(-0.195089,1.000000,-0.980786),Vector3.new(0.000000,-1.000000,-1.000000),Vector3.new(0.195090,-1.000000,-0.980785),Vector3.new(0.382683,-1.000000,-0.923880),Vector3.new(0.555570,-1.000000,-0.831470),Vector3.new(0.707107,-1.000000,-0.707107),Vector3.new(0.831470,-1.000000,-0.555570),Vector3.new(0.923880,-1.000000,-0.382683),Vector3.new(0.980785,-1.000000,-0.195090),Vector3.new(1.000000,-1.000000,-0.000000),Vector3.new(0.980785,-1.000000,0.195090),Vector3.new(0.923880,-1.000000,0.382683),Vector3.new(0.831470,-1.000000,0.555570),Vector3.new(0.707107,-1.000000,0.707107),Vector3.new(0.555570,-1.000000,0.831470),Vector3.new(0.382683,-1.000000,0.923880),Vector3.new(0.195090,-1.000000,0.980785),Vector3.new(-0.000000,-1.000000,1.000000),Vector3.new(-0.195091,-1.000000,0.980785),Vector3.new(-0.382684,-1.000000,0.923879),Vector3.new(-0.555571,-1.000000,0.831469),Vector3.new(-0.707107,-1.000000,0.707106),Vector3.new(-0.831470,-1.000000,0.555570),Vector3.new(-0.923880,-1.000000,0.382683),Vector3.new(-0.980785,-1.000000,0.195089),Vector3.new(-1.000000,-1.000000,-0.000001),Vector3.new(-0.980785,-1.000000,-0.195091),Vector3.new(-0.923879,-1.000000,-0.382684),Vector3.new(-0.831469,-1.000000,-0.555571),Vector3.new(-0.707106,-1.000000,-0.707108),Vector3.new(-0.555569,-1.000000,-0.831470),Vector3.new(-0.382682,-1.000000,-0.923880),Vector3.new(-0.195089,-1.000000,-0.980786)}
  129.    
  130.     for i=1,#Verts do
  131.         Verts[i] = (CF.p+(CF-CF.p)*(Verts[i]*(Size/2)))*Scale
  132.     end
  133.    
  134.     local Faces = {{1,2,4,3},{3,4,6,5},{5,6,8,7},{7,8,10,9},{9,10,12,11},{11,12,14,13},{13,14,16,15},{15,16,18,17},{17,18,20,19},{19,20,22,21},{21,22,24,23},{23,24,26,25},{25,26,28,27},{27,28,30,29},{29,30,32,31},{31,32,34,33},{33,34,36,35},{35,36,38,37},{37,38,40,39},{39,40,42,41},{41,42,44,43},{43,44,46,45},{45,46,48,47},{47,48,50,49},{49,50,52,51},{51,52,54,53},{53,54,56,55},{55,56,58,57},{57,58,60,59},{59,60,62,61},{2,1,63,64},{61,62,64,63},{66,65,96},{66,96,95},{66,95,67},{95,94,67},{94,68,67},{94,93,68},{93,69,68},{93,92,69},{92,70,69},{92,91,70},{91,71,70},{91,90,71},{90,72,71},{90,89,72},{89,73,72},{89,88,73},{88,74,73},{88,87,74},{87,75,74},{87,86,75},{86,76,75},{86,85,76},{85,77,76},{85,84,77},{84,78,77},{84,83,78},{83,79,78},{83,82,79},{82,80,79},{82,81,80},{97,98,128},{98,127,128},{98,99,127},{99,126,127},{99,100,126},{100,125,126},{100,101,125},{101,124,125},{101,102,124},{102,123,124},{102,103,123},{103,122,123},{103,104,122},{104,121,122},{104,105,121},{105,120,121},{105,106,120},{106,119,120},{106,107,119},{107,118,119},{107,108,118},{108,117,118},{108,109,117},{109,116,117},{109,110,116},{110,115,116},{110,111,115},{111,114,115},{111,112,114},{112,113,114}}
  135.     return Verts,Faces,"Cylinder"
  136. end
  137.  
  138. function CornerWedgeFaceList(CF,Size)
  139.     local Verts = {Vector3.new(-1,-1,-1),Vector3.new(1,-1,-1),Vector3.new(1,-1,1),Vector3.new(-1,-1,1),Vector3.new(1,1,-1)}
  140.    
  141.     for i=1,#Verts do
  142.         Verts[i] = (CF.p+(CF-CF.p)*(Verts[i]*(Size/2)))*Scale
  143.     end
  144.    
  145.     local Faces = {{1,2,3,4},{5,1,4},{3,5,4},{2,5,3},{1,5,2}}
  146.     return Verts,Faces,"CornerWedge"
  147. end
  148.  
  149. function WedgeFaceList(CF,Size)
  150.     local Verts = {Vector3.new(-1,-1,-1),Vector3.new(1,-1,-1),Vector3.new(1,-1,1),Vector3.new(-1,-1,1),Vector3.new(-1,1,1),Vector3.new(1,1,1)}
  151.    
  152.     for i=1,#Verts do
  153.         Verts[i] = (CF.p+(CF-CF.p)*(Verts[i]*(Size/2)))*Scale
  154.     end
  155.    
  156.     local Faces = {{1,2,3,4},{1,5,6,2},{5,1,4},{3,6,5,4},{2,6,3}}
  157.     return Verts,Faces,"Wedge"
  158. end
  159.  
  160. function CubicFaceList(CF,Size)
  161.     local Verts = {Vector3.new(1,-1,-1),Vector3.new(1,-1,1),Vector3.new(-1,-1,1),Vector3.new(-1,-1,-1),Vector3.new(1,1,-1),Vector3.new(1,1,1),Vector3.new(-1,1,1),Vector3.new(-1,1,-1)}
  162.    
  163.     for i=1,#Verts do
  164.         Verts[i] = (CF.p+(CF-CF.p)*(Verts[i]*(Size/2)))*Scale
  165.     end
  166.    
  167.     local Faces = {{1,2,3,4},{5,8,7,6},{1,5,6,2},{2,6,7,3},{3,7,8,4},{5,1,4,8}}
  168.     return Verts,Faces,"Cube"
  169. end
  170.  
  171. --------------------------------------------------------------------
  172. -------------------------Advanced Exporting-------------------------
  173. --------------------------------------------------------------------
  174.  
  175. function BasePartFaceList(BPart)
  176.     local OMesh = nil
  177.     local c = BPart:GetChildren()
  178.     for i=1,#c do
  179.         if c[i]:IsA("DataModelMesh") then
  180.             OMesh = c[i]
  181.         end
  182.     end
  183.    
  184.     if OMesh == nil then
  185.         if BPart.className == "Part" then
  186.             if BPart.Shape == Enum.PartType.Block then
  187.                 return CubicFaceList(BPart.CFrame,BPart.Size)
  188.             elseif BPart.Shape == Enum.PartType.Ball then
  189.                 return SphereFaceList(BPart.CFrame,BPart.Size)
  190.             elseif BPart.Shape == Enum.PartType.Cylinder then
  191.                 return CylinderFaceList(BPart.CFrame,BPart.Size)
  192.             end
  193.         elseif BPart.className == "WedgePart" then
  194.             return WedgeFaceList(BPart.CFrame,BPart.Size)
  195.         elseif BPart.className == "CornerWedgePart" then
  196.             return CornerWedgeFaceList(BPart.CFrame,BPart.Size)
  197.         end
  198.     else
  199.         if OMesh.className == "BlockMesh" then
  200.             return CubicFaceList(BPart.CFrame+(BPart.CFrame-BPart.CFrame.p)*OMesh.Offset,BPart.Size*OMesh.Scale)
  201.         elseif OMesh.className == "CylinderMesh" then
  202.             if BPart.Size.X < BPart.Size.Z then
  203.                 return CylinderFaceList(BPart.CFrame+(BPart.CFrame-BPart.CFrame.p)*OMesh.Offset,Vector3.new(BPart.Size.X,BPart.Size.Y,BPart.Size.X)*Vector3.new(OMesh.Scale.X,OMesh.Scale.Y,OMesh.Scale.X))
  204.             else
  205.                 return CylinderFaceList(BPart.CFrame+(BPart.CFrame-BPart.CFrame.p)*OMesh.Offset,Vector3.new(BPart.Size.Z,BPart.Size.Y,BPart.Size.Z)*Vector3.new(OMesh.Scale.X,OMesh.Scale.Y,OMesh.Scale.X))
  206.             end
  207.         elseif OMesh.className == "SpecialMesh" then
  208.             --Offset isn't implemented for SpecialMeshes yet, so I won't implement it either
  209.             if OMesh.MeshType == Enum.MeshType.Brick then
  210.                 return CubicFaceList(BPart.CFrame,BPart.Size*OMesh.Scale)
  211.             elseif OMesh.MeshType == Enum.MeshType.Wedge then
  212.                 return WedgeFaceList(BPart.CFrame,BPart.Size*OMesh.Scale)
  213.             elseif OMesh.MeshType == Enum.MeshType.CornerWedge then
  214.                 return CornerWedgeFaceList(BPart.CFrame,BPart.Size*OMesh.Scale)
  215.             elseif OMesh.MeshType == Enum.MeshType.Cylinder then
  216.                 if BPart.Size.X < BPart.Size.Z then
  217.                     return CylinderFaceList(BPart.CFrame,Vector3.new(BPart.Size.X,BPart.Size.Y,BPart.Size.X)*Vector3.new(OMesh.Scale.X,OMesh.Scale.Y,OMesh.Scale.X))
  218.                 else
  219.                     return CylinderFaceList(BPart.CFrame,Vector3.new(BPart.Size.Z,BPart.Size.Y,BPart.Size.Z)*Vector3.new(OMesh.Scale.X,OMesh.Scale.Y,OMesh.Scale.X))
  220.                 end
  221.             elseif OMesh.MeshType == Enum.MeshType.Sphere then
  222.                 return SphereFaceList(BPart.CFrame,BPart.Size*OMesh.Scale)
  223.             elseif OMesh.MeshType == Enum.MeshType.Head then
  224.                 if BPart.Size.X < BPart.Size.Z then
  225.                     return HeadFaceList(BPart.CFrame,Vector3.new(BPart.Size.X,BPart.Size.Y,BPart.Size.X)*Vector3.new(OMesh.Scale.X,OMesh.Scale.Y,OMesh.Scale.X))
  226.                 else
  227.                     return HeadFaceList(BPart.CFrame,Vector3.new(BPart.Size.Z,BPart.Size.Y,BPart.Size.Z)*Vector3.new(OMesh.Scale.X,OMesh.Scale.Y,OMesh.Scale.X))
  228.                 end
  229.             elseif OMesh.MeshType == Enum.MeshType.Torso then
  230.                 --NOTE
  231.             end
  232.         end
  233.     end
  234. end
  235.  
  236. function ObjVFListInstance(Par)
  237.     local Verts = {}
  238.     local Faces = {}
  239.     local Materials = {}
  240.     local OBegs = {}
  241.    
  242.     local Parts = PartsList(Par)
  243.     for m=1,#Parts do
  244.         local LVerts,LFaces,PType = BasePartFaceList(Parts[m])
  245.         if LVerts ~= nil and LFaces ~= nil then
  246.            
  247.             local LMaterial = {Parts[m].BrickColor.Color,Parts[m].Transparency}
  248.             local MIndex = -1
  249.             for i=1,#Materials do
  250.                 if Materials[i][1] == LMaterial[1] and Materials[i][2] == LMaterial[2] then
  251.                     MIndex = i
  252.                     break
  253.                 end
  254.             end
  255.             if MIndex == -1 then
  256.                 Materials[#Materials+1] = LMaterial
  257.                 OBegs[#OBegs+1] = {#Verts+1,#Faces+1,#Materials,PType}
  258.             else
  259.                 OBegs[#OBegs+1] = {#Verts+1,#Faces+1,MIndex,PType}
  260.             end
  261.            
  262.             for i=1,#LFaces do
  263.                 local LFace = {}
  264.                 for k=1,#LFaces[i] do
  265.                     LFace[k] = LFaces[i][k]+#Verts
  266.                 end
  267.                 Faces[#Faces+1] = LFace
  268.             end
  269.             for i=1,#LVerts do
  270.                 Verts[#Verts+1] = LVerts[i]
  271.             end
  272.         end
  273.     end
  274.     return Verts,Faces,Materials,OBegs
  275. end
  276.  
  277. function VFListToStringTable(Verts,Faces,Materials,OBegs)
  278.     local ObjTable = {}
  279.     local MtlTable = {}
  280.    
  281.     for i=1,#Materials do
  282.         MtlTable = Append(MtlTable,MaterialTag(Materials[i],i))
  283.     end
  284.    
  285.     if Conglomerate then
  286.         ObjTable[#ObjTable+1] = ObjectTag("RobloxPlace",1)
  287.        
  288.         for i=1,#Verts do
  289.             ObjTable[#ObjTable+1] = VertTag(Verts[i])
  290.         end
  291.         for b=1,#OBegs do
  292.             local EndObeg = {}
  293.             if b == #OBegs then
  294.                 EndOBeg = {#Verts+1,#Faces+1,"nil"}
  295.             else
  296.                 EndOBeg = OBegs[b+1]
  297.             end
  298.            
  299.             if OBegs[b][3] ~= nil then
  300.                 ObjTable[#ObjTable+1] = "usemtl Material."..NumPrefix(OBegs[b][3])
  301.             end    
  302.            
  303.             if OBegs[b][4] == "Sphere" or OBegs[b][4] == "Head" or OBegs[b][4] == "Cylinder" then
  304.                 ObjTable[#ObjTable+1] = "s 1"
  305.             else
  306.                 ObjTable[#ObjTable+1] = "s off"
  307.             end
  308.            
  309.             for i=OBegs[b][2],EndOBeg[2]-1 do
  310.                 ObjTable[#ObjTable+1] = FaceTag(Faces[i])
  311.             end
  312.         end
  313.     else
  314.         for b=1,#OBegs do
  315.             local EndObeg = {}
  316.             if b == #OBegs then
  317.                 EndOBeg = {#Verts+1,#Faces+1,"nil"}
  318.             else
  319.                 EndOBeg = OBegs[b+1]
  320.             end
  321.            
  322.             ObjTable[#ObjTable+1] = ObjectTag(OBegs[b][4],b)
  323.             for i=OBegs[b][1],EndOBeg[1]-1 do
  324.                 ObjTable[#ObjTable+1] = VertTag(Verts[i])
  325.             end
  326.            
  327.             if OBegs[b][3] ~= nil then
  328.                 ObjTable[#ObjTable+1] = "usemtl Material."..NumPrefix(OBegs[b][3])
  329.             end
  330.                        
  331.             if OBegs[b][4] == "Sphere" or OBegs[b][4] == "Head" or OBegs[b][4] == "Cylinder" then
  332.                 ObjTable[#ObjTable+1] = "s 1"
  333.             else
  334.                 ObjTable[#ObjTable+1] = "s off"
  335.             end
  336.            
  337.             for i=OBegs[b][2],EndOBeg[2]-1 do
  338.                 ObjTable[#ObjTable+1] = FaceTag(Faces[i])
  339.             end
  340.         end
  341.     end
  342.     return ObjTable,MtlTable
  343. end
  344.  
  345. function ExportPlaceAsObj(PlaceName)
  346.     local ObjStr = OriginTag().."\n"..MtlLibTag(PlaceName)
  347.     local MtlStr = OriginTag()
  348.    
  349.     local ObjTable, MtlTable = VFListToStringTable(ObjVFListInstance(game.Workspace))
  350.    
  351.     for i=1,#ObjTable do
  352.         ObjStr = ObjStr.."\n"..ObjTable[i]
  353.     end
  354.     for i=1,#MtlTable do
  355.         MtlStr = MtlStr.."\n"..MtlTable[i]
  356.     end
  357.    
  358.     return ObjStr,MtlStr
  359. end
  360.  
  361. --------------------------------------------------------------------
  362. ---------------------------Implementation---------------------------
  363. --------------------------------------------------------------------
  364.  
  365. obj, mtl = ExportPlaceAsObj("PlaceName")
  366. -- Change "PlaceName" to the name of the .obj and .mtl files you will use
  367.  
  368. SaveString(mtl,".mtl")
  369. SaveString(obj,".obj")
RAW Paste Data