Example #1
0
        public void generate(NoiseGenerator noise, GraphicsDevice device, int seed)
        {
            radius = 100;
            int scale = noise.random.Next(1, 5);
            width = (radius * 2) / scale;
            height = (radius * 2) / scale;

            planetRadius = (float)((noise.random.NextDouble() * 100000) / scale);

            mass = (float)(noise.random.NextDouble() * 20);
            massRadix = noise.random.Next(24, 70) / scale;

            minTemp = noise.random.Next(-80, 20);
            maxTemp = noise.random.Next(minTemp, minTemp + 80);

            orgRes = noise.random.Next(0, 11);
            indRes = noise.random.Next(0, 11);
            atmosphere = noise.random.Next(0, 11);

            technology = atmosphere > 5 ? noise.random.Next(0, 6) : 0;

            frequency = ((noise.random.NextDouble() * 0.1));
            persistence = ((noise.random.NextDouble() * 1.0) + 0.5) / 2;
            octaves = ((noise.random.NextDouble() * 16) + 4) / 2;
            amplitude = ((noise.random.NextDouble() * 1.1) + 1) / 2;

            heightMap = noise.generateHeightMap(radius * 4, radius * 4, frequency, persistence, octaves, amplitude);

            r1 = (float)(noise.random.NextDouble() * 0.2) + 0.2f;
            g1 = (float)(noise.random.NextDouble() * 0.2) + 0.2f;
            b1 = (float)(noise.random.NextDouble() * 0.2) + 0.2f;

            r2 = (float)(noise.random.NextDouble() * 0.2) + r1;
            g2 = (float)(noise.random.NextDouble() * 0.2) + g1;
            b2 = (float)(noise.random.NextDouble() * 0.2) + b1;

            r3 = (float)(noise.random.NextDouble() * 0.2) + r2;
            g3 = (float)(noise.random.NextDouble() * 0.2) + g2;
            b3 = (float)(noise.random.NextDouble() * 0.2) + b2;

            r4 = (float)(noise.random.NextDouble() * 0.2) + r3;
            g4 = (float)(noise.random.NextDouble() * 0.2) + g3;
            b4 = (float)(noise.random.NextDouble() * 0.2) + b3;

            r5 = (float)(noise.random.NextDouble() * 0.2) + r4;
            g5 = (float)(noise.random.NextDouble() * 0.2) + g4;
            b5 = (float)(noise.random.NextDouble() * 0.2) + b4;

            surface = new Texture2D(device, radius * 4, radius * 4);

            maxHeight = 0;

            circle = new Texture2D(device, radius * 2 + 1, radius * 2 + 1);

            //now draw the circle, same as the surface texture
            Color[] noisyColors = new Color[circle.Width * circle.Height];
            Vector3 rgb = new Vector3();
            int[] center = new int[2];
            int[] point = new int[2];
            center[0] = radius;
            center[1] = radius;
            for (int i = 0; i < radius; i++)
            {
                for (float angle = 0; angle < 360; angle += 0.27f)
                {
                    if (i == radius - 1)
                    {
                        point = noise.getCircleCoordinate(center, i - 1, angle);
                        noisyColors[(point[0] / scale) + (point[1] / scale) * circle.Width] = new Color(new Vector3(0.10f, 0.10f, 0.10f));
                        point = noise.getCircleCoordinate(center, i, angle);
                        noisyColors[(point[0] / scale) + (point[1] / scale) * circle.Width] = new Color(new Vector3(0.05f, 0.05f, 0.05f));
                        point = noise.getCircleCoordinate(center, i + 1, angle);
                        noisyColors[(point[0] / scale) + (point[1] / scale) * circle.Width] = new Color(new Vector3(0.025f, 0.025f, 0.025f));
                    }
                    else
                    {
                        point = noise.getCircleCoordinate(center, i, angle);
                        rgb = getColorFromHeight(heightMap[point[0], point[1]]);
                        noisyColors[(point[0] / scale) + (point[1] / scale) * circle.Width] = new Color(new Vector3((rgb.X - (float)(i * 0.005) > 0 ? rgb.X - (float)(i * 0.005) : 0), (rgb.Y - (float)(i * 0.005) > 0 ? rgb.Y - (float)(i * 0.005) : 0), (rgb.Z - (float)(i * 0.005) > 0 ? rgb.Z - (float)(i * 0.005) : 0)));
                    }
                }
            }

            circle = new Texture2D(device, circle.Width, circle.Height, false, SurfaceFormat.Color);
            circle.SetData(noisyColors);
        }
