Ejemplo n.º 1
0
        Pixel DoRenderPlanet(IntCoordinate c, int width, int height, RenderInfo info, 
			 Vector3 sunvec)
        {
            const double starClose = 2;

              info.InitializeRow(c.Y);

              var sv = new Vector3(sunvec.X, sunvec.Y * info.dy, sunvec.Z * info.sqomdysq);

              double azimuth = Math.Asin(((double) c.Y / (height - 1)) * 2 - 1);
              int lcos = (int) ((height / 2) * Math.Abs(Math.Cos(azimuth)));

              if (c.X >= width / 2 - lcos && c.X <= width / 2 + lcos)
            {
              double r = info.CalculateR(c.X);

              var rgb = (r >= 128) ? RenderLand(r) : RenderWater(r);

              double icet = Math.Pow(Math.Abs(Math.Sin(azimuth)), 1.0 / _icelevel)
            - 0.5;
              RenderPolarIceCaps(r, icet, rgb);

              return ApplyDarkening(width, height, c.X, sv, info.dysq, rgb);
            }
              else if (c.X < width / 2 - (lcos + starClose) ||
               c.X > width / 2 + (lcos + starClose))
            {
              return _starFactory.Generate();
            }
              else
            {
              return new Pixel(3);
            }
        }
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));
            }
            }
        }
Ejemplo n.º 3
0
        Pixel DoRenderClouds(IntCoordinate c, RenderInfo info)
        {
            const double rgbQuant = 255;

              info.InitializeRow(c.Y);
              double r = info.CalculateR(c.X);

              byte w = (byte)((r > 127.0) ? (rgbQuant * ((r - 127.0) / 128.0)) : 0);

              return new Pixel(w, w, (byte) rgbQuant);
        }