Пример #1
0
        /// <overloads>
        /// <summary>
        /// Initializes a new instance of the <see cref="TerrainRoadLayer"/> class.
        /// </summary>
        /// </overloads>
        ///
        /// <summary>
        /// Initializes a new instance of the <see cref="TerrainRoadLayer"/> class with the default
        /// material.
        /// </summary>
        /// <param name="graphicService">The graphic service.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="graphicService"/> is <see langword="null"/>.
        /// </exception>
        public TerrainRoadLayer(IGraphicsService graphicService)
        {
            if (graphicService == null)
            {
                throw new ArgumentNullException("graphicService");
            }

            var effect = graphicService.Content.Load <Effect>("DigitalRune/Terrain/TerrainRoadLayer");

            Material = new Material
            {
                { "Detail", new EffectBinding(graphicService, effect, null, EffectParameterHint.Material) }
            };

            FadeOutStart       = int.MaxValue;
            FadeOutEnd         = int.MaxValue;
            TileSize           = 1;
            DiffuseColor       = new Vector3(1, 1, 1);
            SpecularColor      = new Vector3(1, 1, 1);
            SpecularPower      = 10;
            Alpha              = 1;
            DiffuseTexture     = graphicService.GetDefaultTexture2DWhite();
            SpecularTexture    = graphicService.GetDefaultTexture2DBlack();
            NormalTexture      = graphicService.GetDefaultNormalTexture();
            HeightTextureScale = 1;
            HeightTexture      = graphicService.GetDefaultTexture2DBlack();
            RoadLength         = 1;
        }
Пример #2
0
        /// <overloads>
        /// <summary>
        /// Initializes a new instance of the <see cref="TerrainDecalLayer"/> class.
        /// </summary>
        /// </overloads>
        ///
        /// <summary>
        /// Initializes a new instance of the <see cref="TerrainDecalLayer"/> class with the default
        /// material.
        /// </summary>
        /// <param name="graphicService">The graphic service.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="graphicService"/> is <see langword="null"/>.
        /// </exception>
        public TerrainDecalLayer(IGraphicsService graphicService)
        {
            if (graphicService == null)
            {
                throw new ArgumentNullException("graphicService");
            }

            // Use a down orientation per default.
            Pose = new Pose(Matrix.CreateRotationX(-ConstantsF.PiOver2));

            var effect = graphicService.Content.Load <Effect>("DigitalRune/Terrain/TerrainDecalLayer");

            Material = new Material
            {
                { "Detail", new EffectBinding(graphicService, effect, null, EffectParameterHint.Material) }
            };

            FadeOutStart       = int.MaxValue;
            FadeOutEnd         = int.MaxValue;
            Width              = 1;
            Height             = 1;
            DiffuseColor       = new Vector3(1, 1, 1);
            SpecularColor      = new Vector3(1, 1, 1);
            SpecularPower      = 10;
            Alpha              = 1;
            DiffuseTexture     = graphicService.GetDefaultTexture2DWhite();
            SpecularTexture    = graphicService.GetDefaultTexture2DBlack();
            NormalTexture      = graphicService.GetDefaultNormalTexture();
            HeightTextureScale = 1;
            HeightTexture      = graphicService.GetDefaultTexture2DBlack();

            UpdateAabb();
        }
        /// <overloads>
        /// <summary>
        /// Initializes a new instance of the <see cref="TerrainMaterialLayer"/> class.
        /// </summary>
        /// </overloads>
        ///
        /// <summary>
        /// Initializes a new instance of the <see cref="TerrainMaterialLayer"/> class with the default
        /// material.
        /// </summary>
        /// <param name="graphicService">The graphic service.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="graphicService"/> is <see langword="null"/>.
        /// </exception>
        public TerrainMaterialLayer(IGraphicsService graphicService)
        {
            if (graphicService == null)
            {
                throw new ArgumentNullException("graphicService");
            }

            var effect = graphicService.Content.Load <Effect>("DigitalRune/Terrain/TerrainMaterialLayer");

            Material = new Material
            {
                { "Detail", new EffectBinding(graphicService, effect, null, EffectParameterHint.Material) }
            };

            FadeOutStart            = int.MaxValue;
            FadeOutEnd              = int.MaxValue;
            TileSize                = 1;
            DiffuseColor            = new Vector3(1, 1, 1);
            SpecularColor           = new Vector3(1, 1, 1);
            SpecularPower           = 10;
            Alpha                   = 1;
            DiffuseTexture          = graphicService.GetDefaultTexture2DWhite();
            SpecularTexture         = graphicService.GetDefaultTexture2DBlack();
            NormalTexture           = graphicService.GetDefaultNormalTexture();
            HeightTextureScale      = 1;
            HeightTextureBias       = 0;
            HeightTexture           = graphicService.GetDefaultTexture2DBlack();
            TriplanarTightening     = -1;
            TintStrength            = 1;
            TintTexture             = graphicService.GetDefaultTexture2DWhite();
            BlendThreshold          = 0.5f;
            BlendRange              = 1f;
            BlendHeightInfluence    = 0;
            BlendNoiseInfluence     = 0;
            BlendTextureChannel     = 0;
            BlendTexture            = graphicService.GetDefaultTexture2DWhite();
            NoiseTileSize           = 1;
            TerrainHeightMin        = -1e20f;
            TerrainHeightMax        = +1e20f;
            TerrainHeightBlendRange = 1f;
            TerrainSlopeMin         = -ConstantsF.Pi;
            TerrainSlopeMax         = ConstantsF.Pi;
            TerrainSlopeBlendRange  = MathHelper.ToRadians(10);
        }
