Ejemplo n.º 1
0
 public static void Reset()
 {
     CruncherPluginManager.Startup("");
 }
Ejemplo n.º 2
0
        public static int AddMesh(CruncherIO cruncherIO, CruncherMeshConfiguration cruncherMeshConfiguration)
        {
            if (CruncherPluginManager.cruncherPluginManager == null && !CruncherPluginManager.Startup(""))
            {
                return(-1);
            }
            if (cruncherIO == null || cruncherIO.vertices == null || cruncherIO.triangles == null)
            {
                Debug.LogError("Invalid CruncherIO object, aborting AddMesh.");
                return(-1);
            }
            CruncherPluginManager.cruncherPluginManager.cruncherData.vertices  = cruncherIO.vertices;
            CruncherPluginManager.cruncherPluginManager.cruncherData.triangles = cruncherIO.triangles;
            CruncherPluginManager.cruncherPluginManager.cruncherData.normals   = cruncherIO.normals;
            CruncherPluginManager.cruncherPluginManager.cruncherData.uv0s      = cruncherIO.uv0s;
            CruncherPluginManager.cruncherPluginManager.cruncherData.uv1s      = cruncherIO.uv1s;
            int num = cruncherIO.subMeshTriangles.Length;

            CruncherPluginManager.cruncherPluginManager.arrayLengths    = new int[7 + num];
            CruncherPluginManager.cruncherPluginManager.arrayLengths[6] = num;
            CruncherPluginManager.cruncherPluginManager.arrayLengths[0] = CruncherPluginManager.cruncherPluginManager.cruncherData.vertices.Length;
            CruncherPluginManager.cruncherPluginManager.arrayLengths[1] = CruncherPluginManager.cruncherPluginManager.cruncherData.triangles.Length;
            if (CruncherPluginManager.cruncherPluginManager.cruncherData.normals != null)
            {
                CruncherPluginManager.cruncherPluginManager.arrayLengths[2] = CruncherPluginManager.cruncherPluginManager.cruncherData.normals.Length;
            }
            if (CruncherPluginManager.cruncherPluginManager.cruncherData.uv0s != null)
            {
                CruncherPluginManager.cruncherPluginManager.arrayLengths[3] = CruncherPluginManager.cruncherPluginManager.cruncherData.uv0s.Length;
            }
            if (CruncherPluginManager.cruncherPluginManager.cruncherData.uv1s != null)
            {
                CruncherPluginManager.cruncherPluginManager.arrayLengths[4] = CruncherPluginManager.cruncherPluginManager.cruncherData.uv1s.Length;
            }
            CruncherPluginManager.cruncherPluginManager.cruncherData.lockedVertices = cruncherIO.lockedVertices;
            if (CruncherPluginManager.cruncherPluginManager.cruncherData.lockedVertices != null)
            {
                CruncherPluginManager.cruncherPluginManager.arrayLengths[5] = CruncherPluginManager.cruncherPluginManager.cruncherData.lockedVertices.Length;
            }
            int num2 = 0;

            for (int i = 0; i < num; i++)
            {
                num2 += cruncherIO.subMeshTriangles[i].Length;
            }
            CruncherPluginManager.cruncherPluginManager.cruncherData.subMeshTriangles = new int[num2];
            int num3 = 0;

            for (int j = 0; j < num; j++)
            {
                CruncherPluginManager.cruncherPluginManager.arrayLengths[7 + j] = cruncherIO.subMeshTriangles[j].Length;
                Array.Copy(cruncherIO.subMeshTriangles[j], 0, CruncherPluginManager.cruncherPluginManager.cruncherData.subMeshTriangles, num3, cruncherIO.subMeshTriangles[j].Length);
                num3 += cruncherIO.subMeshTriangles[j].Length;
            }
            if (cruncherMeshConfiguration != null)
            {
                CruncherPluginManager.cruncherPluginManager.meshConfiguration.joinVertices          = cruncherMeshConfiguration.joinVertices;
                CruncherPluginManager.cruncherPluginManager.meshConfiguration.joinVerticesThreshold = cruncherMeshConfiguration.joinVerticesThreshold;
                CruncherPluginManager.cruncherPluginManager.meshConfiguration.joinNormals           = cruncherMeshConfiguration.joinNormals;
                CruncherPluginManager.cruncherPluginManager.meshConfiguration.joinNormalsThreshold  = cruncherMeshConfiguration.joinNormalsThreshold;
                CruncherPluginManager.cruncherPluginManager.meshConfiguration.joinUvs                   = cruncherMeshConfiguration.joinUvs;
                CruncherPluginManager.cruncherPluginManager.meshConfiguration.joinUvsThreshold          = cruncherMeshConfiguration.joinUvsThreshold;
                CruncherPluginManager.cruncherPluginManager.meshConfiguration.removeTJunctions          = cruncherMeshConfiguration.removeTJunctions;
                CruncherPluginManager.cruncherPluginManager.meshConfiguration.removeTJunctionsThreshold = cruncherMeshConfiguration.removeTJunctionsThreshold;
                CruncherPluginManager.cruncherPluginManager.meshConfiguration.recalculateNormals        = cruncherMeshConfiguration.recalculateNormals;
            }
            else
            {
                Debug.Log("cruncherMeshConfiguration == null, you must pass in a valid CruncherMeshConfiguration in order to process meshes.");
            }
            int num4 = CruncherPluginManager.PluginAddMesh(CruncherPluginManager.cruncherPluginManager.cruncherData, CruncherPluginManager.cruncherPluginManager.arrayLengths, ref CruncherPluginManager.cruncherPluginManager.meshConfiguration);

            CruncherPluginManager.cruncherPluginManager.cruncherData = default(CruncherPluginManager.CruncherData);
            if (num4 < 0)
            {
                Debug.LogError(CruncherPluginManager.errorOperationFailed);
                return(-1);
            }
            CruncherPluginManager.UserData userData = new CruncherPluginManager.UserData();
            if (cruncherIO.colors != null && cruncherIO.colors.Length > 0)
            {
                userData.colors = new Color[cruncherIO.colors.Length];
                Array.Copy(cruncherIO.colors, userData.colors, cruncherIO.colors.Length);
            }
            if (cruncherIO.boneWeights != null && cruncherIO.boneWeights.Length > 0)
            {
                userData.boneWeights = new BoneWeight[cruncherIO.boneWeights.Length];
                Array.Copy(cruncherIO.boneWeights, userData.boneWeights, cruncherIO.boneWeights.Length);
            }
            if (cruncherIO.tangents != null && cruncherIO.tangents.Length > 0)
            {
                userData.tangents = new Vector4[cruncherIO.tangents.Length];
                Array.Copy(cruncherIO.tangents, userData.tangents, cruncherIO.tangents.Length);
            }
            userData.originalVertices = new Vector3[cruncherIO.vertices.Length];
            Array.Copy(cruncherIO.vertices, userData.originalVertices, cruncherIO.vertices.Length);
            userData.bindPoses = cruncherIO.bindPoses;
            CruncherPluginManager.cruncherPluginManager.userData = userData;
            return(num4);
        }