Ejemplo n.º 1
0
        public Planet(Drawable drawable,
                      bool stars, double starfraction, double starcolour,
                      bool clouds, Random random,
                      double icelevel, double glaciers,
                      double fracdim,
                      bool hourspec, double hourangle,
                      bool inclspec, double inclangle,
                      double powscale, IUpdater updater)
        {
            _starfraction = starfraction;
            _starcolour   = starcolour;
            _icelevel     = icelevel;
            _glaciers     = glaciers;
            _random       = random;
            _hourspec     = hourspec;
            _inclspec     = inclspec;
            _hourangle    = hourangle;
            _inclangle    = inclangle;

            _starFactory = new StarFactory(_random, _starfraction, _starcolour);

            if (stars)
            {
                updater.Update((c) => _starFactory.Generate());
            }
            else
            {
                var spectrum = new SpectralSynthesis(random);
                var a        = spectrum.Synthesize(meshsize, 3.0 - fracdim);

                var mesh = new Mesh(a, meshsize);

                // Apply power law scaling if non-unity scale is requested.
                if (powscale != 1.0)
                {
                    mesh.ApplyPowerLawScaling(powscale);
                }

                mesh.AutoScale();

                var cp = CalculateIntensities(mesh, meshsize);

                var dimensions = drawable.Dimensions;
                var info       = new RenderInfo(dimensions.Width, dimensions.Height, meshsize,
                                                cp);
                if (clouds)
                {
                    updater.Update((c) => DoRenderClouds(c, info));
                }
                else
                {
                    int width  = dimensions.Width;
                    int height = dimensions.Height;
                    var sunvec = IncidentLightDirectionVector();
                    updater.Update((c) => DoRenderPlanet(c, width, height, info, sunvec));
                }
            }
        }
Ejemplo n.º 2
0
        public Planet(Drawable drawable,
		  bool stars, double starfraction, double starcolour,
		  bool clouds, Random random, 
		  double icelevel, double glaciers,
		  double fracdim, 
		  bool hourspec, double hourangle,
		  bool inclspec, double inclangle,
		  double powscale, IUpdater updater)
        {
            _starfraction = starfraction;
              _starcolour = starcolour;
              _icelevel = icelevel;
              _glaciers = glaciers;
              _random = random;
              _hourspec = hourspec;
              _inclspec = inclspec;
              _hourangle = hourangle;
              _inclangle = inclangle;

              _starFactory = new StarFactory(_random, _starfraction, _starcolour);

              if (stars)
            {
              updater.Update((c) => _starFactory.Generate());
            }
              else
            {
              var spectrum = new SpectralSynthesis(random);
              var a = spectrum.Synthesize(meshsize, 3.0 - fracdim);

              var mesh = new Mesh(a, meshsize);

              // Apply power law scaling if non-unity scale is requested.
              if (powscale != 1.0)
            {
              mesh.ApplyPowerLawScaling(powscale);
            }

              mesh.AutoScale();

              var cp = CalculateIntensities(mesh, meshsize);

              var dimensions = drawable.Dimensions;
              var info = new RenderInfo(dimensions.Width, dimensions.Height, meshsize,
                    cp);
              if (clouds)
            {
              updater.Update((c) => DoRenderClouds(c, info));
            }
              else
            {
              int width = dimensions.Width;
              int height = dimensions.Height;
              var sunvec = IncidentLightDirectionVector();
              updater.Update((c) => DoRenderPlanet(c, width, height, info, sunvec));
            }
            }
        }