コード例 #1
0
        void Create(List <Vertex> vertices, bool translate)
        {
            drawingCanvas.Children.Clear();
            ShowVertices(vertices);

            var config = !translate
                ? new TriangulationComputationConfig()
                : new TriangulationComputationConfig
            {
                PointTranslationType   = PointTranslationType.TranslateInternal,
                PlaneDistanceTolerance = 0.00001,
                // the translation radius should be lower than PlaneDistanceTolerance / 2
                PointTranslationGenerator = TriangulationComputationConfig.RandomShiftByRadius(0.000001, 0)
            };

            try
            {
                voronoiMesh = VoronoiMesh.Create <Vertex, Cell>(vertices, config);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
                return;
            }
            txtBlkTimer.Text = string.Format("{0} faces", voronoiMesh.Vertices.Count());

            Vertices = vertices;

            btnFindDelaunay.IsEnabled = true;
            btnFindVoronoi.IsEnabled  = true;
        }
コード例 #2
0
	// Use this for initialization
	void Start () 
	{
		CreateLineMaterial();
		
		mesh = new Mesh();
		Vertex2[] vertices = new Vertex2[NumberOfVertices];
		Vector3[] meshVerts = new Vector3[NumberOfVertices];
		int[] indices = new int[NumberOfVertices];
		
		Random.seed = 0;
		for (var i = 0; i < NumberOfVertices; i++)
		{
			vertices[i] = new Vertex2(size * Random.Range(-1.0f, 1.0f), size * Random.Range(-1.0f, 1.0f));
			meshVerts[i] = vertices[i].ToVector3();
			indices[i] = i;
		}
		
		mesh.vertices = meshVerts;
		mesh.SetIndices(indices, MeshTopology.Points, 0);
		//mesh.bounds = new Bounds(Vector3.zero, new Vector3((float)size,(float)size,(float)size));
		
		float now = Time.realtimeSinceStartup;
		voronoiMesh = VoronoiMesh.Create<Vertex2, Cell2>(vertices);
		float interval = Time.realtimeSinceStartup - now;

		Debug.Log("time = " + interval * 1000.0f);
		
	}
コード例 #3
0
ファイル: Program.cs プロジェクト: xinqbll001/MIConvexHull
        static void Main()
        {
            const int    NumberOfVertices = 100;
            const double size             = 1000;
            const int    dimension        = 6;

            var r = new Random();

            Console.WriteLine("Ready? Push Return/Enter to start.");
            Console.ReadLine();

            Console.WriteLine("Making " + NumberOfVertices + " random 6D vertices.");
            var vertices = new List <Vertex>();

            for (var i = 0; i < NumberOfVertices; i++)
            {
                var location = new double[dimension];
                for (var j = 0; j < dimension; j++)
                {
                    location[j] = size * r.NextDouble();
                }
                vertices.Add(new Vertex(location));
            }
            Console.WriteLine("Running...");
            var now      = DateTime.Now;
            var voronoi  = VoronoiMesh.Create(vertices);
            var interval = DateTime.Now - now;

            Console.WriteLine("Out of the {0} 6D vertices, there are {1} Voronoi cells and {2} edges.",
                              NumberOfVertices, voronoi.Vertices.Count(), voronoi.Edges.Count());
            Console.WriteLine("time = " + interval);
            Console.ReadLine();
        }
コード例 #4
0
        private void btnMakePoints_Click(object sender, RoutedEventArgs e)
        {
            drawingCanvas.Children.Clear();
            var sizeX = drawingCanvas.ActualWidth;
            var sizeY = drawingCanvas.ActualHeight;

            vertices = new List <Vertex>();
            var r = new Random();

            /****** Random Vertices ******/
            for (var i = 0; i < NumberOfVertices; i++)
            {
                var vi = new Vertex(sizeX * r.NextDouble(), sizeY * r.NextDouble());
                vertices.Add(vi);
            }

            ShowVertices();

            var now = DateTime.Now;

            voronoiMesh = VoronoiMesh.Create <Vertex, Cell>(vertices);
            var interval = DateTime.Now - now;

            txtBlkTimer.Text = string.Format("{0:0.000}s ({1} faces)", interval.TotalSeconds, voronoiMesh.Vertices.Count());

            btnFindDelaunay.IsEnabled = true;
            btnFindVoronoi.IsEnabled  = true;
        }
コード例 #5
0
ファイル: MainWindow.xaml.cs プロジェクト: RobertiF/Dynamo
        private void btnMakePoints_Click(object sender, RoutedEventArgs e)
        {
            drawingCanvas.Children.Clear();
            var sizeX = drawingCanvas.ActualWidth;
            var sizeY = drawingCanvas.ActualHeight;
            vertices = new List<Vertex>();
            var r = new Random();

            /****** Random Vertices ******/
            for (var i = 0; i < NumberOfVertices; i++)
            {
                var vi = new Vertex(sizeX * r.NextDouble(), sizeY * r.NextDouble());
                vertices.Add(vi);
            }
            
            ShowVertices();

            var now = DateTime.Now;
            voronoiMesh = VoronoiMesh.Create<Vertex, Cell>(vertices);
            var interval = DateTime.Now - now;
            txtBlkTimer.Text = string.Format("{0:0.000}s ({1} faces)", interval.TotalSeconds, voronoiMesh.Vertices.Count());

            btnFindDelaunay.IsEnabled = true;
            btnFindVoronoi.IsEnabled = true;
        }
コード例 #6
0
    // Use this for initialization
    void Start()
    {
        CreateLineMaterial();

        mesh = new Mesh();
        Vertex2[] vertices  = new Vertex2[NumberOfVertices];
        Vector3[] meshVerts = new Vector3[NumberOfVertices];
        int[]     indices   = new int[NumberOfVertices];

        Random.seed = 0;
        for (var i = 0; i < NumberOfVertices; i++)
        {
            vertices[i]  = new Vertex2(size * Random.Range(-1.0f, 1.0f), size * Random.Range(-1.0f, 1.0f));
            meshVerts[i] = vertices[i].ToVector3();
            indices[i]   = i;
        }

        mesh.vertices = meshVerts;
        mesh.SetIndices(indices, MeshTopology.Points, 0);
        //mesh.bounds = new Bounds(Vector3.zero, new Vector3((float)size,(float)size,(float)size));

        float now = Time.realtimeSinceStartup;

        voronoiMesh = VoronoiMesh.Create <Vertex2, Cell2>(vertices);
        float interval = Time.realtimeSinceStartup - now;

        Debug.Log("time = " + interval * 1000.0f);
    }
コード例 #7
0
        public override Value Evaluate(FSharpList <Value> args)
        {
            var input  = args[0];
            var result = FSharpList <Value> .Empty;

            if (input.IsList)
            {
                var uvList = (input as Value.List).Item;
                int length = uvList.Length;

                var verts = new List <Vertex2>();

                for (int i = 0; i < length; i++)
                {
                    UV      uv   = (UV)((Value.Container)uvList[i]).Item;
                    Vertex2 vert = new Vertex2(uv.U, uv.V);
                    verts.Add(vert);
                }

                var voronoiMesh = VoronoiMesh.Create <Vertex2, Cell2>(verts);

                _tessellationLines.Clear();

                object arg1 = ((Value.Container)args[1]).Item;
                var    f    = arg1 as Face;

                if (f != null)
                {
                    foreach (VoronoiEdge <Vertex2, Cell2> edge in voronoiMesh.Edges)
                    {
                        var from = edge.Source.Circumcenter;
                        var to   = edge.Target.Circumcenter;

                        var uv1 = new UV(from.X, from.Y);
                        var uv2 = new UV(to.X, to.Y);

                        if (!f.IsInside(uv1) || !f.IsInside(uv2))
                        {
                            continue;
                        }

                        var start = f.Evaluate(uv1);
                        var end   = f.Evaluate(uv2);

                        if (start.DistanceTo(end) > 0.1)
                        {
                            var l = this.UIDocument.Application.Application.Create.NewLineBound(start, end);
                            _tessellationLines.Add(l);

                            result = FSharpList <Value> .Cons(Value.NewContainer(l), result);
                        }
                    }
                }

                return(Value.NewList(result));
            }

            return(Value.NewList(result));
        }
コード例 #8
0
        private void makeMesh()
        {
            var points      = new List <Vertex>();
            var voronoiMesh = VoronoiMesh.Create <Vertex, Cell>(points);
            var vi          = new Vertex();

            foreach (var cell in voronoiMesh.Vertices)
            {
                for (int v = 0; v < 3; v++)
                {
                }
            }
        }
コード例 #9
0
ファイル: Voronoi.cs プロジェクト: tylerputnam/Dynamo
        /// <summary>
        ///     Creates a Voronoi tessellation of a surface with a given set of UV parameters.
        /// </summary>
        /// <param name="uvs">Set of UV parameters.</param>
        /// <param name="face">Surface to tesselate.</param>
        public static IEnumerable <Curve> ByParametersOnSurface(IEnumerable <UV> uvs, Surface face)
        {
            var verts       = uvs.Select(Vertex2.FromUV).ToList();
            var voronoiMesh = VoronoiMesh.Create <Vertex2, Cell2>(verts);

            return(from edge in voronoiMesh.Edges
                   let _from = edge.Source.Circumcenter
                               let to = edge.Target.Circumcenter
                                        let start = face.PointAtParameter(_from.X, _from.Y)
                                                    let end = face.PointAtParameter(to.X, to.Y)
                                                              where start.DistanceTo(end) > 0.1
                                                              select Line.ByStartPointEndPoint(start, end));
        }
コード例 #10
0
ファイル: MIConvexHullTest.cs プロジェクト: whigg/PointClouds
        public void Face_Delaunay()
        {
            string fileNameLong = pathUnitTests + "\\KinectFace_1_15000.obj";

            pointCloudSource = IOUtils.ReadObjFile_ToPointCloud(fileNameLong);


            List <Vertex2D> pointCloudDelaunay = new List <Vertex2D>();

            for (int i = 0; i < pointCloudSource.Count; i++)
            {
                Vertex2D v = new Vertex2D(i, pointCloudSource[i].Vector.X, pointCloudSource[i].Vector.Y);
                pointCloudDelaunay.Add(v);
            }
            //--------------------------------


            //------------------------------------------------

            VoronoiMesh <Vertex2D, Cell2D, VoronoiEdge <Vertex2D, Cell2D> > voronoiMesh;

            voronoiMesh = VoronoiMesh.Create <Vertex2D, Cell2D>(pointCloudDelaunay);
            List <Triangle> listTriangle = new List <Triangle>();

            foreach (Cell2D cell in voronoiMesh.Cells)
            {
                Triangle t = new Triangle();

                t.IndVertices.Add(Convert.ToUInt32(cell.Vertices[0].IndexInPointCloud));
                t.IndVertices.Add(Convert.ToUInt32(cell.Vertices[1].IndexInPointCloud));
                t.IndVertices.Add(Convert.ToUInt32(cell.Vertices[2].IndexInPointCloud));
                listTriangle.Add(t);
                //Vertex2D[] vert = cell.Vertices;
            }

            ////adapt Vertex3d for normal calculation
            //for (int i = 0; i < pointCloudSource.Count; i++)
            //{
            //    Vertex v = pointCloudSource[i]
            //    Vertex2D v = new Vertex2D(i, pointCloudSource[i].Vector.X, pointCloudSource[i].Vector.Y);
            //    pointCloudDelaunay.Add(v);

            //}

            //-------------------


            pointCloudSource.ToObjFile(pathUnitTests, "1_triangulated.obj");

            ShowPointCloud(pointCloudSource);
        }
コード例 #11
0
 public void visualizeVertices(VoronoiMesh <Vector3Vertex, Tetrahedron, VoronoiEdge <Vector3Vertex, Tetrahedron> > triangulation)
 {
     // visualize
     foreach (var cell in triangulation.Vertices)
     {
         foreach (var vertex in cell.Vertices)
         {
             GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
             sphere.transform.position   = vertex.toVector3();
             sphere.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
             sphere.transform.SetParent(_voronoi.transform);
             setColor(sphere, ColorAssistant.getQualitativeColor(1));
         }
     }
 }
コード例 #12
0
 public void ComputeVD()
 {
     voronoiMesh = VoronoiMesh.Create <DualSite2d, Site>(dualSites);
     foreach (Site vertex in voronoiMesh.Vertices)
     {
         Vector2      circumcenter = vertex.Circumcenter;
         Cell         cell         = mg.GetCell(circumcenter);
         DualSite2d[] vertices     = vertex.Vertices;
         foreach (DualSite2d dualSite2d in vertices)
         {
             if (!dualSite2d.visited)
             {
                 dualSite2d.visited = true;
                 if (!dualSite2d.site.dummy)
                 {
                     List <Vector2> list = new List <Vector2>();
                     dualSite2d.site.neighbours = TouchingFaces(dualSite2d, vertex);
                     foreach (Site neighbour in dualSite2d.site.neighbours)
                     {
                         Vector2 circumcenter2 = neighbour.Circumcenter;
                         Color   red           = Color.red;
                         red.a = 0.3f;
                         list.Add(circumcenter2);
                         Vector2 position = circumcenter2;
                         Cell    cell2    = mg.GetCell(position);
                         if (cell != null && cell2 != null)
                         {
                             cell.Add(cell2);
                             cell2.Add(cell);
                             Corner corner  = mg.GetCorner(circumcenter, true);
                             Corner corner2 = mg.GetCorner(position, true);
                             cell.Add(corner);
                             cell.Add(corner2);
                             cell2.Add(corner);
                             cell2.Add(corner2);
                         }
                     }
                     if (list.Count > 0)
                     {
                         Polygon polygon = PolyForRandomPoints(list);
                         dualSite2d.site.poly = polygon.Clip(bounds, ClipType.ctIntersection);
                     }
                 }
             }
         }
     }
     ClipNeighbors();
 }
コード例 #13
0
    public void visualizeCells(VoronoiMesh <Vector3Vertex, Tetrahedron, VoronoiEdge <Vector3Vertex, Tetrahedron> > triangulation)
    {
        Tetrahedron cell = triangulation.Vertices.First <Tetrahedron>();
        //foreach (var cell in triangulation.Vertices)
        //{
        Mesh faces = cell.CreateModel(ColorAssistant.getDivergingColor(0), 1.0f);

        faces.RecalculateNormals();
        faces.RecalculateBounds();
        GameObject o = new GameObject("cell");

        o.AddComponent <MeshFilter>();
        o.GetComponent <MeshFilter>().mesh = faces;
        o.AddComponent <MeshRenderer>();
        //}
    }