Example #2
0
        public void generate(NoiseGenerator noise, int seed)
        {
            radius = 100;
            int scale = noise.random.Next(1, 5);
            width = (radius * 2) / scale;
            height = (radius * 2) / scale;

            planetRadius = (float)((noise.random.NextDouble() * 100000) / scale);

            mass = (float)(noise.random.NextDouble() * 20);
            massRadix = noise.random.Next(24, 70) / scale;

            minTemp = noise.random.Next(-80, 20);
            maxTemp = noise.random.Next(minTemp, minTemp + 80);

            orgRes = noise.random.Next(0, 11);
            indRes = noise.random.Next(0, 11);
            atmosphere = noise.random.Next(0, 11);

            technology = atmosphere > 5 ? noise.random.Next(0, 6) : 0;

            frequency = ((noise.random.NextDouble() * 0.1));
            persistence = ((noise.random.NextDouble() * 1.0) + 0.5) / 2;
            octaves = ((noise.random.NextDouble() * 16) + 4) / 2;
            amplitude = ((noise.random.NextDouble() * 1.1) + 1) / 2;

            heightMap = noise.generateHeightMap(radius * 4, radius * 4, frequency, persistence, octaves, amplitude);

            r1 = noise.random.Next(25, 100);
            g1 = noise.random.Next(25, 100);
            b1 = noise.random.Next(25, 100);

            r2 = noise.random.Next(r1, r1 + 25);
            g2 = noise.random.Next(g1, g1 + 25);
            b2 = noise.random.Next(g1, g1 + 25);

            r3 = noise.random.Next(r2, r2 + 25);
            g3 = noise.random.Next(g2, g2 + 25);
            b3 = noise.random.Next(g2, g2 + 25);

            r4 = noise.random.Next(r3, r3 + 25);
            g4 = noise.random.Next(g3, g3 + 25);
            b4 = noise.random.Next(g3, g3 + 25);

            r5 = noise.random.Next(r4, r4 + 25);
            g5 = noise.random.Next(g4, g4 + 25);
            b5 = noise.random.Next(g4, g4 + 25);

            surface = new Bitmap(radius * 4, radius * 4);

            maxHeight = 0;

            circle = new Bitmap(radius * 2 + 1, radius * 2 + 1);

            //fill with the transparent color first
            for (int x = 0; x < circle.Width; x++)
            {
                for (int y = 0; y < circle.Height; y++)
                {
                    Color c = Color.FromArgb(255, 0, 255);
                    circle.SetPixel(x, y, c);
                }
            }

            //now draw the circle, same as the surface texture
            int[] rgb = new int[3];
            int[] center = new int[2];
            int[] point = new int[2];
            center[0] = radius;
            center[1] = radius;
            for (int i = 0; i < radius; i++)
            {
                for (float angle = 0; angle < 360; angle += 0.27f)
                {
                    if (i == radius - 1)
                    {
                        point = noise.getCircleCoordinate(center, i - 1, angle);
                        circle.SetPixel(point[0] / scale, point[1] / scale, Color.FromArgb(20, 20, 20));
                        point = noise.getCircleCoordinate(center, i, angle);
                        circle.SetPixel(point[0] / scale, point[1] / scale, Color.FromArgb(15, 15, 15));
                        point = noise.getCircleCoordinate(center, i + 1, angle);
                        circle.SetPixel(point[0] / scale, point[1] / scale, Color.FromArgb(5, 5, 5));
                    }
                    else
                    {
                        point = noise.getCircleCoordinate(center, i, angle);
                        rgb = getColorFromHeight(heightMap[point[0], point[1]]);
                        circle.SetPixel(point[0]/scale, point[1]/scale, Color.FromArgb((rgb[0] - (int)(i) > 0 ? rgb[0] - (int)(i) : 0), (rgb[1] - (int)(i) > 0 ? rgb[1] - (int)(i) : 0), (rgb[2] - (int)(i) > 0 ? rgb[2] - (int)(i) : 0)));
                    }
                }
            }
        }