diff --git a/assets/Data/entity/foliage.json b/assets/Data/entity/foliage.json index 3004058b..6eab19a8 100644 --- a/assets/Data/entity/foliage.json +++ b/assets/Data/entity/foliage.json @@ -12,8 +12,9 @@ "growthRate" : 0.001 }, "grassData": { - "baseColor": {"x": 0.05, "y": 0.2, "z": 0.01}, - "tipColor": {"x": 0.25, "y": 0.45, "z": 0} + "baseColor": {"x": 0.25, "y": 0.6, "z": 0.43}, + "tipColor": {"x": 0.17, "y": 0.71, "z": 0.12}, + "maxTipCurve" : 0.27 }, "graphicsTemplate": { "model": { diff --git a/src/main/java/electrosphere/client/terrain/foliage/FoliageModel.java b/src/main/java/electrosphere/client/terrain/foliage/FoliageModel.java index d120fa5f..7f5a3c3b 100644 --- a/src/main/java/electrosphere/client/terrain/foliage/FoliageModel.java +++ b/src/main/java/electrosphere/client/terrain/foliage/FoliageModel.java @@ -218,6 +218,7 @@ public class FoliageModel { scale, placementRandomizer, x, y, z, data.getType(currVoxelPos.x,currVoxelPos.y,currVoxelPos.z), + foliageType, floatBufferView, data ); drawCount = drawCount + numGenerated; @@ -285,10 +286,13 @@ public class FoliageModel { int scale, Random placementRandomizer, int vX, int vY, int vZ, int targetVoxelType, + FoliageType foliageType, FloatBuffer floatBufferView, ChunkData chunkData ){ int rVal = 0; + float maxTipCurve = foliageType.getGrassData().getMaxTipCurve(); + //construct simple grid to place foliage on // Vector3d sample_00 = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(new Vector3d(realPos).add(-SAMPLE_OFFSET,SAMPLE_START_HEIGHT,-SAMPLE_OFFSET), new Vector3d(0,-1,0), RAY_LENGTH); // Vector3d sample_01 = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(new Vector3d(realPos).add(-SAMPLE_OFFSET,SAMPLE_START_HEIGHT, 0), new Vector3d(0,-1,0), RAY_LENGTH); @@ -410,7 +414,7 @@ public class FoliageModel { //convert y to relative to chunk offsetY = offsetY - realPos.y; double rotVar = placementRandomizer.nextDouble() * Math.PI * 2; - double rotVar2 = placementRandomizer.nextDouble(); + double rotVar2 = placementRandomizer.nextDouble() * maxTipCurve; if(floatBufferView.limit() >= floatBufferView.position() + SINGLE_FOLIAGE_DATA_SIZE_BYTES / 4){ floatBufferView.put((float)relativePositionOnGridX + vX); floatBufferView.put((float)offsetY + vY); diff --git a/src/main/java/electrosphere/client/ui/menu/debug/entity/ImGuiEntityFoliageTab.java b/src/main/java/electrosphere/client/ui/menu/debug/entity/ImGuiEntityFoliageTab.java index 52dd5042..2175ff70 100644 --- a/src/main/java/electrosphere/client/ui/menu/debug/entity/ImGuiEntityFoliageTab.java +++ b/src/main/java/electrosphere/client/ui/menu/debug/entity/ImGuiEntityFoliageTab.java @@ -25,6 +25,11 @@ public class ImGuiEntityFoliageTab { */ static float[] grassColorBase = new float[3]; + /** + * Grass Max Tip Curve + */ + static float[] grassMaxTipCurve = new float[1]; + /** * Client scene entity view */ @@ -57,6 +62,10 @@ public class ImGuiEntityFoliageTab { } } + if(ImGui.sliderFloat("Max Tip Curve", grassMaxTipCurve, 0, 1)){ + grassData.setMaxTipCurve(grassMaxTipCurve[0]); + } + if(ImGui.button("Regenerate All Grass")){ Globals.foliageCellManager.evictAll(); } diff --git a/src/main/java/electrosphere/game/data/foliage/type/GrassData.java b/src/main/java/electrosphere/game/data/foliage/type/GrassData.java index e83a99b9..12a3fcab 100644 --- a/src/main/java/electrosphere/game/data/foliage/type/GrassData.java +++ b/src/main/java/electrosphere/game/data/foliage/type/GrassData.java @@ -17,6 +17,11 @@ public class GrassData { */ Vector3f tipColor; + /** + * The maximum curve allowed on the tip + */ + float maxTipCurve; + /** * Gets the base color of the grass * @return The base color @@ -33,6 +38,21 @@ public class GrassData { return tipColor; } + /** + * Gets the maximum curve allowed on the tip + * @return The maximum curve allowed on the tip + */ + public float getMaxTipCurve() { + return maxTipCurve; + } + + /** + * Sets the maximum curve allowed on the tip + * @param maxTipCurve The maximum curve allowed on the tip + */ + public void setMaxTipCurve(float maxTipCurve) { + this.maxTipCurve = maxTipCurve; + } }