/// <summary> /// Set colors on points on the plane /// </summary> private void SetColors(PrimitivePlane plane) { //fUpdateColors = false; int max = plane.Segments; Color color1 = Color.SkyBlue; Color color2 = Color.DeepSkyBlue; bool useColor1 = true; for (int x = 0; x <= max; x++) { Color color; for (int z = 0; z <= max; z++) { VertexPositionNormalColor p1 = plane.GetPoint(x, z); if (useColor1) { color = color1; } else { color = color2; } if (useColor1) { color.R = (byte)(255 * z / max); } useColor1 = !useColor1; p1.Color = color; plane.SetPoint(x, z, p1); } useColor1 = !useColor1; } }
/// <summary> /// Init the plane /// </summary> private void SetPlane() { fUpdatePlane = false; fPlane = new PrimitivePlane(fSpriteBatch.GraphicsDevice, 50, -1500, 1500, -1500, 1500, 0, Color.White); }
/// <summary> /// Init the plane /// </summary> private void SetPlane() { fUpdatePlane = false; fPlane = new PrimitivePlane(fSpriteBatch.GraphicsDevice, 180, -1500, 1500, -1500, 1500, 0, Color.White); SetColors(fPlane); fPlane.GenerateNormals(); fPlanes = new List <PrimitivePlane>(); for (int x = -1; x <= 1; x++) { for (int z = -1; z <= 1; z++) { int minX = 3000 * x - 1500; int maxX = minX + 3000; int minZ = 3000 * z - 1500; int maxZ = minZ + 3000; var plane = new PrimitivePlane(fSpriteBatch.GraphicsDevice, 180, minX, maxX, minZ, maxZ, 0, Color.White); fPlanes.Add(plane); SetColors(plane); plane.GenerateNormals(); minX += 10000; maxX += 10000; minZ += 10000; maxZ += 10000; plane = new PrimitivePlane(fSpriteBatch.GraphicsDevice, 1, minX, maxX, minZ, maxZ, 0, Color.White); fPlanes.Add(plane); SetColors(plane); plane.GenerateNormals(); } } Color color = Color.Yellow; fObject1 = new DynamicPrimitiveTriangles(); bool useBox = true; for (int x = -10; x <= 10; x++) { for (int y = -10; y <= 10; y++) { for (int z = -10; z <= 10; z++) { Vector3 position = new Vector3(1000 * x, 1000 * y, 1000 * z); int spread = 1000; position += new Vector3(fRandom.Next(spread), fRandom.Next(spread), fRandom.Next(spread)); color = new Color((float)fRandom.NextDouble(), (float)fRandom.NextDouble(), (float)fRandom.NextDouble()); int size = 100 + fRandom.Next(300); if (useBox) { fObject1.AddBox(3, position, size, color); } else { fObject1.AddSphere(9, position, size, color); } useBox = !useBox; } } } //fObject1.AddBox(segments, new Vector3(0, 0, 0), 1500, color); //fObject1.AddBox(segments, new Vector3(0, 3000, 0), 1500, color); fObject1.GenerateNormals(); }