Пример #4
0
        private EffectParameterBinding CreateNormalTextureBinding <T>(Effect effect,
                                                                      EffectParameter parameter, IDictionary <string, object> opaqueData) where T : Texture
        {
            object value = null;

            if (opaqueData != null)
            {
                opaqueData.TryGetValue(parameter.Name, out value);
            }

            var texture = value as T;

            if (texture == null)
            {
                texture = _graphicsService.GetDefaultNormalTexture() as T;
            }

            return(new ConstParameterBinding <T>(effect, parameter, texture));
        }
Пример #5
0
        //--------------------------------------------------------------
        /// <overloads>
        /// <summary>
        /// Initializes a new instance of the <see cref="TerrainRoadLayer"/> class.
        /// </summary>
        /// </overloads>
        /// 
        /// <summary>
        /// Initializes a new instance of the <see cref="TerrainRoadLayer"/> class with the default
        /// material.
        /// </summary>
        /// <param name="graphicService">The graphic service.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="graphicService"/> is <see langword="null"/>.
        /// </exception>
        public TerrainRoadLayer(IGraphicsService graphicService)
        {
            if (graphicService == null)
            throw new ArgumentNullException("graphicService");

              var effect = graphicService.Content.Load<Effect>("DigitalRune/Terrain/TerrainRoadLayer");
              Material = new Material
              {
            { "Detail", new EffectBinding(graphicService, effect, null, EffectParameterHint.Material) }
              };

              FadeOutStart = int.MaxValue;
              FadeOutEnd = int.MaxValue;
              TileSize = 1;
              DiffuseColor = new Vector3F(1, 1, 1);
              SpecularColor = new Vector3F(1, 1, 1);
              SpecularPower = 10;
              Alpha = 1;
              DiffuseTexture = graphicService.GetDefaultTexture2DWhite();
              SpecularTexture = graphicService.GetDefaultTexture2DBlack();
              NormalTexture = graphicService.GetDefaultNormalTexture();
              HeightTextureScale = 1;
              HeightTexture = graphicService.GetDefaultTexture2DBlack();
              RoadLength = 1;
        }
