示例#1
0
  /**
   * OpenGL setup post-drawable creation Will be called upon windowed/full screen switch and the GL
   * instance might have changed, so all must be regenerated.
   */
  @Override
  protected void drawableIntialized() throws Exception {
    gl.glShadeModel(GLLightingFunc.GL_SMOOTH); // enable smooth shading
    gl.glClearDepth(1.0f); // set depth buffer
    gl.glEnable(GL.GL_DEPTH_TEST); // enable depth testing
    gl.glDepthFunc(GL.GL_LEQUAL); // depth testing mode
    gl.glHint(GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); // perspective calculations mode
    gl.glTexGeni(
        GL2.GL_S, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_SPHERE_MAP); // set mode S to sphere mapping
    gl.glTexGeni(
        GL2.GL_T, GL2ES1.GL_TEXTURE_GEN_MODE, GL2.GL_SPHERE_MAP); // set mode T to sphere mapping
    gl.glLineWidth(1.0f); // set line width

    // and reinit all the rest because the GL might have changed
    if (scene == null) {
      scene = new Scene(this);
    }
    scene.init();
  }
示例#2
0
  @Override
  public boolean dispatchKeyEvent(KeyEvent e) {
    if (!super.dispatchKeyEvent(e)) {
      int code = e.getKeyCode();
      float t_g = tickTimer.getTime();

      if (MORE_KEYS) {
        if (code == KeyEvent.VK_F2) { // F2 pressed ?
          scene.getRez().toggle(); // toggle on/off REZ
        } else if (code == KeyEvent.VK_F3) { // F3 pressed ?
          scene.getParticles().toggle(); // toggle on/off particles
        } else if (code == KeyEvent.VK_F4) { // F4 pressed ?
          scene.getGlenz().toggle(); // toggle on/off glenz
        } else if (code == KeyEvent.VK_F5) { // F5 pressed ?
          scene.getLiner().toggle(); // toggle on/off liner
        } else if (code == KeyEvent.VK_F6) { // F6 pressed ?
          scene.getTitle().toggle(); // toggle on/off title
        } else if (code == KeyEvent.VK_F7) { // F7 pressed ?
          scene.getMapping().toggle(); // toggle on/off mapping
          scene.getMapping().setSynchroTime(t_g);
        } else if (code == KeyEvent.VK_SPACE) { // space pressed ?
          scene.getCube().setJumpAngle(0.0f);
          scene.getCube().setJump(0.5f);
          scene.getCube().setSynchroTime(t_g);
          f_n = 0.25f;
          f_v2 = f_n;
          f_t2 = t_g;
        } else if (code == KeyEvent.VK_ENTER) { // return pressed ?
          scene.getJump().setEnabled(true); // move cube and title
          f_n = 0.5f;
          f_v1 = f_n;
          f_t1 = t_g;
          scene.getCube().setPosY(-3.85f);
          scene.getJump().setJumpY(3.85f);
          scene.getJump().setSynchroTime(t_g);
        } else if (code == KeyEvent.VK_TAB) { // tab pressed ?
          Zoom zoom = scene.getZoom();
          zoom.setEnabled(true); // move scene
          zoom.setZoom(10.0f);
          zoom.setMainAngle(0.0f);
          zoom.setSynchroTime(t_g);
        } else {
          return false;
        }
      }
    }

    return true;
  }
示例#3
0
 @Override
 protected void reshapeGL() {
   scene.init3D();
 }
示例#4
0
  @Override
  protected void drawGLScene() {
    float t_g = tickTimer.getTime();

    // synchro
    if (isSoundEnabled()) {
      modPlayer.stream();
      // System.out.println(modPlayer);

      int ord = modPlayer.getOrd();
      int row = modPlayer.getRow();

      if (row == 0 || firstDraw) {
        firstDraw = false;

        switch (ord) {
          case 0:
            if (!scene.getMapping().isEnabled()) {
              scene.getMapping().setSynchroTime(t_g);
              scene.getMapping().setEnabled(true);
            }
            break;

          case 1:
            scene.getLiner().setEnabled(true);
            break;

          case 2:
            scene.getGlenz().setEnabled(true);
            boolean jumpEnabled = scene.getJump().isEnabled();
            scene.getRez().setEnabled(jumpEnabled);
            scene.getParticles().setEnabled(false);
            scene.getLiner().setEnabled(false);
            scene.getTitle().setEnabled(true);
            if (!scene.getZoom().isEnabled()) {
              scene.getZoom().setSynchroTime(t_g);
              scene.getZoom().setEnabled(true);
            }
            break;

          case 4:
            scene.getRez().setEnabled(true);
            scene.getParticles().setEnabled(true);
            scene.getLiner().setEnabled(true);
            if (!scene.getJump().isEnabled()) {
              scene.getJump().setSynchroTime(t_g);
              scene.getJump().setEnabled(true);
            }
            scene.getLiner().setTxtCredits();
            break;

          case 6:
            scene.getRez().setEnabled(false);
            scene.getGlenz().setEnabled(false);
            scene.getLiner().setTxtLoop();
            break;
        }
      }
      if (row % 8 == 0) {
        f_n = 0.25f;
        f_v2 = f_n;
        f_t2 = t_g;
      }
      if (row == 0) {
        f_n = 0.5f;
        f_v1 = f_n;
        f_t1 = t_g;
        f_v2 = 0;
      }
      if ((((row % 8 - 4) == 0) || (row == 60) || (row == 62)) && (ord > 1)) {
        scene.getCube().setJumpAngle(0.0f);
        scene.getCube().setJump(0.5f);
        scene.getCube().setSynchroTime(t_g);
      }
    }

    Color f_c = ColorUtils.safe(f_v1 + f_v2, f_v1 + f_v2, f_v1 + f_v2, 1.0f); // fog color
    if (f_v1 > 0) {
      f_v1 = (float) (f_n - f_n * 2.0 * (t_g - f_t1));
    }
    if (f_v2 > 0) {
      f_v2 = (float) (f_n - f_n * 2.0 * (t_g - f_t2));
    }

    // 3d mode
    scene.init3D();
    scene.draw(f_c, t_g);
  }
示例#5
0
 @Override
 protected void drawableDisposed() throws Exception {
   scene.clear();
 }