/** * 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; }
protected void cloneTo(Object3D clone, boolean copyMaterial) { clone.setName(mName); clone.getGeometry().copyFromGeometry3D(mGeometry); clone.isContainer(mIsContainerOnly); if (copyMaterial) { clone.setMaterial(mMaterial); } clone.mElementsBufferType = GLES20.GL_UNSIGNED_INT; clone.mTransparent = this.mTransparent; clone.mEnableBlending = this.mEnableBlending; clone.mBlendFuncSFactor = this.mBlendFuncSFactor; clone.mBlendFuncDFactor = this.mBlendFuncDFactor; clone.mEnableDepthTest = this.mEnableDepthTest; clone.mEnableDepthMask = this.mEnableDepthMask; }
if (o.getGeometry().hasBoundingSphere()) { BoundingSphere bsphere = o.getGeometry().getBoundingSphere(); bsphere.calculateBounds(o.getGeometry()); bsphere.transform(o.getModelMatrix()); BoundingBox bbox = o.getGeometry().getBoundingBox(); bbox.calculateBounds(o.getGeometry()); bbox.transform(o.getModelMatrix());
/** * Maps the (x,y) coordinates of <code>tileName</code> in <code>atlas</code> * to the TextureCoordinates of this BaseObject3D * * Saves a copy of the original TextureCoordinates in case of future mapping. * * @param tileName * @param atlas */ public void setAtlasTile(String tileName, TextureAtlas atlas) { Tile tile = atlas.getTileNamed(tileName); if(mOriginalTextureCoords == null) { mOriginalTextureCoords = this.getGeometry().getTextureCoords().duplicate(); } FloatBuffer fb = FloatBuffer.allocate(mOriginalTextureCoords.capacity()); for (int i = 0; i < fb.capacity(); i++) { double uvIn = mOriginalTextureCoords.get(i); double uvOut; if (i % 2 == 0) { uvOut = (uvIn * (tile.width / atlas.getWidth())) + tile.x / atlas.getWidth(); } else { uvOut = (uvIn * (tile.height / atlas.getHeight())) + tile.y / atlas.getHeight(); } fb.put(i, (float) uvOut); } mGeometry.changeBufferData(mGeometry.getTexCoordBufferInfo(), fb, 0); }
/** * 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; }
Geometry3D g = mObject.getGeometry(); StringBuffer sb = new StringBuffer(9000); BufferedWriter bw = null;
if (o.getGeometry().hasBoundingSphere()) { BoundingSphere bsphere = o.getGeometry().getBoundingSphere(); bsphere.calculateBounds(o.getGeometry()); bsphere.transform(o.getModelMatrix()); BoundingBox bbox = o.getGeometry().getBoundingBox(); bbox.calculateBounds(o.getGeometry()); bbox.transform(o.getModelMatrix());
protected void cloneTo(Object3D clone, boolean copyMaterial) { clone.setName(mName); clone.getGeometry().copyFromGeometry3D(mGeometry); clone.isContainer(mIsContainerOnly); if (copyMaterial) clone.setMaterial(mMaterial); clone.mElementsBufferType = mGeometry.areOnlyShortBuffersSupported() ? GLES20.GL_UNSIGNED_SHORT : GLES20.GL_UNSIGNED_INT; clone.mTransparent = this.mTransparent; clone.mEnableBlending = this.mEnableBlending; clone.mBlendFuncSFactor = this.mBlendFuncSFactor; clone.mBlendFuncDFactor = this.mBlendFuncDFactor; clone.mEnableDepthTest = this.mEnableDepthTest; clone.mEnableDepthMask = this.mEnableDepthMask; }
/** * Maps the (x,y) coordinates of <code>tileName</code> in <code>atlas</code> * to the TextureCoordinates of this BaseObject3D * * @param tileName * @param atlas */ public void setAtlasTile(String tileName, TextureAtlas atlas) { Tile tile = atlas.getTileNamed(tileName); FloatBuffer fb = this.getGeometry().getTextureCoords(); for (int i = 0; i < fb.capacity(); i++) { double uvIn = fb.get(i); double uvOut; if (i % 2 == 0) uvOut = (uvIn * (tile.width / atlas.getWidth())) + tile.x / atlas.getWidth(); else uvOut = (uvIn * (tile.height / atlas.getHeight())) + tile.y / atlas.getHeight(); fb.put(i, (float) uvOut); } mGeometry.changeBufferData(mGeometry.mTexCoordBufferInfo, fb, 0); }
final Geometry3D geom = mObject.getGeometry();