A cell has an infinite amount of points that are all connected to eachother
Exemple #1
0
        public HapticHandler(List <GameObject> chunks, Bounds bounds, Vector3 impactPoint, int id, VoronoiDemo voro)
        {
            impactTime = Time.timeSinceLevelLoad;

            this.chunks      = chunks;
            this.bounds      = bounds;
            this.impactPoint = impactPoint;
            this.id          = id;

            foreach (GameObject chunk in chunks)
            {
                Cell  cell   = chunk.GetComponent <FractureChunk>().cell;
                float length = 1.5f * 2.4f / 6.0f;
                //float length = Mathf.Min((Time.timeSinceLevelLoad - impactTime)*2, 2.0f * 2.4f / 6.0f);
                bool s = (cell.site.ToVector3() - bounds.center - impactPoint).magnitude < length;
                if (s)
                {
                    chunk.GetComponent <FractureChunk>().ApplyForce(impactPoint);
                }
            }

            Vector4 impactShader = new Vector4();

            impactShader.x = impactPoint.x;
            impactShader.y = impactPoint.y;
            impactShader.z = impactPoint.z;
            impactShader.w = Time.time;

            voro.bubbleGenerator.Center   = impactPoint;
            voro.bubbleGenerator.dieCount = 3;
        }
Exemple #2
0
        public void DrawCell(Cell cell, Color c, bool bFill = true,bool bBorder = false)
        {
            if (bFill)
            {
                //Create polygon
                var polygon = new Polygon()
                {
                    Stroke = new SolidColorBrush(Colors.Red),
                    Fill = new SolidColorBrush(c),
                    FillRule = FillRule.EvenOdd,
                    StrokeThickness = 1
                };

                polygon.Stroke = (bBorder) ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(c);

                //Create a point list for the polygon
                var pc = new PointCollection();
                foreach (var point in cell.Points)
                {
                    pc.Add(new System.Windows.Point(point.X, point.Y));
                }

                polygon.Points = pc;

                //Draw
                _drawCanvas.Children.Add(polygon);
            }
            else
            {
                foreach (var edge in cell.Edges)
                {
                    DrawLine(edge,c);
                }
            }

            //Info about the Cell
            //var areaOfCell = cell.Area();
            //var centerOfcell = cell.Center();
            //DrawText($"{areaOfCell}",Colors.Black, centerOfcell);
        }
        private void MathTesting()
        {

            //Setup

            var cell = new Cell();
            cell.SitePoint = new Point(400,400);

            cell.AddPoint(new Point(250,100));
            cell.AddPoint(new Point(700, 300));
            cell.AddPoint(new Point(400, 500));
            cell.AddPoint(new Point(150, 300));
            cell.AddPoint(new Point(100, 200));

            var newCell = cell.Inset(50);
            
           // _drawService.DrawCell(cell,Color.FromArgb(255,100, 100, 100),true,true);
           // _drawService.DrawCell(newCell, Color.FromArgb(255, 180, 180, 180), true, true);

            var triangles = new BowyerWatsonGenerator().DelaunayTriangulation(newCell.Points);
            foreach (var t in triangles)
            {
                //_drawService.DrawTriangle(t, Colors.CornflowerBlue);
            }

            foreach (var p in newCell.GenerateRandomPoints(20))
            {
                //_drawService.DrawPoint(p, 5, Colors.Red);
            }

        }
        public static DistrictCell FromCell(Cell c, string type)
        {
            var dc = new DistrictCell(type)
            {
                Edges = c.Edges,
                SitePoint = c.SitePoint,
                Points = c.Points
            };

            return dc;
        }