public void updateSelectedOctant(GL gl, GLU glu, float[] mousePosition, float[] pickRectangle) {
    // Start Picking mode
    int capacity =
        1 * 4 * visibleLeaves.size(); // Each object take in maximium : 4 * name stack depth
    IntBuffer hitsBuffer = BufferUtil.newIntBuffer(capacity);

    gl.glSelectBuffer(hitsBuffer.capacity(), hitsBuffer);
    gl.glRenderMode(GL.GL_SELECT);
    gl.glDisable(GL.GL_CULL_FACE); // Disable flags

    gl.glInitNames();
    gl.glPushName(0);

    gl.glMatrixMode(GL.GL_PROJECTION);
    gl.glPushMatrix();
    gl.glLoadIdentity();

    glu.gluPickMatrix(
        mousePosition[0],
        mousePosition[1],
        pickRectangle[0],
        pickRectangle[1],
        drawable.getViewport());
    gl.glMultMatrixd(drawable.getProjectionMatrix());

    gl.glMatrixMode(GL.GL_MODELVIEW);

    // Draw the nodes' cube int the select buffer
    int hitName = 1;
    for (int i = 0; i < visibleLeaves.size(); i++) {
      Octant node = visibleLeaves.get(i);
      gl.glLoadName(hitName);
      node.displayOctant(gl);
      hitName++;
    }

    // Restoring the original projection matrix
    gl.glMatrixMode(GL.GL_PROJECTION);
    gl.glPopMatrix();
    gl.glMatrixMode(GL.GL_MODELVIEW);
    gl.glFlush();

    // Returning to normal rendering mode
    int nbRecords = gl.glRenderMode(GL.GL_RENDER);
    if (vizController.getVizModel().isCulling()) {
      gl.glEnable(GL.GL_CULL_FACE);
      gl.glCullFace(GL.GL_BACK);
    }

    // Clean previous selection
    selectedLeaves.clear();

    // Get the hits and put the node under selection in the selectionArray
    for (int i = 0; i < nbRecords; i++) {
      int hit = hitsBuffer.get(i * 4 + 3) - 1; // -1 Because of the glPushName(0)

      Octant nodeHit = visibleLeaves.get(hit);
      selectedLeaves.add(nodeHit);
    }
  }
  private void refreshLimits() {

    float minX = Float.POSITIVE_INFINITY;
    float maxX = Float.NEGATIVE_INFINITY;
    float minY = Float.POSITIVE_INFINITY;
    float maxY = Float.NEGATIVE_INFINITY;
    float minZ = Float.POSITIVE_INFINITY;
    float maxZ = Float.NEGATIVE_INFINITY;

    for (Octant o : leaves) {
      float octanSize = o.getSize() / 2f;
      minX = Math.min(minX, o.getPosX() - octanSize);
      maxX = Math.max(maxX, o.getPosX() + octanSize);
      minY = Math.min(minY, o.getPosY() - octanSize);
      maxY = Math.max(maxY, o.getPosY() + octanSize);
      minZ = Math.min(minZ, o.getPosZ() - octanSize);
      maxZ = Math.max(maxZ, o.getPosZ() + octanSize);
    }

    int viewportMinX = Integer.MAX_VALUE;
    int viewportMaxX = Integer.MIN_VALUE;
    int viewportMinY = Integer.MAX_VALUE;
    int viewportMaxY = Integer.MIN_VALUE;
    double[] point;

    point = drawable.myGluProject(minX, minY, minZ); // bottom far left
    viewportMinX = Math.min(viewportMinX, (int) point[0]);
    viewportMinY = Math.min(viewportMinY, (int) point[1]);
    viewportMaxX = Math.max(viewportMaxX, (int) point[0]);
    viewportMaxY = Math.max(viewportMaxY, (int) point[1]);

    point = drawable.myGluProject(minX, minY, maxZ); // bottom near left
    viewportMinX = Math.min(viewportMinX, (int) point[0]);
    viewportMinY = Math.min(viewportMinY, (int) point[1]);
    viewportMaxX = Math.max(viewportMaxX, (int) point[0]);
    viewportMaxY = Math.max(viewportMaxY, (int) point[1]);

    point = drawable.myGluProject(minX, maxY, maxZ); // up near left
    viewportMinX = Math.min(viewportMinX, (int) point[0]);
    viewportMinY = Math.min(viewportMinY, (int) point[1]);
    viewportMaxX = Math.max(viewportMaxX, (int) point[0]);
    viewportMaxY = Math.max(viewportMaxY, (int) point[1]);

    point = drawable.myGluProject(maxX, minY, maxZ); // bottom near right
    viewportMinX = Math.min(viewportMinX, (int) point[0]);
    viewportMinY = Math.min(viewportMinY, (int) point[1]);
    viewportMaxX = Math.max(viewportMaxX, (int) point[0]);
    viewportMaxY = Math.max(viewportMaxY, (int) point[1]);

    point = drawable.myGluProject(maxX, minY, minZ); // bottom far right
    viewportMinX = Math.min(viewportMinX, (int) point[0]);
    viewportMinY = Math.min(viewportMinY, (int) point[1]);
    viewportMaxX = Math.max(viewportMaxX, (int) point[0]);
    viewportMaxY = Math.max(viewportMaxY, (int) point[1]);

    point = drawable.myGluProject(maxX, maxY, minZ); // up far right
    viewportMinX = Math.min(viewportMinX, (int) point[0]);
    viewportMinY = Math.min(viewportMinY, (int) point[1]);
    viewportMaxX = Math.max(viewportMaxX, (int) point[0]);
    viewportMaxY = Math.max(viewportMaxY, (int) point[1]);

    point = drawable.myGluProject(maxX, maxY, maxZ); // up near right
    viewportMinX = Math.min(viewportMinX, (int) point[0]);
    viewportMinY = Math.min(viewportMinY, (int) point[1]);
    viewportMaxX = Math.max(viewportMaxX, (int) point[0]);
    viewportMaxY = Math.max(viewportMaxY, (int) point[1]);

    point = drawable.myGluProject(minX, maxY, minZ); // up far left
    viewportMinX = Math.min(viewportMinX, (int) point[0]);
    viewportMinY = Math.min(viewportMinY, (int) point[1]);
    viewportMaxX = Math.max(viewportMaxX, (int) point[0]);
    viewportMaxY = Math.max(viewportMaxY, (int) point[1]);

    limits.setMinXoctree(minX);
    limits.setMaxXoctree(maxX);
    limits.setMinYoctree(minY);
    limits.setMaxYoctree(maxY);
    limits.setMinZoctree(minZ);
    limits.setMaxZoctree(maxZ);

    limits.setMinXviewport(viewportMinX);
    limits.setMaxXviewport(viewportMaxX);
    limits.setMinYviewport(viewportMinY);
    limits.setMaxYviewport(viewportMaxY);
  }