コード例 #14
0
ファイル: MIConvexHullTest.cs プロジェクト: whigg/PointClouds
        public void Face_Voronoi_TODO()
        {
            string fileNameLong = pathUnitTests + "\\KinectFace_1_15000.obj";

            pointCloudSource = IOUtils.ReadObjFile_ToPointCloud(fileNameLong);


            List <Vertex2D> pointCloudDelaunay = new List <Vertex2D>();

            for (int i = 0; i < pointCloudSource.Count; i++)
            {
                Vertex2D v = new Vertex2D(i, pointCloudSource[i].Vector.X, pointCloudSource[i].Vector.Y);
                pointCloudDelaunay.Add(v);
            }


            VoronoiMesh <Vertex2D, Cell2D, VoronoiEdge <Vertex2D, Cell2D> > voronoiMesh;

            voronoiMesh = VoronoiMesh.Create <Vertex2D, Cell2D>(pointCloudDelaunay);
            //List<Triangle> listTriangle = new List<Triangle>();

            foreach (var edge in voronoiMesh.Edges)
            {
                var from = edge.Source.Circumcenter;
                var to   = edge.Target.Circumcenter;
                //drawingCanvas.Children.Add(new Line { X1 = from.X, Y1 = from.Y, X2 = to.X, Y2 = to.Y, Stroke = Brushes.Black });
            }

            foreach (var cell in voronoiMesh.Cells)
            {
                for (int i = 0; i < 3; i++)
                {
                    if (cell.Adjacency[i] == null)
                    {
                        var from = cell.Circumcenter;
                        //var t = cell.Vertices.Where((_, j) => j != i).ToArray();
                        //var factor = 100 * IsLeft(t[0].ToPoint(), t[1].ToPoint(), from) * IsLeft(t[0].ToPoint(), t[1].ToPoint(), Center(cell));
                        //var dir = new Point(0.5f * (t[0].Position[0] + t[1].Position[0]), 0.5f * (t[0].Position[1] + t[1].Position[1])) - from;
                        //var to = from + factor * dir;
                        //drawingCanvas.Children.Add(new Line { X1 = from.X, Y1 = from.Y, X2 = to.X, Y2 = to.Y, Stroke = Brushes.Black });
                    }
                }
            }

            //-------------------
            ShowPointCloud(pointCloudSource);
        }
コード例 #15
0
    public void visualizeEdges(VoronoiMesh <Vector3Vertex, Tetrahedron, VoronoiEdge <Vector3Vertex, Tetrahedron> > triangulation)
    {
        // visualize

        foreach (var edge in triangulation.Edges)
        {
            Vector3 from = edge.Source.calculateCircumsphere();
            Vector3 to   = edge.Target.calculateCircumsphere();

            drawLine(from, to, ColorAssistant.getDivergingColor(0));
        }

        /*
         * int cellIdx = 0;
         * foreach(var cell in triangulation.Vertices)
         * {
         *  foreach(var neighbor in cell.Adjacency)
         *  {
         *      if (neighbor == null) continue;
         *      Vector3 from = cell.calculateCircumsphere();
         *      Vector3 to = neighbor.calculateCircumsphere();
         *
         *      drawLine(from, to, ColorAssistant.getQualitativeColor(cellIdx));
         *  }
         *  cellIdx++;
         * }
         */

        /*
         * foreach (var cell in triangulation.Vertices)
         * {
         *  for (int i = 0; i < 4; i++)
         *  {
         *      if (cell.Adjacency[i] == null)
         *      {
         *          Vector3 from = cell.calculateCircumsphere();
         *          var t = cell.Vertices.Where((_, j) => j != i).ToArray();
         *          float factor = 100.0f ;
         *          Vector3 dir = new Vector3((float)(0.5f * (t[0].Position[0] + t[1].Position[0])), (float)(0.5f * (t[0].Position[1] + t[1].Position[1])), (float)(0.5f * (t[0].Position[2] + t[1].Position[2]))) - from;
         *          Vector3 to = from + factor * dir;
         *          drawLine(from, to, ColorAssistant.getDivergingColor(1));
         *      }
         *  }
         * }
         */
    }
コード例 #16
0
        /// <summary>
        /// Creates cells of this volumetric data froma voronoi generators.
        /// </summary>
        /// <typeparam name="TInVertex">Type of input vertices.</typeparam>
        /// <param name="generators">Voronoi generators.</param>
        public void FromVoronoi <TInVertex>(List <TInVertex> generators) where TInVertex : IIndexedVertex
        {
            var cells = new TCell[generators.Count];

            // Create voronoi diagram from the generators.
            var voronoiMesh = VoronoiMesh.Create(generators);

            // Iteratate over all voronoi vertices.
            // They are represented as tetrahedra in the implementation of the voronoi diagram.
            // So each vertex of the tetrahedron is a generator of an adjecent voronoi cell.
            foreach (var tetrahedron in voronoiMesh.Vertices)
            {
                // Iterate over all adjecent generators.
                for (int i = 0; i < tetrahedron.Vertices.Length; i++)
                {
                    // Create a voronoi cell for the generator or find it if the generator has already been visited.
                    TCell sourceCell = this.AddCellToDictionary(tetrahedron.Vertices[i], cells);

                    // From the comments above follows that vertices of the tetrahedron and their corresponding voronoi cells are each other's neighbors.
                    // So iterate over neighbors of the current source cell.
                    for (int j = i + 1; j < tetrahedron.Vertices.Length; j++)
                    {
                        // Create a voronoi cell for the neighboring generator or find it if the generator has already been visited.
                        TCell targetCell = this.AddCellToDictionary(tetrahedron.Vertices[j], cells);

                        // Check if the target cell has already been added to the neighbors of the source cell.
                        // If it hasn't create a new edge separating them.
                        if (!sourceCell.Edges.Any(edge => edge.Target == targetCell))
                        {
                            // Get position of the source and target
                            // The source is the cell and the target its neigbor
                            var sourcePosition = tetrahedron.Vertices[i].Position;
                            var targetPosition = tetrahedron.Vertices[j].Position;

                            this.ComputeVoronoiEdge(sourcePosition, targetPosition, sourceCell, targetCell);
                        }
                    }
                }
            }

            this.Cells = cells.ToList();
        }
コード例 #17
0
        void Create(List <Vertex> vertices)
        {
            drawingCanvas.Children.Clear();
            ShowVertices(vertices);

            try
            {
                voronoiMesh = VoronoiMesh.Create <Vertex, Cell>(vertices);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
                return;
            }
            txtBlkTimer.Text = string.Format("{0} faces", voronoiMesh.Vertices.Count());

            Vertices = vertices;

            btnFindDelaunay.IsEnabled = true;
            btnFindVoronoi.IsEnabled  = true;
        }
コード例 #18
0
        private Dictionary <MIVector, VoronoiCell> GetAreasForPositions(List <MIVector> vertices)
        {
            Dictionary <MIVector, VoronoiCell> verticesToVoronoi = new Dictionary <MIVector, VoronoiCell>();

            foreach (MIVector position in vertices)
            {
                verticesToVoronoi[position] = new VoronoiCell()
                {
                    Generator = position.Clone()
                };
            }

            VoronoiMesh <MIVector, DelaunayCell, VoronoiEdge <MIVector, DelaunayCell> > delaunayMesh = VoronoiMesh.Create <MIVector, DelaunayCell>(vertices);

            foreach (var cell in delaunayMesh.Vertices)
            {
                GetEdgesForDelaunayCell(cell, verticesToVoronoi);
            }

            foreach (VoronoiCell cell in verticesToVoronoi.Values.ToList())
            {
                _createCellPolygon(cell);
            }

            return(verticesToVoronoi);
        }
コード例 #19
0
ファイル: Program.cs プロジェクト: hipigod/Dynamo
        static TimeSpan TestNDVoronoi(int dim, int numVert, double size)
        {
            var vertices = CreateRandomVertices(dim, numVert, size);

            return(RunComputation(() => VoronoiMesh.Create(vertices)));
        }
コード例 #20
0
        void Create(List<Vertex> vertices, bool translate)
        {
            drawingCanvas.Children.Clear();
            ShowVertices(vertices);

            var config = !translate
                ? new TriangulationComputationConfig()
                : new TriangulationComputationConfig
                {
                    PointTranslationType = PointTranslationType.TranslateInternal,
                    PlaneDistanceTolerance = 0.00001,
                    // the translation radius should be lower than PlaneDistanceTolerance / 2
                    PointTranslationGenerator = TriangulationComputationConfig.RandomShiftByRadius(0.000001, 0)
                };

            try
            {
                voronoiMesh = VoronoiMesh.Create<Vertex, Cell>(vertices, config);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
                return;
            }
            txtBlkTimer.Text = string.Format("{0} faces", voronoiMesh.Vertices.Count());

            Vertices = vertices;

            btnFindDelaunay.IsEnabled = true;
            btnFindVoronoi.IsEnabled = true;
        }
コード例 #21
0
    // Use this for initialization
    void Start()
    {
        const int   NumberOfVertices = 10;
        const float size             = 20;
        const int   dimension        = 3;



        List <List <Vector3> > vc = new List <List <Vector3> > ();

//		vc.Add(new List<Vector3>(){
//			new Vector3(-1,-1,-1) ,
//			new Vector3(1,-1,-1),
//			new Vector3(-1,1,-1),
//			new Vector3(0,1,1),
//			new Vector3(-1,-1,1),
//			new Vector3(1,-1,1),
//			new Vector3(-1,1,1),
//			new Vector3(1,0,1),
//			new Vector3(1,0,-1),
//			new Vector3(0,1,-1)

//		});

        //ALL VC POINTS:



//		//BAD BLOCK
//		//SHOULD BE BAD
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.16764f,-0.0700706f,-0.5f),
//			new Vector3(-0.0464072f,-0.0647357f,-0.5f),
//			new Vector3(-0.144536f,0.237344f,-0.5f),
//			new Vector3(-0.149231f,0.240476f,-0.5f),
//
//			new Vector3(-0.16764f,-0.0700706f,0.5f),
//			new Vector3(-0.0464072f,-0.0647357f,0.5f),
//			new Vector3(-0.144536f,0.237344f,0.5f),
//			new Vector3(-0.149231f,0.240476f,0.5f),
//
//		});
//
//		//Fails on completely parallel triangles
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.348162f,-0.0982212f,-0.5f),
//			new Vector3(-0.0326806f,-0.398012f,0.5f),
//			new Vector3(-0.348162f,-0.0982212f,0.5f),
//			//new Vector3(-0.0326806f,-0.398012f,-0.2f),//Introduced a way point
//			new Vector3(-0.0326806f,-0.398012f,-0.5f),
//			new Vector3(-0.232884f,-0.0832066f,-0.5f),
//			new Vector3(-0.232884f,-0.0832066f,0.5f),
//
//		});

