Exemplo n.º 1
0
  public void renderBox(GL gl) {
    gl.glDisable(GL_TEXTURE_2D);
    int c1 = Math.abs(this.hashCode()) % 256;
    int c2 = Math.abs(getImage().hashCode()) % 256;
    gl.glColor4f(c1 / 256f, c2 / 256f, ((c1 + c2) * 34) % 256 / 256f, 0.3f);
    gl.glPushMatrix();
    gl.glTranslatef(bounds.getLeft(), bounds.getTop(), minHeight);
    gl.glScalef(bounds.getWidth(), bounds.getHeight(), maxHeight - minHeight);
    gl.glBegin(GL_QUADS);
    gl.glVertex3f(0, 0, 0);
    gl.glVertex3f(0, 1, 0);
    gl.glVertex3f(1, 1, 0);
    gl.glVertex3f(1, 0, 0);

    gl.glVertex3f(0, 0, 1);
    gl.glVertex3f(0, 1, 1);
    gl.glVertex3f(1, 1, 1);
    gl.glVertex3f(1, 0, 1);
    gl.glEnd();
    gl.glColor4f(1, 1, 0, 0.2f);
    gl.glBegin(GL_QUAD_STRIP);
    gl.glVertex3f(0, 0, 0);
    gl.glVertex3f(0, 0, 1);
    gl.glVertex3f(0, 1, 0);
    gl.glVertex3f(0, 1, 1);
    gl.glVertex3f(1, 1, 0);
    gl.glVertex3f(1, 1, 1);
    gl.glVertex3f(1, 0, 0);
    gl.glVertex3f(1, 0, 1);
    gl.glVertex3f(0, 0, 0);
    gl.glVertex3f(0, 0, 1);
    gl.glEnd();
    gl.glPopMatrix();
  }
Exemplo n.º 2
0
  private void renderPin(GL gl, Coordinates position, float[] color, float size) {
    float height = heightmap.getHeight(projection.getGeoCoordinates(position));
    gl.glPushMatrix();
    double[] model = new double[16];
    gl.glGetDoublev(GL_MODELVIEW_MATRIX, model, 0);
    double zoomH =
        0.1 / Math.sqrt((model[0] * model[0]) + (model[1] * model[1]) + (model[2] * model[2]));
    double zoomZ =
        0.1 / Math.sqrt((model[8] * model[8]) + (model[9] * model[9]) + (model[10] * model[10]));
    gl.glTranslatef(position.getLongitude(), position.getLatitude(), height);
    gl.glScaled(zoomH * size, zoomH * size, zoomZ * size);
    gl.glDisable(GL_TEXTURE_2D);

    gl.glRotatef(20, 0.3f, 1, 0);

    GLU glu = new GLU();
    GLUquadric quadric = glu.gluNewQuadric();
    // glu.gluQuadricNormals(quadric, GLU.GLU_FLAT);
    gl.glColor3f(0.5f, 0.5f, 0.5f);
    gl.glEnable(GL_LIGHTING);
    glu.gluCylinder(quadric, 0.03, 0.03, 0.6f, 5, 1);
    gl.glTranslatef(0, 0, 0.6f);

    gl.glColor3f(color[0], color[1], color[2]);
    gl.glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
    glu.gluSphere(quadric, 0.12, 8, 8);
    // glu.gluCylinder(quadric, 0.2, 0.1, 0.5, 8, 1);
    gl.glDisable(GL_LIGHTING);
    glu.gluDeleteQuadric(quadric);
    gl.glPopMatrix();
  }
Exemplo n.º 3
0
 private float getShade(int x, int y, float stepSize) {
   float height = heights[x][y];
   float min = height, max = height;
   for (int i = -1; i < 2; i++) {
     for (int k = -1; k < 2; k++) {
       height = heights[x + HEIGHT_BORDER + i][y + HEIGHT_BORDER + k];
       min = Math.min(min, height);
       max = Math.max(max, height);
     }
   }
   return 1 - MathUtil.clip(SLOPE_SHADE_FACTOR * (max - min) / stepSize, 0, MAX_SLOPE_SHADE_VALUE);
 }
Exemplo n.º 4
0
 /**
  * Creates the random noise texture that will be used as detail texture on the tiles.
  *
  * @param gl
  */
 private static void createGrainTexture(GL gl) {
   BufferedImage grainImage =
       new BufferedImage(GRAIN_RESOLUTION, GRAIN_RESOLUTION, BufferedImage.TYPE_INT_RGB);
   for (int x = 0; x < GRAIN_RESOLUTION; x++) {
     for (int y = 0; y < GRAIN_RESOLUTION; y++) {
       float random = (float) (Math.random() * GRAIN_INTENSITY) + (1 - GRAIN_INTENSITY);
       grainImage.setRGB(x, y, (new Color(random, random, random)).getRGB());
     }
   }
   grainTextureID = createTexture(gl, grainImage, true);
 }