Beispiel #1
0
        public Renderer(VariableSet variables, Drawable drawable) :
            base(variables)
        {
            _drawable = drawable;

            const double lensAngle   = 70.0;
            const double earthRadius = 6375.0;
            var          amplitudes  = new double[] { 1.0, 0.5, 0.25, 0.125, 0.0625,
                                                      0.03125, 0.05, 0.05, 0.04, 0.0300 };

            _width  = drawable.Width;
            _height = drawable.Height;

            _clouds = new Perlin3D(10, 16.0, amplitudes,
                                   (int)GetValue <UInt32>("seed"));
            _cameraDistance = _width * 0.5 / Math.Tan(lensAngle * Math.PI / 180.0);

            _intSunX = (int)Math.Round((_width - 1) * GetValue <double>("sun_x"));
            _intSunY = (int)Math.Round((_height - 1) * GetValue <double>("sun_y"));

            _horizonColor2 = FromScreen("horizon_color");
            _skyColor2     = FromScreen("sky_color");
            _sunColor2     = FromScreen("sun_color");
            _cloudColor2   = FromScreen("cloud_color");
            _shadowColor2  = FromScreen("shadow_color");

            var tilt     = new TMatrix(GetValue <double>("tilt"), 1);
            var rotation = new TMatrix(GetValue <double>("rotation"), 2);

            _transform      = TMatrix.Combine(tilt, rotation);
            _cameraLocation = new Vector3(0.0, earthRadius + 0.2, 0.0);
        }
Beispiel #2
0
        public Renderer(VariableSet variables, Drawable drawable)
            : base(variables)
        {
            _drawable = drawable;

              const double lensAngle = 70.0;
              const double earthRadius = 6375.0;
              var amplitudes = new double[]{1.0, 0.5, 0.25, 0.125, 0.0625,
                    0.03125, 0.05, 0.05, 0.04, 0.0300};

              _width = drawable.Width;
              _height = drawable.Height;

              _clouds = new Perlin3D(10, 16.0, amplitudes,
                 (int) GetValue<UInt32>("seed"));
              _cameraDistance = _width * 0.5 / Math.Tan(lensAngle * Math.PI / 180.0);

              _intSunX = (int) Math.Round((_width - 1) * GetValue<double>("sun_x"));
              _intSunY = (int) Math.Round((_height - 1) * GetValue<double>("sun_y"));

              _horizonColor2 = FromScreen("horizon_color");
              _skyColor2 = FromScreen("sky_color");
              _sunColor2 = FromScreen("sun_color");
              _cloudColor2 = FromScreen("cloud_color");
              _shadowColor2 = FromScreen("shadow_color");

              var tilt = new TMatrix(GetValue<double>("tilt"), 1);
              var rotation = new TMatrix(GetValue<double>("rotation"), 2);
              _transform = TMatrix.Combine(tilt, rotation);
              _cameraLocation = new Vector3(0.0, earthRadius + 0.2, 0.0);
        }
Beispiel #3
0
        static public TMatrix Combine(TMatrix in1, TMatrix in2)
        {
            var result = Multiply(in1, in2);

            for (int i = 0; i < 3; i++)
            {
                result[i, 3] = in1[i, 3] + in2[i, 3];
            }
            return(result);
        }
Beispiel #4
0
        public static TMatrix Combine(TMatrix in1, TMatrix in2)
        {
            var result = Multiply(in1, in2);

              for (int i = 0; i < 3; i++)
            {
              result[i, 3] = in1[i, 3] + in2[i, 3];
            }
              return result;
        }
Beispiel #5
0
        static public TMatrix Multiply(TMatrix in1, TMatrix in2)
        {
            var result = new TMatrix();

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    double sum = 0.0;

                    for (int k = 0; k < 4; k++)
                    {
                        sum += in1[i, k] * in2[k, j];
                    }
                    result[i, j] = sum;
                }
            }
            return(result);
        }
Beispiel #6
0
        public static TMatrix Multiply(TMatrix in1, TMatrix in2)
        {
            var result = new TMatrix();

              for (int i = 0; i < 4; i++)
            {
              for (int j = 0; j < 4; j++)
            {
              double sum = 0.0;

              for (int k = 0; k < 4; k++)
            {
              sum += in1[i, k] * in2[k, j];
            }
              result[i, j] = sum;
            }
            }
              return result;
        }