示例#1
0
  private List<Triangle> getTriangles() {
    List<Triangle> triangles = new ArrayList<Triangle>();

    IntBuffer verticesBuffer = mVertexBuffers.getVertexBuffer();
    int[] verticesInt = new int[verticesBuffer.capacity()];

    for (int i = 0; i < verticesBuffer.capacity(); i++) {
      verticesInt[i] = verticesBuffer.get(i);
    }

    // Fixed Point Conversion
    float[] vertices = new float[verticesInt.length];
    for (int i = 0; i < verticesInt.length; i++) {
      vertices[i] = (float) verticesInt[i] / 65536;
    }

    ShortBuffer indicesBuffer = mVertexBuffers.getIndexBuffer();
    short[] indices = new short[indicesBuffer.capacity()];
    for (int i = 0; i < indicesBuffer.capacity(); i++) {
      indices[i] = indicesBuffer.get(i);
    }

    Triangle triangle;
    Point3f vec;
    for (int i = 0; i < indices.length; i++) {
      triangle = new Triangle();
      vec = new Point3f();
      vec.x = vertices[indices[i] * 3];
      vec.y = vertices[indices[i] * 3 + 1];
      vec.z = vertices[indices[i] * 3 + 2];
      triangle.mX = vec;
      i++;
      vec = new Point3f();
      vec.x = vertices[indices[i] * 3];
      vec.y = vertices[indices[i] * 3 + 1];
      vec.z = vertices[indices[i] * 3 + 2];
      triangle.mY = vec;
      i++;
      vec = new Point3f();
      vec.x = vertices[indices[i] * 3];
      vec.y = vertices[indices[i] * 3 + 1];
      vec.z = vertices[indices[i] * 3 + 2];
      triangle.mZ = vec;

      triangles.add(triangle);
    }

    return triangles;
  }
示例#2
0
 private void init() {
   mBox = new BoundingBox(mVertexBuffers.getVertexBuffer());
   t = new Matrix4f();
   t.setIdentity();
   mZeroVector = new Vector3f(0, 0, 0);
   mEpsilon = 0.001f;
 }
示例#3
0
 public Box2DShape enableBox2D() {
   return new Box2DShape(mVertexBuffers.getVertexBuffer());
 }