Skip to content

Commit

Permalink
feat: weather sun size
Browse files Browse the repository at this point in the history
  • Loading branch information
vinceh121 committed Jan 14, 2024
1 parent b46c05f commit c03fe21
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 10 deletions.
10 changes: 10 additions & 0 deletions android/assets/story/singleplayer/chapter00/part01/skyIntro.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
exports.skyIntro = {
"sunSize": {
"0.75": 0.0,
"0.875": 1.0,
"0.0": 1.0,
"0.125": 1.0,
"0.25": 1.0,
"0.375": 1.0,
"0.5": 1.0,
"0.625": 1.0
},
"sunShineColor": {
"0.75": {
"r": 0.0,
Expand Down
14 changes: 10 additions & 4 deletions core/src/me/vinceh121/wanderer/glx/SkyProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class SkyProperties {
private final NavigableMap<Float, Color> sunShineColor = new TreeMap<>();
private final NavigableMap<Float, Color> starsColor = new TreeMap<>();
private final NavigableMap<Float, Color> galaxyColor = new TreeMap<>();
private final NavigableMap<Float, Float> sunSize = new TreeMap<>();

public NavigableMap<Float, Color> getSunColor() {
return sunColor;
Expand Down Expand Up @@ -57,11 +58,16 @@ public NavigableMap<Float, Color> getGalaxyColor() {
return galaxyColor;
}

public NavigableMap<Float, Float> getSunSize() {
return sunSize;
}

@Override
public String toString() {
return "SkyProperties [sunColor=" + sunColor + ", sunLightColor=" + sunLightColor + ", ambLightColor="
+ ambLightColor + ", skyTopColor=" + skyTopColor + ", skyMiddleColor=" + skyMiddleColor
+ ", skyBottomColor=" + skyBottomColor + ", sunShineColor=" + sunShineColor + ", starsColor="
+ starsColor + ", galaxyColor=" + galaxyColor + "]";
return "SkyProperties [sunColor=" + sunColor + ", sunLightColor=" + sunLightColor + ", moonLightColor="
+ moonLightColor + ", ambLightColor=" + ambLightColor + ", skyTopColor=" + skyTopColor
+ ", skyMiddleColor=" + skyMiddleColor + ", skyBottomColor=" + skyBottomColor + ", sunShineColor="
+ sunShineColor + ", starsColor=" + starsColor + ", galaxyColor=" + galaxyColor + ", sunSize=" + sunSize
+ "]";
}
}
6 changes: 5 additions & 1 deletion core/src/me/vinceh121/wanderer/glx/SkyboxRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ public void update(final float time) {
((ColorAttribute) this.stars.materials.get(0).get(ColorAttribute.Diffuse)).color
.set(this.interpolatedColor(time, this.skyProperties.getStarsColor()));

this.move(this.sun, MathUtils.PI * 0.65f, time * MathUtils.PI2, 0.6f, 0);
this.move(this.sun,
MathUtils.PI * 0.65f,
time * MathUtils.PI2,
0.6f * this.interpolatedFloat(time, this.skyProperties.getSunSize()),
0);
((ColorAttribute) this.sun.materials.get(0).get(ColorAttribute.Diffuse)).color
.set(this.interpolatedColor(time, this.skyProperties.getSunColor()));
MathUtilsW.preciseSetFromSpherical(this.sunDir, MathUtils.PI * 0.65f, time * MathUtils.PI2);
Expand Down
30 changes: 25 additions & 5 deletions tools/src/me/vinceh121/wanderer/tools/WeatherCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public class WeatherCommand implements Callable<Integer> {
entry("galaxy_diff", new ConversionEntry("galaxyColor")),
entry("licht1_color", new ConversionEntry("sunLightColor")),
entry("licht2_color", new ConversionEntry("moonLightColor")),
entry("sun2_em", new ConversionEntry("sunShineColor").setAlphaFromScale("sun2_s")));
entry("sun2_em", new ConversionEntry("sunShineColor").setAlphaFromScale("sun2_s")),
entry("sun1_s", new ConversionEntry("sunSize").setNormalize(50)));

@Spec
private CommandSpec spec;
Expand Down Expand Up @@ -172,10 +173,15 @@ private ObjectNode buildSkyProp(File input, Map<String, NOBClazz> model) throws
} else if (cmd.equals("setkey2f")) {
keyFrame = MAPPER.createArrayNode().add((float) arguments[2]).add((float) arguments[3]);
} else if (cmd.equals("setkey3f")) {
keyFrame = MAPPER.createArrayNode()
.add((float) arguments[2])
.add((float) arguments[3])
.add((float) arguments[4]);
if (entry.isNormalize()) {
keyFrame =
FloatNode.valueOf(MathUtils.norm(0, entry.getNormalizeMax(), (float) arguments[2]));
} else {
keyFrame = MAPPER.createArrayNode()
.add((float) arguments[2])
.add((float) arguments[3])
.add((float) arguments[4]);
}
} else {
throw new UnsupportedOperationException(cmd);
}
Expand Down Expand Up @@ -341,6 +347,7 @@ public static Color average(Collection<Color> colors) {
private static class ConversionEntry {
private final String name;
private String alphaFromScale;
private Float normalizeMax;

public ConversionEntry(String name) {
this.name = name;
Expand All @@ -359,6 +366,19 @@ public ConversionEntry setAlphaFromScale(String alphaFromScale) {
return this;
}

public boolean isNormalize() {
return normalizeMax != null;
}

public Float getNormalizeMax() {
return normalizeMax;
}

public ConversionEntry setNormalize(float max) {
this.normalizeMax = max;
return this;
}

@Override
public String toString() {
return this.getName();
Expand Down

0 comments on commit c03fe21

Please sign in to comment.