Esempio n. 1
0
        /// <summary>
        /// Called when the parent sphere builds it's height
        /// </summary>
        public override void OnVertexBuildHeight(VertexBuildData data)
        {
            Single n = (Single)((this.simplex.noise(data.directionFromCenter) + 1) * 0.5);
            Color  c = new Color(n * rBlend, n * gBlend, n * bBlend);

            data.vertColor = Color.Lerp(data.vertColor, c, blend);
        }
        /// <summary>
        /// Called when the parent sphere builds it's height
        /// </summary>
        public override void OnVertexBuildHeight(VertexBuildData data)
        {
            Double h = data.vertHeight - sphere.radiusMin;
            Single t;

            if (h <= this.simplexHeightStart)
            {
                t = 0f;
            }
            else if (h < simplexHeightEnd)
            {
                t = (Single)((h - simplexHeightStart) * (1 / (simplexHeightEnd - simplexHeightStart)));
            }
            else
            {
                t = 1f;
            }
            Double s = simplex.noiseNormalized(data.directionFromCenter) * simplexCurve.Evaluate(t);

            if (s == 0f)
            {
                return;
            }
            Double r = ridgedAdd.GetValue(data.directionFromCenter) - ridgedSub.GetValue(data.directionFromCenter);

            if (r < -1)
            {
                r = -1;
            }
            if (r > 1)
            {
                r = 1;
            }
            data.vertHeight += (r + 1) * 0.5 * deformity * s;
        }
        /// <summary>
        /// Called when the parent sphere builds it's height
        /// </summary>
        public override void OnVertexBuildHeight(VertexBuildData data)
        {
            Double h = data.vertHeight - sphere.radiusMin;
            Single t = 0;

            if (h <= heightStart)
            {
                t = 0f;
            }
            else if (h < heightEnd)
            {
                t = (Single)(h - heightStart) / (heightEnd - heightStart);
            }
            else
            {
                t = 1f;
            }
            Double n = noiseMap.GetValue(data.directionFromCenter);

            if (n < -1)
            {
                n = -1;
            }
            if (n > 1)
            {
                n = 1;
            }
            data.vertHeight += (n + 1) * 0.5 * deformity * curve.Evaluate(t);
        }
Esempio n. 4
0
        /// <summary>
        /// Called when the parent sphere builds it's height
        /// </summary>
        public override void OnVertexBuildHeight(VertexBuildData data)
        {
            Double a = Math.Sin(Math.PI * data.v);

            a = Math.Pow(a, pow);
            data.vertHeight += a * height;
        }
Esempio n. 5
0
        /// <summary>
        /// Call OnVertexBuild in all Mods
        /// </summary>
        /// <param name="data">The data.</param>
        public void OnVertexBuild(VertexBuildData data)
        {
            // Build VertexBuildData
            data.latitude = Math.Asin(data.directionFromCenter.Y);
            if (Double.IsNaN(data.latitude))
            {
                data.latitude = Math.PI / 2;
            }
            data.directionXZ = Vector3.Normalize(new Vector3(data.directionFromCenter.X, 0, data.directionFromCenter.Z));
            if (data.directionXZ.Length() <= 0)
            {
                data.longitude = 0;
            }
            else
            {
                data.longitude = data.directionXZ.Z >= 0 ? Math.Asin(data.directionXZ.X / data.directionXZ.Length()) : Math.PI - Math.Asin(data.directionXZ.X / data.directionXZ.Length());
            }
            data.v = data.latitude / Math.PI + 0.5;
            data.u = data.longitude / Math.PI * 0.5;

            foreach (PQSMod mod in mods)
            {
                mod.OnVertexBuild(data);
            }
        }
 /// <summary>
 /// Called when the parent sphere builds it's height
 /// </summary>
 public override void OnVertexBuildHeight(VertexBuildData data)
 {
     if (data.vertHeight < (oceanRadius + sphere.radius))
     {
         data.vertHeight = (oceanRadius + sphere.radius);
     }
 }
        /// <summary>
        /// Called when the parent sphere builds it's color
        /// </summary>
        public override void OnVertexBuild(VertexBuildData data)
        {
            Single h = (Single)((noiseMap.GetValue(data.directionFromCenter) + 1.0) * 0.5);

            c.r            = h; c.g = h; c.b = h;
            data.vertColor = Color.Lerp(data.vertColor, c, blend);
        }
