public void updateDrawData() {
    mBGStarPositionsBuffer.position(0);
    mBGStarColorsBuffer.position(0);
    mBGStarTexturesBuffer.position(0);

    // Update the star data
    for (Star star : BGStarSet) {
      Geocentric position = star.getCoords();
      Geocentric u = MathUtils.normalize(MathUtils.crossProduct(position, Z_UP_VECTOR));
      Geocentric v = MathUtils.crossProduct(u, position);

      float sizer = star.magnitude * mRenderer.mPointSizeFactor;
      Geocentric sized_u = new Geocentric(u.x * sizer, u.y * sizer, u.z * sizer);
      Geocentric sized_v = new Geocentric(v.x * sizer, v.y * sizer, v.z * sizer);

      float[] bottomLeft = {
        position.x - sized_u.x - sized_v.x,
        position.y - sized_u.y - sized_v.y,
        position.z - sized_u.z - sized_v.z
      };
      float[] topLeft = {
        position.x - sized_u.x + sized_v.x,
        position.y - sized_u.y + sized_v.y,
        position.z - sized_u.z + sized_v.z
      };
      float[] bottomRight = {
        position.x + sized_u.x - sized_v.x,
        position.y + sized_u.y - sized_v.y,
        position.z + sized_u.z - sized_v.z
      };
      float[] topRight = {
        position.x + sized_u.x + sized_v.x,
        position.y + sized_u.y + sized_v.y,
        position.z + sized_u.z + sized_v.z
      };

      // Inserting first triangle (counter-clockwise)
      mBGStarPositionsBuffer.put(topLeft);
      mBGStarPositionsBuffer.put(bottomLeft);
      mBGStarPositionsBuffer.put(topRight);
      // Inserting second triangle (counter-clockwise)
      mBGStarPositionsBuffer.put(bottomLeft);
      mBGStarPositionsBuffer.put(bottomRight);
      mBGStarPositionsBuffer.put(topRight);

      // Inserting Color per Star (white)
      mBGStarColorsBuffer.put(STAR_COLOR_DATA_ARRAY);

      // Inserting Texture Coordinates per Star
      mBGStarTexturesBuffer.put(TEX_COORD_ARRAY);
    }
    mBGStarPositionsBuffer.position(0);
    mBGStarColorsBuffer.position(0);
    mBGStarTexturesBuffer.position(0);
  }
Ejemplo n.º 2
0
  private void changeMapX(float radians) {
    Geocentric lookVector = mUser.getLookDir();
    Geocentric crossVector = MathUtils.crossProduct(lookVector, mUser.getLookNormal());
    Geocentric deltaLookVector =
        new Geocentric(crossVector.x * radians, crossVector.y * radians, crossVector.z * radians);

    Geocentric newLookDir = MathUtils.add(lookVector, deltaLookVector);
    newLookDir = MathUtils.normalize(newLookDir);

    mUser.setLookDir(newLookDir);
  }