Beispiel #1
0
  public void draw(GL10 gl, Lighting Lights, long delta) {
    zRot += delta / 5.0f;
    gl.glPushMatrix();
    gl.glTranslatef(getXpos(), getYpos(), 0.0f);

    gl.glEnable(GL10.GL_LIGHTING);
    gl.glEnable(GL10.GL_DEPTH_TEST);
    gl.glDepthMask(true);
    gl.glEnable(GL10.GL_NORMALIZE);
    gl.glTranslatef(0.0f, 0.0f, model.getBBoxSize().v[2] / 8f);
    gl.glScalef(0.2f, 0.2f, 0.2f);
    gl.glRotatef(zRot, 0, 0, 1);
    gl.glEnable(GL10.GL_CULL_FACE);
    model.draw(gl, ColourSpecular[diffuse], ColourDiffuse[specular]);
    gl.glDisable(GL10.GL_CULL_FACE);

    gl.glDisable(GL10.GL_BLEND);
    gl.glDisable(GL10.GL_LIGHTING);
    gl.glPopMatrix();
  }
Beispiel #2
0
  public boolean isVisible(Camera cam) {
    Vec v1;
    Vec v2;
    Vec tmp = new Vec(getXpos(), getYpos(), 0.0f);
    int lod_level = 2;
    float d, s;
    int i;
    int LC_LOD = 3;
    float fov = 120;

    boolean retValue;

    v1 = cam._target.sub(cam._cam);
    v1.normalize();

    v2 = cam._cam.sub(tmp);

    d = v2.length();

    for (i = 0; i < LC_LOD && d >= LOD_DIST[lod_level][i]; i++) ;

    if (i >= LC_LOD) {
      retValue = false;
    } else {
      v2 = tmp.sub(cam._cam);
      v2.normalize();

      s = v1.dot(v2);
      d = (float) Math.cos((fov / 2) * 2 * Math.PI / 360.0f);

      if (s < d - (model.getBBoxRadius() * 2.0f)) {
        retValue = false;
      } else {
        retValue = true;
      }
    }

    return retValue;
  }