/// <summary> /// Adds a grass billboard /// </summary> private void AddGrass(VertexTerrain v, List<VertexBillboard> grassVertices, List<int> grassIndices, Random r, Climate climate) { float rg = r.Next(50, 101) / 100.0f; Vector3 color = Vector3.One; if (climate == Climate.Tropical) color = new Vector3(rg, rg, r.Next(40, 101) / 100.0f); else if (climate == Climate.Polar) color = new Vector3(rg, rg, rg); else if (climate == Climate.Dry) color = new Vector3(rg, rg, r.Next(1, 40) / 100.0f); Vector2 scale = new Vector2(r.Next(5, 8), r.Next(5, 20) / 10.0f); grassVertices.Add(new VertexBillboard(v.Position, v.Normal, color, Vector2.Zero, scale)); grassVertices.Add(new VertexBillboard(v.Position, v.Normal, color, Vector2.UnitX, scale)); grassVertices.Add(new VertexBillboard(v.Position, v.Normal, color, Vector2.One, scale)); grassVertices.Add(new VertexBillboard(v.Position, v.Normal, color, Vector2.UnitY, scale)); int[] baseIndices = new int[] { 0, 1, 2, 0, 2, 3 }; int offset = grassIndices.Count / 6 * 4; for (int i = 0; i < 6; i++) grassIndices.Add(baseIndices[i] + offset); }
/// <summary> /// Adds a tree billboard /// </summary> private void AddTree(VertexTerrain v, List<VertexBillboard> treeVertices, List<int> treeIndices, Random r, Climate climate) { Vector3 color; if (climate == Climate.Polar) color = new Vector3(1, r.Next(90, 101) / 100.0f, r.Next(90, 101) / 100.0f); else color = new Vector3(1, r.Next(90, 101) / 100.0f, r.Next(40, 101) / 100.0f); Vector2 scale = new Vector2(r.Next(4, 11), r.Next(50, 100) / 10.0f); treeVertices.Add(new VertexBillboard(v.Position, Vector3.Up, color, Vector2.Zero, scale)); treeVertices.Add(new VertexBillboard(v.Position, Vector3.Up, color, Vector2.UnitX, scale)); treeVertices.Add(new VertexBillboard(v.Position, Vector3.Up, color, Vector2.One, scale)); treeVertices.Add(new VertexBillboard(v.Position, Vector3.Up, color, Vector2.UnitY, scale)); int[] baseIndices = new int[] { 0, 1, 2, 0, 2, 3 }; int offset = treeIndices.Count / 6 * 4; for (int i = 0; i < 6; i++) treeIndices.Add(baseIndices[i] + offset); }