Пример #6
0
        //--------------------------------------------------------------
        /// <overloads>
        /// <summary>
        /// Initializes a new instance of the <see cref="TerrainMaterialLayer"/> class.
        /// </summary>
        /// </overloads>
        /// 
        /// <summary>
        /// Initializes a new instance of the <see cref="TerrainMaterialLayer"/> class with the default
        /// material.
        /// </summary>
        /// <param name="graphicService">The graphic service.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="graphicService"/> is <see langword="null"/>.
        /// </exception>
        public TerrainMaterialLayer(IGraphicsService graphicService)
        {
            if (graphicService == null)
            throw new ArgumentNullException("graphicService");

              var effect = graphicService.Content.Load<Effect>("DigitalRune/Terrain/TerrainMaterialLayer");
              Material = new Material
              {
            { "Detail", new EffectBinding(graphicService, effect, null, EffectParameterHint.Material) }
              };

              FadeOutStart = int.MaxValue;
              FadeOutEnd = int.MaxValue;
              TileSize = 1;
              DiffuseColor = new Vector3F(1, 1, 1);
              SpecularColor = new Vector3F(1, 1, 1);
              SpecularPower = 10;
              Alpha = 1;
              DiffuseTexture = graphicService.GetDefaultTexture2DWhite();
              SpecularTexture = graphicService.GetDefaultTexture2DBlack();
              NormalTexture = graphicService.GetDefaultNormalTexture();
              HeightTextureScale = 1;
              HeightTextureBias = 0;
              HeightTexture = graphicService.GetDefaultTexture2DBlack();
              TriplanarTightening = -1;
              TintStrength = 1;
              TintTexture = graphicService.GetDefaultTexture2DWhite();
              BlendThreshold = 0.5f;
              BlendRange = 1f;
              BlendHeightInfluence = 0;
              BlendNoiseInfluence = 0;
              BlendTextureChannel = 0;
              BlendTexture = graphicService.GetDefaultTexture2DWhite();
              NoiseTileSize = 1;
              TerrainHeightMin = -1e20f;
              TerrainHeightMax = +1e20f;
              TerrainHeightBlendRange = 1f;
              TerrainSlopeMin = -ConstantsF.Pi;
              TerrainSlopeMax = ConstantsF.Pi;
              TerrainSlopeBlendRange = MathHelper.ToRadians(10);
        }
Пример #7
0
        //--------------------------------------------------------------
        /// <overloads>
        /// <summary>
        /// Initializes a new instance of the <see cref="TerrainDecalLayer"/> class.
        /// </summary>
        /// </overloads>
        /// 
        /// <summary>
        /// Initializes a new instance of the <see cref="TerrainDecalLayer"/> class with the default
        /// material.
        /// </summary>
        /// <param name="graphicService">The graphic service.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="graphicService"/> is <see langword="null"/>.
        /// </exception>
        public TerrainDecalLayer(IGraphicsService graphicService)
        {
            if (graphicService == null)
            throw new ArgumentNullException("graphicService");

              // Use a down orientation per default.
              Pose = new Pose(Matrix33F.CreateRotationX(-ConstantsF.PiOver2));

              var effect = graphicService.Content.Load<Effect>("DigitalRune/Terrain/TerrainDecalLayer");
              Material = new Material
              {
            { "Detail", new EffectBinding(graphicService, effect, null, EffectParameterHint.Material) }
              };

              FadeOutStart = int.MaxValue;
              FadeOutEnd = int.MaxValue;
              Width = 1;
              Height = 1;
              DiffuseColor = new Vector3F(1, 1, 1);
              SpecularColor = new Vector3F(1, 1, 1);
              SpecularPower = 10;
              Alpha = 1;
              DiffuseTexture = graphicService.GetDefaultTexture2DWhite();
              SpecularTexture = graphicService.GetDefaultTexture2DBlack();
              NormalTexture = graphicService.GetDefaultNormalTexture();
              HeightTextureScale = 1;
              HeightTexture = graphicService.GetDefaultTexture2DBlack();

              UpdateAabb();
        }