public FloatBuffer getVertices() { if (mOriginalGeometry != null) { return mOriginalGeometry.getVertices(); } return (FloatBuffer) mBuffers.get(VERTEX_BUFFER_KEY).buffer; }
public void calculateBounds(Geometry3D geometry) { double radius = 0, maxRadius = 0; Vector3 vertex = new Vector3(); FloatBuffer vertices = geometry.getVertices(); vertices.rewind(); while(vertices.hasRemaining()) { vertex.x = vertices.get(); vertex.y = vertices.get(); vertex.z = vertices.get(); radius = vertex.length(); if(radius > maxRadius) maxRadius = radius; } mRadius = maxRadius; }
/** * Retrieve the number of triangles this scene contains, recursive method * * @return int the total triangle count for the scene. */ public int getNumTriangles() { int triangleCount = 0; ArrayList<Object3D> children = getChildrenCopy(); for (int i = 0, j = children.size(); i < j; i++) { Object3D child = children.get(i); if (child.getGeometry() != null && child.getGeometry().getVertices() != null && child.isVisible()) if (child.getNumChildren() > 0) { triangleCount += child.getNumTriangles(); } else { triangleCount += child.getGeometry().getVertices().limit() / 9; } } return triangleCount; }
public void calculateBounds(Geometry3D geometry) { mMin.setAll(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE); mMax.setAll(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE); FloatBuffer vertices = geometry.getVertices(); if (vertices != null) { calculateMinMaxVertices(vertices, mMin, mMax); calculatePoints(); } }
/** * Retrieve the number of objects on the screen, recursive method * * @return int the total object count for the screen. */ public int getNumObjects() { int objectCount = 0; ArrayList<Object3D> children = getChildrenCopy(); for (int i = 0, j = children.size(); i < j; i++) { Object3D child = children.get(i); if (child.getGeometry() != null && child.getGeometry().getVertices() != null && child.isVisible()) if (child.getNumChildren() > 0) { objectCount += child.getNumObjects() + 1; } else { objectCount++; } } return objectCount; } }
/** * Retrieve the number of triangles of the object, recursive method * * @return int the total triangle count for the object. */ public int getNumTriangles() { int triangleCount = 0; for (int i = 0, j = getNumChildren(); i < j; i++) { Object3D child = getChildAt(i); if (child.getGeometry() != null && child.getGeometry().getVertices() != null && child.isVisible()) { if (child.getNumChildren() > 0) { triangleCount += child.getNumTriangles(); } else { triangleCount += child.getGeometry().getVertices().limit() / 9; } } } return triangleCount; }
@Test public void testVertices() { float[] expected = new float[]{ -0.5f, -0.5f, 0, -0.5f, 0.5f, 0, 0.5f, -0.5f, 0, 0.5f, 0.5f, 0, }; float[] result = new float[4 * 3]; screenQuad.getGeometry().getVertices().get(result); for (int i = 0; i < result.length; i++) { assertEquals(expected[i], result[i], 1e-10); } }
/** * Retrieve the number of objects in the object, recursive method * * @return int the total object count for the object. */ public int getNumObjects() { int objectCount = 0; for (int i = 0, j = getNumChildren(); i < j; i++) { Object3D child = getChildAt(i); if (child.getGeometry() != null && child.getGeometry().getVertices() != null && child.isVisible()) { if (child.getNumChildren() > 0) { objectCount += child.getNumObjects() + 1; } else { objectCount++; } } } return objectCount; }
public float[] calculateNormals(int[] indices) { float[] vertices = new float[mGeometry.getVertices().capacity()]; mGeometry.getVertices().get(vertices).position(0); float[] faceNormals = new float[indices.length]; float[] vertNormals = new float[vertices.length];
private void updateBox(BoundingBox bb) { FloatBuffer b = mGeometry.getVertices(); int index = 0; bb.copyPoints(mBBoxVertices); addVertexToBuffer(b, index++, mBBoxVertices[0]); addVertexToBuffer(b, index++, mBBoxVertices[1]); addVertexToBuffer(b, index++, mBBoxVertices[2]); addVertexToBuffer(b, index++, mBBoxVertices[3]); addVertexToBuffer(b, index++, mBBoxVertices[0]); addVertexToBuffer(b, index++, mBBoxVertices[4]); addVertexToBuffer(b, index++, mBBoxVertices[5]); addVertexToBuffer(b, index++, mBBoxVertices[1]); addVertexToBuffer(b, index++, mBBoxVertices[5]); addVertexToBuffer(b, index++, mBBoxVertices[6]); addVertexToBuffer(b, index++, mBBoxVertices[2]); addVertexToBuffer(b, index++, mBBoxVertices[6]); addVertexToBuffer(b, index++, mBBoxVertices[7]); addVertexToBuffer(b, index++, mBBoxVertices[3]); addVertexToBuffer(b, index++, mBBoxVertices[7]); addVertexToBuffer(b, index++, mBBoxVertices[4]); mGeometry.changeBufferData( mGeometry.getVertexBufferInfo(), mGeometry.getVertices(), 0); }
/** * Returns a {@link BoundingBox} for this Object3D and creates it if needed. * Utilizes children's bounding values to calculate its own {@link BoundingBox}. * * @return */ public BoundingBox getBoundingBox() { if (getNumChildren() > 0 && !mGeometry.hasBoundingBox()) { Vector3 min = new Vector3(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE); Vector3 max = new Vector3(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE); for (int i = 0; i < getNumChildren(); i++) { Object3D child = getChildAt(i); updateMaxMinCoords(min, max, child); } if (mGeometry.getVertices() != null) { updateMaxMinCoords(min, max, this); } mGeometry.setBoundingBox(new BoundingBox(min, max)); } return mGeometry.getBoundingBox(); }
float[] addVertices = getFloatArrayFromBuffer(geometry.getVertices()); if (offset != null) { for (int i = 0, j = addVertices.length; i < j; ++i) {
FloatBuffer b = mGeometry.getVertices(); int index = 0; mGeometry.getVertices(), 0);
public FloatBuffer getVertices() { if (mOriginalGeometry != null) return mOriginalGeometry.getVertices(); return mVertices; }
public void calculateBounds(Geometry3D geometry) { double radius = 0, maxRadius = 0; Vector3 vertex = new Vector3(); FloatBuffer vertices = geometry.getVertices(); vertices.rewind(); while (vertices.hasRemaining()) { vertex.x = vertices.get(); vertex.y = vertices.get(); vertex.z = vertices.get(); radius = vertex.length(); if (radius > maxRadius) maxRadius = radius; } mRadius = maxRadius; }
public void calculateBounds(Geometry3D geometry) { FloatBuffer vertices = geometry.getVertices(); vertices.rewind(); mMin.setAll(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE); mMax.setAll(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE); Vector3 vertex = new Vector3(); while (vertices.hasRemaining()) { vertex.x = vertices.get(); vertex.y = vertices.get(); vertex.z = vertices.get(); if (vertex.x < mMin.x) mMin.x = vertex.x; if (vertex.y < mMin.y) mMin.y = vertex.y; if (vertex.z < mMin.z) mMin.z = vertex.z; if (vertex.x > mMax.x) mMax.x = vertex.x; if (vertex.y > mMax.y) mMax.y = vertex.y; if (vertex.z > mMax.z) mMax.z = vertex.z; } calculatePoints(); }
/** * Retrieve the number of triangles this scene contains, recursive method * * @return int the total triangle count for the scene. */ public int getNumTriangles() { int triangleCount = 0; ArrayList<Object3D> children = getChildrenCopy(); for (int i = 0, j = children.size(); i < j; i++) { Object3D child = children.get(i); if (child.getGeometry() != null && child.getGeometry().getVertices() != null && child.isVisible()) if (child.getNumChildren() > 0) { triangleCount += child.getNumTriangles(); } else { triangleCount += child.getGeometry().getVertices().limit() / 9; } } return triangleCount; }
/** * Retrieve the number of objects on the screen, recursive method * * @return int the total object count for the screen. */ public int getNumObjects() { int objectCount = 0; ArrayList<Object3D> children = getChildrenCopy(); for (int i = 0, j = children.size(); i < j; i++) { Object3D child = children.get(i); if (child.getGeometry() != null && child.getGeometry().getVertices() != null && child.isVisible()) if (child.getNumChildren() > 0) { objectCount += child.getNumObjects() + 1; } else { objectCount++; } } return objectCount; } }
/** * Retrieve the number of triangles of the object, recursive method * * @return int the total triangle count for the object. */ public int getNumTriangles() { int triangleCount = 0; for (int i = 0, j = getNumChildren(); i < j; i++) { Object3D child = getChildAt(i); if (child.getGeometry() != null && child.getGeometry().getVertices() != null && child.isVisible()) if (child.getNumChildren() > 0) { triangleCount += child.getNumTriangles(); } else { triangleCount += child.getGeometry().getVertices().limit() / 9; } } return triangleCount; }
/** * Retrieve the number of objects in the object, recursive method * * @return int the total object count for the object. */ public int getNumObjects() { int objectCount = 0; for (int i = 0, j = getNumChildren(); i < j; i++) { Object3D child = getChildAt(i); if (child.getGeometry() != null && child.getGeometry().getVertices() != null && child.isVisible()) if (child.getNumChildren() > 0) { objectCount += child.getNumObjects() + 1; } else { objectCount++; } } return objectCount; }