Esempio n. 1
0
            protected override void SetGrassColor(GrassColors grassColors)
            {
                DaggerfallDateTime daggerfallDateTime = DaggerfallUnity.Instance.WorldTime.Now;
                int day = daggerfallDateTime.DayOfYear;

                if (day < DaysOfYear.Spring)
                {
                    float t = Mathf.InverseLerp(DaysOfYear.GrowDay, DaysOfYear.Spring, day);
                    Grass.healthyColor = Color.Lerp(Color.white, grassColors.SpringHealthy, t);
                    Grass.dryColor     = Color.Lerp(Color.white, grassColors.SpringDry, t);
                }
                else if (day <= DaysOfYear.MidYear)
                {
                    float t = Mathf.InverseLerp(DaysOfYear.Spring, DaysOfYear.MidYear, day);
                    Grass.healthyColor = Color.Lerp(grassColors.SpringHealthy, grassColors.SummerHealty, t);
                    Grass.dryColor     = Color.Lerp(grassColors.SpringDry, grassColors.SummerDry, t);
                }
                else if (day < DaysOfYear.Winter)
                {
                    float t = Mathf.InverseLerp(DaysOfYear.MidYear, DaysOfYear.Winter, day);
                    Grass.healthyColor = Color.Lerp(grassColors.SummerHealty, grassColors.FallHealty, t);
                    Grass.dryColor     = Color.Lerp(grassColors.SummerDry, grassColors.FallDry, t);
                }
                else
                {
                    float t = Mathf.InverseLerp(DaysOfYear.Winter, DaysOfYear.DieDay, day);
                    Grass.healthyColor = Color.Lerp(grassColors.FallHealty, Color.white, t);
                    Grass.dryColor     = Color.Lerp(grassColors.FallDry, Color.white, t);
                }
            }
Esempio n. 2
0
            protected virtual void SetGrassColor(GrassColors grassColors)
            {
                DaggerfallDateTime daggerfallDateTime = DaggerfallUnity.Instance.WorldTime.Now;

                switch (daggerfallDateTime.SeasonValue)
                {
                case DaggerfallDateTime.Seasons.Spring:
                    Grass.healthyColor = grassColors.SpringHealthy;
                    Grass.dryColor     = grassColors.SpringDry;
                    break;

                case DaggerfallDateTime.Seasons.Summer:
                    Grass.healthyColor = grassColors.SummerHealty;
                    Grass.dryColor     = grassColors.SummerDry;
                    break;

                case DaggerfallDateTime.Seasons.Fall:
                    Grass.healthyColor = grassColors.FallHealty;
                    Grass.dryColor     = grassColors.FallDry;
                    break;

                default:
                    Grass.healthyColor = Color.white;
                    Grass.dryColor     = Color.white;
                    break;
                }
            }
Esempio n. 3
0
 internal SizeColor(GrassStyle grassStyle, GrassColors grassColors, Range <float> grassHeight, float noiseSpread, DetailPrototype grass, DetailPrototype detail, DetailPrototype accent)
 {
     this.GrassStyle  = grassStyle;
     this.grassColors = grassColors;
     this.grassHeight = grassHeight;
     this.noiseSpread = noiseSpread;
     this.Grass       = grass;
     this.GrassDetail = detail;
     this.GrassAccent = accent;
 }
