public void AddAdjacency(PlanetVertex newAdjacency) { if (Adjacencies.Exists(n => n == newAdjacency) == false) { Adjacencies.Add(newAdjacency); } }
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(); }
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); }
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"); }
public void AddMutualAdjacency(PlanetVertex newAdjacency) { AddAdjacency(newAdjacency); newAdjacency.AddAdjacency(this); }
public void AddOuterVertex(PlanetVertex vertex) { AddVertex(vertex); OuterVertices.Add(vertex); }
public void AddVertex(PlanetVertex vertex) { vertex.Tile = this; Vertices.Add(vertex); }
public Tile(PlanetVertex origin) { Origin = origin; }