MyVoxelImport(MyVoxelMap voxelMap, Vector3[] vertexes, MyTriangleVertexIndices[] triangles, MyvoxelImportAction importAction, Matrix modelWorld, MyMwcVoxelMaterialsEnum? voxelMaterial, ref bool changed)
        {
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("voxel import");

            // Load model, get triangles transformed to model's world matrix
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("load model");
            LoadModel(vertexes, triangles, modelWorld);

            //  Fill lookup array with triangles located at specified voxel positions. Array is 2D.
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("fill lookup");
            FillTrianglesLookup(voxelMap);

            // Performs action
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("perform action");
            PerformAction(voxelMap, importAction, voxelMaterial, ref changed);

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }
        void LoadModel(Vector3[] vertexes, MyTriangleVertexIndices[] triangles, Matrix world)
        {
            m_minCoord = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
            m_maxCoord = new Vector3(float.MinValue, float.MinValue, float.MinValue);

            m_triangles = new List<MyImportTriangle>(triangles.Length);

            for (int i = 0; i < triangles.Length; i++)
            {
                Vector3 vertex0 = Vector3.Transform(vertexes[triangles[i].I0], world);
                Vector3 vertex1 = Vector3.Transform(vertexes[triangles[i].I1], world);
                Vector3 vertex2 = Vector3.Transform(vertexes[triangles[i].I2], world);

                MyImportTriangle triangle = new MyImportTriangle(vertex0, vertex1, vertex2);
                //  Ignore triangles that lie in XZ plane
                if (triangle.Normal.Y != 0)
                {
                    m_triangles.Add(triangle);
                    CheckMinMaxCoords(vertex0);
                    CheckMinMaxCoords(vertex1);
                    CheckMinMaxCoords(vertex2);
                }
            }
        }
 public static void Run(MyVoxelMap voxelMap, Vector3[] vertexes, MyTriangleVertexIndices[] triangles, MyvoxelImportAction importAction, Matrix modelWorld, MyMwcVoxelMaterialsEnum? voxelMaterial, ref bool changed)
 {
     MyVoxelImport voxelImport = new MyVoxelImport(voxelMap, vertexes, triangles, importAction, modelWorld, voxelMaterial, ref changed);
 }