protected override void PopulateParameters(LightningBoltParameters p)
        {
            base.PopulateParameters(p);

            p.RandomOverride = RandomOverride;
            float duration   = DurationRange.Random(p.Random);
            float trunkWidth = TrunkWidthRange.Random(p.Random);

            p.Generations            = Generations;
            p.LifeTime               = duration;
            p.ChaosFactor            = ChaosFactor;
            p.ChaosFactorForks       = ChaosFactorForks;
            p.TrunkWidth             = trunkWidth;
            p.Intensity              = Intensity;
            p.GlowIntensity          = GlowIntensity;
            p.GlowWidthMultiplier    = GlowWidthMultiplier;
            p.Forkedness             = Forkedness;
            p.ForkLengthMultiplier   = ForkLengthMultiplier;
            p.ForkLengthVariance     = ForkLengthVariance;
            p.FadePercent            = FadePercent;
            p.FadeInMultiplier       = FadeInMultiplier;
            p.FadeOutMultiplier      = FadeOutMultiplier;
            p.FadeFullyLitMultiplier = FadeFullyLitMultiplier;
            p.GrowthMultiplier       = GrowthMultiplier;
            p.EndWidthMultiplier     = EndWidthMultiplier;
            p.ForkEndWidthMultiplier = ForkEndWidthMultiplier;
            p.DelayRange             = DelayRange;
            p.LightParameters        = LightParameters;
        }
Пример #2
0
        private void ProcessParameters(LightningBoltParameters p, RangeOfFloats delay, LightningBoltDependencies depends)
        {
            Vector3 start, end;

            MinimumDelay   = Mathf.Min(delay.Minimum, MinimumDelay);
            p.delaySeconds = delay.Random(p.Random);

            // apply LOD if specified
            if (depends.LevelOfDetailDistance > Mathf.Epsilon)
            {
                float d;
                if (p.Points.Count > 1)
                {
                    d = Vector3.Distance(depends.CameraPos, p.Points[0]);
                    d = Mathf.Min(Vector3.Distance(depends.CameraPos, p.Points[p.Points.Count - 1]));
                }
                else
                {
                    d = Vector3.Distance(depends.CameraPos, p.Start);
                    d = Mathf.Min(Vector3.Distance(depends.CameraPos, p.End));
                }
                int modifier = Mathf.Min(8, (int)(d / depends.LevelOfDetailDistance));
                p.Generations = Mathf.Max(1, p.Generations - modifier);
                p.GenerationWhereForksStopSubtractor = Mathf.Clamp(p.GenerationWhereForksStopSubtractor - modifier, 0, 8);
            }

            p.generationWhereForksStop = p.Generations - p.GenerationWhereForksStopSubtractor;
            lifeTime               = Mathf.Max(p.LifeTime + p.delaySeconds, lifeTime);
            maxLifeTime            = Mathf.Max(lifeTime, maxLifeTime);
            p.forkednessCalculated = (int)Mathf.Ceil(p.Forkedness * (float)p.Generations);
            if (p.Generations > 0)
            {
                p.Generator = p.Generator ?? LightningGenerator.GeneratorInstance;
                p.Generator.GenerateLightningBolt(this, p, out start, out end);
                p.Start = start;
                p.End   = end;
            }
        }
Пример #3
0
 private void CalculateNextLightningTimestamp(float offset)
 {
     nextLightningTimestamp = (IntervalRange.Minimum == IntervalRange.Maximum ? IntervalRange.Minimum : offset + IntervalRange.Random());
 }