Exemplo n.º 1
0
 public void AddAdjacency(PlanetVertex newAdjacency)
 {
     if (Adjacencies.Exists(n => n == newAdjacency) == false)
     {
         Adjacencies.Add(newAdjacency);
     }
 }
Exemplo n.º 2
0
        void initializeAdjacencies(IEnumerable <IndexTriangle> triangles)
        {
            Console.Write("Initializing adjacencies... ");
            Stopwatch stopwatch = Stopwatch.StartNew();

            foreach (IndexTriangle triangle in triangles)
            {
                PlanetVertex aVertex = vertices[triangle.AIndex];
                PlanetVertex bVertex = vertices[triangle.BIndex];
                PlanetVertex cVertex = vertices[triangle.CIndex];
                aVertex.AddMutualAdjacency(bVertex);
                aVertex.AddMutualAdjacency(cVertex);
                bVertex.AddMutualAdjacency(cVertex);
            }

            stopwatch.Stop();
            Console.WriteLine("" + stopwatch.ElapsedMilliseconds + " ms");

            //List<PlanetVertex> adjacencyless = vertices.Where(vertex => vertex.Adjacencies.Count == 0).ToList();
        }
Exemplo n.º 3
0
        public void Expand(Random random)
        {
            if (OuterVertices.Count == 0)
            {
                return;
            }

            PlanetVertex vertex = OuterVertices[random.Next(OuterVertices.Count)];

            foreach (PlanetVertex adjacentVertex in vertex.Adjacencies)
            {
                if (adjacentVertex.Tile == null)
                {
                    AddOuterVertex(adjacentVertex);
                }
                else if (adjacentVertex.Tile != this)
                {
                    AddMutualAdjacency(adjacentVertex.Tile);
                }
            }
            OuterVertices.Remove(vertex);
        }
Exemplo n.º 4
0
        void initializeVertices(Icosphere icosphere)
        {
            Console.Write("Initializing vertices... ");
            Stopwatch stopwatch = Stopwatch.StartNew();

            vertices = new List <PlanetVertex>(icosphere.Vertices.Count);
            float vertexSeparation = icosphere.GetVertexSeparation();

            for (int i = 0; i < icosphere.Vertices.Count; i++)
            {
                Vector3 position = icosphere.Vertices[i];
                float   xOffset  = (-0.5f + random.NextFloat()) * vertexSeparation / 2;
                float   yOffset  = (-0.5f + random.NextFloat()) * vertexSeparation / 2;
                float   zOffset  = (-0.5f + random.NextFloat()) * vertexSeparation / 2;
                position += new Vector3(xOffset, yOffset, zOffset);
                position.Normalize();

                PlanetVertex vertex = new PlanetVertex(position);
                vertices.Add(vertex);
            }

            stopwatch.Stop();
            Console.WriteLine("" + stopwatch.ElapsedMilliseconds + " ms");
        }
Exemplo n.º 5
0
 public void AddMutualAdjacency(PlanetVertex newAdjacency)
 {
     AddAdjacency(newAdjacency);
     newAdjacency.AddAdjacency(this);
 }
Exemplo n.º 6
0
 public void AddOuterVertex(PlanetVertex vertex)
 {
     AddVertex(vertex);
     OuterVertices.Add(vertex);
 }
Exemplo n.º 7
0
 public void AddVertex(PlanetVertex vertex)
 {
     vertex.Tile = this;
     Vertices.Add(vertex);
 }
Exemplo n.º 8
0
 public Tile(PlanetVertex origin)
 {
     Origin = origin;
 }