コード例 #1
0
ファイル: Planet.cs プロジェクト: unhammer/gimp-sharp
        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));
            }
            }
        }
コード例 #2
0
ファイル: Planet.cs プロジェクト: unhammer/gimp-sharp
        byte[] CalculateIntensities(Mesh mesh, int n)
        {
            var cp = new byte[n * n];
              int index = 0;

              for (int i = 0; i < n; i++)
            {
              for (int j = 0; j < n; j++)
            {
              cp[index++] = (byte) (255.0 * (mesh[i, j] + 1.0) / 2.0);
            }
            }
              return cp;
        }