Esempio n. 1
0
        internal static ModelData Create(LinkedList <M3D.Model.Utils.Vector3> verticies, LinkedList <int[]> triangleIndecies = null, ProgressHelper.PercentageDelagate percentageDeligate = null)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var progressHelper = new ProgressHelper(percentageDeligate, 3);

            if (triangleIndecies != null)
            {
                ModelData.GenerateOrderedList(ref verticies, triangleIndecies);
            }

            if (verticies.Count % 3 != 0)
            {
                return(null);
            }

            progressHelper.SetStage(verticies.Count <M3D.Model.Utils.Vector3>());
            if (!ModelData.HashVertexesAndFaces_Helper(verticies, ref progressHelper, out List <Utils.Vector3> newVerticesList, out List <FaceIndex> newFaceList))
            {
                return(null);
            }

            progressHelper.SetStage(newFaceList.Count <ModelData.FaceIndex>());
            List <ModelData.VertexIndex> faceLinkHelper = ModelData.GenerateFaceLink_Helper(newVerticesList, newFaceList, progressHelper);
            var modelData = new ModelData(newFaceList, newVerticesList, faceLinkHelper);

            modelData.InitalizeConvexHull(modelData.GetAllVertexs());
            modelData.ProcessMinMaxBounds();
            stopwatch.Stop();
            if (percentageDeligate == null)
            {
                return(modelData);
            }

            percentageDeligate(100);
            return(modelData);
        }