Ejemplo n.º 1
0
 //Constructors//
 public RendererNormal()
 {
     BumpHeight = 1.0;
     IsWrapEnabled = false;
     DestImage = null;
     SourceNoiseMap = null;
 }
Ejemplo n.º 2
0
 //Constructors//
 public RendererImage()
 {
     IsLightEnabled = false;
     IsWrapEnabled = false;
     LightAzimuth = 45.0;
     LightBrightness = 1.0;
     LightColor = Color.white;
     LightContrast = 1.0;
     LightElev = 45.0;
     LightIntensity = 1.0;
     BackgroundImage = null;
     DestImage = null;
     SourceNoiseMap = null;
     calcLightValues = true;
     //BuildGrayscaleGradient();
     BuildTerrainGradient();
 }
Ejemplo n.º 3
0
        //Methods//
        public void Render()
        {
            int width = SourceNoiseMap.Width;
            int height = SourceNoiseMap.Height;
            DestImage = new ImageMap(width, height);

            for (int y=0; y < height; y++) {
                for (int x=0; x < width; x++) {
                    int xRightOffset, yUpOffset;
                    if (IsWrapEnabled) {
                        if (x == (int)width - 1) {
                            xRightOffset = -((int)width - 1);
                        }
                        else {
                            xRightOffset = 1;
                        }
                        if ( y == (int)height - 1) {
                            yUpOffset = -((int)height - 1);
                        }
                        else {
                            yUpOffset = 1;
                        }
                    }
                    else {
                        if (x == (int)width - 1) {
                            xRightOffset = 0;
                        }
                        else {
                            xRightOffset = 1;
                        }
                        if ( y == (int)height - 1) {
                            yUpOffset = 0;
                        }
                        else {
                            yUpOffset = 1;
                        }
                    }
                    double nc = (double)SourceNoiseMap.GetValue(x, y);
                    double nr = (double)SourceNoiseMap.GetValue(x + xRightOffset, y);
                    double nu = (double)SourceNoiseMap.GetValue(x, y + yUpOffset);

                    DestImage.SetValue(x, y, CalcNormalColor(nc, nr, nu, BumpHeight));
                }
            }
        }
Ejemplo n.º 4
0
        //Methods//
        public void Render()
        {
            int width  = SourceNoiseMap.Width;
            int height = SourceNoiseMap.Height;

            DestImage = new ImageMap(width, height);

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    int xRightOffset, yUpOffset;

                    if (IsWrapEnabled)
                    {
                        if (x == (int)width - 1)
                        {
                            xRightOffset = -((int)width - 1);
                        }

                        else
                        {
                            xRightOffset = 1;
                        }

                        if (y == (int)height - 1)
                        {
                            yUpOffset = -((int)height - 1);
                        }

                        else
                        {
                            yUpOffset = 1;
                        }
                    }

                    else
                    {
                        if (x == (int)width - 1)
                        {
                            xRightOffset = 0;
                        }

                        else
                        {
                            xRightOffset = 1;
                        }

                        if (y == (int)height - 1)
                        {
                            yUpOffset = 0;
                        }

                        else
                        {
                            yUpOffset = 1;
                        }
                    }

                    double nc = (double)SourceNoiseMap.GetValue(x, y);
                    double nr = (double)SourceNoiseMap.GetValue(x + xRightOffset, y);
                    double nu = (double)SourceNoiseMap.GetValue(x, y + yUpOffset);
                    DestImage.SetValue(x, y, CalcNormalColor(nc, nr, nu, BumpHeight));
                }
            }
        }
Ejemplo n.º 5
0
        //Methods//
        public void Render()
        {
            int width = SourceNoiseMap.Width;
            int height = SourceNoiseMap.Height;
            DestImage = new ImageMap(width, height);

            for (int y=0; y < height; y++) {
                for (int x=0; x < width; x++) {
                    Color destColor = gradient.GetColor(SourceNoiseMap.GetValue(x, y));
                    double lightIntensity;
                    if (IsLightEnabled) {
                        int xLeftOffset, xRightOffset;
                        int yUpOffset, yDownOffset;
                        if (IsWrapEnabled) {
                            if (x == 0) {
                                xLeftOffset = (int)width - 1;
                                xRightOffset = 1;
                            }
                            else if (x == (int)width - 1) {
                                xLeftOffset = -1;
                                xRightOffset = -((int)width - 1);
                            }
                            else {
                                xLeftOffset = -1;
                                xRightOffset = 1;
                            }
                            if (y == 0) {
                                yDownOffset = (int)height - 1;
                                yUpOffset = 1;
                            }
                            else if (y == (int)height - 1) {
                                yDownOffset = -1;
                                yUpOffset = -((int)height - 1);
                            }
                            else {
                                yDownOffset = -1;
                                yUpOffset = 1;
                            }
                        }
                        else {
                            if (x == 0) {
                                xLeftOffset = 0;
                                xRightOffset = 1;
                            }
                            else if (x == (int)width - 1) {
                                xLeftOffset = -1;
                                xRightOffset = 0;
                            }
                            else {
                                xLeftOffset = -1;
                                xRightOffset = 1;
                            }
                            if (y == 0) {
                                yDownOffset = 0;
                                yUpOffset = 1;
                            }
                            else if (y == (int)height - 1) {
                                yDownOffset = -1;
                                yUpOffset = 0;
                            }
                            else {
                                yDownOffset = -1;
                                yUpOffset = 1;
                            }
                        }

                        double nc = (double)SourceNoiseMap.GetValue(x, y);
                        double nl = (double)SourceNoiseMap.GetValue(x + xLeftOffset, y);
                        double nr = (double)SourceNoiseMap.GetValue(x + xRightOffset, y);
                        double nd = (double)SourceNoiseMap.GetValue(x, y + yDownOffset);
                        double nu = (double)SourceNoiseMap.GetValue(x, y + yUpOffset);

                        lightIntensity = CalcLightIntensity(nc, nl, nr, nd, nu);
                        lightIntensity *= LightBrightness;
                    }
                    else {
                        lightIntensity = 1.0;
                    }

                    Color backgroundColor = Color.white;
                    if (BackgroundImage != null) {
                        backgroundColor = BackgroundImage.GetValue(x, y);
                    }

                    DestImage.SetValue(x, y, CalcDestColor(destColor, backgroundColor, lightIntensity));
                }
            }
        }