scripts
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace Parabox.STL
|
||||
{
|
||||
// Token: 0x02000002 RID: 2
|
||||
public enum FileType
|
||||
{
|
||||
// Token: 0x04000002 RID: 2
|
||||
Ascii,
|
||||
// Token: 0x04000003 RID: 3
|
||||
Binary
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyTitle("pb_Stl")]
|
||||
[assembly: AssemblyDescription("Import and export STL files in Unity.")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Parabox, LLC")]
|
||||
[assembly: AssemblyProduct("pb_Stl")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("90d62c90-5899-4985-8db6-bfca337c80bf")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Parabox.STL
|
||||
{
|
||||
// Token: 0x02000003 RID: 3
|
||||
public static class pb_Stl
|
||||
{
|
||||
// Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
|
||||
public static bool WriteFile(string path, Mesh mesh, FileType type = FileType.Ascii, bool convertToRightHandedCoordinates = true)
|
||||
{
|
||||
return pb_Stl.WriteFile(path, new Mesh[] { mesh }, type, convertToRightHandedCoordinates);
|
||||
}
|
||||
|
||||
// Token: 0x06000002 RID: 2 RVA: 0x00002064 File Offset: 0x00000264
|
||||
public static bool WriteFile(string path, IList<Mesh> meshes, FileType type = FileType.Ascii, bool convertToRightHandedCoordinates = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (type == FileType.Binary)
|
||||
{
|
||||
using (BinaryWriter binaryWriter = new BinaryWriter(File.Open(path, FileMode.Create), new ASCIIEncoding()))
|
||||
{
|
||||
binaryWriter.Write(new byte[80]);
|
||||
uint num = (uint)(meshes.Sum((Mesh x) => x.triangles.Length) / 3);
|
||||
binaryWriter.Write(num);
|
||||
foreach (Mesh mesh in meshes)
|
||||
{
|
||||
Vector3[] array = (convertToRightHandedCoordinates ? pb_Stl.Left2Right(mesh.vertices) : mesh.vertices);
|
||||
Vector3[] array2 = (convertToRightHandedCoordinates ? pb_Stl.Left2Right(mesh.normals) : mesh.normals);
|
||||
int[] triangles = mesh.triangles;
|
||||
int num2 = triangles.Length;
|
||||
if (convertToRightHandedCoordinates)
|
||||
{
|
||||
Array.Reverse(triangles);
|
||||
}
|
||||
for (int i = 0; i < num2; i += 3)
|
||||
{
|
||||
int num3 = triangles[i];
|
||||
int num4 = triangles[i + 1];
|
||||
int num5 = triangles[i + 2];
|
||||
Vector3 vector = pb_Stl.AvgNrm(array2[num3], array2[num4], array2[num5]);
|
||||
binaryWriter.Write(vector.x);
|
||||
binaryWriter.Write(vector.y);
|
||||
binaryWriter.Write(vector.z);
|
||||
binaryWriter.Write(array[num3].x);
|
||||
binaryWriter.Write(array[num3].y);
|
||||
binaryWriter.Write(array[num3].z);
|
||||
binaryWriter.Write(array[num4].x);
|
||||
binaryWriter.Write(array[num4].y);
|
||||
binaryWriter.Write(array[num4].z);
|
||||
binaryWriter.Write(array[num5].x);
|
||||
binaryWriter.Write(array[num5].y);
|
||||
binaryWriter.Write(array[num5].z);
|
||||
binaryWriter.Write(0);
|
||||
}
|
||||
}
|
||||
goto IL_21C;
|
||||
}
|
||||
}
|
||||
string text = pb_Stl.WriteString(meshes, true);
|
||||
File.WriteAllText(path, text);
|
||||
IL_21C:;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError(ex.ToString());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x06000003 RID: 3 RVA: 0x000022F0 File Offset: 0x000004F0
|
||||
public static string WriteString(Mesh mesh, bool convertToRightHandedCoordinates = true)
|
||||
{
|
||||
return pb_Stl.WriteString(new Mesh[] { mesh }, convertToRightHandedCoordinates);
|
||||
}
|
||||
|
||||
// Token: 0x06000004 RID: 4 RVA: 0x00002304 File Offset: 0x00000504
|
||||
public static string WriteString(IList<Mesh> meshes, bool convertToRightHandedCoordinates = true)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
string text = ((meshes.Count == 1) ? meshes[0].name : "Composite Mesh");
|
||||
stringBuilder.AppendLine(string.Format("solid {0}", text));
|
||||
foreach (Mesh mesh in meshes)
|
||||
{
|
||||
Vector3[] array = (convertToRightHandedCoordinates ? pb_Stl.Left2Right(mesh.vertices) : mesh.vertices);
|
||||
Vector3[] array2 = (convertToRightHandedCoordinates ? pb_Stl.Left2Right(mesh.normals) : mesh.normals);
|
||||
int[] triangles = mesh.triangles;
|
||||
if (convertToRightHandedCoordinates)
|
||||
{
|
||||
Array.Reverse(triangles);
|
||||
}
|
||||
int num = triangles.Length;
|
||||
for (int i = 0; i < num; i += 3)
|
||||
{
|
||||
int num2 = triangles[i];
|
||||
int num3 = triangles[i + 1];
|
||||
int num4 = triangles[i + 2];
|
||||
Vector3 vector = pb_Stl.AvgNrm(array2[num2], array2[num3], array2[num4]);
|
||||
stringBuilder.AppendLine(string.Format("facet normal {0} {1} {2}", vector.x, vector.y, vector.z));
|
||||
stringBuilder.AppendLine("outer loop");
|
||||
stringBuilder.AppendLine(string.Format("\tvertex {0} {1} {2}", array[num2].x, array[num2].y, array[num2].z));
|
||||
stringBuilder.AppendLine(string.Format("\tvertex {0} {1} {2}", array[num3].x, array[num3].y, array[num3].z));
|
||||
stringBuilder.AppendLine(string.Format("\tvertex {0} {1} {2}", array[num4].x, array[num4].y, array[num4].z));
|
||||
stringBuilder.AppendLine("endloop");
|
||||
stringBuilder.AppendLine("endfacet");
|
||||
}
|
||||
}
|
||||
stringBuilder.AppendLine(string.Format("endsolid {0}", text));
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x06000005 RID: 5 RVA: 0x00002578 File Offset: 0x00000778
|
||||
private static Vector3[] Left2Right(Vector3[] v)
|
||||
{
|
||||
Matrix4x4 matrix4x = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(1f, 1f, -1f));
|
||||
Vector3[] array = new Vector3[v.Length];
|
||||
for (int i = 0; i < v.Length; i++)
|
||||
{
|
||||
array[i] = matrix4x.MultiplyPoint3x4(v[i]);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000006 RID: 6 RVA: 0x000025D8 File Offset: 0x000007D8
|
||||
private static Vector3 AvgNrm(Vector3 a, Vector3 b, Vector3 c)
|
||||
{
|
||||
return new Vector3((a.x + b.x + c.x) / 3f, (a.y + b.y + c.y) / 3f, (a.z + b.z + c.z) / 3f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{99604A24-13D0-4C83-A3AA-9A315339FA4D}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Parabox.STL</RootNamespace>
|
||||
<AssemblyName>pb_Stl</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
</PropertyGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FileType.cs" />
|
||||
<Compile Include="pb_Stl.cs" />
|
||||
<Compile Include="pb_Stl_Exporter.cs" />
|
||||
<Compile Include="pb_Stl_Importer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\mscorlib\mscorlib.csproj">
|
||||
<Project>{99604a24-13d0-4c83-a3aa-9a315339fa4c}</Project>
|
||||
<Name>mscorlib</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\System.Core\System.Core.csproj">
|
||||
<Project>{99604a24-13d0-4c83-a3aa-9a315339fa55}</Project>
|
||||
<Name>System.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\UnityEngine\UnityEngine.csproj">
|
||||
<Project>{99604a24-13d0-4c83-a3aa-9a315339fa58}</Project>
|
||||
<Name>UnityEngine</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Parabox.STL
|
||||
{
|
||||
// Token: 0x02000004 RID: 4
|
||||
public static class pb_Stl_Exporter
|
||||
{
|
||||
// Token: 0x06000007 RID: 7 RVA: 0x00002638 File Offset: 0x00000838
|
||||
public static bool Export(string path, GameObject[] gameObjects, FileType type)
|
||||
{
|
||||
Mesh[] array = pb_Stl_Exporter.CreateWorldSpaceMeshesWithTransforms(gameObjects.Select((GameObject x) => x.transform).ToArray<Transform>());
|
||||
bool flag = false;
|
||||
if (array != null && array.Length != 0 && !string.IsNullOrEmpty(path))
|
||||
{
|
||||
flag = pb_Stl.WriteFile(path, array, type, true);
|
||||
}
|
||||
int num = 0;
|
||||
while (array != null && num < array.Length)
|
||||
{
|
||||
global::UnityEngine.Object.DestroyImmediate(array[num]);
|
||||
num++;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x06000008 RID: 8 RVA: 0x000026AC File Offset: 0x000008AC
|
||||
private static Mesh[] CreateWorldSpaceMeshesWithTransforms(IList<Transform> transforms)
|
||||
{
|
||||
if (transforms == null || transforms.Count < 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Vector3 vector = Vector3.zero;
|
||||
for (int i = 0; i < transforms.Count; i++)
|
||||
{
|
||||
vector += transforms[i].position;
|
||||
}
|
||||
Vector3 vector2 = vector / (float)transforms.Count;
|
||||
GameObject gameObject = new GameObject();
|
||||
gameObject.name = "ROOT";
|
||||
gameObject.transform.position = vector2;
|
||||
foreach (Transform transform in transforms)
|
||||
{
|
||||
GameObject gameObject2 = (GameObject)global::UnityEngine.Object.Instantiate(transform.gameObject);
|
||||
gameObject2.transform.SetParent(transform.parent, false);
|
||||
gameObject2.transform.SetParent(gameObject.transform, true);
|
||||
}
|
||||
gameObject.transform.position = Vector3.zero;
|
||||
List<MeshFilter> list = (from x in gameObject.GetComponentsInChildren<MeshFilter>()
|
||||
where x.sharedMesh != null
|
||||
select x).ToList<MeshFilter>();
|
||||
int count = list.Count;
|
||||
Mesh[] array = new Mesh[count];
|
||||
for (int j = 0; j < count; j++)
|
||||
{
|
||||
Transform transform2 = list[j].transform;
|
||||
Vector3[] vertices = list[j].sharedMesh.vertices;
|
||||
Vector3[] normals = list[j].sharedMesh.normals;
|
||||
for (int k = 0; k < vertices.Length; k++)
|
||||
{
|
||||
vertices[k] = transform2.TransformPoint(vertices[k]);
|
||||
normals[k] = transform2.TransformDirection(normals[k]);
|
||||
}
|
||||
array[j] = new Mesh
|
||||
{
|
||||
name = list[j].name,
|
||||
vertices = vertices,
|
||||
normals = normals,
|
||||
triangles = list[j].sharedMesh.triangles
|
||||
};
|
||||
}
|
||||
global::UnityEngine.Object.DestroyImmediate(gameObject);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Parabox.STL
|
||||
{
|
||||
// Token: 0x02000005 RID: 5
|
||||
public static class pb_Stl_Importer
|
||||
{
|
||||
// Token: 0x06000009 RID: 9 RVA: 0x000028CC File Offset: 0x00000ACC
|
||||
public static Mesh[] Import(string path)
|
||||
{
|
||||
if (pb_Stl_Importer.IsBinary(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
return pb_Stl_Importer.ImportBinary(path);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning(string.Format("Failed importing mesh at path {0}.\n{1}", path, ex.ToString()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return pb_Stl_Importer.ImportAscii(path);
|
||||
}
|
||||
|
||||
// Token: 0x0600000A RID: 10 RVA: 0x00002920 File Offset: 0x00000B20
|
||||
private static Mesh[] ImportBinary(string path)
|
||||
{
|
||||
pb_Stl_Importer.Facet[] array;
|
||||
using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(fileStream, new ASCIIEncoding()))
|
||||
{
|
||||
binaryReader.ReadBytes(80);
|
||||
uint num = binaryReader.ReadUInt32();
|
||||
array = new pb_Stl_Importer.Facet[num];
|
||||
for (uint num2 = 0U; num2 < num; num2 += 1U)
|
||||
{
|
||||
array[(int)num2] = new pb_Stl_Importer.Facet();
|
||||
array[(int)num2].normal.x = binaryReader.ReadSingle();
|
||||
array[(int)num2].normal.y = binaryReader.ReadSingle();
|
||||
array[(int)num2].normal.z = binaryReader.ReadSingle();
|
||||
array[(int)num2].a.x = binaryReader.ReadSingle();
|
||||
array[(int)num2].a.y = binaryReader.ReadSingle();
|
||||
array[(int)num2].a.z = binaryReader.ReadSingle();
|
||||
array[(int)num2].b.x = binaryReader.ReadSingle();
|
||||
array[(int)num2].b.y = binaryReader.ReadSingle();
|
||||
array[(int)num2].b.z = binaryReader.ReadSingle();
|
||||
array[(int)num2].c.x = binaryReader.ReadSingle();
|
||||
array[(int)num2].c.y = binaryReader.ReadSingle();
|
||||
array[(int)num2].c.z = binaryReader.ReadSingle();
|
||||
binaryReader.ReadUInt16();
|
||||
}
|
||||
}
|
||||
}
|
||||
return pb_Stl_Importer.CreateMeshWithFacets(array);
|
||||
}
|
||||
|
||||
// Token: 0x0600000B RID: 11 RVA: 0x00002AC0 File Offset: 0x00000CC0
|
||||
private static int ReadState(string line)
|
||||
{
|
||||
if (line.StartsWith("solid"))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (line.StartsWith("facet"))
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
if (line.StartsWith("outer"))
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
if (line.StartsWith("vertex"))
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
if (line.StartsWith("endloop"))
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
if (line.StartsWith("endfacet"))
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
if (line.StartsWith("endsolid"))
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Token: 0x0600000C RID: 12 RVA: 0x00002B38 File Offset: 0x00000D38
|
||||
private static Mesh[] ImportAscii(string path)
|
||||
{
|
||||
List<pb_Stl_Importer.Facet> list = new List<pb_Stl_Importer.Facet>();
|
||||
using (StreamReader streamReader = new StreamReader(path))
|
||||
{
|
||||
int num = 0;
|
||||
pb_Stl_Importer.Facet facet = null;
|
||||
bool flag = false;
|
||||
while (streamReader.Peek() > 0 && !flag)
|
||||
{
|
||||
string text = streamReader.ReadLine().Trim();
|
||||
switch (pb_Stl_Importer.ReadState(text))
|
||||
{
|
||||
case 2:
|
||||
facet = new pb_Stl_Importer.Facet();
|
||||
facet.normal = pb_Stl_Importer.StringToVec3(text.Replace("facet normal ", ""));
|
||||
break;
|
||||
case 3:
|
||||
num = 0;
|
||||
break;
|
||||
case 4:
|
||||
if (num == 0)
|
||||
{
|
||||
facet.a = pb_Stl_Importer.StringToVec3(text.Replace("vertex ", ""));
|
||||
}
|
||||
else if (num == 1)
|
||||
{
|
||||
facet.b = pb_Stl_Importer.StringToVec3(text.Replace("vertex ", ""));
|
||||
}
|
||||
else if (num == 2)
|
||||
{
|
||||
facet.c = pb_Stl_Importer.StringToVec3(text.Replace("vertex ", ""));
|
||||
}
|
||||
num++;
|
||||
break;
|
||||
case 6:
|
||||
list.Add(facet);
|
||||
break;
|
||||
case 7:
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return pb_Stl_Importer.CreateMeshWithFacets(list);
|
||||
}
|
||||
|
||||
// Token: 0x0600000D RID: 13 RVA: 0x00002C88 File Offset: 0x00000E88
|
||||
private static Vector3 StringToVec3(string str)
|
||||
{
|
||||
string[] array = str.Trim().Split(null);
|
||||
Vector3 vector = default(Vector3);
|
||||
float.TryParse(array[0], out vector.x);
|
||||
float.TryParse(array[1], out vector.y);
|
||||
float.TryParse(array[2], out vector.z);
|
||||
return vector;
|
||||
}
|
||||
|
||||
// Token: 0x0600000E RID: 14 RVA: 0x00002CDC File Offset: 0x00000EDC
|
||||
private static bool IsBinary(string path)
|
||||
{
|
||||
FileInfo fileInfo = new FileInfo(path);
|
||||
if (fileInfo.Length < 130L)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool flag = false;
|
||||
using (FileStream fileStream = fileInfo.OpenRead())
|
||||
{
|
||||
using (BufferedStream bufferedStream = new BufferedStream(fileStream))
|
||||
{
|
||||
for (long num = 0L; num < 80L; num += 1L)
|
||||
{
|
||||
if (bufferedStream.ReadByte() == 0)
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
using (FileStream fileStream2 = fileInfo.OpenRead())
|
||||
{
|
||||
using (BufferedStream bufferedStream2 = new BufferedStream(fileStream2))
|
||||
{
|
||||
byte[] array = new byte[6];
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
array[i] = (byte)bufferedStream2.ReadByte();
|
||||
}
|
||||
flag = Encoding.UTF8.GetString(array) != "solid ";
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x0600000F RID: 15 RVA: 0x00002DE8 File Offset: 0x00000FE8
|
||||
private static Mesh[] CreateMeshWithFacets(IList<pb_Stl_Importer.Facet> facets)
|
||||
{
|
||||
int count = facets.Count;
|
||||
int num = 0;
|
||||
int num2 = 65535;
|
||||
Mesh[] array = new Mesh[count / 21845 + 1];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
int num3 = Math.Min(num2, (count - num) * 3);
|
||||
Vector3[] array2 = new Vector3[num3];
|
||||
Vector3[] array3 = new Vector3[num3];
|
||||
int[] array4 = new int[num3];
|
||||
for (int j = 0; j < num3; j += 3)
|
||||
{
|
||||
array2[j] = facets[num].a;
|
||||
array2[j + 1] = facets[num].b;
|
||||
array2[j + 2] = facets[num].c;
|
||||
array3[j] = facets[num].normal;
|
||||
array3[j + 1] = facets[num].normal;
|
||||
array3[j + 2] = facets[num].normal;
|
||||
array4[j] = j;
|
||||
array4[j + 1] = j + 1;
|
||||
array4[j + 2] = j + 2;
|
||||
num++;
|
||||
}
|
||||
array[i] = new Mesh();
|
||||
array[i].vertices = array2;
|
||||
array[i].normals = array3;
|
||||
array[i].triangles = array4;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x04000004 RID: 4
|
||||
private const int MAX_FACETS_PER_MESH = 21845;
|
||||
|
||||
// Token: 0x04000005 RID: 5
|
||||
private const int SOLID = 1;
|
||||
|
||||
// Token: 0x04000006 RID: 6
|
||||
private const int FACET = 2;
|
||||
|
||||
// Token: 0x04000007 RID: 7
|
||||
private const int OUTER = 3;
|
||||
|
||||
// Token: 0x04000008 RID: 8
|
||||
private const int VERTEX = 4;
|
||||
|
||||
// Token: 0x04000009 RID: 9
|
||||
private const int ENDLOOP = 5;
|
||||
|
||||
// Token: 0x0400000A RID: 10
|
||||
private const int ENDFACET = 6;
|
||||
|
||||
// Token: 0x0400000B RID: 11
|
||||
private const int ENDSOLID = 7;
|
||||
|
||||
// Token: 0x0400000C RID: 12
|
||||
private const int EMPTY = 0;
|
||||
|
||||
// Token: 0x02000008 RID: 8
|
||||
private class Facet
|
||||
{
|
||||
// Token: 0x06000017 RID: 23 RVA: 0x00002F7C File Offset: 0x0000117C
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0:F2}: {1:F2}, {2:F2}, {3:F2}", new object[] { this.normal, this.a, this.b, this.c });
|
||||
}
|
||||
|
||||
// Token: 0x04000012 RID: 18
|
||||
public Vector3 normal;
|
||||
|
||||
// Token: 0x04000013 RID: 19
|
||||
public Vector3 a;
|
||||
|
||||
// Token: 0x04000014 RID: 20
|
||||
public Vector3 b;
|
||||
|
||||
// Token: 0x04000015 RID: 21
|
||||
public Vector3 c;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user