From fd845f0539ee309d3dac8096b9d7cc3fb8722ac8 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 17 Jan 2014 15:45:19 +0100 Subject: Trailing whitespace killer --- src/RaceTrack.java | 60 +++++++++++++++++++++---------------------- src/Robot.java | 16 ++++++------ src/RobotRace.java | 30 +++++++++++----------- src/Terrain.java | 30 +++++++++++----------- src/Tree.java | 74 +++++++++++++++++++++++++++--------------------------- 5 files changed, 105 insertions(+), 105 deletions(-) (limited to 'src') diff --git a/src/RaceTrack.java b/src/RaceTrack.java index d588fbe..aa02518 100644 --- a/src/RaceTrack.java +++ b/src/RaceTrack.java @@ -88,76 +88,76 @@ class RaceTrack extends BetterBase { new Vector( 8, -15, 1), new Vector( 15, -8, 1), }; - + controlPointsLTrack = new Vector[] { /// FAIL // top-right curve to bottom new Vector( -4, 15, 1), - + new Vector( -2.5, 15, 1), new Vector( -1, 15, 1), - + new Vector( -1, 12, 1), - - + + new Vector( -1, -5, 1), - new Vector( -1, -6.5, 1), - new Vector( 0.5, -8, 1), + new Vector( -1, -6.5, 1), + new Vector( 0.5, -8, 1), new Vector( 2, -8, 1), - - + + new Vector( 8, -8, 1), new Vector( 9.5, -8, 1), new Vector( 11, -9.5, 1), new Vector( 11, -11, 1), - + new Vector( 11, -12.5, 1), new Vector( 9.5, -14, 1), new Vector( 8, -14, 1), - - + + new Vector ( -4, -14, 1), new Vector ( -5.5, -14, 1), new Vector ( -7, -12.5, 1), new Vector ( -7, -11, 1), - + new Vector ( -7, 12, 1), new Vector ( -7, 13.5, 1), new Vector ( -5.5, 15, 1), - new Vector ( -4, 15, 1), - + new Vector ( -4, 15, 1), + }; - + controlPointsCTrack = new Vector[] { // CORRECT new Vector( 2, 15, 1), - + new Vector( 6.5, 15, 1), new Vector( 11, 15, 1), - + new Vector( 11, 12, 1), - + new Vector( 11, 9, 1), new Vector( 6.5, 9, 1), - - - new Vector( 2, 9, 1), - + + + new Vector( 2, 9, 1), + new Vector( -10, 9, 1), new Vector( -10, -6, 1), - + new Vector( 2, -6, 1), - + new Vector(6.5, -6, 1), new Vector(11, -6, 1), - + new Vector(11, -9, 1), - + new Vector(11, -12, 1), new Vector(6.5, -12, 1), - + new Vector(2, -12, 1), - + new Vector(-17, -12, 1), new Vector(-17, 15, 1), }; @@ -353,7 +353,7 @@ class RaceTrack extends BetterBase { // Draw track itself // Every 20 segments a distance line is drawn, - // and at the start, a start line is drawn. + // and at the start, a start line is drawn. gl.glBegin(GL_QUADS); glNormal(Vector.Z); gl.glTexCoord2f(i == 1 ? 0 : 0.2f, 0); diff --git a/src/Robot.java b/src/Robot.java index 612ecec..ad1f2f3 100644 --- a/src/Robot.java +++ b/src/Robot.java @@ -121,14 +121,14 @@ class Robot extends BetterBase { race.getTorsoTexture().bind(gl); } drawTorso(); - + // Rotate the head so it looks forward (for texturing) gl.glRotatef(180, 0, 0, 1); if (race.enableTextures) { race.getHeadTexture().bind(gl); } drawHead(); - + // Rotate back so the other robot parts are facing the right direction gl.glRotatef(-180, 0, 0, 1); @@ -146,7 +146,7 @@ class Robot extends BetterBase { // draw left and right arms drawArm(false, walkAnim.getArmAngleLeft()); drawArm(true, walkAnim.getArmAngleRight()); - + // // The following function call exist to make a point clear. Adding // comments for the sake of having comments is silly, pointless and an @@ -208,7 +208,7 @@ class Robot extends BetterBase { gl.glScalef(x, y, z); // Depending on if it needs to be textured, use our own method - // or the glut solid cube. + // or the glut solid cube. if (isTextured && race.enableTextures) { drawCube(); } else { @@ -478,18 +478,18 @@ class Robot extends BetterBase { // Set color and draw head setColor(asStickFigure ? boneColor : Colors.PALE_TURQOISE); - + // Create glu quadric object GLUquadric sphere = glu.gluNewQuadric(); - + // Set glu drawing settings glu.gluQuadricDrawStyle(sphere, glu.GLU_FILL); glu.gluQuadricTexture(sphere, true); glu.gluQuadricNormals(sphere, glu.GLU_SMOOTH); - + // Draw the glu sphere glu.gluSphere(sphere, headRadius, 16, 16); - + // glut.glutSolidSphere(headRadius, 32, 32); // Pop so we are at the origin again diff --git a/src/RobotRace.java b/src/RobotRace.java index 81a9355..40f0146 100644 --- a/src/RobotRace.java +++ b/src/RobotRace.java @@ -23,12 +23,12 @@ import java.util.Random; /** * Handles all of the RobotRace graphics functionality, * which should be extended per the assignment. - * + * * OpenGL functionality: * - Basic commands are called via the gl object; * - Utility commands are called via the glu and * glut objects; - * + * * GlobalState: * The gs object contains the GlobalState as described * in the assignment: @@ -44,7 +44,7 @@ import java.util.Random; * left and right with the 'a' and 'd' keys; * - Other settings are changed via the menus * at the top of the screen. - * + * * Textures: * Place your "track.jpg", "brick.jpg", "head.jpg", * and "torso.jpg" files in the same folder as this @@ -53,7 +53,7 @@ import java.util.Random; * Be aware, these objects are already defined and * cannot be used for other purposes. The texture * objects can be used as follows: - * + * * gl.glColor3f(1f, 1f, 1f); * track.bind(gl); * gl.glBegin(GL_QUADS); @@ -65,8 +65,8 @@ import java.util.Random; * gl.glVertex3d(1, 1, 0); * gl.glTexCoord2d(0, 1); * gl.glVertex3d(0, 1, 0); - * gl.glEnd(); - * + * gl.glEnd(); + * * Note that it is hard or impossible to texture * objects drawn with GLUT. Either define the * primitives of the object yourself (as seen @@ -237,14 +237,14 @@ public class RobotRace extends Base { gl.glEnable(GL_DEPTH_TEST); gl.glDepthFunc(GL_LESS); - // Enable textures. + // Enable textures. gl.glEnable(GL_TEXTURE_2D); gl.glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); gl.glBindTexture(GL_TEXTURE_2D, 0); // initialize lighting effects (lighting bit is not enabled here though) initLighting(); - + // init terrain terrain.createTerrain(); } @@ -580,27 +580,27 @@ public class RobotRace extends Base { // reset color gl.glColor3f(0, 0, 0); } - + public Texture getTorsoTexture() { assert torso != null; return torso; } - + public Texture getHeadTexture() { assert head != null; return head; } - + public Texture getBrickTexture() { assert brick != null; return brick; } - + public Texture getTrackTexture() { assert track != null; return track; } - + /** * Main program execution body, delegates to an instance of the RobotRace * implementation. @@ -691,7 +691,7 @@ public class RobotRace extends Base { }; int i = Arrays.asList(trackNumbers).indexOf(e.getKeyCode()); assert i != -1 : "Track number not found for key"; - System.err.println("Changing to track number " + i); + System.err.println("Changing to track number " + i); robotRace.gs.trackNr = i; robotRace.mainWindow.updateElements(); } @@ -716,7 +716,7 @@ public class RobotRace extends Base { } return enableTextures; } - + /** * If pause toggle is requested, check state and update. Otherwise, adjust * global animation time. 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; } diff --git a/src/Tree.java b/src/Tree.java index a773b9b..43e45c5 100644 --- a/src/Tree.java +++ b/src/Tree.java @@ -18,31 +18,31 @@ public class Tree extends BetterBase { * are set with the values 0 and 1. */ private final int treeVariation; - + /** - * Defines the position where the tree is placed on the terrain. - * + * Defines the position where the tree is placed on the terrain. + * * The position is defined from in both x and y direction as [-20, 20] - * so position transformations are based on the origin. + * so position transformations are based on the origin. */ private Vector treePosition; - + /** - * The display list containing the tree. + * The display list containing the tree. */ private int treeDisplayList; - - private final float treeTrunkHeight; + + private final float treeTrunkHeight; private final float treeTrunkRadius; private final Terrain terrain; /** * Initialize a tree. - * + * * @param terrain * @param position * @param scale - * @param variation + * @param variation */ public Tree(Terrain terrain, Vector position, float scale, int variation) { // Set up variables @@ -50,50 +50,50 @@ public class Tree extends BetterBase { this.treeVariation = variation; this.treeScale = scale; this.treeDisplayList = 0; - + // Set properties of a tree this.treeTrunkHeight = 2.5f; this.treeTrunkRadius = 0.25f; - - + + // Set the height based on the terrains height - this.treePosition = position; + this.treePosition = position; } - public void createTree() { + public void createTree() { // Create display list this.treeDisplayList = gl.glGenLists(1); // Initialize display list gl.glNewList(treeDisplayList, GL2.GL_COMPILE); - + // Push matrix so we can restore the state after drawing gl.glPushMatrix(); - - // Set the position of the tree and the right height - gl.glTranslatef((float) treePosition.x(), (float) treePosition.y(), + + // Set the position of the tree and the right height + gl.glTranslatef((float) treePosition.x(), (float) treePosition.y(), (float) treePosition.z() - 0.2f); - + // Translate so the tree appears on the right place - gl.glTranslatef(-treeTrunkRadius / 2, -treeTrunkRadius / 2, + gl.glTranslatef(-treeTrunkRadius / 2, -treeTrunkRadius / 2, 0); - + // Now draw the trunk drawTrunk(); - + // Translate to trunk height and draw the leaves drawLeaves(); - + // Restore drawing state gl.glPopMatrix(); - + /** End the list, everything in the list can be easily drawed by using - * this display list. This is more efficient then just drawing + * this display list. This is more efficient then just drawing * everything every time. */ gl.glEndList(); } - + /** * Draw this tree, this method will be called from the Terrain class * that will contain all trees in an array. @@ -107,16 +107,16 @@ public class Tree extends BetterBase { setColor(new Color(83, 53, 10)); glut.glutSolidCylinder(treeTrunkRadius, treeTrunkHeight + treeScale, 6, 6); } - + /** - * Draw the leaves of the tree, based on the variation. + * Draw the leaves of the tree, based on the variation. */ private void drawLeaves() { - + float totalHeight = treeScale + treeTrunkHeight; - + if(treeVariation == 0) { - // Draw the christmas tree + // Draw the christmas tree setColor(new Color(20, 51, 6)); gl.glTranslatef(0, 0, totalHeight - 0.5f); glut.glutSolidCone(4f * treeTrunkRadius, totalHeight / 1.2f, 6, 6); @@ -134,12 +134,12 @@ public class Tree extends BetterBase { glut.glutSolidSphere(radius / 1.25f, 6, 6); } } - + public Vector getPosition() { return treePosition; } - - - - + + + + } -- cgit v1.2.1