//		//TEST #2
//		vc.Add(new List<Vector3>(){
//			new Vector3(-1f,-1f,-0.5f),
//			new Vector3(0.536051f,-1f,-0.5f),
//			new Vector3(-0.191468f,-0.375987f,-0.5f),
//			new Vector3(0.0555073f,-0.372317f,-0.5f),
//			new Vector3(-1f,-1f,0.5f),
//			new Vector3(0.536051f,-1f,0.5f),
//			new Vector3(0.0173284f,-0.361066f,0.5f),
//			new Vector3(0.0555073f,-0.372317f,0.5f),
//			new Vector3(0.0173284f,-0.361066f,-0.5f),
//			new Vector3(-1f,-0.795192f,-0.5f),
//			new Vector3(-1f,-0.795192f,0.5f),
//			new Vector3(-0.191468f,-0.375987f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.102548f,-0.119624f,-0.5f),
//			new Vector3(-0.0611588f,-0.0380439f,-0.5f),
//			new Vector3(0.00741258f,-0.118741f,0.5f),
//			new Vector3(0.00741258f,-0.118741f,-0.5f),
//			new Vector3(-0.102548f,-0.119624f,0.5f),
//			new Vector3(-0.006146f,-0.0269761f,-0.5f),
//			new Vector3(-0.0611588f,-0.0380439f,0.5f),
//			new Vector3(-0.006146f,-0.0269761f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.191468f,-0.375987f,0.5f),
//			new Vector3(-0.191468f,-0.375987f,-0.5f),
//			new Vector3(-0.0793624f,-0.200597f,-0.5f),
//			new Vector3(-0.0340186f,-0.214759f,0.5f),
//			new Vector3(0.0173284f,-0.361066f,0.5f),
//			new Vector3(-0.0340186f,-0.214759f,-0.5f),
//			new Vector3(-0.0793624f,-0.200597f,0.5f),
//			new Vector3(0.0173284f,-0.361066f,-0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-1f,-0.795192f,-0.5f),
//			new Vector3(-0.0793624f,-0.200597f,-0.5f),
//			new Vector3(-0.107104f,-0.12395f,-0.5f),
//			new Vector3(-0.0793624f,-0.200597f,0.5f),
//			new Vector3(-1f,-0.795192f,0.5f),
//			new Vector3(-0.191468f,-0.375987f,0.5f),
//			new Vector3(-1f,-0.781501f,0.5f),
//			new Vector3(-1f,-0.781501f,-0.5f),
//			new Vector3(-0.191468f,-0.375987f,-0.5f),
//			new Vector3(-0.107104f,-0.12395f,0.5f),
//			new Vector3(-0.257323f,-0.0957589f,0.5f),
//			new Vector3(-0.257323f,-0.0957589f,-0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(0.00741258f,-0.118741f,0.5f),
//			new Vector3(-0.0793624f,-0.200597f,-0.5f),
//			new Vector3(-0.107104f,-0.12395f,0.5f),
//			new Vector3(0.123349f,-0.160472f,0.5f),
//			new Vector3(-0.0340186f,-0.214759f,0.5f),
//			new Vector3(-0.0340186f,-0.214759f,-0.5f),
//			new Vector3(-0.0793624f,-0.200597f,0.5f),
//			new Vector3(-0.102548f,-0.119624f,0.5f),
//			new Vector3(-0.102548f,-0.119624f,-0.5f),
//			new Vector3(-0.107104f,-0.12395f,-0.5f),
//			new Vector3(0.12004f,-0.17124f,0.5f),
//			new Vector3(0.12004f,-0.17124f,-0.5f),
//			new Vector3(0.123349f,-0.160472f,-0.5f),
//			new Vector3(0.00741258f,-0.118741f,-0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.257323f,-0.0957589f,0.5f),
//			new Vector3(-0.102548f,-0.119624f,0.5f),
//			new Vector3(-0.171954f,0.0668147f,0.5f),
//			new Vector3(-0.117652f,0.0686361f,-0.5f),
//			new Vector3(-0.257323f,-0.0957589f,-0.5f),
//			new Vector3(-0.107104f,-0.12395f,0.5f),
//			new Vector3(-0.124183f,0.0732046f,0.5f),
//			new Vector3(-0.0611588f,-0.0380439f,-0.5f),
//			new Vector3(-0.107104f,-0.12395f,-0.5f),
//			new Vector3(-0.102548f,-0.119624f,-0.5f),
//			new Vector3(-0.117652f,0.0686361f,0.5f),
//			new Vector3(-0.0611588f,-0.0380439f,0.5f),
//			new Vector3(-0.124183f,0.0732046f,-0.5f),
//			new Vector3(-0.171954f,0.0668147f,-0.5f),
//			new Vector3(-0.254036f,-0.0717289f,0.5f),
//			new Vector3(-0.254036f,-0.0717289f,-0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(0.536051f,-1f,0.5f),
//			new Vector3(0.855617f,-1f,-0.5f),
//			new Vector3(0.121255f,-0.180823f,-0.5f),
//			new Vector3(0.121255f,-0.180823f,0.5f),
//			new Vector3(0.0555073f,-0.372317f,0.5f),
//			new Vector3(0.855617f,-1f,0.5f),
//			new Vector3(0.0555073f,-0.372317f,-0.5f),
//			new Vector3(0.536051f,-1f,-0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(0.267402f,0.130015f,-0.5f),
//			new Vector3(1f,-0.194706f,0.5f),
//			new Vector3(0.165052f,-0.118485f,0.5f),
//			new Vector3(0.846305f,0.532869f,-0.5f),
//			new Vector3(1f,-0.194706f,-0.5f),
//			new Vector3(0.165052f,-0.118485f,-0.5f),
//			new Vector3(0.267402f,0.130015f,0.5f),
//			new Vector3(1f,0.59539f,-0.5f),
//			new Vector3(0.846305f,0.532869f,0.5f),
//			new Vector3(1f,0.59539f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(0.855617f,-1f,-0.5f),
//			new Vector3(1f,-1f,-0.5f),
//			new Vector3(0.121255f,-0.180823f,0.5f),
//			new Vector3(1f,-0.194706f,-0.5f),
//			new Vector3(0.855617f,-1f,0.5f),
//			new Vector3(1f,-1f,0.5f),
//			new Vector3(0.147274f,-0.12381f,-0.5f),
//			new Vector3(1f,-0.194706f,0.5f),
//			new Vector3(0.12004f,-0.17124f,0.5f),
//			new Vector3(0.121255f,-0.180823f,-0.5f),
//			new Vector3(0.123349f,-0.160472f,0.5f),
//			new Vector3(0.165052f,-0.118485f,-0.5f),
//			new Vector3(0.123349f,-0.160472f,-0.5f),
//			new Vector3(0.12004f,-0.17124f,-0.5f),
//			new Vector3(0.147274f,-0.12381f,0.5f),
//			new Vector3(0.165052f,-0.118485f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(0.12004f,-0.17124f,-0.5f),
//			new Vector3(-0.0340186f,-0.214759f,-0.5f),
//			new Vector3(0.12004f,-0.17124f,0.5f),
//			new Vector3(0.121255f,-0.180823f,0.5f),
//			new Vector3(0.0555073f,-0.372317f,-0.5f),
//			new Vector3(0.0555073f,-0.372317f,0.5f),
//			new Vector3(-0.0340186f,-0.214759f,0.5f),
//			new Vector3(0.121255f,-0.180823f,-0.5f),
//			new Vector3(0.0173284f,-0.361066f,0.5f),
//			new Vector3(0.0173284f,-0.361066f,-0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(0.00741258f,-0.118741f,-0.5f),
//			new Vector3(0.123349f,-0.160472f,0.5f),
//			new Vector3(0.0657027f,0.00496402f,-0.5f),
//			new Vector3(0.0657027f,0.00496402f,0.5f),
//			new Vector3(0.00741258f,-0.118741f,0.5f),
//			new Vector3(0.123349f,-0.160472f,-0.5f),
//			new Vector3(-0.006146f,-0.0269761f,-0.5f),
//			new Vector3(-0.006146f,-0.0269761f,0.5f),
//			new Vector3(0.147274f,-0.12381f,-0.5f),
//			new Vector3(0.147274f,-0.12381f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-1f,-0.781501f,0.5f),
//			new Vector3(-0.660971f,0.601722f,-0.5f),
//			new Vector3(-1f,0.909721f,-0.5f),
//			new Vector3(-0.752045f,0.71827f,0.5f),
//			new Vector3(-0.257323f,-0.0957589f,-0.5f),
//			new Vector3(-0.254036f,-0.0717289f,-0.5f),
//			new Vector3(-1f,0.909721f,0.5f),
//			new Vector3(-0.752045f,0.71827f,-0.5f),
//			new Vector3(-1f,-0.781501f,-0.5f),
//			new Vector3(-0.660971f,0.601722f,0.5f),
//			new Vector3(-0.254036f,-0.0717289f,0.5f),
//			new Vector3(-0.257323f,-0.0957589f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.124183f,0.0732046f,0.5f),
//			new Vector3(0.0399654f,0.0694558f,0.5f),
//			new Vector3(-0.0225365f,0.3006f,-0.5f),
//			new Vector3(0.0399654f,0.0694558f,-0.5f),
//			new Vector3(-0.124183f,0.0732046f,-0.5f),
//			new Vector3(-0.0225365f,0.3006f,0.5f),
//			new Vector3(-0.117652f,0.0686361f,-0.5f),
//			new Vector3(-0.117652f,0.0686361f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(0.0680041f,0.0421237f,-0.5f),
//			new Vector3(-0.006146f,-0.0269761f,0.5f),
//			new Vector3(-0.117652f,0.0686361f,-0.5f),
//			new Vector3(0.0399654f,0.0694558f,0.5f),
//			new Vector3(0.0399654f,0.0694558f,-0.5f),
//			new Vector3(0.0680041f,0.0421237f,0.5f),
//			new Vector3(-0.0611588f,-0.0380439f,-0.5f),
//			new Vector3(0.0657027f,0.00496402f,0.5f),
//			new Vector3(-0.0611588f,-0.0380439f,0.5f),
//			new Vector3(-0.117652f,0.0686361f,0.5f),
//			new Vector3(-0.006146f,-0.0269761f,-0.5f),
//			new Vector3(0.0657027f,0.00496402f,-0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.660971f,0.601722f,-0.5f),
//			new Vector3(-0.660971f,0.601722f,0.5f),
//			new Vector3(-0.254036f,-0.0717289f,-0.5f),
//			new Vector3(-0.171954f,0.0668147f,-0.5f),
//			new Vector3(-0.171954f,0.0668147f,0.5f),
//			new Vector3(-0.254036f,-0.0717289f,0.5f),
//			new Vector3(-0.254036f,-0.0717289f,0f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.171954f,0.0668147f,0.5f),
//			new Vector3(-0.124183f,0.0732046f,-0.5f),
//			new Vector3(-0.752045f,0.71827f,-0.5f),
//			new Vector3(-0.0219509f,0.323106f,0.5f),
//			new Vector3(-0.660971f,0.601722f,0.5f),
//			new Vector3(-0.124183f,0.0732046f,0.5f),
//			new Vector3(-0.752045f,0.71827f,0.5f),
//			new Vector3(-0.0219509f,0.323106f,-0.5f),
//			new Vector3(-0.660971f,0.601722f,-0.5f),
//			new Vector3(-0.171954f,0.0668147f,-0.5f),
//			new Vector3(-0.0225365f,0.3006f,-0.5f),
//			new Vector3(-0.0225365f,0.3006f,0.5f),
//			new Vector3(-0.0216151f,0.309922f,-0.5f),
//			new Vector3(-0.0216151f,0.309922f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.0219509f,0.323106f,0.5f),
//			new Vector3(0.151151f,0.0961385f,-0.5f),
//			new Vector3(-0.0219509f,0.323106f,-0.5f),
//			new Vector3(0.846305f,0.532869f,-0.5f),
//			new Vector3(0.267402f,0.130015f,-0.5f),
//			new Vector3(0.846305f,0.532869f,0.5f),
//			new Vector3(0.267402f,0.130015f,0.5f),
//			new Vector3(0.151151f,0.0961385f,0.5f),
//			new Vector3(-0.0216151f,0.309922f,-0.5f),
//			new Vector3(-0.0216151f,0.309922f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(0.151151f,0.0961385f,-0.5f),
//			new Vector3(0.0680041f,0.0421237f,0.5f),
//			new Vector3(-0.0225365f,0.3006f,-0.5f),
//			new Vector3(0.0399654f,0.0694558f,0.5f),
//			new Vector3(0.151151f,0.0961385f,0.5f),
//			new Vector3(-0.0216151f,0.309922f,-0.5f),
//			new Vector3(0.0399654f,0.0694558f,-0.5f),
//			new Vector3(0.0680041f,0.0421237f,-0.5f),
//			new Vector3(-0.0225365f,0.3006f,0.5f),
//			new Vector3(-0.0216151f,0.309922f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(0.0680041f,0.0421237f,-0.5f),
//			new Vector3(0.0657027f,0.00496402f,-0.5f),
//			new Vector3(0.151151f,0.0961385f,-0.5f),
//			new Vector3(0.267402f,0.130015f,-0.5f),
//			new Vector3(0.147274f,-0.12381f,-0.5f),
//			new Vector3(0.147274f,-0.12381f,0.5f),
//			new Vector3(0.151151f,0.0961385f,0.5f),
//			new Vector3(0.267402f,0.130015f,0.5f),
//			new Vector3(0.165052f,-0.118485f,-0.5f),
//			new Vector3(0.165052f,-0.118485f,0.5f),
//			new Vector3(0.0657027f,0.00496402f,0.5f),
//			new Vector3(0.0680041f,0.0421237f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-1f,0.909721f,0.5f),
//			new Vector3(1f,0.59539f,0.5f),
//			new Vector3(-1f,1f,-0.5f),
//			new Vector3(1f,1f,-0.5f),
//			new Vector3(-1f,0.909721f,-0.5f),
//			new Vector3(0.846305f,0.532869f,0.5f),
//			new Vector3(-1f,1f,0.5f),
//			new Vector3(1f,1f,0.5f),
//			new Vector3(-0.0219509f,0.323106f,0.5f),
//			new Vector3(-0.0219509f,0.323106f,-0.5f),
//			new Vector3(-0.752045f,0.71827f,0.5f),
//			new Vector3(-0.752045f,0.71827f,-0.5f),
//			new Vector3(0.846305f,0.532869f,-0.5f),
//			new Vector3(1f,0.59539f,-0.5f),
//
//		});



