public override void OnVertexBuildHeight(PQS.VertexBuildData data) { if (limitEffectToRange == true) { if (data.vertHeight > minAltitude + sphere.radius && data.vertHeight < maxAltitude + sphere.radius) { if (data.vertHeight > average + sphere.radius) { data.vertHeight = data.vertHeight / average; } if (data.vertHeight < average + sphere.radius) { data.vertHeight = data.vertHeight * average; } } } if (limitEffectToRange == false) { if (data.vertHeight > average + sphere.radius) { data.vertHeight = data.vertHeight / average; } if (data.vertHeight < average + sphere.radius) { data.vertHeight = data.vertHeight * average; } } }
public override void OnVertexBuildHeight(PQS.VertexBuildData data) { if (data.vertHeight < sphere.radius + rangeEnd && data.vertHeight > sphere.radius + rangeStart) { data.vertHeight += simplex.noise(data.directionFromCenter) * deformity; } }
public override void OnVertexBuildHeight(PQS.VertexBuildData data) { if ((((canyonPlacementSimplex.noise(data.directionFromCenter) + 1) * 0.5 * canyonThreshold) - canyonSize) < 0) { data.vertHeight += ((canyonNoiseMap.GetValue(data.directionFromCenter) * noiseDeformity) * multiplyCanyonBy) + addCanyonDepth; } }
public override void OnVertexBuild(PQS.VertexBuildData data) { float value = (float)((data.vertHeight - sphere.radius - minHeight) / (maxHeight - minHeight)); Color color = new Color(value, value, value, 1f); data.vertColor = color; }
public override void OnVertexBuildHeight(PQS.VertexBuildData data) { if (addHeight) { data.vertHeight += Noise.GetValue(data.directionFromCenter) * deformity; } }
public override void OnVertexBuildHeight(PQS.VertexBuildData data) { double scalar = data.vertHeight - sphere.radius; scalar *= deformationBalance; scalar += sphere.radius; scalar *= tiling; Vector3d position = data.directionFromCenter * scalar; // Now that we have the position, we need to sample the MapSO // thrice, once for each plane. float x = tiledMap.GetPixelFloat(position.y, position.z); float y = tiledMap.GetPixelFloat(position.x, position.z); float z = tiledMap.GetPixelFloat(position.x, position.y); // Next, we need to process the normal (directionFromCenter). var blend = data.directionFromCenter; blend.x = Math.Pow(Math.Abs(blend.x), smoothness); blend.y = Math.Pow(Math.Abs(blend.y), smoothness); blend.z = Math.Pow(Math.Abs(blend.z), smoothness); blend /= (blend.x + blend.y + blend.z); double height = (blend.x * x) + (blend.y * y) + (blend.z * z); if (scaleByRadius) { height *= sphere.radius; } data.vertHeight += deformity * height; }
public override void OnVertexBuild(PQS.VertexBuildData data) { var color = overlay.GetPixelColor(data.u, data.v); //if the alpha is 0, use current color. if the alpha is 1, use new color data.vertColor = Color.Lerp(data.vertColor, color, color.a); }
public override void OnVertexBuildHeight(PQS.VertexBuildData data) { if (data.vertHeight >= maxAltitude + sphere.radius) { data.vertHeight = maxAltitude + sphere.radius; } }
public override void OnVertexBuildHeight(PQS.VertexBuildData vbData) { var hei = Math.Sin(3.14159265358979 * vbData.v); hei = Math.Pow(hei, power); vbData.vertHeight = vbData.vertHeight + hei * offset; }
public override void OnVertexBuildHeight(PQS.VertexBuildData data) { var absoluteNoise = 1 + Noise.GetValue(data.directionFromCenter); //From -1 - 1 to 0 - 2. var deformation = deformity * 0.5; //Scale by 0.5 for the new maxValue of 2. data.vertHeight = (data.vertHeight - deformation) + offset; //Negative by default as valleys are the targeted feature. }
public override void OnVertexBuild(PQS.VertexBuildData data) { if (data.vertHeight < sphere.radius + 5) { data.vertColor = Color.red; } }
public override void OnVertexBuildHeight(PQS.VertexBuildData data) { if (data.vertHeight > (altitude + sphere.radius)) { data.vertHeight = sphere.radius + altitude; } }
public override void OnVertexBuildHeight(PQS.VertexBuildData data) { if (cutoffStartToInfinity && cutoffEndToInfinity) { data.vertHeight = flattenTo + sphere.radius; } if (cutoffStartToInfinity && !cutoffEndToInfinity) { if (data.vertHeight <= cutoffEnd + sphere.radius) { data.vertHeight = flattenTo + sphere.radius; } } if (!cutoffStartToInfinity && cutoffEndToInfinity) { if (data.vertHeight >= cutoffStart + sphere.radius) { data.vertHeight = flattenTo + sphere.radius; } } if (!cutoffStartToInfinity && !cutoffEndToInfinity) { if (data.vertHeight >= cutoffStart + sphere.radius && data.vertHeight <= cutoffEnd + sphere.radius) { data.vertHeight = flattenTo + sphere.radius; } } }
public override void OnVertexBuildHeight(PQS.VertexBuildData data) { offset = data.vertHeight - sphere.radius - altitude; offset *= offset > 0 ? overMult : underMult; data.vertHeight = sphere.radius + altitude + offset; }
public override void OnVertexBuild(PQS.VertexBuildData data) { Color mapCol = map.GetPixelColor(data.u, data.v); float alpha = mapCol.a; Color vertexColor = new Color(alpha, alpha, alpha, alpha); data.vertColor = vertexColor; //Required for STOCK bodies } //Module manager syntax is f*****g difficult, man
public override void OnVertexBuildHeight(PQS.VertexBuildData vbData) { if (vbData.vertHeight < minAlt) { minAlt = vbData.vertHeight; //print("new minAlt "+minAlt); } }
public override void OnVertexBuildHeight(PQS.VertexBuildData data) { var color = overlay.GetPixelColor(data.u, data.v); var height = (double)color.grayscale * Deformity; data.vertHeight += height; }
public override void OnVertexBuildHeight(PQS.VertexBuildData data) { if (useMap) { if (map.GetPixelFloat(data.u, data.v) == cutoff) { //Get active range if (data.vertHeight > finalStart && data.vertHeight < finalEnd) { //Current altitude to altitude ASL var altitude = data.vertHeight - sphere.radius; //Altitude ASL -> position in range var position = altitude / endingAltitude; //To inversely exponential curvepoint var FloatCurve = (Math.Pow(position, 2)) + (-2 * position) + 1; //Adapt strength to position on curve var strengthConv = FloatCurve * (1 / strength); //Get altitude fraction var NewAlt = Math.Pow(altitude, strengthConv); //Finalize data.vertHeight = (altitude / NewAlt) + sphere.radius + offset; //Ninja'd } } } else { //Get active range if (data.vertHeight > finalStart && data.vertHeight < finalEnd) { //Current altitude to altitude ASL var altitude = data.vertHeight - sphere.radius; //Altitude ASL -> position in range var position = altitude / endingAltitude; //To inversely exponential curvepoint var FloatCurve = (Math.Pow(position, 2)) + (-2 * position) + 1; //Adapt strength to position on curve var strengthConv = FloatCurve * (1 / strength); //Get altitude fraction var NewAlt = Math.Pow(altitude, strengthConv); //Finalize data.vertHeight = (altitude / NewAlt) + sphere.radius + offset; //Ninja'd again } } }
public override void OnVertexBuild(PQS.VertexBuildData data) { if (addColor) { var colorFloat = Convert.ToSingle(Noise = new CustomNoise(frequency, lacunarity, seed, octaves, mode, persistence, pass1, pass2, pass3, pass4, pass5, pass6, pass7, pass8, pass9, pass10)); var finalColor = Color.Lerp(colorStart, colorEnd, colorFloat); data.vertColor = Color.Lerp(finalColor, data.vertColor, blend); } }
public override void OnVertexBuild(PQS.VertexBuildData data) { if ((((canyonPlacementSimplex.noise(data.directionFromCenter) + 1) * 0.5 * canyonThreshold) - canyonSize) < 0) { if (addColor) { data.vertColor = Color.Lerp(data.vertColor, canyonColor, colorBlend); } } }
public override void OnVertexBuildHeight(PQS.VertexBuildData data) { if (useEnum) { switch (noiseType) { case NoiseType.billow: noise = new Billow(frequency, lacunarity, persistence, octaves, seed, mode); break; case NoiseType.riggedMultifractal: noise = new RiggedMultifractal(frequency, lacunarity, octaves, seed, mode); break; case NoiseType.perlin: noise = new Perlin(frequency, lacunarity, persistence, octaves, seed, mode); break; case NoiseType.voronoi: noise = new Voronoi(frequency, displacement, seed, enableDistance); break; default: throw new ArgumentNullException("noiseType is undefinable.", nameof(noiseType)); } } if (!useEnum) { //0 = Billow //1 = Rigged //2 = Perlin //3 = Voronoi if (ModMode == 0) { noise = new Billow(frequency, lacunarity, persistence, octaves, seed, mode); } if (ModMode == 1) { noise = new RiggedMultifractal(frequency, lacunarity, octaves, seed, mode); } if (ModMode == 2) { noise = new Perlin(frequency, lacunarity, persistence, octaves, seed, mode); } if (ModMode >= 3) { noise = new Voronoi(frequency, displacement, seed, enableDistance); } } if (noise.GetValue(data.directionFromCenter) > startLimiter && noise.GetValue(data.directionFromCenter) < endLimiter) { data.vertHeight += convDeformity; } }
public override void OnVertexBuildHeight(PQS.VertexBuildData data) { // Get the HeightAlpha, not the Float-Value from the Map MapSO.HeightAlpha ha = heightMap.GetPixelHeightAlpha(data.u, data.v); // Get the height data from the terrain Double height = (ha.height + ha.alpha * (Double)Byte.MaxValue) / (Double)(Byte.MaxValue + 1); // Apply it data.vertHeight += heightMapOffset + heightMapDeformity * height; }
public override void OnVertexBuildHeight(PQS.VertexBuildData data) { // Get the Color, not the Float-Value from the Map Color32 c = heightMap.GetPixelColor32(data.u, data.v); // Get the height data from the terrain Double height = BitConverter.ToUInt16(new [] { c.g, c.a }, 0) / (Double)UInt16.MaxValue; // Apply it data.vertHeight += heightMapOffset + heightMapDeformity * height; }
public override void OnVertexBuildHeight(PQS.VertexBuildData data) { if (data.vertHeight > minHeight && data.vertHeight < maxHeight) { // 7th order polynomial smoothstep. double x = (data.vertHeight - minHeight) / (maxHeight - minHeight); x = Math.Min(Math.Max(0.0, (x - 0.5) * slopeScale + 0.5), 1.0); // No Math.clamp? double y = -20.0 * Math.Pow(x, 7.0) + 70 * Math.Pow(x, 6.0) - 84.0 * Math.Pow(x, 5.0) + 35.0 * Math.Pow(x, 4.0); data.vertHeight = y * (maxHeight - minHeight) + minHeight; } }
public override void OnVertexBuild(PQS.VertexBuildData data) { float height = (float)(data.vertHeight - sphere.radius); var colors = Ramp.Evaluate(height); var color = colors [0]; var noiseColor = colors [1]; double noise = simplex.noise(data.directionFromCenter); float blend = Mathf.Clamp01(Mathf.Abs((float)noise) + BaseColorBias); data.vertColor = Color.Lerp(color, noiseColor, blend); }
/// <summary> /// Uses the PQS System to query the color of the undergound /// </summary> /// <param name="body"></param> /// <param name="lat"></param> /// <param name="lon"></param> /// <returns></returns> public static Color GetSurfaceColorPQS(CelestialBody body, Double lat, Double lon) { // Tell the PQS that our actions are not supposed to end up in the terrain body.pqsController.isBuildingMaps = true; body.pqsController.isFakeBuild = true; // Create the vertex information PQS.VertexBuildData data = new PQS.VertexBuildData { directionFromCenter = body.GetRelSurfaceNVector(lat, lon).normalized, //vertHeight = body.pqsController.radius vertHeight = body.pqsController.GetSurfaceHeight(body.GetRelSurfaceNVector(lat, lon).normalized *body.Radius) }; // Fetch all enabled Mods //PQSMod[] mods = body.GetComponentsInChildren<PQSMod>(true).Where(m => m.modEnabled && m.sphere == body.pqsController).ToArray(); List <PQSMod> modsList = body.GetComponentsInChildren <PQSMod>(true).Where(m => m.modEnabled && m.sphere == body.pqsController).ToList(); modsList.Sort(delegate(PQSMod first, PQSMod second) { return(first.order.CompareTo(second.order)); }); PQSMod[] mods = modsList.ToArray(); // Iterate over them and build the height at this point // This is neccessary for mods that use the terrain height to // color the terrain (like HeightColorMap) foreach (PQSMod mod in mods) { mod.OnVertexBuildHeight(data); } // Iterate over the mods again, this time build the color component foreach (PQSMod mod in mods) { mod.OnVertexBuild(data); } // Reset the PQS body.pqsController.isBuildingMaps = false; body.pqsController.isFakeBuild = false; Color vertColor = data.vertColor; vertColor += new Color(0.01f, 0.01f, 0.02f); vertColor.a = 1; // The terrain color is now stored in data.vertColor. // For getting the height at this point you can use data.vertHeight return(vertColor); }
public static PQS.VertexBuildData getBuildData(CelestialBody body, double lat, double lon) { if (lat > 90 || lat < -90 || lon > 180 || lon < -180) return new PQS.VertexBuildData (); PQS pqs = body.pqsController; Vector3d radialVector = body.GetRelSurfaceNVector (lat, lon); var buildData = new PQS.VertexBuildData (); buildData.directionFromCenter = radialVector.normalized; buildData.vertHeight = pqs.radius; typeof(PQS).InvokeMember ("Mod_OnVertexBuildHeight", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.NonPublic, null, pqs, new object[]{buildData}); typeof(PQS).InvokeMember ("Mod_OnVertexBuild", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.NonPublic, null, pqs, new object[]{buildData}); buildData.vertColor.a = 1.0f; return buildData; }
public override void OnVertexBuildHeight(PQS.VertexBuildData data) { if (addRange) { if (data.vertHeight < maxAlt && data.vertHeight > minAlt) { data.vertHeight += noise.GetValue(data.directionFromCenter) * deformity; } } if (!addRange) { data.vertHeight += noise.GetValue(data.directionFromCenter) * deformity; } }
public override void OnVertexBuildHeight(PQS.VertexBuildData data) { if (ModMode == 4 && effect == 0) { throw new ArgumentException("That's not funny, man.", nameof(effect)); } if (!effectIsPercentage) { if (ModMode == 1) { data.vertHeight = data.vertHeight + effect; } if (ModMode == 2) { data.vertHeight = data.vertHeight - effect; } if (ModMode == 3) { data.vertHeight = data.vertHeight * effect; } if (ModMode == 4) { data.vertHeight = data.vertHeight / effect; } } if (effectIsPercentage) { if (ModMode == 1) { data.vertHeight = data.vertHeight + (data.vertHeight * effectAsPercent); } if (ModMode == 2) { data.vertHeight = data.vertHeight - (data.vertHeight * effectAsPercent); } if (ModMode == 3) { data.vertHeight = data.vertHeight * (data.vertHeight * effectAsPercent); } if (ModMode == 4) { data.vertHeight = data.vertHeight / (data.vertHeight * effectAsPercent); } } }
public override void OnVertexBuildHeight(PQS.VertexBuildData data) { if (addSimplexNoise == true && smoothHeightMap == true) { data.vertHeight = data.vertHeight + (simplex1.noise(data.directionFromCenter) * deformity) + (simplex2.noise(data.directionFromCenter) * smoothDeformity) + offset + (heightDeformity * heightMap.GetPixelFloat(data.u, data.v)); } if (addSimplexNoise == true && smoothHeightMap == false) { data.vertHeight = data.vertHeight + (simplex1.noise(data.directionFromCenter) * deformity) + offset + (heightDeformity * heightMap.GetPixelFloat(data.u, data.v)); } if (addSimplexNoise == false && smoothHeightMap == true) { data.vertHeight = data.vertHeight + (simplex2.noise(data.directionFromCenter) * smoothDeformity) + offset + (heightDeformity * heightMap.GetPixelFloat(data.u, data.v)); } if (addSimplexNoise == false && smoothHeightMap == false) { data.vertHeight = data.vertHeight + offset + (heightDeformity * heightMap.GetPixelFloat(data.u, data.v)); } }
public override void OnVertexBuild(PQS.VertexBuildData data) { maximumAltitude = sphere.radiusMax; Double vHeight = (data.vertHeight - sphere.radiusMin) / sphere.radiusDelta; 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.convertAltStart / maximumAltitude)) / ((lcSelected.convertAltEnd / maximumAltitude) - (lcSelected.convertAltStart / maximumAltitude)))), blend); } else { data.vertColor = data.vertColor; } //enter data for else }