Ejemplo n.º 1
0
 public static int prepareSphere(int texId, float size) {
   int list = glGenLists(1);
   glNewList(list, GL_COMPILE);
   glBindTexture(GL_TEXTURE_2D, texId);
   sphere.draw(size, Config.details, Config.details);
   glEndList();
   return list;
 }
Ejemplo n.º 2
0
  public static void renderSphereGeometry() {
    if (displayListSphere == -1) {
      displayListSphere = glGenLists(1);

      Sphere sphere = new Sphere();

      glNewList(displayListSphere, GL11.GL_COMPILE);

      sphere.draw(1, 8, 8);

      glEndList();
    }

    glCallList(displayListSphere);
  }
Ejemplo n.º 3
0
  private void render(Entity e) {
    Vector pos = e.getPosition();
    // System.out.println(e.getId() + ": ( " + pos.getVar(0) + ", " + pos.getVar(1) + " )");
    glLoadIdentity();

    double x = pos.getVar(0);
    double y = (pos.getDimensions() > 1) ? pos.getVar(1) : 0;
    glTranslated(x, y, 100.0f);

    Color c = getColor(e);
    glColor3b((byte) c.getRed(), (byte) c.getGreen(), (byte) c.getBlue());

    Sphere s = new Sphere();
    s.draw((float) e.getRadius(), 20, 16);
  }
Ejemplo n.º 4
0
 /** Applys the Material and renders the Sphere */
 public void render() {
   m.apply();
   s.draw(1, slices, stacks);
 }
Ejemplo n.º 5
0
  protected void render() {

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer

    glLoadIdentity();

    camera.look();

    // Each frame we calculate the new frustum.  In reality you only need to
    // calculate the frustum when we move the camera.
    GameCore.gFrustum.calculateFrustum();

    // Initialize the total node count that is being draw per frame
    Octree.totalNodesDrawn = 0;

    glPushMatrix();
    // Here we draw the octree, starting with the root node and recursing down each node.
    // This time, we pass in the root node and just the original world model.  You could
    // just store the world in the root node and not have to keep the original data around.
    // This is up to you.  I like this way better because it's easy, though it could be
    // more error prone.
    octree.drawOctree(octree, g_World);
    glPopMatrix();

    // Render the cubed nodes to visualize the octree (in wire frame mode)
    if (g_bDisplayNodes) Octree.debug.drawBoundingBox();

    glPushMatrix();
    // If there was a collision, make the Orange ball Red.
    if (octree.isObjectColliding()) {
      glColor3f(1.0f, 0.0f, 0.0f);
    } else {
      glColor3f(1.0f, 0.5f, 0.0f); // Disable Lighting.
    }
    // Move the Ball into place.
    glTranslatef(g_BallEntity.x, g_BallEntity.y, g_BallEntity.z);

    glDisable(GL_LIGHTING);
    // Draw the Ground Intersection Line.
    glBegin(GL_LINES);
    glColor3f(1, 1, 1);
    glVertex3f(g_vGroundISector[0].x, g_vGroundISector[0].y, g_vGroundISector[0].z);
    glVertex3f(g_vGroundISector[1].x, g_vGroundISector[1].y, g_vGroundISector[1].z);
    glEnd();

    // Draw the Forward Intersection Line.
    glBegin(GL_LINES);
    glColor3f(1, 1, 0);
    glVertex3f(
        g_vForwardISector[0].x * 10.0f, g_vForwardISector[0].y, g_vForwardISector[0].z * 10.0f);
    glVertex3f(
        g_vForwardISector[1].x * 10.0f, g_vForwardISector[1].y, g_vForwardISector[1].z * 10.0f);
    glEnd();

    // Re-enable lighting.
    glEnable(GL_LIGHTING);

    // System.out.println("x " + g_BallEntity.x + " y " + g_BallEntity.y);
    // Draw it!
    pObj.draw(g_BallEntity.fRadius, 20, 20);

    glPopMatrix();

    screen.setTitle(
        "Triangles: "
            + Octree.maxTriangles
            + "  -Total Draw: "
            + Octree.totalNodesDrawn
            + "  -Subdivisions: "
            + Octree.maxSubdivisions
            + "  -FPS: "
            + FPSCounter.get()
            + "  -Node Collisions: "
            + Octree.numNodesCollided
            + "  -Object Colliding? "
            + octree.isObjectColliding());
  }