//		//TEST#3
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-1f,-0.960555f,0.5f),
//			new Vector3(-1f,-0.960555f,-0.5f),
//			new Vector3(-1f,0.55324f,-0.5f),
//			new Vector3(-0.426258f,0.124114f,0.5f),
//			new Vector3(-0.304973f,-0.213889f,0.5f),
//			new Vector3(-0.479205f,0.176951f,0.5f),
//			new Vector3(-1f,0.55324f,0.5f),
//			new Vector3(-0.304973f,-0.213889f,-0.5f),
//			new Vector3(-0.426258f,0.124114f,-0.5f),
//			new Vector3(-0.479205f,0.176951f,-0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.186329f,-0.243634f,0.5f),
//			new Vector3(-0.186329f,-0.243634f,-0.5f),
//			new Vector3(0.0540037f,-0.225309f,-0.5f),
//			new Vector3(0.0540037f,-0.225309f,0.5f),
//			new Vector3(-0.217051f,-0.197398f,0.5f),
//			new Vector3(-0.217051f,-0.197398f,-0.5f),
//			new Vector3(-0.151959f,-0.0789192f,0.5f),
//			new Vector3(-0.104137f,-0.077778f,0.5f),
//			new Vector3(-0.104137f,-0.077778f,-0.5f),
//			new Vector3(-0.151959f,-0.0789192f,-0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.304973f,-0.213889f,-0.5f),
//			new Vector3(-0.217051f,-0.197398f,-0.5f),
//			new Vector3(-0.426258f,0.124114f,-0.5f),
//			new Vector3(-0.151959f,-0.0789192f,0.5f),
//			new Vector3(-0.304973f,-0.213889f,0.5f),
//			new Vector3(-0.217051f,-0.197398f,0.5f),
//			new Vector3(-0.426258f,0.124114f,0.5f),
//			new Vector3(-0.151959f,-0.0789192f,-0.5f),
//			new Vector3(-0.254596f,0.0110088f,-0.5f),
//			new Vector3(-0.254596f,0.0110088f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-1f,-1f,-0.5f),
//			new Vector3(-0.304973f,-0.213889f,-0.5f),
//			new Vector3(-0.186329f,-0.243634f,-0.5f),
//			new Vector3(-0.217051f,-0.197398f,0.5f),
//			new Vector3(-1f,-1f,0.5f),
//			new Vector3(-0.0660014f,-1f,-0.5f),
//			new Vector3(-0.217051f,-0.197398f,-0.5f),
//			new Vector3(-0.304973f,-0.213889f,0.5f),
//			new Vector3(-0.186329f,-0.243634f,0.5f),
//			new Vector3(-0.0660014f,-1f,0.5f),
//			new Vector3(-1f,-0.960555f,-0.5f),
//			new Vector3(-1f,-0.960555f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.0660014f,-1f,-0.5f),
//			new Vector3(0.298754f,-0.441025f,-0.5f),
//			new Vector3(-0.186329f,-0.243634f,-0.5f),
//			new Vector3(0.0854744f,-0.245537f,0.5f),
//			new Vector3(-0.0660014f,-1f,0.5f),
//			new Vector3(0.607584f,-1f,-0.5f),
//			new Vector3(-0.186329f,-0.243634f,0.5f),
//			new Vector3(0.0854744f,-0.245537f,-0.5f),
//			new Vector3(0.0540037f,-0.225309f,-0.5f),
//			new Vector3(0.0540037f,-0.225309f,0.5f),
//			new Vector3(0.298754f,-0.441025f,0.5f),
//			new Vector3(0.607584f,-1f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.00424733f,0.0677186f,-0.5f),
//			new Vector3(0.0854744f,-0.245537f,0.5f),
//			new Vector3(-0.104137f,-0.077778f,-0.5f),
//			new Vector3(0.0421851f,0.0652789f,-0.5f),
//			new Vector3(-0.104137f,-0.077778f,0.5f),
//			new Vector3(0.0540037f,-0.225309f,0.5f),
//			new Vector3(-0.00424733f,0.0677186f,0.5f),
//			new Vector3(0.0421851f,0.0652789f,0.5f),
//			new Vector3(0.0540037f,-0.225309f,-0.5f),
//			new Vector3(0.0854744f,-0.245537f,-0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(0.22418f,0.03625f,0.5f),
//			new Vector3(0.298754f,-0.441025f,-0.5f),
//			new Vector3(0.0421851f,0.0652789f,-0.5f),
//			new Vector3(0.0854744f,-0.245537f,-0.5f),
//			new Vector3(0.298754f,-0.441025f,0.5f),
//			new Vector3(0.22418f,0.03625f,-0.5f),
//			new Vector3(0.0421851f,0.0652789f,0.5f),
//			new Vector3(0.0854744f,-0.245537f,0.5f),
//			new Vector3(0.174432f,0.0976613f,-0.5f),
//			new Vector3(0.174432f,0.0976613f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.0692106f,0.1823f,-0.5f),
//			new Vector3(-0.0473917f,0.169589f,-0.5f),
//			new Vector3(-0.150062f,0.303337f,-0.5f),
//			new Vector3(0.0137812f,0.261091f,0.5f),
//			new Vector3(-0.0692106f,0.1823f,0.5f),
//			new Vector3(-0.00990032f,0.297795f,-0.5f),
//			new Vector3(-0.150062f,0.303337f,0.5f),
//			new Vector3(-0.0296384f,0.314197f,-0.5f),
//			new Vector3(-0.0473917f,0.169589f,0.5f),
//			new Vector3(0.0137812f,0.261091f,-0.5f),
//			new Vector3(-0.0296384f,0.314197f,0.5f),
//			new Vector3(-0.00990032f,0.297795f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.0828026f,0.091434f,0.5f),
//			new Vector3(-0.426258f,0.124114f,0.5f),
//			new Vector3(-0.254596f,0.0110088f,0.5f),
//			new Vector3(-0.254596f,0.0110088f,-0.5f),
//			new Vector3(-0.0828026f,0.091434f,-0.5f),
//			new Vector3(-0.201087f,0.146032f,0.5f),
//			new Vector3(-0.201087f,0.146032f,-0.5f),
//			new Vector3(-0.426258f,0.124114f,-0.5f),
//			new Vector3(-0.479205f,0.176951f,0.5f),
//			new Vector3(-0.479205f,0.176951f,-0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.479205f,0.176951f,-0.5f),
//			new Vector3(-0.0692106f,0.1823f,0.5f),
//			new Vector3(-1f,0.582126f,-0.5f),
//			new Vector3(-0.150062f,0.303337f,-0.5f),
//			new Vector3(-1f,0.55324f,-0.5f),
//			new Vector3(-0.201087f,0.146032f,0.5f),
//			new Vector3(-1f,0.582126f,0.5f),
//			new Vector3(-0.150062f,0.303337f,0.5f),
//			new Vector3(-0.201087f,0.146032f,-0.5f),
//			new Vector3(-0.0692106f,0.1823f,-0.5f),
//			new Vector3(-0.479205f,0.176951f,0.5f),
//			new Vector3(-1f,0.55324f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.201087f,0.146032f,0.5f),
//			new Vector3(-0.0692106f,0.1823f,0.5f),
//			new Vector3(-0.0473917f,0.169589f,0.5f),
//			new Vector3(-0.0179331f,0.0835178f,0.5f),
//			new Vector3(-0.0828026f,0.091434f,0.5f),
//			new Vector3(-0.0828026f,0.091434f,0f),
//			new Vector3(-0.201087f,0.146032f,-0.5f),
//			new Vector3(-0.0692106f,0.1823f,-0.5f),
//			new Vector3(-0.0828026f,0.091434f,-0.5f),
//			new Vector3(-0.0179331f,0.0835178f,-0.5f),
//			new Vector3(-0.0473917f,0.169589f,-0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.254596f,0.0110088f,0.5f),
//			new Vector3(-0.151959f,-0.0789192f,0.5f),
//			new Vector3(-0.104137f,-0.077778f,0.5f),
//			new Vector3(-0.0828026f,0.091434f,-0.5f),
//			new Vector3(-0.0179331f,0.0835178f,-0.5f),
//			new Vector3(-0.0828026f,0.091434f,0.5f),
//			new Vector3(-0.0179331f,0.0835178f,0.5f),
//			new Vector3(-0.104137f,-0.077778f,-0.5f),
//			new Vector3(-0.254596f,0.0110088f,-0.5f),
//			new Vector3(-0.151959f,-0.0789192f,-0.5f),
//			new Vector3(-0.011291f,0.0763045f,0.5f),
//			new Vector3(-0.011291f,0.0763045f,-0.5f),
//			new Vector3(-0.00424733f,0.0677186f,-0.5f),
//			new Vector3(-0.00424733f,0.0677186f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.011291f,0.0763045f,0.5f),
//			new Vector3(-0.011291f,0.0763045f,-0.5f),
//			new Vector3(0.189929f,0.226259f,0.5f),
//			new Vector3(0.189929f,0.226259f,-0.5f),
//			new Vector3(0.174432f,0.0976613f,0.5f),
//			new Vector3(0.0421851f,0.0652789f,0.5f),
//			new Vector3(0.0536377f,0.249979f,-0.5f),
//			new Vector3(0.0536377f,0.249979f,0.5f),
//			new Vector3(-0.00424733f,0.0677186f,0.5f),
//			new Vector3(-0.00424733f,0.0677186f,-0.5f),
//			new Vector3(0.0421851f,0.0652789f,-0.5f),
//			new Vector3(0.174432f,0.0976613f,-0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(0.22418f,0.03625f,-0.5f),
//			new Vector3(1f,0.27234f,-0.5f),
//			new Vector3(1f,0.792096f,-0.5f),
//			new Vector3(1f,0.792096f,0.5f),
//			new Vector3(0.174432f,0.0976613f,-0.5f),
//			new Vector3(1f,0.27234f,0.5f),
//			new Vector3(0.271967f,0.357577f,-0.5f),
//			new Vector3(0.271967f,0.357577f,0.5f),
//			new Vector3(0.189929f,0.226259f,-0.5f),
//			new Vector3(0.189929f,0.226259f,0.5f),
//			new Vector3(0.22418f,0.03625f,0.5f),
//			new Vector3(0.174432f,0.0976613f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.0473917f,0.169589f,0.5f),
//			new Vector3(0.0536377f,0.249979f,0.5f),
//			new Vector3(0.0137812f,0.261091f,0.5f),
//			new Vector3(-0.0179331f,0.0835178f,0.5f),
//			new Vector3(-0.011291f,0.0763045f,0.5f),
//			//new Vector3(-0.011291f,0.0763045f,0f),
//			new Vector3(-0.0473917f,0.169589f,-0.5f),
//			new Vector3(0.0536377f,0.249979f,-0.5f),
//			new Vector3(0.0137812f,0.261091f,-0.5f),
//			new Vector3(-0.0179331f,0.0835178f,-0.5f),
//			new Vector3(-0.011291f,0.0763045f,-0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(0.0536377f,0.249979f,-0.5f),
//			new Vector3(0.189929f,0.226259f,-0.5f),
//			new Vector3(0.140247f,0.396627f,0.5f),
//			new Vector3(0.271967f,0.357577f,0.5f),
//			new Vector3(0.0137812f,0.261091f,0.5f),
//			new Vector3(0.189929f,0.226259f,0.5f),
//			new Vector3(0.0536377f,0.249979f,0.5f),
//			new Vector3(0.0137812f,0.261091f,-0.5f),
//			new Vector3(0.271967f,0.357577f,-0.5f),
//			new Vector3(0.140247f,0.396627f,-0.5f),
//			new Vector3(-0.00990032f,0.297795f,0.5f),
//			new Vector3(-0.00990032f,0.297795f,-0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(0.607584f,-1f,0.5f),
//			new Vector3(1f,-1f,-0.5f),
//			new Vector3(0.22418f,0.03625f,-0.5f),
//			new Vector3(1f,0.27234f,-0.5f),
//			new Vector3(0.298754f,-0.441025f,0.5f),
//			new Vector3(1f,-1f,0.5f),
//			new Vector3(0.22418f,0.03625f,0.5f),
//			new Vector3(1f,0.27234f,0.5f),
//			new Vector3(0.298754f,-0.441025f,-0.5f),
//			new Vector3(0.607584f,-1f,-0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.150062f,0.303337f,-0.5f),
//			new Vector3(-0.0296384f,0.314197f,-0.5f),
//			new Vector3(-1f,1f,-0.5f),
//			new Vector3(-0.360437f,1f,0.5f),
//			new Vector3(-1f,0.582126f,-0.5f),
//			new Vector3(-0.0296384f,0.314197f,0.5f),
//			new Vector3(-1f,1f,0.5f),
//			new Vector3(0.00799953f,0.465615f,0.5f),
//			new Vector3(0.00799953f,0.465615f,-0.5f),
//			new Vector3(-0.360437f,1f,-0.5f),
//			new Vector3(-0.150062f,0.303337f,0.5f),
//			new Vector3(-1f,0.582126f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(0.140247f,0.396627f,0.5f),
//			new Vector3(0.140247f,0.396627f,-0.5f),
//			new Vector3(0.00799953f,0.465615f,-0.5f),
//			new Vector3(0.00799953f,0.465615f,0.5f),
//			new Vector3(-0.0296384f,0.314197f,-0.5f),
//			new Vector3(-0.0296384f,0.314197f,0.5f),
//			new Vector3(-0.00990032f,0.297795f,-0.5f),
//			new Vector3(-0.00990032f,0.297795f,0.5f),
//
//		});
//
//		vc.Add(new List<Vector3>(){
//			new Vector3(0.00799953f,0.465615f,-0.5f),
//			new Vector3(1f,0.792096f,0.5f),
//			new Vector3(-0.360437f,1f,-0.5f),
//			new Vector3(1f,1f,-0.5f),
//			new Vector3(0.00799953f,0.465615f,0.5f),
//			new Vector3(0.140247f,0.396627f,-0.5f),
//			new Vector3(-0.360437f,1f,0.5f),
//			new Vector3(1f,1f,0.5f),
//			new Vector3(0.271967f,0.357577f,-0.5f),
//			new Vector3(1f,0.792096f,-0.5f),
//			new Vector3(0.271967f,0.357577f,0.5f),
//			new Vector3(0.140247f,0.396627f,0.5f),
//
//		});


