Exemplo n.º 1
0
  private void renderBoard(GL10 gl) {
    float beatPeriod = 60000.0f / m_bpm;
    float timeToUnits = BOARD_LENGTH_AHEAD / (beatPeriod * BEATS_AHEAD);

    GLHelpers.setColor(gl, Config.getBaseColor(), m_readiness);

    {
      gl.glBindTexture(GL10.GL_TEXTURE_2D, m_stringTexture);
      gl.glPushMatrix();
      gl.glScalef(STRING_WIDTH, 1, BOARD_LENGTH);
      gl.glTranslatef(STRING_SPACE / STRING_WIDTH, 0, +0.5f);

      for (int string = 0; string != Song.STRING_COUNT; ++string) {
        if (Guitar.stringsCheck(m_activeStrings, string)) {
          gl.glScalef(2f, 1, 1);
        }
        GLHelpers.drawTextureXZ(gl);
        if (Guitar.stringsCheck(m_activeStrings, string)) {
          gl.glScalef(1 / 2f, 1, 1);
        }
        gl.glTranslatef(-STRING_SPACE / STRING_WIDTH, 0, 0);
      }

      gl.glPopMatrix();
    }

    {
      gl.glBindTexture(GL10.GL_TEXTURE_2D, m_barTexture);
      gl.glPushMatrix();

      int beatsAhead = BEATS_AHEAD + 1;
      float z = (m_position % beatPeriod) * timeToUnits;
      if (z < 0) {
        z = -z;
      } else {
        z = beatPeriod * timeToUnits - z;
      }
      if (z > BAR_WIDTH) {
        beatsAhead -= 1;
      }
      gl.glTranslatef(0, 0, z + SADDLE_OFFSET);
      gl.glScalef((Song.STRING_COUNT - 1) * STRING_SPACE + NOTE_HEAD_SIZE * 2, 1, BAR_WIDTH);
      float dz = beatPeriod * timeToUnits / BAR_WIDTH;
      for (int i = 0; i != beatsAhead; ++i) {
        GLHelpers.drawTextureLineX(gl);
        gl.glTranslatef(0, 0, dz);
      }

      gl.glPopMatrix();
    }
  }
