public void CreateTerrain()
        {
            float x = 0f;

            float[]        height         = new float[256 * 256];
            ImprovedPerlin improvedPerlin = new ImprovedPerlin(0, LibNoise.NoiseQuality.Best);

            for (int i = 0; i < 256 * 256; i++)
            {
                height[i] = improvedPerlin.GetValue(x / 10, x / 10, x * 100) / 3.5f + 1;

                //if (height[i] > 1.1f)
                //{
                //    height[i] = height[i] * 0.8f;
                //}
                //else if (height[i] < 0.9f)
                //{
                //    height[i] = height[i] * 1.2f;
                //}
                x += 0.001f;
            }

            SendMessageAndOnResponse(mainCommand.TerrainAdd(new int[] { 256, 256 }, height, "terrain"), "terrain",
                                     (message) =>
            {
                SendMessageAndOnResponse(mainCommand.renderTerrain("renderTerrain"), "renderTerrain",
                                         (message) =>
                {
                    terrainId          = JSONParser.GetTerrainID(message);
                    string addLayerMsg = mainCommand.AddLayer(terrainId, "addLayer");
                    SendMessageAndOnResponse(addLayerMsg, "addLayer", (message) => Console.WriteLine(""));
                });
            });
        }
Example #2
0
        public void StartSimulation()
        {
            Console.WriteLine("simulating bike...");
            //Example BLE Message
            //4A-09-4E-05-19-16-00-FF-28-00-00-20-F0

            this.running = true;

            float x = 0.0f;

            //Perlin for Random values
            ImprovedPerlin improvedPerlin = new ImprovedPerlin(0, LibNoise.NoiseQuality.Best);

            while (this.running)
            {
                CalculateVariables(improvedPerlin.GetValue(x) + 1);

                //Simulate sending data
                foreach (IDataReceiver dataReceiver in this.dataReceivers)
                {
                    dataReceiver.Bike(GenerateBike0x19());
                    dataReceiver.Bike(GenerateBike0x10());
                    dataReceiver.BPM(GenerateHeart());
                }

                Thread.Sleep(1000);

                x += 0.1f;
                eventCounter++;
                elapsedTime++;
            }
        }
Example #3
0
        public float GetPerlin(int x, int y)
        {
            var scale = (new Vector2(x, y) - new Vector2(RegionSize / 2f, RegionSize / 2f)).Length() / RegionSize * 2f;

            // QUAD MACHINE
            scale = scale * scale * scale;
            scale = Math.Min(Math.Max(scale, 0f), 1f);

            var major = _perlin.GetValue(x / 1024f, 0f, y / 1024f);

            var normal = _perlin.GetValue(x / 128f, 0f, y / 128f) * 0.4f;

            var minor = _perlin.GetValue(x / 32f, 0f, y / 32f) * 0.1f;

            return((major + normal + minor) - scale);
        }
Example #4
0
 public override double Execute(double x, double y, double z, CallableNode flow)
 {
     return(perlin.GetValue(x * frequency, z * frequency) * scale);
 }
Example #5
0
 private float[] GetPos(float n, ImprovedPerlin improvedPerlin)
 {
     float[] res = new float[] { improvedPerlin.GetValue(n) * 50, 0, improvedPerlin.GetValue(n) * 50 };
     return(res);
 }