diff options
Diffstat (limited to 'src/Terrain.java')
-rw-r--r-- | src/Terrain.java | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/Terrain.java b/src/Terrain.java index 54c6d2a..e06b36c 100644 --- a/src/Terrain.java +++ b/src/Terrain.java @@ -41,16 +41,16 @@ public class Terrain extends BetterBase { * The array containing all trees of the terrain. */ private Tree[] terrainTrees; - + /** - * Contains the name of the height map file. + * Contains the name of the height map file. */ private final String heightMapFile; - + private boolean heightMapFileMode; private RaceTrack track; - + /** * Can be used to set up a display list. */ @@ -65,7 +65,7 @@ public class Terrain extends BetterBase { this.heightMapFile = "heightmap.bmp"; this.heightMapFileMode = true; this.track = track; - + // Fill the height map array File f = new File("src/" + heightMapFile); if(f.exists()) { @@ -89,7 +89,7 @@ public class Terrain extends BetterBase { } /** - * Generate the heightmap based on a formula. + * Generate the heightmap based on a formula. */ private void fillHeightMapFormula() { for (int y = 0; y < 41; y++) { @@ -108,7 +108,7 @@ public class Terrain extends BetterBase { */ private float[][] readHeightMapFromFile(String fileName) throws IOException { BufferedImage image = ImageIO.read(getClass().getResource(fileName)); - + float[][] heightArray = new float[41][41]; for (int y = 0; y < 41; y++) { @@ -137,7 +137,7 @@ public class Terrain extends BetterBase { Random r = new Random(); double distance; int x, y; - + // Make sure all trees are moved away from the track do { x = 19 - r.nextInt(39); @@ -145,7 +145,7 @@ public class Terrain extends BetterBase { distance = Math.sqrt(x * x + y * y); } while (distance < 19); - + return new Vector(x, y, heightAt(x + 20, y + 20)); } @@ -170,7 +170,7 @@ public class Terrain extends BetterBase { if (Math.abs(tree.getPosition().y() - y) < marge) { return false; } - + if(x < - 19 || x > 19 || y < - 19 || y > 19) { return false; } @@ -208,7 +208,7 @@ public class Terrain extends BetterBase { // Create the 1D texture int colorTextureID = create1DTexture(gl, textureColors); - // Setting up texture + // Setting up texture gl.glBindTexture(GL_TEXTURE_1D, colorTextureID); // Create all points of the terrain based on the heightAt function @@ -220,7 +220,7 @@ public class Terrain extends BetterBase { int arrayX = x + 20; int arrayY = y + 20; - // Create all vertices + // Create all vertices Vector pointA = new Vector(x, y, heightMap[arrayX][arrayY]); Vector pointB = new Vector(x + 1, y, heightMap[arrayX + 1][arrayY]); Vector pointC = new Vector(x, y + 1, heightMap[arrayX][arrayY + 1]); @@ -285,7 +285,7 @@ public class Terrain extends BetterBase { System.out.println("Terrain created"); } - + /** * Fills the array with new valid trees. */ @@ -380,7 +380,7 @@ public class Terrain extends BetterBase { */ public final float heightAt(int x, int y) { float height; - + if(heightMapFileMode == false) { // Use the formula to return the height height = (float) (0.6f * Math.cos(0.3f * x + 0.2f * y) + 0.4f @@ -389,7 +389,7 @@ public class Terrain extends BetterBase { // Use the values in the height array instead (file mode) height = (float) heightMap[x][y]; } - + return height; } |