Skip to content

Commit

Permalink
documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Jul 21, 2024
1 parent cac5c6f commit 82f9d2b
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 19 deletions.
Binary file modified assets/maps/light.msav
Binary file not shown.
8 changes: 5 additions & 3 deletions src/sw/content/SWPlanets.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package sw.content;

import arc.graphics.*;
import mindustry.content.*;
import mindustry.game.*;
import mindustry.graphics.*;
import mindustry.graphics.g3d.*;
import mindustry.type.*;
import sw.content.blocks.*;
Expand All @@ -29,8 +29,10 @@ public static void load() {
r.showSpawns = false;
};

iconColor = Color.valueOf("469662");
hasAtmosphere = false;
iconColor = Pal.lancerLaser;
atmosphereColor = Pal.lancerLaser.cpy().mul(0.3f);
atmosphereRadIn = 0f;
atmosphereRadOut = 0.2f;
startSector = 69;

itemWhitelist.addAll(
Expand Down
88 changes: 72 additions & 16 deletions src/sw/maps/HeightPass.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,24 @@ public abstract class HeightPass {
public abstract float height(Vec3 pos, float height);

/**
* A pass for creating craters defined by a sphere.
* offset sets the offset that the crater creates.
* set defines if the offset increments or sets the height of the mesh.
* A pass that affects points inside a sphere.
*/
public static class CraterHeight extends HeightPass {
public static class SphereHeight extends HeightPass {
/**
* Position of the sphere relative to the planet.
*/
public Vec3 pos = new Vec3();
public float radius = 0f, offset = 0f;
/**
* Radius of the sphere.
*/
public float radius = 0f;
/**
* Height offset applied inside the sphere
*/
public float offset = 0f;
/**
* When true, this pass will set the current height to the offset instead of increasing the height by the offset.
*/
public boolean set = false;

@Override
Expand All @@ -27,25 +38,46 @@ public float height(Vec3 pos, float height) {
}
}
/**
* A pass for creating a noisy terrain. That uses simplex Noise.
* offset is a noise position offset.
* heightOffset is the noise result offset.
* A pass that affects points based on noise.
* @see Simplex
*/
public static class NoiseHeight extends HeightPass {
/**
* Offset for the noise sample relative to the planet. Values far away from the origin are reccomended.
*/
public Vec3 offset = new Vec3();
/**
* Noise seed.
*/
public int seed;
public double octaves = 1.0, persistence = 1.0, scale = 1.0;
public float magnitude = 1, heightOffset = 0;
/**
* The amount of octves added to the noise.
*/
public double octaves = 1.0;
/**
* Intensity multiplier for each octave.
*/
public double persistence = 1.0;
/**
* Noise scale.
*/
public double scale = 1.0;
/**
* Noise magnitude.
*/
public float magnitude = 1;
/**
* Value offset applied to the noise result.
*/
public float heightOffset = 0;

@Override
public float height(Vec3 pos, float height) {
pos = new Vec3(pos).add(offset);
return Simplex.noise3d(seed, octaves, persistence, scale, pos.x, pos.y, pos.z) * magnitude + heightOffset + height;
return Simplex.noise3d(seed, octaves, persistence, scale, pos.x + offset.x, pos.y + offset.y, pos.z + offset.z) * magnitude + heightOffset + height;
}
}
/**
* A pass for clamping the height between 2 values.
* A pass that clamps the current point's height between a min and max value.
*/
public static class ClampHeight extends HeightPass {
public float min, max;
Expand All @@ -61,16 +93,40 @@ public float height(Vec3 pos, float height) {
}
}
/**
* uses the angle relative to a certain direction as input to an interp function.
* A pass that affects points based on it's dot product in relation to a direction.
*/
public static class AngleInterpHeight extends HeightPass {
public static class DotHeight extends HeightPass {
/**
* Main direction vector. Is normalized later.
*/
public Vec3 dir = new Vec3();

/**
* Min and max dot result where this pass applies.
*/
public float min = -1f;
public float max = 1f;

/**
* When true, the dot result will be mapped from min to max instead of -1 to 1.
*/
public boolean map = true;

/**
* Interpolation curve applied to the mapped dot result.
*/
public Interp interp = Interp.linear;
/**
* Magnitude applied to the final height offset.
*/
public float magnitude = 1;

@Override
public float height(Vec3 pos, float height) {
return interp.apply(1f - pos.angle(dir)/180f) * magnitude + height;
float dot = dir.nor().dot(pos);
if (dot < min || dot > max) return height;
dot = Mathf.map(dot, map ? min : -1f, map ? max : 1f, 0f, 1f);
return interp.apply(dot) * magnitude + height;
}
}
}

0 comments on commit 82f9d2b

Please sign in to comment.