Exemplo n.º 2
0
  private void renderNotes(GL10 gl) {

    //		{
    //			gl.glPushMatrix();
    //			gl.glBindTexture(GL10.GL_TEXTURE_2D,m_stringTexture);
    //
    //			gl.glTranslatef(STRING_SPACE,0,SADDLE_OFFSET+0.3f);
    //			m_fakeNote.setString(0);
    //			m_fakeNote.pick();
    //			renderNoteTail(gl,4,m_fakeNote,false);
    //
    //			gl.glTranslatef(-STRING_SPACE,0,0);
    //			m_fakeNote.setString(1);
    //			m_fakeNote.pick();
    //			renderNoteTail(gl,4,m_fakeNote,false);
    //
    //			gl.glTranslatef(-STRING_SPACE,0,0);
    //			m_fakeNote.setString(2);
    //			m_fakeNote.makeIntact();
    //			renderNoteTail(gl,4,m_fakeNote,false);
    //
    //			gl.glPopMatrix();
    //		}
    //
    //		{
    //			gl.glDisable(GL10.GL_TEXTURE_2D);
    //			gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    //			gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    //
    //			gl.glEnable(GL10.GL_CULL_FACE);
    //			gl.glFrontFace(GL10.GL_CCW);
    //			m_noteMesh.beginRender(gl);
    //			gl.glEnable(GL10.GL_COLOR_MATERIAL);
    //
    //			gl.glPushMatrix();
    //
    //			m_fakeNote.pick();
    //
    //			gl.glTranslatef(STRING_SPACE,0,SADDLE_OFFSET+0.3f);
    //			m_fakeNote.setString(0);
    //			renderNoteHead(gl,m_fakeNote);
    //
    //			gl.glTranslatef(-STRING_SPACE,0,0);
    //			m_fakeNote.setString(1);
    //			renderNoteHead(gl,m_fakeNote);
    //
    //			gl.glTranslatef(-STRING_SPACE,0,0);
    //			m_fakeNote.setString(2);
    //			renderNoteHead(gl,m_fakeNote);
    //
    //			gl.glPopMatrix();
    //
    //			gl.glDisable(GL10.GL_COLOR_MATERIAL);
    //			m_noteMesh.endRender(gl);
    //			gl.glDisable(GL10.GL_CULL_FACE);
    //
    //			gl.glEnable(GL10.GL_TEXTURE_2D);
    //			gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    //			gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    //		}
    //
    //		//gl.glDisable(GL10.GL_BLEND);
    //
    //		if (true) return;

    float beatPeriod = 60000 / m_bpm;
    float timeToUnits = BOARD_LENGTH_AHEAD / (beatPeriod * BEATS_AHEAD);

    gl.glBindTexture(GL10.GL_TEXTURE_2D, m_stringTexture);
    GLHelpers.beginDrawTextureXZ(gl);
    for (int string = 0; string != Song.STRING_COUNT; ++string) {
      int color = Config.getStringColor(string);
      float x = STRING_SPACE * (Song.STRING_COUNT - 1 - 2 * string) / 2;

      EventList<NoteEvent> notes = m_song.getNoteEvents(string);
      long range =
          notes.range(
              m_position - beatPeriod * SADDLE_OFFSET / BOARD_LENGTH_AHEAD * BEATS_AHEAD,
              m_position + beatPeriod * BEATS_AHEAD);
      int rangeBegin = EventList.rangeBegin(range);
      int rangeEnd = EventList.rangeEnd(range);
      for (int i = rangeBegin; i != rangeEnd; ++i) {
        NoteEvent note = notes.get(i);
        float z = SADDLE_OFFSET + (note.getTime() - m_position) * timeToUnits;
        boolean behindSaddle = (z <= SADDLE_OFFSET);
        float length = note.getLength() * timeToUnits;

        gl.glPushMatrix();
        gl.glTranslatef(x, 0, z);
        gl.glScalef(NOTE_TAIL_WIDTH, 1, length);
        gl.glTranslatef(0, 0, 0.5f);
        {
          float factor = (!behindSaddle || note.isUnpicked()) ? 1.0f : NOTE_SLIP_COLOR_FACTOR;
          GLHelpers.setColor(gl, color, m_readiness * factor);
        }
        GLHelpers.doDrawTextureXZ(gl);
        gl.glPopMatrix();

        if (behindSaddle && note.isPicked()) {
          gl.glPushMatrix();
          gl.glTranslatef(x, 0, z);
          float position = m_position + note.getString() * note.getTime();
          drawWaveform(gl, length, position * timeToUnits, color);
          gl.glPopMatrix();
          gl.glBindTexture(GL10.GL_TEXTURE_2D, m_stringTexture);
          GLHelpers.beginDrawTextureXZ(gl);
        }
      }
    }

    gl.glDisable(GL10.GL_TEXTURE_2D);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glFrontFace(GL10.GL_CCW);
    gl.glEnable(GL10.GL_COLOR_MATERIAL);
    m_noteMesh.beginRender(gl);

    gl.glPushMatrix();
    gl.glScalef(NOTE_HEAD_SIZE, NOTE_HEAD_SIZE, NOTE_HEAD_SIZE);

    float lastX = 0;
    float lastZ = 0;
    for (int string = 0; string != Song.STRING_COUNT; ++string) {
      GLHelpers.setColor(gl, Config.getStringColor(string), m_readiness);
      float x = STRING_SPACE * (Song.STRING_COUNT - 1 - 2 * string) / 2;

      EventList<NoteEvent> notes = m_song.getNoteEvents(string);
      long range =
          notes.range(
              m_position - beatPeriod * SADDLE_OFFSET / BOARD_LENGTH_AHEAD * BEATS_AHEAD,
              m_position + beatPeriod * BEATS_AHEAD);
      int rangeBegin = EventList.rangeBegin(range);
      int rangeEnd = EventList.rangeEnd(range);
      for (int i = rangeBegin; i != rangeEnd; ++i) {
        NoteEvent note = notes.get(i);
        float z = SADDLE_OFFSET + (note.getTime() - m_position) * timeToUnits;
        if (z <= SADDLE_OFFSET) {
          continue;
        }
        // gl.glPushMatrix();
        gl.glTranslatef((x - lastX) / NOTE_HEAD_SIZE, 0, (z - lastZ) / NOTE_HEAD_SIZE);
        // gl.glScalef(NOTE_HEAD_SIZE,NOTE_HEAD_SIZE,NOTE_HEAD_SIZE);
        m_noteMesh.renderGeometry(gl);
        lastX = x;
        lastZ = z;
      }
    }

    gl.glPopMatrix();

    m_noteMesh.endRender(gl);
    gl.glDisable(GL10.GL_COLOR_MATERIAL);
    gl.glDisable(GL10.GL_CULL_FACE);

    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
  }