Exemple #1
0
  private void setFog() {

    gl.glEnable(GL2.GL_FOG);
    gl.glFogf(GL2.GL_FOG_START, 5.0f);
    gl.glFogf(GL2.GL_FOG_END, 50.0f);
    gl.glFogfv(GL2.GL_FOG_COLOR, new float[] {0.8f, 0.8f, 0.9f, 1.0f}, 0);
    gl.glFogi(GL2.GL_FOG_MODE, GL.GL_LINEAR);
  }
 public void configureGL(GL2 gl) {
   gl.glEnable(GL2.GL_FOG);
   gl.glFogi(GL2.GL_FOG_MODE, GL2.GL_LINEAR);
   gl.glFogf(GL2.GL_FOG_DENSITY, 0.25f);
   gl.glFogf(GL2.GL_FOG_START, Math.max(getNearClippingPlane(), fadeOut * 1.0f));
   gl.glFogf(GL2.GL_FOG_END, Math.max(1.1f, fadeOut * 1.1f * getSpawnDistance()));
   gl.glMatrixMode(GL2.GL_PROJECTION);
   gl.glLoadIdentity();
   gl.glFrustumf(-1, 1, -man.vheight(), man.vheight(), getNearClippingPlane(), 128.0f);
   gl.glScalef(2.0f, 2.0f, 1);
   gl.glTranslatef(-0.5f, -man.vheight() / 2.0f, 0);
   gl.glMatrixMode(GL2.GL_MODELVIEW);
   gl.glLoadIdentity();
 }
Exemple #3
0
 @Override
 public void doRender(DrawContext dc) {
   Position eyePos = dc.getView().getEyePosition();
   if (eyePos == null) return;
   // View altitude
   float alt = (float) eyePos.getElevation();
   alt = alt < 100 ? 100 : alt; // Clamp altitudes below 100m
   // Start based on view altitude
   float start = alt * this.nearFactor;
   // End based on distance to horizon
   float end = (float) (dc.getView().getHorizonDistance() * this.farFactor);
   // Set GL fog
   GL2 gl = dc.getGL().getGL2();
   gl.glFogfv(GL2.GL_FOG_COLOR, fogColor, 0); // Set fog color
   gl.glFogi(GL2.GL_FOG_MODE, GL2.GL_LINEAR); // Set fog mode
   gl.glFogf(GL2.GL_FOG_START, start); // Set fog start distance
   gl.glFogf(GL2.GL_FOG_END, end); // Set fog end distance
   gl.glHint(GL2.GL_FOG_HINT, GL2.GL_DONT_CARE); // Set fog hint
   gl.glEnable(GL2.GL_FOG); // Enable fog
 }
  /*
   * Initialize fog
   */
  public void init(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();
    glu = new GLU();
    //
    float fogColor[] = {0.0f, 0.25f, 0.25f, 1.0f};
    f1 = 1.0f;
    f2 = 5.0f;
    f3 = 10.0f;

    gl.glEnable(GL2.GL_FOG);
    gl.glFogi(GL2.GL_FOG_MODE, GL2.GL_EXP);
    gl.glFogfv(GL2.GL_FOG_COLOR, fogColor, 0);
    gl.glFogf(GL2.GL_FOG_DENSITY, 0.25f);
    gl.glHint(GL2.GL_FOG_HINT, GL.GL_DONT_CARE);
    gl.glFogi(GL2.GL_FOG_COORDINATE_SOURCE, GL2.GL_FOG_COORDINATE);
    gl.glClearColor(0.0f, 0.25f, 0.25f, 1.0f); /* fog color */
  }