Esempio n. 8
0
 /// <summary>
 /// Called when the parent sphere builds it's height
 /// </summary>
 public override void OnVertexBuildHeight(VertexBuildData data)
 {
     if (data.vertHeight < oceanRadius)
     {
         data.vertHeight += depthOffset;
     }
 }
Esempio n. 9
0
        /// <summary>
        /// Called when the parent sphere builds it's height
        /// </summary>
        public override void OnVertexBuildHeight(VertexBuildData data)
        {
            Double value = simplex.noiseNormalized(data.directionFromCenter);

            if (value > cutoff)
            {
                data.vertHeight += deformity * ((value - cutoff) * (1 / cutoff));
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Called when the parent sphere builds it's height
        /// </summary>
        public override void OnVertexBuildHeight(VertexBuildData data)
        {
            Single vorH = (Single)voronoi.GetValue(data.directionFromCenter);
            Single spxH = (Single)simplex.noise(data.directionFromCenter);
            Single jtt  = spxH * jitter * jitterCurve.Evaluate(vorH);

            r = vorH + jtt;
            Single h = craterCurve.Evaluate(r);

            data.vertHeight += ((Double)h + jitterHeight * jtt * h) * deformation;
        }
        /// <summary>
        /// Called when the parent sphere builds it's color
        /// </summary>
        public override void OnVertexBuild(VertexBuildData data)
        {
            Color c = new Color
            {
                r = (Single)redSimplex.noiseNormalized(data.directionFromCenter),
                g = (Single)blueSimplex.noiseNormalized(data.directionFromCenter),
                b = (Single)greenSimplex.noiseNormalized(data.directionFromCenter),
                a = (Single)alphaSimplex.noiseNormalized(data.directionFromCenter)
            };

            data.vertColor = Color.Lerp(data.vertColor, c, blend);
        }
Esempio n. 12
0
        /// <summary>
        /// Builds the relative rectangular point of the sphere
        /// </summary>
        public VertexBuildData BuildData(Double x, Double y)
        {
            VertexBuildData data = new VertexBuildData
            {
                directionFromCenter = (Quaternion.CreateFromAxisAngle(Vector3.Up, Math.PI * 2 / x) * Quaternion.CreateFromAxisAngle(Vector3.Right, 90d - Math.PI / y)) * Vector3.Forward,
                vertHeight          = radius
            };

            OnVertexBuildHeight(data);
            OnVertexBuild(data);
            return(data);
        }
Esempio n. 13
0
        /// <summary>
        /// Called when the parent sphere builds it's color
        /// </summary>
        public override void OnVertexBuild(VertexBuildData data)
        {
            Double h = (data.vertHeight - sphere.radius) / atmosphereDepth;

            if (invert)
            {
                data.vertColor.a = (Single)(1.0 - h);
            }
            else
            {
                data.vertColor.a = (Single)h;
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Called when the parent sphere builds it's height
        /// </summary>
        public override void OnVertexBuildHeight(VertexBuildData data)
        {
            Double h = heightMap.GetPixelColor(data.u, data.v).grayscale;

            if (h < coastHeight)
            {
                data.vertHeight += heightMapOffset;
            }
            else
            {
                data.vertHeight += heightMapOffset + h * heightDeformity;
            }
        }
        /// <summary>
        /// Called when the parent sphere builds it's color
        /// </summary>
        public override void OnVertexBuild(VertexBuildData data)
        {
            Double    vHeight = (data.vertHeight - heightMin) / heightDelta;
            Int32     index;
            LandClass lcSelected = SelectLandClassByHeight(vHeight, out index);

            if (lcSelected.lerpToNext)
            {
                data.vertColor = Color.Lerp(data.vertColor,
                                            Color.Lerp(lcSelected.color, landClasses[index + 1].color,
                                                       (Single)((vHeight - lcSelected.altStart) / (lcSelected.altEnd - lcSelected.altStart))), blend);
            }
            else
            {
                data.vertColor = Color.Lerp(data.vertColor, lcSelected.color, blend);
            }
        }
        /// <summary>
        /// Called when the parent sphere builds it's height
        /// </summary>
        public override void OnVertexBuildHeight(VertexBuildData data)
        {
            Double continentalDeformity = 1;
            Double continental2Height   = continentalSmoothing.simplex.noiseNormalized(data.directionFromCenter);

            continental.simplex.persistence = continental.persistance - continentalSmoothing.persistance * continental2Height;
            Double continentialHeight         = continental.simplex.noiseNormalized(data.directionFromCenter);
            Double continentialSharpnessValue = (continentalSharpness.noise.GetValue(data.directionFromCenter) + 1) * 0.5;

            continentialSharpnessValue *= MathHelper.Lerp(continentalSharpness.deformity, continentalSharpness.deformity * terrainRidgeBalance, (continental2Height + continentialSharpnessValue) * 0.5);
            Double continentialSharpnessMapValue = MathHelper.Clamp((continentalSharpnessMap.simplex.noise(data.directionFromCenter) + 1) * 0.5, terrainRidgesMin, terrainRidgesMax);

            continentialSharpnessMapValue = (continentialSharpnessMapValue - terrainRidgesMin) / (terrainRidgesMax - terrainRidgesMin) * continentalSharpnessMap.deformity;
            continentialSharpnessValue    = continentialSharpnessValue + MathHelper.Lerp(0, continentialSharpnessValue, continentialSharpnessMapValue);
            continentialHeight           += continentialSharpnessValue;
            continentalDeformity          = continentalDeformity + continentalSharpness.deformity * continentalSharpnessMap.deformity;
            continentialHeight            = continentialHeight / continentalDeformity;
            Double continentalDelta = (continentialHeight - oceanLevel) / (1 - oceanLevel);
            Double vHeight;

            if (continentialHeight >= oceanLevel)
            {
                continentalRuggedness.simplex.persistence = continentalRuggedness.persistance * continentalDelta;
                Double continentalRHeight = continentalRuggedness.simplex.noiseNormalized(data.directionFromCenter) * continentalDelta * continentalDelta;
                continentialHeight          = continentalDelta * continental.deformity + continentalRHeight * this.continentalRuggedness.deformity;
                continentialHeight         /= (continental.deformity + continentalRuggedness.deformity);
                continentialHeightPreSmooth = continentialHeight;
                continentialHeight          = MathHelper.Hermite(0, terrainShapeStart, 1, terrainShapeEnd, continentialHeight);
                vHeight = continentialHeight;
            }
            else
            {
                if (!oceanSnap)
                {
                    vHeight = continentalDelta * this.oceanDepth - this.oceanStep;
                }
                else
                {
                    vHeight = -oceanStep;
                }
                continentialHeightPreSmooth = vHeight;
            }
            data.vertHeight += Math.Round(vHeight, 5) * deformity;
        }
Esempio n. 17
0
        /// <summary>
        /// Called when the parent sphere builds it's height
        /// </summary>
        public override void OnVertexBuildHeight(VertexBuildData data)
        {
            Double h = (data.vertHeight - sphere.radiusMin) / sphere.radiusDelta;

            if (!(h >= heightStart) || !(h <= heightEnd))
            {
                return;
            }
            h = (h - heightStart) * (1d / (heightEnd - heightStart));
            Double n = noiseMap.GetValue(data.directionFromCenter);

            if (n < -1)
            {
                n = -1;
            }
            if (n > 1)
            {
                n = 1;
            }
            data.vertHeight = data.vertHeight + (n + 1) * 0.5 * deformity * h;
        }
Esempio n. 18
0
        /// <summary>
        /// Called when the parent sphere builds it's height
        /// </summary>
        public override void OnVertexBuildHeight(VertexBuildData data)
        {
            Double h = heightMap.GetPixelColor(data.u, data.v).grayscale;

            if (!(h >= heightStart) || !(h <= heightEnd))
            {
                return;
            }
            h = (h - heightStart) * (1d / (heightEnd - heightStart));
            Double n = noiseMap.GetValue(data.directionFromCenter);

            if (n < -1)
            {
                n = -1;
            }
            if (n > 1)
            {
                n = 1;
            }
            data.vertHeight = data.vertHeight + (n + 1) * 0.5 * deformity * h;
        }
Esempio n. 19
0
        /// <summary>
        /// Called when the parent sphere builds it's height
        /// </summary>
        public override void OnVertexBuildHeight(VertexBuildData data)
        {
            Double angle = Math.Acos(Vector3.Dot(data.directionFromCenter, positionN));

            // Check for outer angle
            if (angle >= oAngle)
            {
                return;
            }

            // Check for inner angle
            if (angle < iAngle)
            {
                data.vertHeight = sphere.radius + flattenTo;
                return;
            }

            // Flatten
            Double delta = (angle - iAngle) / (oAngle - iAngle);

            data.vertHeight = MathHelper.Hermite(sphere.radius + flattenTo, smoothStart, data.vertHeight, smoothEnd, delta);
        }
 /// <summary>
 /// Called when the parent sphere builds it's color
 /// </summary>
 public override void OnVertexBuild(VertexBuildData data)
 {
     if (!buildHeightColors)
     {
         Double    d1         = terrainType.simplex.noiseNormalized(data.directionFromCenter);
         Double    tHeight    = Mathf.Clamp01((Single)((continentialHeightPreSmooth + d1 * terrainType.deformity) * (Single)((data.vertHeight - sphere.radius) / colorDeformity)));
         LandClass lcSelected = SelectLandClassByHeight(tHeight);
         Color     c1         = Color.Lerp(lcSelected.baseColor, lcSelected.colorNoise, (Single)(lcSelected.colorNoiseAmount * lcSelected.colorNoiseMap.simplex.noiseNormalized(data.directionFromCenter)));
         if (lcSelected.lerpToNext)
         {
             LandClass lcLerp = landClasses[landClasses.ToList().IndexOf(lcSelected) + 1];
             Color     c2     = Color.Lerp(lcLerp.baseColor, lcLerp.colorNoise, (Single)(lcLerp.colorNoiseAmount * lcLerp.colorNoiseMap.simplex.noiseNormalized(data.directionFromCenter)));
             c1 = Color.Lerp(c1, c2, (Single)((tHeight - lcSelected.fractalStart) / (lcSelected.fractalEnd - lcSelected.fractalStart)));
         }
         data.vertColor   = c1;
         data.vertColor.a = (Single)continentialHeightPreSmooth;
     }
     else
     {
         data.vertColor.r = data.vertColor.g = data.vertColor.b = (Single)((data.vertHeight - sphere.radius) / colorDeformity);
     }
 }
Esempio n. 21
0
 /// <summary>
 /// Called when the parent sphere builds it's color
 /// </summary>
 public override void OnVertexBuild(VertexBuildData data)
 {
     r = r * rFactor + rOffset;
     data.vertColor = !DebugColorMapping?Color.Lerp(data.vertColor, craterColourRamp.Evaluate(r), (1f - r) *colorOpacity) : Color.Lerp(Color.magenta, data.vertColor, r);
 }
Esempio n. 22
0
 public virtual void OnVertexBuild(VertexBuildData data)
 {
 }
Esempio n. 23
0
 public virtual void OnVertexBuildHeight(VertexBuildData data)
 {
 }
 /// <summary>
 /// Called when the parent sphere builds it's height
 /// </summary>
 public override void OnVertexBuildHeight(VertexBuildData data)
 {
     data.vertHeight += terrainHeightMap.GetValue(data.directionFromCenter * sphere.radius) * noiseDeformity;
 }
Esempio n. 25
0
 /// <summary>
 /// Called when the parent sphere builds it's color
 /// </summary>
 public override void OnVertexBuild(VertexBuildData data)
 {
     data.vertColor = Color.Lerp(data.vertColor, vertexColorMap.GetPixelColor(data.u, data.v), blend);
 }
 /// <summary>
 /// Called when the parent sphere builds it's height
 /// </summary>
 public override void OnVertexBuildHeight(VertexBuildData data)
 {
     data.vertHeight += noiseMap.GetValue(data.directionFromCenter) * deformity;
 }
Esempio n. 27
0
 /// <summary>
 /// Called when the parent sphere builds it's color
 /// </summary>
 public override void OnVertexBuild(VertexBuildData data)
 {
     data.vertColor = color;
 }
 /// <summary>
 /// Called when the parent sphere builds it's height
 /// </summary>
 public override void OnVertexBuildHeight(VertexBuildData data)
 {
     data.vertHeight += simplex.noise(data.directionFromCenter) * deformity;
 }
 /// <summary>
 /// Called when the parent sphere builds it's color
 /// </summary>
 public override void OnVertexBuild(VertexBuildData data)
 {
     data.vertColor = Color.Lerp(data.vertColor, color, blend);
 }
 /// <summary>
 /// Called when the parent sphere builds it's height
 /// </summary>
 public override void OnVertexBuildHeight(VertexBuildData data)
 {
     data.vertHeight += heightMapOffset + heightDeformity * heightMap.GetPixelFloat(data.u, data.v);
 }