Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ColoredTerrain" /> class.
        /// </summary>
        /// <param name="heightMap">The height map.</param>
        /// <param name="coloringMethod">The coloring method.</param>
        public ColoredTerrain(GraphicsDevice device, IHeightMap heightMap, IHeightToColorTranslationMethod coloringMethod)
        {
            this.effect = new BasicEffect(device);
            this.effect.VertexColorEnabled = true;
            Vector3 lightDir = new Vector3(1, -1, -1);
            lightDir.Normalize();
            this.effect.LightingEnabled = true;
            this.effect.PreferPerPixelLighting = true;
            this.effect.DirectionalLight0.Direction = lightDir;

            this.Width = heightMap.Width;
            this.Height = heightMap.Height;
            this.heightMap = heightMap;
            this.coloringMethod = coloringMethod;

            this.SetUpVertices();
            this.SetUpIndices();
            this.CalculateNormals();
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ColoredTerrain" /> class.
        /// </summary>
        /// <param name="heightMap">The height map.</param>
        /// <param name="coloringMethod">The coloring method.</param>
        public ColoredTerrain(GraphicsDevice device, IHeightMap heightMap, IHeightToColorTranslationMethod coloringMethod)
        {
            this.effect = new BasicEffect(device);
            this.effect.VertexColorEnabled = true;
            Vector3 lightDir = new Vector3(1, -1, -1);

            lightDir.Normalize();
            this.effect.LightingEnabled             = true;
            this.effect.PreferPerPixelLighting      = true;
            this.effect.DirectionalLight0.Direction = lightDir;

            this.Width          = heightMap.Width;
            this.Height         = heightMap.Height;
            this.heightMap      = heightMap;
            this.coloringMethod = coloringMethod;

            this.SetUpVertices();
            this.SetUpIndices();
            this.CalculateNormals();
        }