Beispiel #1
0
  /**
   * Renders this AABB.
   *
   * <p>
   *
   * @param lineThickness The thickness of the line
   */
  public void render(float lineThickness) {
    CoreRegistry.get(ShaderManager.class).enableDefault();

    glPushMatrix();
    Vector3f cameraPosition = CoreRegistry.get(WorldRenderer.class).getActiveCamera().getPosition();
    glTranslated(
        aabb.getCenter().x - cameraPosition.x,
        -cameraPosition.y,
        aabb.getCenter().z - cameraPosition.z);

    renderLocally(lineThickness);

    glPopMatrix();
  }
Beispiel #2
0
  private void generateDisplayListWire() {
    float offset = 0.001f;

    displayListWire = glGenLists(1);

    glNewList(displayListWire, GL11.GL_COMPILE);
    glColor4f(0.0f, 0.0f, 0.0f, 1.0f);

    Vector3f dimensions = aabb.getExtents();

    // FRONT
    glBegin(GL_LINE_LOOP);
    glVertex3f(-dimensions.x - offset, -dimensions.y - offset, -dimensions.z - offset);
    glVertex3f(+dimensions.x + offset, -dimensions.y - offset, -dimensions.z - offset);
    glVertex3f(+dimensions.x + offset, +dimensions.y + offset, -dimensions.z - offset);
    glVertex3f(-dimensions.x - offset, +dimensions.y + offset, -dimensions.z - offset);
    glEnd();

    // BACK
    glBegin(GL_LINE_LOOP);
    glVertex3f(-dimensions.x - offset, -dimensions.y - offset, +dimensions.z + offset);
    glVertex3f(+dimensions.x + offset, -dimensions.y - offset, +dimensions.z + offset);
    glVertex3f(+dimensions.x + offset, +dimensions.y + offset, +dimensions.z + offset);
    glVertex3f(-dimensions.x - offset, +dimensions.y + offset, +dimensions.z + offset);
    glEnd();

    // TOP
    glBegin(GL_LINE_LOOP);
    glVertex3f(-dimensions.x - offset, -dimensions.y - offset, -dimensions.z - offset);
    glVertex3f(+dimensions.x + offset, -dimensions.y - offset, -dimensions.z - offset);
    glVertex3f(+dimensions.x + offset, -dimensions.y - offset, +dimensions.z + offset);
    glVertex3f(-dimensions.x - offset, -dimensions.y - offset, +dimensions.z + offset);
    glEnd();

    // BOTTOM
    glBegin(GL_LINE_LOOP);
    glVertex3f(-dimensions.x - offset, +dimensions.y + offset, -dimensions.z - offset);
    glVertex3f(+dimensions.x + offset, +dimensions.y + offset, -dimensions.z - offset);
    glVertex3f(+dimensions.x + offset, +dimensions.y + offset, +dimensions.z + offset);
    glVertex3f(-dimensions.x - offset, +dimensions.y + offset, +dimensions.z + offset);
    glEnd();

    // LEFT
    glBegin(GL_LINE_LOOP);
    glVertex3f(-dimensions.x - offset, -dimensions.y - offset, -dimensions.z - offset);
    glVertex3f(-dimensions.x - offset, -dimensions.y - offset, +dimensions.z + offset);
    glVertex3f(-dimensions.x - offset, +dimensions.y + offset, +dimensions.z + offset);
    glVertex3f(-dimensions.x - offset, +dimensions.y + offset, -dimensions.z - offset);
    glEnd();

    // RIGHT
    glBegin(GL_LINE_LOOP);
    glVertex3f(+dimensions.x + offset, -dimensions.y - offset, -dimensions.z - offset);
    glVertex3f(+dimensions.x + offset, -dimensions.y - offset, +dimensions.z + offset);
    glVertex3f(+dimensions.x + offset, +dimensions.y + offset, +dimensions.z + offset);
    glVertex3f(+dimensions.x + offset, +dimensions.y + offset, -dimensions.z - offset);
    glEnd();
    glEndList();
  }
Beispiel #3
0
  public void renderLocally(float lineThickness) {
    CoreRegistry.get(ShaderManager.class).enableDefault();

    if (displayListWire == -1) {
      generateDisplayListWire();
    }

    glPushMatrix();
    glTranslated(0f, aabb.getCenter().y, 0f);

    glLineWidth(lineThickness);
    glCallList(displayListWire);

    glPopMatrix();
  }
Beispiel #4
0
  public void renderSolidLocally() {
    CoreRegistry.get(ShaderManager.class).enableDefault();

    if (displayListSolid == -1) {
      generateDisplayListSolid();
    }
    glEnable(GL_BLEND);
    glPushMatrix();

    glTranslated(0f, aabb.getCenter().y, 0f);
    glScalef(1.5f, 1.5f, 1.5f);

    glCallList(displayListSolid);

    glPopMatrix();
    glDisable(GL_BLEND);
  }
Beispiel #5
0
  private void generateDisplayListSolid() {
    displayListSolid = glGenLists(1);

    glNewList(displayListSolid, GL11.GL_COMPILE);
    glBegin(GL_QUADS);
    glColor4f(solidColor.x, solidColor.y, solidColor.z, solidColor.w);

    Vector3f dimensions = aabb.getExtents();

    GL11.glVertex3f(-dimensions.x, dimensions.y, dimensions.z);
    GL11.glVertex3f(dimensions.x, dimensions.y, dimensions.z);
    GL11.glVertex3f(dimensions.x, dimensions.y, -dimensions.z);
    GL11.glVertex3f(-dimensions.x, dimensions.y, -dimensions.z);

    GL11.glVertex3f(-dimensions.x, -dimensions.y, -dimensions.z);
    GL11.glVertex3f(-dimensions.x, -dimensions.y, dimensions.z);
    GL11.glVertex3f(-dimensions.x, dimensions.y, dimensions.z);
    GL11.glVertex3f(-dimensions.x, dimensions.y, -dimensions.z);

    GL11.glVertex3f(-dimensions.x, -dimensions.y, dimensions.z);
    GL11.glVertex3f(dimensions.x, -dimensions.y, dimensions.z);
    GL11.glVertex3f(dimensions.x, dimensions.y, dimensions.z);
    GL11.glVertex3f(-dimensions.x, dimensions.y, dimensions.z);

    GL11.glVertex3f(dimensions.x, dimensions.y, -dimensions.z);
    GL11.glVertex3f(dimensions.x, dimensions.y, dimensions.z);
    GL11.glVertex3f(dimensions.x, -dimensions.y, dimensions.z);
    GL11.glVertex3f(dimensions.x, -dimensions.y, -dimensions.z);

    GL11.glVertex3f(-dimensions.x, dimensions.y, -dimensions.z);
    GL11.glVertex3f(dimensions.x, dimensions.y, -dimensions.z);
    GL11.glVertex3f(dimensions.x, -dimensions.y, -dimensions.z);
    GL11.glVertex3f(-dimensions.x, -dimensions.y, -dimensions.z);

    GL11.glVertex3f(-dimensions.x, -dimensions.y, -dimensions.z);
    GL11.glVertex3f(dimensions.x, -dimensions.y, -dimensions.z);
    GL11.glVertex3f(dimensions.x, -dimensions.y, dimensions.z);
    GL11.glVertex3f(-dimensions.x, -dimensions.y, dimensions.z);
    glEnd();
    glEndList();
  }
Beispiel #6
0
 public void setAABB(AABB from) {
   if (from != null && !from.equals(this.aabb)) {
     this.aabb = from;
     dispose();
   }
 }