예제 #1
0
 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();
 }
예제 #2
0
  @Override
  public void draw(final GL2 gl, final boolean picking) {
    JOGLRenderer renderer = drawer.getRenderer();
    gl.glColor3d(1.0, 1.0, 1.0);
    if (picking) {
      if (renderer.colorPicking) {
        gl.glDisable(GL.GL_DITHER);
        gl.glDisable(GLLightingFunc.GL_LIGHTING);
        gl.glDisable(GL.GL_TEXTURE);

        int viewport[] = new int[4];
        gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);

        FloatBuffer pixels = FloatBuffer.allocate(4);
        gl.glReadPixels(
            renderer.camera.getLastMousePressedPosition().x,
            viewport[3] - renderer.camera.getLastMousePressedPosition().y,
            1,
            1,
            GL.GL_RGBA,
            GL.GL_FLOAT,
            pixels);

        gl.glEnable(GL.GL_DITHER);
        gl.glEnable(GLLightingFunc.GL_LIGHTING);
        gl.glEnable(GL.GL_TEXTURE);

        // Color index = new Color(pixels.get(0), pixels.get(1), pixels.get(2));
        // System.out.println("color picked " + index.toString());
      } else {
        gl.glPushMatrix();
        gl.glInitNames();
        gl.glPushName(0);
        double alpha = 0d;
        int size = objects.size();
        double delta = size == 0 ? 0 : 1d / size;
        for (final List<T> list : objects) {
          alpha = alpha + delta;
          for (T object : list) {
            if (isFading) {
              double originalAlpha = object.getAlpha();
              object.setAlpha(originalAlpha * alpha);
              object.draw(gl, drawer, picking);
              object.setAlpha(originalAlpha);
            } else {
              object.draw(gl, drawer, picking);
            }
          }
        }

        gl.glPopName();
        gl.glPopMatrix();
      }
    } else if (drawAsList) {
      Integer index = openGLListIndex;
      if (index == null) {

        index = gl.glGenLists(1);
        gl.glNewList(index, GL2.GL_COMPILE);
        double alpha = 0d;
        int size = objects.size();
        double delta = size == 0 ? 0 : 1d / size;
        for (final List<T> list : objects) {
          alpha = alpha + delta;
          for (T object : list) {
            if (isFading) {
              double originalAlpha = object.getAlpha();
              object.setAlpha(originalAlpha * alpha);
              object.draw(gl, drawer, picking);
              object.setAlpha(originalAlpha);
            } else {
              object.draw(gl, drawer, picking);
            }
          }
        }
        gl.glEndList();
      }
      gl.glCallList(index);
      openGLListIndex = index;
    } else if (drawAsVBO) {
      if (vah == null) {
        GLU glu = renderer.getGlu();
        vah = new VertexArrayHandler(gl, glu, renderer);
        vah.buildVertexArray(getObjects());
      } else {
        // vah.loadCollada(null);
      }

    } else {
      for (final T object : getObjects()) {
        object.draw(gl, drawer, picking);
      }
    }
  }