diff --git a/src/main/java/com/dfsek/noise/swing/NoisePanel.java b/src/main/java/com/dfsek/noise/swing/NoisePanel.java index 0bd2913..59cbd90 100644 --- a/src/main/java/com/dfsek/noise/swing/NoisePanel.java +++ b/src/main/java/com/dfsek/noise/swing/NoisePanel.java @@ -208,11 +208,14 @@ private boolean[][][] getNoiseVals3d(long seed) { double originZ = this.settingsPanel.getOriginZ(); int sampleRes = this.settingsPanel.getVoxelResolution(); - boolean[][][] noiseVals = new boolean[sampleRes][sampleRes][sampleRes]; + int sampleYMin = this.settingsPanel.getVoxelBottomY(); + int sampleYMax = this.settingsPanel.getVoxelTopY(); + + boolean[][][] noiseVals = new boolean[sampleRes][sampleYMax - sampleYMin][sampleRes]; for (int x = 0; x < noiseVals.length; x++) { for (int y = 0; y < noiseVals[x].length; y++) { for(int z = 0; z < (noiseVals[x][y]).length; z++) { - double n = noiseSeeded.noise(seed, x + originX, y, z + originZ); + double n = noiseSeeded.noise(seed, x + originX, y + sampleYMin, z + originZ); noiseVals[x][y][z] = n > 0; } } diff --git a/src/main/java/com/dfsek/noise/swing/NoiseSettingsPanel.java b/src/main/java/com/dfsek/noise/swing/NoiseSettingsPanel.java index 41eb7b6..630eaef 100644 --- a/src/main/java/com/dfsek/noise/swing/NoiseSettingsPanel.java +++ b/src/main/java/com/dfsek/noise/swing/NoiseSettingsPanel.java @@ -17,6 +17,8 @@ public class NoiseSettingsPanel extends JPanel { // Voxel preview settings private final JSpinner voxelResolution = new JSpinner(new SpinnerNumberModel(128, 0, Integer.MAX_VALUE, 1)); + private final JSpinner voxelBottomY = new JSpinner(new SpinnerNumberModel(-64, Integer.MIN_VALUE, Integer.MAX_VALUE, 1)); + private final JSpinner voxelTopY = new JSpinner(new SpinnerNumberModel(319, Integer.MIN_VALUE, Integer.MAX_VALUE, 1)); // Color scale presets private final ColorScale customColorScalePreset = new ColorScale("Custom", false, (float[][]) null); @@ -48,6 +50,11 @@ public NoiseSettingsPanel() { add(new JLabel("Voxel preview resolution: ")); add(voxelResolution); + add(new JLabel("Voxel preview bottom Y: ")); + add(voxelBottomY); + add(new JLabel("Voxel preview top Y: ")); + add(voxelTopY); + add(new JLabel("Color scale preset: ")); colorScalePresets.setSelectedItem(ColorScale.GRAYSCALE_NORMALIZED); add(colorScalePresets); @@ -104,7 +111,7 @@ public void actionPerformed(ActionEvent e) { } }); - SwingUtils.makeCompactGrid(this, 7, 2, 10, 10, 10, 10); + SwingUtils.makeCompactGrid(this, 9, 2, 10, 10, 10, 10); } public int getSeed() { @@ -131,6 +138,14 @@ public int getVoxelResolution() { return ((Number) voxelResolution.getValue()).intValue(); } + public int getVoxelBottomY() { + return ((Number) voxelBottomY.getValue()).intValue(); + } + + public int getVoxelTopY() { + return ((Number) voxelTopY.getValue()).intValue(); + } + public ColorScale getColorScale() { ColorScale selection = (ColorScale) colorScalePresets.getSelectedItem(); if (selection == customColorScalePreset) {