Esempio n. 1
0
        /// <summary>
        /// Smooth all free nodes.
        /// </summary>
        private void Step()
        {
            BoundedVoronoi voronoi = new BoundedVoronoi(this.mesh, false);

            var cells = voronoi.Regions;

            float x, y;
            int n;

            foreach (var cell in cells)
            {
                n = 0;
                x = y = 0.0f;
                foreach (var p in cell.Vertices)
                {
                    n++;
                    x += p.x;
                    y += p.y;
                }

                cell.Generator.x = x / n;
                cell.Generator.y = y / n;
            }
        }
Esempio n. 2
0
        private void menuViewVoronoi_Click(object sender, EventArgs e)
        {
            if (mesh == null)
            {
                return;
            }

            if (menuViewVoronoi.Checked)
            {
                renderManager.ShowVoronoi = false;
                menuViewVoronoi.Checked = false;
                return;
            }

            IVoronoi voronoi;

            if (mesh.IsPolygon)
            {
                voronoi = new BoundedVoronoi(mesh);
            }
            else
            {
                voronoi = new Voronoi(mesh);
            }

            renderData.SetVoronoi(voronoi);
            renderManager.SetData(renderData);

            menuViewVoronoi.Checked = true;
        }