Esempio n. 4
0
        public DetailPrototypesManager(Mod mod, Transform parent, RealGrassOptions options, PrototypesProperties properties)
        {
            Color healthyColor = new Color(0.70f, 0.70f, 0.70f);
            Color dryColor     = new Color(0.40f, 0.40f, 0.40f);

            this.mod        = mod;
            this.parent     = parent;
            this.options    = options;
            textureOverride = properties.TextureOverride;
            float noiseSpread = properties.NoiseSpread;

            useGrassShader = properties.UseGrassShader;

            List <DetailPrototype> detailPrototypes = new List <DetailPrototype>();
            int index = 0;

            var grassPrototypes = new DetailPrototype()
            {
                minWidth         = properties.GrassWidth.Min,
                maxWidth         = properties.GrassWidth.Max,
                noiseSpread      = properties.NoiseSpread,
                renderMode       = useGrassShader ? DetailRenderMode.Grass : DetailRenderMode.GrassBillboard,
                usePrototypeMesh = useGrassShader
            };

            detailPrototypes.Add(grassPrototypes);
            Grass = index;

            if ((options.GrassStyle & GrassStyle.Mixed) == GrassStyle.Mixed)
            {
                detailPrototypes.Add(new DetailPrototype()
                {
                    minWidth         = properties.GrassWidth.Min,
                    maxWidth         = properties.GrassWidth.Max,
                    noiseSpread      = properties.NoiseSpread,
                    healthyColor     = healthyColor,
                    dryColor         = dryColor,
                    renderMode       = useGrassShader ? DetailRenderMode.Grass : DetailRenderMode.GrassBillboard,
                    usePrototypeMesh = useGrassShader
                });
                GrassDetails = ++index;

                detailPrototypes.Add(new DetailPrototype()
                {
                    minWidth         = properties.GrassWidth.Min,
                    maxWidth         = properties.GrassWidth.Max,
                    noiseSpread      = properties.NoiseSpread,
                    healthyColor     = healthyColor,
                    dryColor         = dryColor,
                    renderMode       = useGrassShader ? DetailRenderMode.Grass : DetailRenderMode.GrassBillboard,
                    usePrototypeMesh = useGrassShader
                });
                GrassAccents = ++index;
            }

            if (options.WaterPlants)
            {
                var waterPlantsNear = new DetailPrototype()
                {
                    usePrototypeMesh = true,
                    noiseSpread      = 0.6f,
                    healthyColor     = healthyColor,
                    dryColor         = dryColor,
                    renderMode       = DetailRenderMode.Grass
                };
                detailPrototypes.Add(waterPlantsNear);
                WaterPlants = ++index;
            }

            if (options.TerrainStones)
            {
                detailPrototypes.Add(new DetailPrototype()
                {
                    minWidth         = 0.4f,
                    maxWidth         = 1,
                    minHeight        = 0.25f,
                    maxHeight        = 1.5f,
                    usePrototypeMesh = true,
                    noiseSpread      = 1,
                    renderMode       = DetailRenderMode.VertexLit
                });
                Rocks = ++index;
            }

            DetailPrototypes = detailPrototypes.ToArray();

            GrassColors   grassColors = properties.GrassColors;
            Range <float> grassHeight = properties.GrassHeight;

            sizeColor = grassColors.SeasonInterpolation ?
                        new InterpolatedSizeColor(options.GrassStyle, grassColors, grassHeight, noiseSpread, detailPrototypes[Grass], detailPrototypes[GrassDetails], detailPrototypes[GrassAccents]) :
                        new SizeColor(options.GrassStyle, grassColors, grassHeight, noiseSpread, detailPrototypes[Grass], detailPrototypes[GrassDetails], detailPrototypes[GrassAccents]);
        }
