示例#1
0
  public void checkGameInput() {

    if (moveLeft.isPressed()) {
      g_RotationSpeed -= 0.001f;
    }

    if (moveRight.isPressed()) {

      g_RotationSpeed += 0.001f;
    }

    if (modTex.isPressed()) {
      if (modo == GL_REPLACE) {
        modo = GL_MODULATE;
      } else {
        modo = GL_REPLACE;
      }
      // Ajusta o modo de aplicação da textura
      glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, modo);
    }
    if (drawMode.isPressed()) {

      if (g_ViewMode == GL_TRIANGLES) { // We our drawing mode is at triangles
        g_ViewMode = GL_LINE_STRIP; // Go to line stips
      } else {
        g_ViewMode = GL_TRIANGLES; // Go to triangles
      }
    }

    if (fullScreen.isPressed()) {
      setFullScreen(!isFullScreen());
    }

    if (debug.isPressed()) {
      g_bDisplayNodes = !g_bDisplayNodes;
    }
  }
示例#2
0
  @Override
  public void init() throws IOException {
    super.init();

    screen.setTitle("MD2 Loader");

    createGameActions();

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.0f, 800 / 600, 1.0f, 2000.0f);
    glMatrixMode(GL_MODELVIEW);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

    // Here, we turn on a lighting and enable lighting.  We don't need to
    // set anything else for lighting because we will just take the defaults.
    // We also want color, so we turn that on

    // Habilita Z-Buffer
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_LIGHT0); // Turn on a light with defaults set
    glEnable(GL_LIGHTING); // Turn on lighting
    glEnable(GL_COLOR_MATERIAL); // Allow color

    // To make our model render somewhat faster, we do some front back culling.
    // It seems that Quake2 orders their polygons clock-wise.
    // Seleciona o modo de aplicação da textura
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, modo);
    glEnable(GL_CULL_FACE); // Turn culling on
    glCullFace(GL_FRONT);
    glEnable(GL_TEXTURE_2D);
    g_World.load(FILE_NAME);
    // g_LoadMd2.importMD2(g_World, "modelsd2/model8/head.md2", "modelsd2/model8/head.png");
    // g_LoadMd2.importMD2(g_World, "modelsd2/model8/throne.md2", "modelsd2/model8/throne.png");
  }