//		vc.Add(new List<Vector3>(){
//			new Vector3(-0.806506f,0.343989f,-0.5f),
//			new Vector3(0.0101658f,0.420679f,0.5f),
//			new Vector3(0.0101658f,0.420679f,-0.5f),
//			new Vector3(-0.14343f,0.205019f,0.5f),
//			new Vector3(-0.14343f,0.205019f,-0.5f),
//			//new Vector3(-0.806506f,0.343989f,0f),
//			new Vector3(-0.806506f,0.343989f,0.5f),
//
//		});



        vc.Add(new List <Vector3>()
        {
            new Vector3(-1f, -1f, -0.5f),
            new Vector3(-0.0448597f, -0.598239f, -0.5f),
            new Vector3(-1f, -0.362044f, -0.5f),
            new Vector3(-0.385575f, -0.221627f, -0.5f),
            new Vector3(-1f, -1f, 0.5f),
            new Vector3(-0.385575f, -0.221627f, 0.5f),
            new Vector3(-1f, -0.362044f, 0.5f),
            new Vector3(-0.103467f, -1f, -0.5f),
            new Vector3(-0.18347f, -0.420897f, -0.5f),
            new Vector3(-0.18347f, -0.420897f, 0.5f),
            new Vector3(-0.0448597f, -0.598239f, 0.5f),
            new Vector3(-0.103467f, -1f, 0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(-0.0448597f, -0.598239f, -0.5f),
            new Vector3(1f, -1f, -0.5f),
            new Vector3(-0.103467f, -1f, 0.5f),
            new Vector3(0.518295f, -0.459347f, -0.5f),
            new Vector3(-0.103467f, -1f, -0.5f),
            new Vector3(1f, -1f, 0.5f),
            new Vector3(0.0743321f, -0.34692f, -0.5f),
            new Vector3(1f, -0.709246f, -0.5f),
            new Vector3(0.518295f, -0.459347f, 0.5f),
            new Vector3(1f, -0.709246f, 0.5f),
            new Vector3(-0.0448597f, -0.598239f, 0.5f),
            new Vector3(0.0743321f, -0.34692f, 0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(0.0743321f, -0.34692f, 0.5f),
            new Vector3(0.518295f, -0.459347f, -0.5f),
            new Vector3(0.222638f, -0.250217f, -0.5f),
            new Vector3(0.356161f, -0.286853f, -0.5f),
            new Vector3(0.079184f, -0.323635f, 0.5f),
            new Vector3(0.518295f, -0.459347f, 0.5f),
            new Vector3(0.222638f, -0.250217f, 0.5f),
            new Vector3(0.356161f, -0.286853f, 0.5f),
            new Vector3(0.079184f, -0.323635f, -0.5f),
            new Vector3(0.0743321f, -0.34692f, -0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(-0.385575f, -0.221627f, -0.5f),
            new Vector3(-1f, 0.144961f, 0.5f),
            new Vector3(-0.312959f, -0.137179f, -0.5f),
            new Vector3(-0.684528f, 0.136085f, 0.5f),
            new Vector3(-1f, -0.362044f, -0.5f),
            new Vector3(-0.312959f, -0.137179f, 0.5f),
            new Vector3(-0.684528f, 0.136085f, -0.5f),
            new Vector3(-1f, 0.144961f, -0.5f),
            new Vector3(-0.385575f, -0.221627f, 0.5f),
            new Vector3(-1f, -0.362044f, 0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(-0.684528f, 0.136085f, -0.5f),
            new Vector3(-0.312959f, -0.137179f, 0.5f),
            new Vector3(-0.283868f, 0.0376008f, 0.5f),
            new Vector3(-0.312959f, -0.137179f, -0.5f),
            new Vector3(-0.343069f, 0.143474f, 0.5f),
            new Vector3(-0.312229f, -0.136512f, 0.5f),
            new Vector3(-0.684528f, 0.136085f, 0.5f),
            new Vector3(-0.312229f, -0.136512f, -0.5f),
            new Vector3(-0.283868f, 0.0376008f, -0.5f),
            new Vector3(-0.343069f, 0.143474f, -0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(-0.312229f, -0.136512f, 0.5f),
            new Vector3(-0.385575f, -0.221627f, -0.5f),
            new Vector3(-0.312229f, -0.136512f, -0.5f),
            new Vector3(-0.216008f, -0.160551f, -0.5f),
            new Vector3(-0.18347f, -0.420897f, 0.5f),
            new Vector3(-0.18347f, -0.420897f, -0.5f),
            new Vector3(-0.312959f, -0.137179f, -0.5f),
            new Vector3(-0.216008f, -0.160551f, 0.5f),
            new Vector3(-0.312959f, -0.137179f, 0.5f),
            new Vector3(-0.385575f, -0.221627f, 0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(-0.312229f, -0.136512f, -0.5f),
            new Vector3(-0.216008f, -0.160551f, -0.5f),
            new Vector3(0.0139972f, -0.15204f, -0.5f),
            new Vector3(0.0153618f, -0.0473141f, -0.5f),
            new Vector3(-0.312229f, -0.136512f, 0.5f),
            new Vector3(-0.216008f, -0.160551f, 0.5f),
            new Vector3(-0.283868f, 0.0376008f, -0.5f),
            new Vector3(-0.283868f, 0.0376008f, 0.5f),
            new Vector3(-0.0237972f, -0.020674f, -0.5f),
            new Vector3(-0.0237972f, -0.020674f, 0.5f),
            new Vector3(0.0153618f, -0.0473141f, 0.5f),
            new Vector3(0.0139972f, -0.15204f, 0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(-0.0448597f, -0.598239f, 0.5f),
            new Vector3(0.079184f, -0.323635f, -0.5f),
            new Vector3(-0.216008f, -0.160551f, -0.5f),
            new Vector3(0.0139972f, -0.15204f, -0.5f),
            new Vector3(-0.18347f, -0.420897f, 0.5f),
            new Vector3(0.0743321f, -0.34692f, -0.5f),
            new Vector3(-0.216008f, -0.160551f, 0.5f),
            new Vector3(0.0139972f, -0.15204f, 0.5f),
            new Vector3(-0.18347f, -0.420897f, -0.5f),
            new Vector3(-0.0448597f, -0.598239f, -0.5f),
            new Vector3(0.079184f, -0.323635f, 0.5f),
            new Vector3(0.0743321f, -0.34692f, 0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(0.335603f, -0.119844f, -0.5f),
            new Vector3(0.0139972f, -0.15204f, -0.5f),
            new Vector3(0.079184f, -0.323635f, 0.5f),
            new Vector3(0.307884f, 0.0428469f, -0.5f),
            new Vector3(0.222638f, -0.250217f, 0.5f),
            new Vector3(0.0139972f, -0.15204f, 0.5f),
            new Vector3(0.335603f, -0.119844f, 0.5f),
            new Vector3(0.307884f, 0.0428469f, 0.5f),
            new Vector3(0.0277375f, -0.0346146f, -0.5f),
            new Vector3(0.0153618f, -0.0473141f, -0.5f),
            new Vector3(0.079184f, -0.323635f, -0.5f),
            new Vector3(0.222638f, -0.250217f, -0.5f),
            new Vector3(0.0153618f, -0.0473141f, 0.5f),
            new Vector3(0.0277375f, -0.0346146f, 0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(0.335603f, -0.119844f, 0.5f),
            new Vector3(1f, -0.206532f, -0.5f),
            new Vector3(0.307884f, 0.0428469f, -0.5f),
            new Vector3(1f, 1f, -0.5f),
            new Vector3(0.335603f, -0.119844f, -0.5f),
            new Vector3(1f, -0.206532f, 0.5f),
            new Vector3(0.683389f, 0.692466f, 0.5f),
            new Vector3(1f, 1f, 0.5f),
            new Vector3(0.544173f, -0.176223f, -0.5f),
            new Vector3(0.544173f, -0.176223f, 0.5f),
            new Vector3(0.307884f, 0.0428469f, 0.5f),
            new Vector3(0.906816f, 1f, 0.5f),
            new Vector3(0.906816f, 1f, -0.5f),
            new Vector3(0.683389f, 0.692466f, -0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(0.356161f, -0.286853f, -0.5f),
            new Vector3(1f, -0.709246f, 0.5f),
            new Vector3(0.544173f, -0.176223f, -0.5f),
            new Vector3(1f, -0.206532f, -0.5f),
            new Vector3(0.356161f, -0.286853f, 0.5f),
            new Vector3(0.518295f, -0.459347f, 0.5f),
            new Vector3(0.544173f, -0.176223f, 0.5f),
            new Vector3(1f, -0.206532f, 0.5f),
            new Vector3(0.518295f, -0.459347f, -0.5f),
            new Vector3(1f, -0.709246f, -0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(0.335603f, -0.119844f, -0.5f),
            new Vector3(0.222638f, -0.250217f, -0.5f),
            new Vector3(0.335603f, -0.119844f, 0.5f),
            new Vector3(0.544173f, -0.176223f, -0.5f),
            new Vector3(0.356161f, -0.286853f, -0.5f),
            new Vector3(0.544173f, -0.176223f, 0.5f),
            new Vector3(0.356161f, -0.286853f, 0.5f),
            new Vector3(0.222638f, -0.250217f, 0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(-1f, 0.144961f, 0.5f),
            new Vector3(-0.300478f, 0.206166f, 0.5f),
            new Vector3(-1f, 1f, -0.5f),
            new Vector3(-0.738741f, 1f, -0.5f),
            new Vector3(-1f, 0.144961f, -0.5f),
            new Vector3(-0.332252f, 0.156636f, -0.5f),
            new Vector3(-1f, 1f, 0.5f),
            new Vector3(-0.738741f, 1f, 0.5f),
            new Vector3(-0.302425f, 0.202496f, -0.5f),
            new Vector3(-0.300478f, 0.206166f, -0.5f),
            new Vector3(-0.302425f, 0.202496f, 0.5f),
            new Vector3(-0.332252f, 0.156636f, 0.5f),
            new Vector3(-0.343069f, 0.143474f, 0.5f),
            new Vector3(-0.343069f, 0.143474f, -0.5f),
            new Vector3(-0.684528f, 0.136085f, 0.5f),
            new Vector3(-0.684528f, 0.136085f, -0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(-0.283868f, 0.0376008f, 0.5f),
            new Vector3(-0.0237972f, -0.020674f, -0.5f),
            new Vector3(-0.332252f, 0.156636f, -0.5f),
            new Vector3(-0.0815209f, 0.114455f, -0.5f),
            new Vector3(-0.343069f, 0.143474f, 0.5f),
            new Vector3(-0.0237972f, -0.020674f, 0.5f),
            new Vector3(-0.332252f, 0.156636f, 0.5f),
            new Vector3(-0.0815209f, 0.114455f, 0.5f),
            new Vector3(-0.343069f, 0.143474f, -0.5f),
            new Vector3(-0.283868f, 0.0376008f, -0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(-0.0986741f, 0.419068f, 0.5f),
            new Vector3(-0.0840575f, 0.147685f, -0.5f),
            new Vector3(-0.0986741f, 0.419068f, -0.5f),
            new Vector3(-0.0585627f, 0.273246f, -0.5f),
            new Vector3(-0.302425f, 0.202496f, -0.5f),
            new Vector3(-0.0840575f, 0.147685f, 0.5f),
            new Vector3(-0.302425f, 0.202496f, 0.5f),
            new Vector3(-0.0585627f, 0.273246f, 0.5f),
            new Vector3(-0.300478f, 0.206166f, -0.5f),
            new Vector3(-0.300478f, 0.206166f, 0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(-0.0840575f, 0.147685f, 0.5f),
            new Vector3(-0.0840575f, 0.147685f, -0.5f),
            new Vector3(-0.0585627f, 0.273246f, 0.5f),
            new Vector3(0.0277375f, -0.0346146f, 0.5f),
            new Vector3(-0.0237972f, -0.020674f, -0.5f),
            new Vector3(0.0675767f, 0.128497f, 0.5f),
            new Vector3(-0.0585627f, 0.273246f, -0.5f),
            new Vector3(0.0675767f, 0.128497f, -0.5f),
            new Vector3(-0.0815209f, 0.114455f, 0.5f),
            new Vector3(-0.0815209f, 0.114455f, -0.5f),
            new Vector3(0.0153618f, -0.0473141f, 0.5f),
            new Vector3(-0.0237972f, -0.020674f, 0.5f),
            new Vector3(0.0153618f, -0.0473141f, -0.5f),
            new Vector3(0.0277375f, -0.0346146f, -0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(-0.332252f, 0.156636f, -0.5f),
            new Vector3(-0.302425f, 0.202496f, -0.5f),
            new Vector3(-0.0815209f, 0.114455f, 0.5f),
            new Vector3(-0.302425f, 0.202496f, 0.5f),
            new Vector3(-0.332252f, 0.156636f, 0.5f),
            new Vector3(-0.0815209f, 0.114455f, -0.5f),
            new Vector3(-0.0840575f, 0.147685f, -0.5f),
            new Vector3(-0.0840575f, 0.147685f, 0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(0.683389f, 0.692466f, 0.5f),
            new Vector3(0.0277375f, -0.0346146f, -0.5f),
            new Vector3(0.0675767f, 0.128497f, -0.5f),
            new Vector3(0.683389f, 0.692466f, -0.5f),
            new Vector3(0.307884f, 0.0428469f, 0.5f),
            new Vector3(0.307884f, 0.0428469f, -0.5f),
            new Vector3(0.0277375f, -0.0346146f, 0.5f),
            new Vector3(0.0675767f, 0.128497f, 0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(0.0675767f, 0.128497f, -0.5f),
            new Vector3(0.683389f, 0.692466f, -0.5f),
            new Vector3(-0.0585627f, 0.273246f, 0.5f),
            new Vector3(0.906816f, 1f, -0.5f),
            new Vector3(0.0675767f, 0.128497f, 0.5f),
            new Vector3(0.683389f, 0.692466f, 0.5f),
            new Vector3(0.114596f, 1f, -0.5f),
            new Vector3(0.906816f, 1f, 0.5f),
            new Vector3(-0.0986741f, 0.419068f, -0.5f),
            new Vector3(-0.0585627f, 0.273246f, -0.5f),
            new Vector3(-0.0986741f, 0.419068f, 0.5f),
            new Vector3(0.114596f, 1f, 0.5f),
        });

        vc.Add(new List <Vector3>()
        {
            new Vector3(-0.738741f, 1f, 0.5f),
            new Vector3(0.114596f, 1f, -0.5f),
            new Vector3(-0.738741f, 1f, -0.5f),
            new Vector3(-0.300478f, 0.206166f, -0.5f),
            new Vector3(-0.300478f, 0.206166f, 0.5f),
            new Vector3(-0.0986741f, 0.419068f, -0.5f),
            new Vector3(0.114596f, 1f, 0.5f),
            new Vector3(-0.0986741f, 0.419068f, 0.5f),
        });



        var cc = 0;

        foreach (var vv in vc)
        {
            cc++;
            randomVerts = vv;
            var vertices = new List <Vertex> ();
            var color    = new Color(139.0f / 255f, 244f / 255f, 23f / 255f, 1);
            if (cc % 2 == 0)
            {
                color = new Color(255f / 255f, 0, 240f / 255f);
            }
            if (cc % 3 == 0)
            {
                color = new Color(0f / 255f, 255f / 255f, 252f / 255f);
            }                   //new Color (UnityEngine.Random.Range (0.0f, 1.0f),
//							UnityEngine.Random.Range (0.0f, 1.0f),
//							UnityEngine.Random.Range (0.0f, 1.0f));
            //add a random control point in the center?
//
//			vv.Add( Vector3.Scale( Vector3.Normalize (new Vector3 (randomVerts [1].x, randomVerts [1].y, randomVerts [1].z)
//				- new Vector3 (randomVerts [0].x, randomVerts [0].y, randomVerts [0].z)), new Vector3(0.1f,0.1f,0.1f))
//				+ new Vector3 (randomVerts [0].x, randomVerts [0].y, randomVerts [0].z));

            //control point seems to have to be in z-depth?

            //vv.Add(new Vector3(randomVerts[1].x, randomVerts[1].y, 0f);
            Debug.Log(String.Format("{0} - {1} - {2}", cc, vv.Count(), randomVerts.Count));
            foreach (var v in vv)
            {
                var location = new double[dimension];
                location [0] = v.x;
                location [1] = v.y;
                location [2] = v.z;
                vertices.Add(new Vertex(location));
            }

//		for (var i = 0; i < NumberOfVertices; i++)
//		{
//			var location = new double[dimension];
//			for (var j = 0; j < dimension; j++)
//				location[j] = UnityEngine.Random.Range(0,size);
//
//			var v = new Vertex (location);
//			vertices.Add(v);
//			randomVerts.Add (new Vector3((float)location[0], (float)location[1], 0f));
//		}

            voronoi = VoronoiMesh.Create(vertices);
            //var delaunay = Triangulation.CreateDelaunay<Vertex> (vertices);
            //var c = Triangulation.CreateDelaunay<Vertex, Tetrahedron>(vertices).Cells;
            //verticesList = new List<Vector3> ();
            //lines = new List<Vector3[]> ();


            var convexHull = ConvexHull.Create <Vertex>(vertices);
            foreach (var f in convexHull.Faces)
            {
                _CreateTriangle(f.ToString(), new Vector3[] {
                    _CreateVector3FromPosition(f.Vertices[0]),
                    _CreateVector3FromPosition(f.Vertices[1]),
                    _CreateVector3FromPosition(f.Vertices[2])
                });
            }

//			foreach (var e in voronoi.Vertices) {
//				//CreateTriangles (e);
//				CreateTetrahedron (cc, e,color);
//			}
        }
//		foreach (var e in voronoi.Edges) {
//			var l = e;
//
//			lines.Add (new Vector3[]{
//				new Vector3((float)e.Source.Vertices[0].Position[0],
//					(float)e.Source.Vertices[0].Position[1],
//					0.0f),
//				new Vector3((float)e.Target.Vertices[0].Position[0],
//					(float)e.Target.Vertices[0].Position[1],
//					0.0f)
//
//			});
//
//		}
//		var component = GetComponent<MeshFilter> ().mesh;
    }
コード例 #22
0
        protected override int[] GenerateDataImpl(long x, long y, long z, long width, long height, long depth)
        {
            int[] data = new int[width * height * depth];

            // Determine output values.
            int noneOutput     = 0;
            int originalOutput = 1;
            int centerOutput   = (this.Result == VoronoiResult.AllValues) ? 2 : 1;
            int edgeOutput     = (this.Result == VoronoiResult.AllValues) ? 3 : (this.Result == VoronoiResult.EdgesAndOriginals) ? 2 : 1;

            // Scan through the size of the array, randomly creating points.
            List <double[]> points = new List <double[]>();

            for (int i = -this.EdgeSampling; i < width + this.EdgeSampling; i++)
            {
                for (int j = -this.EdgeSampling; j < height + this.EdgeSampling; j++)
                {
                    for (int k = -this.EdgeSampling; k < depth + this.EdgeSampling; k++)
                    {
                        int s = this.GetRandomRange(x + i, y + j, z + k, this.PointValue, this.Modifier);
                        if (s == 0)
                        {
                            points.Add(new double[] { i, j, k });
                            if (i >= 0 && i < width &&
                                j >= 0 && j < height &&
                                k >= 0 && k < depth)
                            {
                                if (this.Result == VoronoiResult.AllValues ||
                                    this.Result == VoronoiResult.EdgesAndOriginals ||
                                    this.Result == VoronoiResult.OriginalOnly)
                                {
                                    data[i + j * width + k * width * height] = originalOutput;
                                }
                            }
                        }
                    }
                }
            }

            // Skip computations if we are only outputting original scatter values.
            if (this.Result == VoronoiResult.OriginalOnly)
            {
                return(data);
            }

            try
            {
                // Compute the Voronoi diagram.
                var graph = VoronoiMesh.Create <DefaultVertex, VoronoiCell3D>(points.Select(p => new DefaultVertex {
                    Position = p.ToArray()
                }));

                // Output the edges if needed.
                if (this.Result == VoronoiResult.AllValues ||
                    this.Result == VoronoiResult.EdgesAndOriginals ||
                    this.Result == VoronoiResult.EdgeOnly)
                {
                    foreach (var v in graph.Edges)
                    {
                        var a = v.Source.Circumcentre;
                        var b = v.Target.Circumcentre;

                        // Normalize vector between two points.
                        double cx = 0, cy = 0, cz = 0;
                        double sx     = b[0] < a[0] ? b[0] : a[0];
                        double sy     = b[0] < a[0] ? b[1] : a[1];
                        double sz     = b[0] < a[0] ? b[2] : a[2];
                        double mx     = b[0] > a[0] ? b[0] : a[0];
                        double tx     = b[0] > a[0] ? b[0] - a[0] : a[0] - b[0];
                        double ty     = b[0] > a[0] ? b[1] - a[1] : a[1] - b[1];
                        double tz     = b[0] > a[0] ? b[2] - a[2] : a[2] - b[2];
                        double length = Math.Sqrt(Math.Pow(tx, 2) + Math.Pow(ty, 2) + Math.Pow(tz, 2));
                        tx /= length;
                        ty /= length;
                        tz /= length;

                        // Iterate until we reach the target.
                        while (sx + cx < mx)// && sy + cy < my)
                        {
                            if ((int)(sx + cx) >= 0 && (int)(sx + cx) < width &&
                                (int)(sy + cy) >= 0 && (int)(sy + cy) < height &&
                                (int)(sz + cz) >= 0 && (int)(sz + cz) < depth &&
                                data[(int)(sx + cx) + (int)(sy + cy) * width + (int)(sz + cz) * width * height] == noneOutput)
                            {
                                data[(int)(sx + cx) + (int)(sy + cy) * width + (int)(sz + cz) * width * height] = edgeOutput;
                            }

                            cx += tx;
                            cy += ty;
                            cz += tz;
                        }
                    }
                }

                // Output the center points if needed.
                if (this.Result == VoronoiResult.AllValues ||
                    this.Result == VoronoiResult.CenterOnly)
                {
                    foreach (var vv in graph.Vertices)
                    {
                        foreach (var v in vv.Vertices)
                        {
                            if ((int)v.Position[0] >= 0 && (int)v.Position[0] < width &&
                                (int)v.Position[1] >= 0 && (int)v.Position[1] < height)
                            {
                                data[(int)v.Position[0] + (int)v.Position[1] * width] = centerOutput;
                            }
                        }
                    }
                }
            }
            catch (InvalidOperationException)
            {
                // Empty array.
                return(new int[width * height * depth]);
            }

            // Return the result.
            return(data);
        }
コード例 #23
0
    public override void OnInspectorGUI()
    {
        var galaxy = target as Galaxy;

        if (_currentLayer == null)
        {
            _currentLayer = galaxy.MapData.StarDensity;
        }

        if (Screen.width != _width)
        {
            _width   = Screen.width;
            _starTex = new Texture2D(_width, _width, TextureFormat.ARGB32, false);
            _linkTex = new Texture2D(_width, _width, TextureFormat.ARGB32, false);
            RenderStars();
            RenderLinks();
        }

        GUILayout.Label("Preview", EditorStyles.boldLabel);
        _galaxyMat.SetFloat("Arms", galaxy.MapData.GlobalData.Arms);
        _galaxyMat.SetFloat("Twist", galaxy.MapData.GlobalData.Twist);
        _galaxyMat.SetFloat("TwistPower", galaxy.MapData.GlobalData.TwistPower);
        _galaxyMat.SetFloat("SpokeOffset", _currentLayer.SpokeOffset);
        _galaxyMat.SetFloat("SpokeScale", _currentLayer.SpokeScale);
        _galaxyMat.SetFloat("CoreBoost", _currentLayer.CoreBoost);
        _galaxyMat.SetFloat("CoreBoostOffset", _currentLayer.CoreBoostOffset);
        _galaxyMat.SetFloat("CoreBoostPower", _currentLayer.CoreBoostPower);
        _galaxyMat.SetFloat("EdgeReduction", _currentLayer.EdgeReduction);
        _galaxyMat.SetFloat("NoisePosition", _currentLayer.NoisePosition);
        _galaxyMat.SetFloat("NoiseAmplitude", _currentLayer.NoiseAmplitude);
        _galaxyMat.SetFloat("NoiseOffset", _currentLayer.NoiseOffset);
        _galaxyMat.SetFloat("NoiseGain", _currentLayer.NoiseGain);
        _galaxyMat.SetFloat("NoiseLacunarity", _currentLayer.NoiseLacunarity);
        _galaxyMat.SetFloat("NoiseFrequency", _currentLayer.NoiseFrequency);
        var rect = GetControlRect(false, _width);

        EditorGUI.DrawPreviewTexture(rect, _white, _galaxyMat);
        if (_drawLinks)
        {
            EditorGUI.DrawPreviewTexture(rect, _linkTex, _transparent);
        }
        if (_drawStars)
        {
            EditorGUI.DrawPreviewTexture(rect, _starTex, _transparent);
        }

        _drawStars    = ToggleLeft($"Display {_stars.Count()} Stars", _drawStars);
        _drawResource = ToggleLeft("Display Resources", _drawResource);
        _drawLinks    = ToggleLeft($"Display {_starLinks.Count} Links", _drawLinks);

        GUILayout.Space(10);

        // Show default inspector property editor
        DrawDefaultInspector();

        BeginVertical("Box");
        EditorGUI.indentLevel++;
        GUILayout.Label(_currentLayerName);
        Inspect(_currentLayer);
        EditorGUI.indentLevel--;
        EndVertical();

        BeginVertical("Box");
        EditorGUI.indentLevel++;
        _showResourceMaps = Foldout(_showResourceMaps, "Resource Density Maps");
        if (_showResourceMaps)
        {
            EditorGUI.indentLevel++;
            foreach (var resourceDensity in galaxy.MapData.ResourceDensities)
            {
                BeginHorizontal();
                resourceDensity.Name = DelayedTextField(resourceDensity.Name);
                if (GUILayout.Button("Inspect"))
                {
                    _currentLayer = resourceDensity;
                }
                if (GUILayout.Button("Copy"))
                {
                    galaxy.MapData.ResourceDensities.Add(resourceDensity.Copy());
                }
                EndHorizontal();
            }
            EditorGUI.indentLevel--;
            if (GUILayout.Button("Add New Resource"))
            {
                galaxy.MapData.ResourceDensities.Add(new GalaxyMapLayerData()
                {
                    Name = "New Resource"
                });
            }
        }
        else if (_currentLayer != galaxy.MapData.StarDensity)
        {
            _currentLayerName = "Star Density";
            _currentLayer     = galaxy.MapData.StarDensity;
        }
        EditorGUI.indentLevel--;
        EndVertical();

        BeginVertical("Box");
        EditorGUI.indentLevel++;
        _showStarEditor = Foldout(_showStarEditor, "Star Tools");
        if (_showStarEditor)
        {
            _hilbertOrder = IntField("Hilbert Order", _hilbertOrder);
            _starCount    = IntField("Star Count", _starCount);
            //_hilbertIndex = (ulong) EditorGUILayout.IntField("Hilbert Index", (int) _hilbertIndex);
            if (GUILayout.Button("Evaluate Hilbert Curve"))
            {
                var points = EvaluateHilbert(_hilbertOrder, false);
                Debug.Log($"Hilbert curve has {points.Count()} points, resolution {Mathf.RoundToInt(points.Max(p=>p.x))+1}");
            }

            _minStarDistance = FloatField("Minimum Star Distance", _minStarDistance);

            if (GUILayout.Button("Generate Stars"))
            {
                var points = EvaluateHilbert(_hilbertOrder).ToArray();
                var stars  = new List <Vector2>();
                int bail   = 0;
                while (stars.Count < _starCount && bail < 10)
                {
                    var accum = 0f;
                    foreach (var hp in points.Select(p => p + Random.insideUnitCircle * ((points[0] - points[1]).magnitude / 2)))
                    {
                        var den = galaxy.MapData.StarDensity.Evaluate(hp, galaxy.MapData.GlobalData);
                        if (!float.IsNaN(den))
                        {
                            accum += saturate(den) * Random.value;
                        }
//						else
//							Debug.Log($"Density at ({hp.x},{hp.y}) is NaN");
                        if (accum > 1 && (!stars.Any() || stars.Min(s => (s - hp).magnitude) > _minStarDistance))
                        {
                            stars.Add(hp);
                            accum = 0;
                        }
                        //Debug.Log($"Accumulator: {accum}");
                    }
                    bail++;
                }
                Debug.Log($"Generated {stars.Count} stars.");
                _stars = stars;
                RenderStars();
            }
            if (_stars.Any())
            {
                _maxLinkLength = FloatField("Max Link Length", _maxLinkLength);
                if (GUILayout.Button("Generate Star Links"))
                {
                    _voronoiMesh = VoronoiMesh <Vertex2, Cell2, VoronoiEdge <Vertex2, Cell2> > .Create(_stars.Select(s => new Vertex2(s.x, s.y)).ToList());

                    _starLinks.Clear();
                    // Each cell in this collection represents one of the triangle faces of the Delaunay Triangulation
                    foreach (var cell in _voronoiMesh.Vertices)
                    {
                        var links = new[] { new VoronoiLink(cell.Vertices[0], cell.Vertices[1]),
                                            new VoronoiLink(cell.Vertices[0], cell.Vertices[2]),
                                            new VoronoiLink(cell.Vertices[2], cell.Vertices[1]) };

                        _starLinks.AddRange(links.Where(l => !_starLinks.ContainsLine(l) && l.Length < _maxLinkLength));
                        RenderLinks();
                    }
                }
                if (_starLinks.Any())
                {
                    _linkFilter = FloatField("Link Filter Percentage", _linkFilter);
                    if (GUILayout.Button("Filter Star Links"))
                    {
                        var bail      = 0;
                        var count     = _starLinks.Count * Mathf.Clamp01(_linkFilter);
                        var deadLinks = new List <VoronoiLink>();
                        for (int i = 0; i < count && bail < count * 10; bail++)
                        {
                            var link = _starLinks.ElementAt(Random.Range(0, _starLinks.Count));

                            if (deadLinks.Contains(link))
                            {
                                continue;
                            }

                            var mapMinusLink = _starLinks.Where(l => !l.Equals(link)).ToArray();
                            if (!mapMinusLink.ConnectedRegion(link.point1).Contains(link.point2))
                            {
                                deadLinks.Add(link);
                            }
                            else
                            {
                                _starLinks.Remove(link);
                                i++;
                            }
                            //if (_starLinks.Count(sl => sl.ContainsPoint(link.point1)) > 1 && _starLinks.Count(sl => sl.ContainsPoint(link.point2)) > 1)
                        }
                        RenderLinks();
                    }
                    if (GUILayout.Button("Save Star Data"))
                    {
                        galaxy.MapData.Stars = _stars.Select(s => new StarData {
                            Position = s
                        }).ToList();
                        foreach (var star in galaxy.MapData.Stars)
                        {
                            star.Links.Clear();
                            star.Links.AddRange(_starLinks.Where(sl => (sl.point1.ToVector2() - star.Position).sqrMagnitude < float.Epsilon)
                                                .Select(sl => galaxy.MapData.Stars.IndexOf(galaxy.MapData.Stars.First(s => (sl.point2.ToVector2() - s.Position).sqrMagnitude < float.Epsilon))));
                            star.Links.AddRange(_starLinks.Where(sl => (sl.point2.ToVector2() - star.Position).sqrMagnitude < float.Epsilon)
                                                .Select(sl => galaxy.MapData.Stars.IndexOf(galaxy.MapData.Stars.First(s => (sl.point1.ToVector2() - s.Position).sqrMagnitude < float.Epsilon))));
                        }
                    }

                    if (GUILayout.Button("Connect to RethinkDB"))
                    {
                        _connection = R.Connection().Hostname(EditorPrefs.GetString("RethinkDB.URL")).Port(RethinkDBConstants.DefaultPort).Timeout(60).Connect();
                    }
                    EditorGUI.BeginDisabledGroup(_connection == null);

                    if (GUILayout.Button("Drop Galaxy Table"))
                    {
                        R.Db("Aetheria").TableDrop("Galaxy").Run(_connection);
                    }

                    if (GUILayout.Button("Create Galaxy Table"))
                    {
                        R.Db("Aetheria").TableCreate("Galaxy").Run(_connection);
                    }

                    EditorGUI.BeginDisabledGroup(!galaxy.MapData.Stars.Any());

                    if (GUILayout.Button("Upload Star Data"))
                    {
                        Converter.Serializer.Converters.Add(new MathJsonConverter());
                        JsonConvert.DefaultSettings = () => new JsonSerializerSettings
                        {
                            Converters = new List <JsonConverter>
                            {
                                new MathJsonConverter(),
                                Converter.DateTimeConverter,
                                Converter.BinaryConverter,
                                Converter.GroupingConverter,
                                Converter.PocoExprConverter
                            }
                        };
                        var starIDs = new Dictionary <StarData, Guid>();
                        foreach (var star in galaxy.MapData.Stars)
                        {
                            starIDs[star] = Guid.NewGuid();
                        }
                        foreach (var star in galaxy.MapData.Stars)
                        {
                            R.Db("Aetheria").Table("Galaxy").Insert(new ZoneData
                            {
                                ID        = starIDs[star],
                                Name      = starIDs[star].ToString().Substring(0, 8),
                                Wormholes = star.Links.Select(i => starIDs[galaxy.MapData.Stars[i]]).ToList(),
                                Position  = star.Position
                            }).Run(_connection);
                        }

                        //galaxy.MapData.GlobalData.MapLayers["StarDensity"] = galaxy.MapData.StarDensity.ID = Guid.NewGuid();
                        galaxy.MapData.StarDensity.Name = "StarDensity";
                        R.Db("Aetheria").Table("Galaxy").Insert(galaxy.MapData.StarDensity).Run(_connection);
                        foreach (var data in galaxy.MapData.ResourceDensities)
                        {
                            // galaxy.MapData.GlobalData.MapLayers[data.Name] = data.ID = Guid.NewGuid();
                            R.Db("Aetheria").Table("Galaxy").Insert(data).Run(_connection);
                        }

                        R.Db("Aetheria").Table("Galaxy").Insert(galaxy.MapData.GlobalData).Run(_connection);
                    }

                    EditorGUI.EndDisabledGroup();

                    EditorGUI.EndDisabledGroup();
                }
            }
        }
        EditorGUI.indentLevel--;
        EndVertical();


        EditorUtility.SetDirty(target);
    }
コード例 #24
0
        public void ComputeVD3d()
        {
            List <DualSite3d> list = new List <DualSite3d>();

            foreach (Site site in sites)
            {
                list.Add(site.ToDualSite());
            }
            for (int i = 0; i < externalEdgePoints.Count; i++)
            {
                list.Add(externalEdgePoints[i].ToDualSite());
            }
            VoronoiMesh <DualSite3d, TriangulationCellExt <DualSite3d>, VoronoiEdge <DualSite3d, TriangulationCellExt <DualSite3d> > > voronoiMesh = VoronoiMesh.Create <DualSite3d, TriangulationCellExt <DualSite3d> >(list);

            foreach (TriangulationCellExt <DualSite3d> vertex in voronoiMesh.Vertices)
            {
                Vector3      a        = Vector3.zero;
                DualSite3d[] vertices = vertex.Vertices;
                foreach (DualSite3d dualSite3d in vertices)
                {
                    a += dualSite3d.coord;
                }
                a *= 0.333333343f;
                DebugExtension.DebugPoint(a, Color.red, 1f, 0f, true);
            }
        }
コード例 #25
0
    public void Create()
    {
        foreach (Transform child in transform)
        {
            Destroy(child.gameObject);
        }

        //InputField[] fields = FindObjectsOfType<InputField>();
        //InputField numseed = fields[0];
        //InputField numplates = fields[1];
        //InputField numtiles = fields[2];
        //numberOfVertices = Convert.ToInt32(numtiles.text);
        //plates = Convert.ToInt32(numplates.text);
        //seed = Convert.ToInt32(numseed.text);

        // INITIALIZATION
        Vertex3[] vertices  = new Vertex3[numberOfVertices];
        Vector3[] meshVerts = new Vector3[numberOfVertices];
        allVerts            = new List <Vector3>();
        vertsForVoronoiHull = new List <Vector3>();

        // VORONOI VERTICES NEED ONE EXTRA ONE IN CENTER
        Vertex3[] voronoiVertices = new Vertex3[numberOfVertices + 1];

        // RANDOM SEED
        Random.seed = seed;

        // GENERATE UNIFORM POINTS
        allVerts = GeneratePointsUniformly();
        allVerts.Sort((v1, v2) => v1.y.CompareTo(v2.y));

        // SET INDICES FOR VORONOI
        int i = 0;

        while (i < numberOfVertices)
        {
            vertices[i]        = new Vertex3(allVerts[i].x, allVerts[i].y, allVerts[i].z);
            voronoiVertices[i] = vertices[i];
            meshVerts[i]       = vertices[i].ToVector3();;
            i++;
        }
        // SET LAST EXTRA VERTEX
        voronoiVertices[numberOfVertices] = new Vertex3(0, 0, 0);


        // VORONOI
        voronoiMesh = VoronoiMesh.Create <Vertex3, Cell3>(voronoiVertices);



        // VORONOI HULL GENERATION
        int index = 0;

        foreach (var edge in voronoiMesh.Edges)
        {
            Vector3 source = new Vector3(edge.Source.Circumcenter.x, edge.Source.Circumcenter.y, edge.Source.Circumcenter.z);
            Vector3 target = new Vector3(edge.Target.Circumcenter.x, edge.Target.Circumcenter.y, edge.Target.Circumcenter.z);
            source *= ((float)size / 2.5f);
            target *= ((float)size / 2.5f);
            vertsForVoronoiHull.Add(source);
            vertsForVoronoiHull.Add(target);
            index++;
        }

        // REMOVE DUPLICATE POINTS
        vertsForVoronoiHull = vertsForVoronoiHull.Distinct().ToList();

        // CONVERT FROM VECTOR3 LIST TO VERTEX3 LIST FOR FINAL HULL
        Vertex3[] verticesDelaunay = new Vertex3[vertsForVoronoiHull.Count];

        int g = 0;

        while (g < vertsForVoronoiHull.Count)
        {
            verticesDelaunay[g] = new Vertex3(vertsForVoronoiHull[g].x, vertsForVoronoiHull[g].y, vertsForVoronoiHull[g].z);
            g++;
        }

        // GENERATE VORONOI HULL
        ConvexHull <Vertex3, Face3> convexHull = ConvexHull.Create <Vertex3, Face3>(verticesDelaunay);

        convexHullVertices = new List <Vertex3>(convexHull.Points);
        convexHullFaces    = new List <Face3>(convexHull.Faces);
        convexHullIndices  = new List <int>();

        foreach (Face3 f in convexHullFaces)
        {
            convexHullIndices.Add(convexHullVertices.IndexOf(f.Vertices[0]));
            convexHullIndices.Add(convexHullVertices.IndexOf(f.Vertices[1]));
            convexHullIndices.Add(convexHullVertices.IndexOf(f.Vertices[2]));
        }

        Dictionary <Vector3, List <Vector3> > normals = new Dictionary <Vector3, List <Vector3> >();

        // CREATE TRIANGLES FOR MESH
        for (int j = 0; j < convexHullIndices.Count; j += 3)
        {
            int v0 = convexHullIndices[j + 0];
            int v1 = convexHullIndices[j + 1];
            int v2 = convexHullIndices[j + 2];

            Vector3 a = new Vector3((float)convexHullVertices[v0].x, (float)convexHullVertices[v0].y, (float)convexHullVertices[v0].z);
            Vector3 b = new Vector3((float)convexHullVertices[v1].x, (float)convexHullVertices[v1].y, (float)convexHullVertices[v1].z);
            Vector3 c = new Vector3((float)convexHullVertices[v2].x, (float)convexHullVertices[v2].y, (float)convexHullVertices[v2].z);

            Vector3 normal = Vector3.Cross(a - b, a - c);

            // DECLARE KEY AND ROUND IT TO AVOID FLOATING POINT ISSUES
            Vector3 key        = normal.normalized;
            float   roundX     = Mathf.Round(key.x * 100) / 100;
            float   roundY     = Mathf.Round(key.y * 100) / 100;
            float   roundZ     = Mathf.Round(key.z * 100) / 100;
            Vector3 roundedKey = new Vector3(roundX, roundY, roundZ);

            // POPULATE DICTIONARY
            if (!normals.ContainsKey(roundedKey))
            {
                normals.Add(roundedKey, new List <Vector3>());
            }
            normals[roundedKey].Add(a);
            normals[roundedKey].Add(b);
            normals[roundedKey].Add(c);
        }

        // CREATE VORONOI TILES
        List <VoronoiTile> tiles = new List <VoronoiTile>();

        foreach (var pair in normals)
        {
            List <Vector3> tileVerts = new List <Vector3>();
            for (int p = 0; p < pair.Value.Count; ++p)
            {
                tileVerts.Add(pair.Value[p]);
            }
            GameObject tile     = new GameObject("Tile", typeof(VoronoiTile), typeof(MeshFilter), typeof(MeshRenderer), typeof(MeshCollider));
            var        thisTile = tile.GetComponent <VoronoiTile>() as VoronoiTile;

            thisTile.Initialize(tileVerts, false); // OPTIMIZE HERE

            tile.GetComponent <MeshFilter>().mesh         = thisTile.tileMesh;
            tile.GetComponent <MeshCollider>().sharedMesh = thisTile.tileMesh;

            thisTile.Normal = pair.Key;
            tiles.Add(thisTile);
            ++numberOfTiles;
        }

        foreach (var tile in tiles)
        {
            tile.FindNeighbors(tiles);
        }

        List <VoronoiTile> waterTiles = new List <VoronoiTile>();
        Material           oceanMat   = (Material)Resources.Load("Ocean", typeof(Material));

        foreach (var pair in normals)
        {
            List <Vector3> tileVerts = new List <Vector3>();
            for (int p = 0; p < pair.Value.Count; ++p)
            {
                tileVerts.Add(pair.Value[p]);
            }
            GameObject tile     = new GameObject("WaterTile", typeof(VoronoiTile), typeof(MeshFilter), typeof(MeshRenderer));
            var        thisTile = tile.GetComponent <VoronoiTile>() as VoronoiTile;
            thisTile.Initialize(tileVerts, true);
            tile.GetComponent <MeshFilter>().mesh       = thisTile.tileMesh;
            tile.GetComponent <MeshRenderer>().material = oceanMat;
            waterTiles.Add(thisTile);
        }

        ocean = new GameObject("Ocean");
        ocean.transform.parent = transform;
        foreach (var tile in waterTiles)
        {
            tile.transform.parent = ocean.transform;
        }

        // FLOOD FILLS
        // GENERATE PLATES
        List <VoronoiTile> plateStartNodes = GeneratePlateStartNodes(plates, ref tiles);

        // GENERATE PLATE MATERIALS
        List <Material> plateMaterials = GenerateMaterials(1); // changed here

        // GENERATE START LISTS
        List <List <VoronoiTile> > colors = new List <List <VoronoiTile> >();

        for (int b = 0; b < plates; ++b)
        {
            colors.Add(new List <VoronoiTile>()
            {
                plateStartNodes[b]
            });
        }


        // FILL
        FloodFillSimultaneous(ref colors, plateMaterials, ref tiles);


        // GROUP PLATES
        plateList = new List <TectonicPlate>();
        for (int q = 0; q < plates; ++q)
        {
            GameObject         plateTest      = new GameObject("Plate" + q, typeof(TectonicPlate));
            List <VoronoiTile> testPlateTiles = new List <VoronoiTile>();
            foreach (var voronoiTile in tiles)
            {
                if (voronoiTile.plate == q)
                {
                    testPlateTiles.Add(voronoiTile);
                }
            }
            var thisTecPlate = plateTest.GetComponent <TectonicPlate>();
            thisTecPlate.Initialize(ref testPlateTiles);
            int land = Random.Range(0, 10);
            if (land < landAmount)
            {
                thisTecPlate.isLand = true;
            }
            plateTest.transform.parent = transform;
            plateList.Add(thisTecPlate);
        }

        LoadMaterials();

        // CREATE WATER AND LAND AREAS FOR HEIGHT
        FindWaterAndLandPoints();

        // DETERMINE BIOMES
        AssignPlateProperties();
        AssignTileProperties();
        DetermineBiomes(true);
        GenerateHeight();
        DetermineHeightBiomes();
    }
コード例 #26
0
ファイル: MIConvexHullTest.cs プロジェクト: whigg/PointClouds
        public void Face_Delaunay_New()
        {
            string fileNameLong = pathUnitTests + "\\KinectFace_1_15000.obj";

            pointCloudSource = IOUtils.ReadObjFile_ToPointCloud(fileNameLong);

            PointCloud pointCloudTemp = PointCloud.CloneAll(pointCloudSource);

            for (int i = 0; i < pointCloudTemp.Count; i++)
            {
                pointCloudTemp[i].Vector.Z = 0;
            }

            //List<Vertex2D> pointCloudDelaunay = new List<Vertex2D>();

            //for (int i = 0; i < pointCloudSource.Count; i++)
            //{
            //    Vertex2D v = new Vertex2D(i, pointCloudSource[i].Vector.X, pointCloudSource[i].Vector.Y);
            //    pointCloudDelaunay.Add(v);

            //}
            //--------------------------------


            //------------------------------------------------

            //VoronoiMesh<Vertex2D, Cell2D, VoronoiEdge<Vertex2D, Cell2D>> voronoiMesh;
            VoronoiMesh <Vertex, CellVertex, VoronoiEdge <Vertex, CellVertex> > voronoiMesh;

            voronoiMesh = VoronoiMesh.Create <Vertex, CellVertex>(pointCloudTemp);
            List <Triangle> listTriangle  = new List <Triangle>();
            int             indexTriangle = 0;

            foreach (CellVertex cell in voronoiMesh.Cells)
            {
                Triangle t = new Triangle();

                t.IndVertices.Add(Convert.ToUInt32(cell.Vertices[0].Index));
                t.IndVertices.Add(Convert.ToUInt32(cell.Vertices[1].Index));
                t.IndVertices.Add(Convert.ToUInt32(cell.Vertices[2].Index));
                listTriangle.Add(t);

                cell.Vertices[0].IndexTriangles.Add(indexTriangle);
                cell.Vertices[1].IndexTriangles.Add(indexTriangle);
                cell.Vertices[2].IndexTriangles.Add(indexTriangle);
                indexTriangle++;

                //Vertex2D[] vert = cell.Vertices;
            }

            //set triangle indices for normal calculation
            for (int i = 0; i < pointCloudTemp.Count; i++)
            {
                pointCloudSource[i].IndexTriangles = pointCloudTemp[i].IndexTriangles;
            }

            //-------------------
            PointCloud myPointCloud = new PointCloud();



            pointCloudSource.ToObjFile(pathUnitTests, "1_triangulated.obj");
            ShowPointCloud(pointCloudSource);
        }
コード例 #27
0
        public World InitializeWorld(IEnumerable <Vector2> points, Vector2 lowerWorldLimit, Vector2 upperWorldLimit)
        {
            var corners = new[] {
                new DefaultVertex()
                {
                    Position = new double[] { lowerWorldLimit.X, lowerWorldLimit.Y }
                },
                new DefaultVertex()
                {
                    Position = new double[] { upperWorldLimit.X, lowerWorldLimit.Y }
                },
                new DefaultVertex()
                {
                    Position = new double[] { upperWorldLimit.X, upperWorldLimit.Y }
                },
                new DefaultVertex()
                {
                    Position = new double[] { lowerWorldLimit.X, upperWorldLimit.Y }
                }
            };

            var verteces = points
                           .Select((point) => point.ToVertex())
                           .Append(corners[0])
                           .Append(corners[1])
                           .Append(corners[2])
                           .Append(corners[3])
                           .ToArray();
            var mesh = VoronoiMesh.Create <IVertex, VoronoiCell>(verteces);

            if (mesh == null)
            {
                throw new ApplicationException("Unable to generate Voronoi");
            }

            var cells = new List <Cell>();

            foreach (var vertex in verteces.Except(corners))
            {
                var cellPoints = new List <Vector2>();
                var edges      = mesh.Edges
                                 .Where(x => x.Source.Vertices.Any(z => z == vertex) && x.Target.Vertices.Any(z => z == vertex))
                                 .ToArray();

                if (!edges.Any())
                {
                    continue;
                }

                var current = edges.First().Source.Circumcenter;

                while (!cellPoints.Contains(current))
                {
                    cellPoints.Add(current);
                    var cell = edges.FirstOrDefault(x =>
                                                    (x.Source.Circumcenter == current && !cellPoints.Contains(x.Target.Circumcenter)) ||
                                                    (x.Target.Circumcenter == current && !cellPoints.Contains(x.Source.Circumcenter)));

                    if (cell == null)
                    {
                        break;
                    }

                    var point = cell.Source.Circumcenter == current
                        ? cell.Target.Circumcenter
                        : cell.Source.Circumcenter;
                    current = point;
                }

                cellPoints = ScopePoints(cellPoints, lowerWorldLimit, upperWorldLimit).ToList();

                cells.Add(new Cell(cellPoints, new Vector2((float)vertex.Position[0], (float)vertex.Position[1])));
            }

            var world = new World(upperWorldLimit, lowerWorldLimit)
            {
                Cells = cells
            };

            return(world);
        }
コード例 #28
0
ファイル: Map.cs プロジェクト: olemstrom/the-morko
    public void Generate()
    {
        int tries = 0;
        while (Rooms.Count < RoomCount) {
            tries++;
            if(tries > RoomCount + 1000*1000) break;
            Random rand = new Random();
            int width = rand.Next(MinRoomSize, MaxRoomSize);
            int height = rand.Next(MinRoomSize, MaxRoomSize);
            int x = rand.Next(CellCount);
            int y = rand.Next(CellCount);

            Room room = new Room(width, height, x, y);
            if(IsInside (room) && !Overlaps(room, 2)) AddRoom (room);
        }
        //AddRoom (new Room (2, 2, 0, 0));

        RoomCount = Rooms.Count;

        Vertex2[] vertices = new Vertex2[Rooms.Count];

        int index = 0;
        foreach (Room r in Rooms) {
            vertices[index++] = r.GetCenterPoint();
        }

        voronoiMesh = VoronoiMesh.Create<Vertex2, Cell2> (vertices);
        foreach (var edge in voronoiMesh.Vertices) {
            int x1 = (int)edge.Vertices[0].x;
            int y1 = (int)edge.Vertices[0].y;
            int x2 = (int)edge.Vertices[1].x;
            int y2 = (int)edge.Vertices[1].y;
            edges.Add (new Edge(new Vertex2(x1, y1), new Vertex2(x2, y2)));

            x1 = x2;
            y1 = y2;
            x2 = (int)edge.Vertices[2].x;
            y2 = (int)edge.Vertices[2].y;
            edges.Add (new Edge(new Vertex2(x1, y1), new Vertex2(x2, y2)));

            x1 = x2;
            y1 = y2;
            x2 = (int)edge.Vertices[0].x;
            y2 = (int)edge.Vertices[0].y;
            edges.Add (new Edge(new Vertex2(x1, y1), new Vertex2(x2, y2)));
        }

        Edge[] edgeAry = new Edge[edges.Count];
        edges.CopyTo (edgeAry);

        c = new ConnectionGraph (new List<Edge>(edges));
        allEdges = edges;
        edges = c.GetEdges ();

        PathGenerator p = new PathGenerator (this);
        Edge[] pedge = new Edge[edges.Count];
        edges.CopyTo (pedge);
        Array.Sort (pedge);
        foreach (var edge in edges) {
            p.AddPath(edge);
        }

        p.GrowOpen ();
        savePaths (p);

        ptiles = p.tiles;
    }
コード例 #29
0
        public void Render(SKCanvas canvas, MapDataContext mapDataContext)
        {
            var solarSystemVertexes = new List <SolarSystemVertex>();

            foreach (var solarSystem in mapDataContext.SolarSystems)
            {
                solarSystemVertexes.Add(new SolarSystemVertex(solarSystem));
            }

            var voronoiMesh  = VoronoiMesh.Create <SolarSystemVertex, SolarySystemTriangulationCell>(solarSystemVertexes);
            var voronoiCells = CreateVoronoiCells(voronoiMesh);

            using (var paint = new SKPaint())
            {
                paint.Style       = SKPaintStyle.Fill;
                paint.IsAntialias = true;

                foreach (var cell in voronoiCells)
                {
                    var solarSystem  = cell.SolarSystemVertex.SolarSystem;
                    var cellVertices = cell.SolarSystemVoronoiEdges;
                    var points       = SortVertices(cellVertices.SelectMany(x => new List <SKPoint>()
                    {
                        x.PointOne, x.PointTwo
                    }).Distinct().ToList()).ToArray();

                    if (solarSystem.allianceID != null && solarSystem.allianceID != 0)
                    {
                        var md5  = MD5.Create();
                        var hash = md5.ComputeHash(Encoding.UTF8.GetBytes(solarSystem.allianceID.ToString()));
                        paint.Color = new SKColor(hash[0], hash[1], hash[2]).WithAlpha(60);

                        var path = new SKPath();

                        // for (var i = 0; i < cellVertices.Count(); i++)
                        // {
                        //     path.MoveTo(cellVertices[i].PointOne);
                        //     path.LineTo(cellVertices[i].PointTwo);
                        // }

                        path.MoveTo(points.First());
                        for (var i = 0; i < points.Count(); i++)
                        {
                            path.LineTo(points[i]);
                        }
                        path.LineTo(points.First());

                        canvas.DrawPath(path, paint);

                        // canvas.DrawPoints(SKPointMode.Polygon, points, paint);
                    }
                    else
                    {
                        paint.Color = new SKColor(0xB0, 0xB0, 0xFF).WithAlpha(50);
                        var path = new SKPath();
                        for (var i = 0; i < cellVertices.Count(); i++)
                        {
                            path.MoveTo(cellVertices[i].PointOne);
                            path.LineTo(cellVertices[i].PointTwo);
                        }

                        // canvas.DrawPath(path, paint);
                    }

                    // paint.Color = new SKColor(randomBytes[0], randomBytes[1], randomBytes[2]);
                }
                canvas.DrawLine(new SKPoint(0.0f, 0.0f), new SKPoint(100.0f, 100.0f), paint);
            }
        }
コード例 #30
0
    public void Create()
    {
        foreach (Transform child in transform)
        {
            Destroy(child.gameObject);
        }

        //InputField[] fields = FindObjectsOfType<InputField>();
        //InputField numseed = fields[0];
        //InputField numplates = fields[1];
        //InputField numtiles = fields[2];
        //numberOfVertices = Convert.ToInt32(numtiles.text);
        //plates = Convert.ToInt32(numplates.text);
        //seed = Convert.ToInt32(numseed.text);

        // INITIALIZATION
        Vertex3[] vertices = new Vertex3[numberOfVertices];
        Vector3[] meshVerts = new Vector3[numberOfVertices];
        allVerts = new List<Vector3>();
        vertsForVoronoiHull = new List<Vector3>();

        // VORONOI VERTICES NEED ONE EXTRA ONE IN CENTER
        Vertex3[] voronoiVertices = new Vertex3[numberOfVertices + 1];

        // RANDOM SEED
        Random.seed = seed;

        // GENERATE UNIFORM POINTS
        allVerts = GeneratePointsUniformly(); 
        allVerts.Sort((v1, v2) => v1.y.CompareTo(v2.y));

        // SET INDICES FOR VORONOI
        int i = 0;
        while (i < numberOfVertices)
        {
            vertices[i] = new Vertex3(allVerts[i].x, allVerts[i].y, allVerts[i].z);
            voronoiVertices[i] = vertices[i];
            meshVerts[i] = vertices[i].ToVector3(); ;
            i++;
        }
        // SET LAST EXTRA VERTEX
        voronoiVertices[numberOfVertices] = new Vertex3(0, 0, 0);

        
        // VORONOI
        voronoiMesh = VoronoiMesh.Create<Vertex3, Cell3>(voronoiVertices);
        

        
        // VORONOI HULL GENERATION
        int index = 0;
        foreach (var edge in voronoiMesh.Edges)
        {
            Vector3 source = new Vector3(edge.Source.Circumcenter.x, edge.Source.Circumcenter.y, edge.Source.Circumcenter.z);
            Vector3 target = new Vector3(edge.Target.Circumcenter.x, edge.Target.Circumcenter.y, edge.Target.Circumcenter.z);
            source *= ((float)size / 2.5f);
            target *= ((float)size / 2.5f);
            vertsForVoronoiHull.Add(source);
            vertsForVoronoiHull.Add(target);
            index++;
        }

        // REMOVE DUPLICATE POINTS
        vertsForVoronoiHull = vertsForVoronoiHull.Distinct().ToList();

        // CONVERT FROM VECTOR3 LIST TO VERTEX3 LIST FOR FINAL HULL
        Vertex3[] verticesDelaunay = new Vertex3[vertsForVoronoiHull.Count];

        int g = 0;
        while (g < vertsForVoronoiHull.Count)
        {
            verticesDelaunay[g] = new Vertex3(vertsForVoronoiHull[g].x, vertsForVoronoiHull[g].y, vertsForVoronoiHull[g].z);
            g++;
        }

        // GENERATE VORONOI HULL
        ConvexHull<Vertex3, Face3> convexHull = ConvexHull.Create<Vertex3, Face3>(verticesDelaunay);
        convexHullVertices = new List<Vertex3>(convexHull.Points);
        convexHullFaces = new List<Face3>(convexHull.Faces);
        convexHullIndices = new List<int>();

        foreach (Face3 f in convexHullFaces)
        {
            convexHullIndices.Add(convexHullVertices.IndexOf(f.Vertices[0]));
            convexHullIndices.Add(convexHullVertices.IndexOf(f.Vertices[1]));
            convexHullIndices.Add(convexHullVertices.IndexOf(f.Vertices[2]));
        }

        Dictionary<Vector3, List<Vector3>> normals = new Dictionary<Vector3, List<Vector3>>();

        // CREATE TRIANGLES FOR MESH
        for (int j = 0; j < convexHullIndices.Count; j += 3)
        {
            int v0 = convexHullIndices[j + 0];
            int v1 = convexHullIndices[j + 1];
            int v2 = convexHullIndices[j + 2];

            Vector3 a = new Vector3((float)convexHullVertices[v0].x, (float)convexHullVertices[v0].y, (float)convexHullVertices[v0].z);
            Vector3 b = new Vector3((float)convexHullVertices[v1].x, (float)convexHullVertices[v1].y, (float)convexHullVertices[v1].z);
            Vector3 c = new Vector3((float)convexHullVertices[v2].x, (float)convexHullVertices[v2].y, (float)convexHullVertices[v2].z);

            Vector3 normal = Vector3.Cross(a - b, a - c);

            // DECLARE KEY AND ROUND IT TO AVOID FLOATING POINT ISSUES
            Vector3 key = normal.normalized;
            float roundX = Mathf.Round(key.x * 100) / 100;
            float roundY = Mathf.Round(key.y * 100) / 100;
            float roundZ = Mathf.Round(key.z * 100) / 100;
            Vector3 roundedKey = new Vector3(roundX, roundY, roundZ);

            // POPULATE DICTIONARY
            if (!normals.ContainsKey(roundedKey))
            {
                normals.Add(roundedKey, new List<Vector3>());
            }
            normals[roundedKey].Add(a);
            normals[roundedKey].Add(b);
            normals[roundedKey].Add(c);
        }
 
        // CREATE VORONOI TILES
        List<VoronoiTile> tiles = new List<VoronoiTile>();
        foreach (var pair in normals)
        {
            List<Vector3> tileVerts = new List<Vector3>();
            for (int p = 0; p < pair.Value.Count; ++p)
            {
                tileVerts.Add(pair.Value[p]);
            }
            GameObject tile = new GameObject("Tile", typeof(VoronoiTile), typeof(MeshFilter), typeof(MeshRenderer), typeof(MeshCollider));
            var thisTile = tile.GetComponent<VoronoiTile>() as VoronoiTile;
            
            thisTile.Initialize(tileVerts, false); // OPTIMIZE HERE
            
            tile.GetComponent<MeshFilter>().mesh = thisTile.tileMesh;
            tile.GetComponent<MeshCollider>().sharedMesh = thisTile.tileMesh;

            thisTile.Normal = pair.Key;
            tiles.Add(thisTile);
            ++numberOfTiles;
        }

        foreach (var tile in tiles)
        {
            tile.FindNeighbors(tiles); 
        }

        List<VoronoiTile> waterTiles = new List<VoronoiTile>();
        Material oceanMat = (Material)Resources.Load("Ocean", typeof(Material));
        foreach (var pair in normals)
        {
            List<Vector3> tileVerts = new List<Vector3>();
            for (int p = 0; p < pair.Value.Count; ++p)
            {
                tileVerts.Add(pair.Value[p]);
            }
            GameObject tile = new GameObject("WaterTile", typeof(VoronoiTile), typeof(MeshFilter), typeof(MeshRenderer));
            var thisTile = tile.GetComponent<VoronoiTile>() as VoronoiTile;
            thisTile.Initialize(tileVerts, true);
            tile.GetComponent<MeshFilter>().mesh = thisTile.tileMesh;
            tile.GetComponent<MeshRenderer>().material = oceanMat;
            waterTiles.Add(thisTile);
        }

        ocean = new GameObject("Ocean");
        ocean.transform.parent = transform;
        foreach (var tile in waterTiles)
        {
            tile.transform.parent = ocean.transform;
        }

        // FLOOD FILLS
        // GENERATE PLATES
        List<VoronoiTile> plateStartNodes = GeneratePlateStartNodes(plates, ref tiles);

        // GENERATE PLATE MATERIALS
        List<Material> plateMaterials = GenerateMaterials(1); // changed here

        // GENERATE START LISTS
        List<List<VoronoiTile>> colors = new List<List<VoronoiTile>>();
        for (int b = 0; b < plates; ++b)
        {
            colors.Add(new List<VoronoiTile>() { plateStartNodes[b] });
        }

        
        // FILL
        FloodFillSimultaneous(ref colors, plateMaterials, ref tiles);
        
        
        // GROUP PLATES
        plateList = new List<TectonicPlate>();
        for (int q = 0; q < plates; ++q)
        {
            GameObject plateTest = new GameObject("Plate" + q, typeof(TectonicPlate));
            List<VoronoiTile> testPlateTiles = new List<VoronoiTile>();
            foreach (var voronoiTile in tiles)
            {
                if (voronoiTile.plate == q) testPlateTiles.Add(voronoiTile);
            }
            var thisTecPlate = plateTest.GetComponent<TectonicPlate>();
            thisTecPlate.Initialize(ref testPlateTiles);
            int land = Random.Range(0, 10);
            if (land < landAmount) thisTecPlate.isLand = true;
            plateTest.transform.parent = transform;
            plateList.Add(thisTecPlate);
        }

        LoadMaterials();
        
        // CREATE WATER AND LAND AREAS FOR HEIGHT
        FindWaterAndLandPoints();

        // DETERMINE BIOMES
        AssignPlateProperties();
        AssignTileProperties();
        DetermineBiomes(true);
        GenerateHeight();
        DetermineHeightBiomes();
    }