Esempio n. 5
0
 internal InterpolatedSizeColor(GrassStyle grassStyle, GrassColors grassColors, Range <float> grassHeight, float noiseSpread, DetailPrototype grass, DetailPrototype detail, DetailPrototype accent)
     : base(grassStyle, grassColors, grassHeight, noiseSpread, grass, detail, accent)
 {
 }
        /// <summary>
        /// Initialize detail protoypes.
        /// </summary>
        public DetailPrototypesManager(PrototypesProperties properties)
        {
            Color healthyColor = new Color(0.70f, 0.70f, 0.70f);
            Color dryColor     = new Color(0.40f, 0.40f, 0.40f);

            this.textureOverride = properties.TextureOverride;

            // Create a holder for our grass and plants
            List <DetailPrototype> detailPrototypes = new List <DetailPrototype>();
            int index = 0;

            // Grass settings
            grassHeight    = properties.GrassHeight;
            grassColors    = properties.GrassColors;
            useGrassShader = properties.UseGrassShader;

            // We use GrassBillboard or Grass rendermode
            var grassPrototypes = new DetailPrototype()
            {
                minWidth         = properties.GrassWidth.Min,
                maxWidth         = properties.GrassWidth.Max,
                noiseSpread      = properties.NoiseSpread,
                renderMode       = useGrassShader ? DetailRenderMode.Grass : DetailRenderMode.GrassBillboard,
                usePrototypeMesh = useGrassShader
            };

            detailPrototypes.Add(grassPrototypes);
            Grass = index;

            if (RealGrass.Instance.RealisticGrass)
            {
                detailPrototypes.Add(new DetailPrototype()
                {
                    minWidth         = properties.GrassWidth.Min,
                    maxWidth         = properties.GrassWidth.Max,
                    noiseSpread      = properties.NoiseSpread,
                    healthyColor     = healthyColor,
                    dryColor         = dryColor,
                    renderMode       = useGrassShader ? DetailRenderMode.Grass : DetailRenderMode.GrassBillboard,
                    usePrototypeMesh = useGrassShader
                });
                GrassDetails = ++index;

                detailPrototypes.Add(new DetailPrototype()
                {
                    minWidth         = properties.GrassWidth.Min,
                    maxWidth         = properties.GrassWidth.Max,
                    noiseSpread      = properties.NoiseSpread,
                    healthyColor     = healthyColor,
                    dryColor         = dryColor,
                    renderMode       = useGrassShader ? DetailRenderMode.Grass : DetailRenderMode.GrassBillboard,
                    usePrototypeMesh = useGrassShader
                });
                GrassAccents = ++index;
            }

            if (RealGrass.Instance.WaterPlants)
            {
                // Near-water plants settings
                // Here we use the Grass shader which support meshes, and textures with transparency.
                // This allow us to have more realistic plants which still bend in the wind.
                var waterPlantsNear = new DetailPrototype()
                {
                    usePrototypeMesh = true,
                    noiseSpread      = properties.NoiseSpreadPlants,
                    healthyColor     = healthyColor,
                    dryColor         = dryColor,
                    renderMode       = DetailRenderMode.Grass
                };
                detailPrototypes.Add(waterPlantsNear);
                WaterPlants = ++index;
            }

            if (RealGrass.Instance.TerrainStones)
            {
                detailPrototypes.Add(new DetailPrototype()
                {
                    minWidth         = 0.4f,
                    maxWidth         = 1,
                    minHeight        = 0.25f,
                    maxHeight        = 1.5f,
                    usePrototypeMesh = true,
                    noiseSpread      = 1,
                    renderMode       = DetailRenderMode.VertexLit
                });
                Rocks = ++index;
            }

            if (RealGrass.Instance.Flowers)
            {
                var flowerPrototypes = new DetailPrototype()
                {
                    usePrototypeMesh = true,
                    noiseSpread      = 0.4f,
                    healthyColor     = healthyColor,
                    dryColor         = healthyColor,
                    renderMode       = DetailRenderMode.Grass
                };
                detailPrototypes.Add(flowerPrototypes);
                Flowers = ++index;
            }

            this.detailPrototypes = detailPrototypes.ToArray();
        }
        /// <summary>
        /// Initialize detail protoypes.
        /// </summary>
        public DetailPrototypesManager(PrototypesProperties properties)
        {
            Color healthyColor = new Color(0.70f, 0.70f, 0.70f);
            Color dryColor     = new Color(0.40f, 0.40f, 0.40f);

            this.textureOverride = properties.TextureOverride;

            // Create a holder for our grass and plants
            List <DetailPrototype> detailPrototypes = new List <DetailPrototype>();
            int index = 0;

            // Grass settings
            grassHeight    = properties.GrassHeight;
            grassColors    = properties.GrassColors;
            useGrassShader = properties.UseGrassShader;

            // We use GrassBillboard or Grass rendermode
            var grassPrototypes = new DetailPrototype()
            {
                minWidth         = properties.GrassWidth.Min,
                maxWidth         = properties.GrassWidth.Max,
                noiseSpread      = properties.NoiseSpread,
                renderMode       = useGrassShader ? DetailRenderMode.Grass : DetailRenderMode.GrassBillboard,
                usePrototypeMesh = useGrassShader
            };

            detailPrototypes.Add(grassPrototypes);
            Grass = index;

            if (RealGrass.Instance.RealisticGrass)
            {
                detailPrototypes.Add(new DetailPrototype()
                {
                    minWidth         = properties.GrassWidth.Min,
                    maxWidth         = properties.GrassWidth.Max,
                    noiseSpread      = properties.NoiseSpread,
                    healthyColor     = healthyColor,
                    dryColor         = dryColor,
                    renderMode       = useGrassShader ? DetailRenderMode.Grass : DetailRenderMode.GrassBillboard,
                    usePrototypeMesh = useGrassShader
                });
                GrassDetails = ++index;

                detailPrototypes.Add(new DetailPrototype()
                {
                    minWidth         = properties.GrassWidth.Min,
                    maxWidth         = properties.GrassWidth.Max,
                    noiseSpread      = properties.NoiseSpread,
                    healthyColor     = healthyColor,
                    dryColor         = dryColor,
                    renderMode       = useGrassShader ? DetailRenderMode.Grass : DetailRenderMode.GrassBillboard,
                    usePrototypeMesh = useGrassShader
                });
                GrassAccents = ++index;
            }

            if (RealGrass.Instance.WaterPlants)
            {
                // Near-water plants settings
                // Here we use the Grass shader which support meshes, and textures with transparency.
                // This allow us to have more realistic plants which still bend in the wind.
                var waterPlantsNear = new DetailPrototype()
                {
                    usePrototypeMesh = true,
                    noiseSpread      = properties.NoiseSpreadPlants,
                    healthyColor     = healthyColor,
                    dryColor         = dryColor,
                    renderMode       = DetailRenderMode.Grass
                };
                detailPrototypes.Add(waterPlantsNear);
                WaterPlants = ++index;

                // In-water plants settings
                // We use Grass as above
                var waterPlantsInside = new DetailPrototype()
                {
                    usePrototypeMesh = true,
                    noiseSpread      = properties.NoiseSpreadPlants,
                    healthyColor     = healthyColor,
                    dryColor         = dryColor,
                    renderMode       = DetailRenderMode.Grass
                };
                detailPrototypes.Add(waterPlantsInside);
                WaterPlantsAlt = ++index;
            }

            if (RealGrass.Instance.TerrainStones)
            {
                // Little stones
                // For stones we use VertexLit as we are placing 3d static models.
                var stonesPrototypes = new DetailPrototype()
                {
                    usePrototypeMesh = true,
                    noiseSpread      = 0.4f,
                    healthyColor     = healthyColor,
                    dryColor         = dryColor,
                    renderMode       = DetailRenderMode.VertexLit,
                    prototype        = LoadGameObject(stone)
                };
                detailPrototypes.Add(stonesPrototypes);
                Stones = ++index;

                var rocksPrototypes = new DetailPrototype()
                {
                    usePrototypeMesh = true,
                    noiseSpread      = 0.4f,
                    healthyColor     = healthyColor,
                    dryColor         = dryColor,
                    renderMode       = DetailRenderMode.VertexLit,
                };
                detailPrototypes.Add(rocksPrototypes);
                Rocks = ++index;
            }

            if (RealGrass.Instance.Flowers)
            {
                // Medium-sized vegetation
                var bushesPrototypes = new DetailPrototype()
                {
                    usePrototypeMesh = true,
                    noiseSpread      = 0.4f,
                    healthyColor     = healthyColor,
                    dryColor         = dryColor,
                    renderMode       = DetailRenderMode.Grass,
                };
                detailPrototypes.Add(bushesPrototypes);
                Bushes = ++index;

                // Little flowers
                var flowerPrototypes = new DetailPrototype()
                {
                    usePrototypeMesh = true,
                    noiseSpread      = 0.4f,
                    healthyColor     = healthyColor,
                    dryColor         = healthyColor,
                    renderMode       = DetailRenderMode.Grass,
                };
                detailPrototypes.Add(flowerPrototypes);
                Flowers = ++index;
            }

            this.detailPrototypes = detailPrototypes.ToArray();
        }