/** Calculates the squared radius of the bounding sphere around the specified center for the specified part. * @param centerX The X coordinate of the center of the bounding sphere * @param centerY The Y coordinate of the center of the bounding sphere * @param centerZ The Z coordinate of the center of the bounding sphere * @return the squared radius of the bounding sphere. */ public float calculateRadius (final float centerX, final float centerY, final float centerZ) { return calculateRadius(centerX, centerY, centerZ, 0, getNumIndices(), null); }
/** Calculates the squared radius of the bounding sphere around the specified center for the specified part. * @param centerX The X coordinate of the center of the bounding sphere * @param centerY The Y coordinate of the center of the bounding sphere * @param centerZ The Z coordinate of the center of the bounding sphere * @return the squared radius of the bounding sphere. */ public float calculateRadius (final float centerX, final float centerY, final float centerZ) { return calculateRadius(centerX, centerY, centerZ, 0, getNumIndices(), null); }
/** Convenience method to set this btIndexedMesh to the specified {@link Mesh} * The specified mesh must be indexed and triangulated and must outlive this btIndexedMesh. * The buffers for the vertices and indices are shared amonst both. */ public void set(final Mesh mesh) { set(mesh, mesh, 0, mesh.getNumIndices()); }
/** Adds the specified mesh part to the current node. The Mesh will be managed by the model and disposed when the model is * disposed. The resources the Material might contain are not managed, use {@link #manage(Disposable)} to add those to the * model. * @return The added MeshPart. */ public MeshPart part (final String id, final Mesh mesh, int primitiveType, final Material material) { return part(id, mesh, primitiveType, 0, mesh.getNumIndices(), material); }
/** Calculates the squared radius of the bounding sphere around the specified center for the specified part. * @param center The center of the bounding sphere * @return the squared radius of the bounding sphere. */ public float calculateRadius (final Vector3 center) { return calculateRadius(center.x, center.y, center.z, 0, getNumIndices(), null); }
/** Convenience method to set this btIndexedMesh to the specified {@link Mesh} * The specified mesh must be indexed and triangulated and must outlive this btIndexedMesh. * The buffers for the vertices and indices are shared amonst both. */ public void set(final Object tag, final Mesh mesh) { set(tag, mesh, 0, mesh.getNumIndices()); }
/** Convenience method to set this btIndexedMesh to the specified {@link Mesh} * The specified mesh must be indexed and triangulated and must outlive this btIndexedMesh. * The buffers for the vertices and indices are shared amonst both. */ public void set(final Mesh mesh) { set(mesh, mesh, 0, mesh.getNumIndices()); }
/** Convenience method to set this btIndexedMesh to the specified {@link Mesh} * The specified mesh must be indexed and triangulated and must outlive this btIndexedMesh. * The buffers for the vertices and indices are shared amonst both. */ public void set(final Object tag, final Mesh mesh) { set(tag, mesh, 0, mesh.getNumIndices()); }
/** Calculates the squared radius of the bounding sphere around the specified center for the specified part. * @param center The center of the bounding sphere * @return the squared radius of the bounding sphere. */ public float calculateRadius (final Vector3 center) { return calculateRadius(center.x, center.y, center.z, 0, getNumIndices(), null); }
/** Adds the specified mesh part to the current node. The Mesh will be managed by the model and disposed when the model is * disposed. The resources the Material might contain are not managed, use {@link #manage(Disposable)} to add those to the * model. * @return The added MeshPart. */ public MeshPart part (final String id, final Mesh mesh, int primitiveType, final Material material) { return part(id, mesh, primitiveType, 0, mesh.getNumIndices(), material); }
@Override public void addMesh (Mesh mesh) { addMesh(mesh, 0, mesh.getNumIndices()); }
@Override public void addMesh (Mesh mesh) { addMesh(mesh, 0, mesh.getNumIndices()); }
/** Adds the specified sprite to the cache. */ public void add (Sprite sprite) { if (mesh.getNumIndices() > 0) { add(sprite.getTexture(), sprite.getVertices(), 0, SPRITE_SIZE); return; } float[] spriteVertices = sprite.getVertices(); System.arraycopy(spriteVertices, 0, tempVertices, 0, 3 * VERTEX_SIZE); // temp0,1,2=sprite0,1,2 System.arraycopy(spriteVertices, 2 * VERTEX_SIZE, tempVertices, 3 * VERTEX_SIZE, VERTEX_SIZE); // temp3=sprite2 System.arraycopy(spriteVertices, 3 * VERTEX_SIZE, tempVertices, 4 * VERTEX_SIZE, VERTEX_SIZE); // temp4=sprite3 System.arraycopy(spriteVertices, 0, tempVertices, 5 * VERTEX_SIZE, VERTEX_SIZE); // temp5=sprite0 add(sprite.getTexture(), tempVertices, 0, 30); }
/** Adds the specified sprite to the cache. */ public void add (Sprite sprite) { if (mesh.getNumIndices() > 0) { add(sprite.getTexture(), sprite.getVertices(), 0, SPRITE_SIZE); return; } float[] spriteVertices = sprite.getVertices(); System.arraycopy(spriteVertices, 0, tempVertices, 0, 3 * VERTEX_SIZE); // temp0,1,2=sprite0,1,2 System.arraycopy(spriteVertices, 2 * VERTEX_SIZE, tempVertices, 3 * VERTEX_SIZE, VERTEX_SIZE); // temp3=sprite2 System.arraycopy(spriteVertices, 3 * VERTEX_SIZE, tempVertices, 4 * VERTEX_SIZE, VERTEX_SIZE); // temp4=sprite3 System.arraycopy(spriteVertices, 0, tempVertices, 5 * VERTEX_SIZE, VERTEX_SIZE); // temp5=sprite0 add(sprite.getTexture(), tempVertices, 0, 30); }
/** Starts the definition of a new cache, allowing the add and {@link #endCache()} methods to be called. */ public void beginCache () { if (drawing) throw new IllegalStateException("end must be called before beginCache"); if (currentCache != null) throw new IllegalStateException("endCache must be called before begin."); int verticesPerImage = mesh.getNumIndices() > 0 ? 4 : 6; currentCache = new Cache(caches.size, mesh.getVerticesBuffer().limit()); caches.add(currentCache); mesh.getVerticesBuffer().compact(); }
/** Adds the specified vertices to the cache. Each vertex should have 5 elements, one for each of the attributes: x, y, color, * u, and v. If indexed geometry is used, each image should be specified as 4 vertices, otherwise each image should be * specified as 6 vertices. */ public void add (Texture texture, float[] vertices, int offset, int length) { if (currentCache == null) throw new IllegalStateException("beginCache must be called before add."); int verticesPerImage = mesh.getNumIndices() > 0 ? 4 : 6; int count = length / (verticesPerImage * VERTEX_SIZE) * 6; int lastIndex = textures.size - 1; if (lastIndex < 0 || textures.get(lastIndex) != texture) { textures.add(texture); counts.add(count); } else counts.incr(lastIndex, count); mesh.getVerticesBuffer().put(vertices, offset, length); }
/** Adds the specified vertices to the cache. Each vertex should have 5 elements, one for each of the attributes: x, y, color, * u, and v. If indexed geometry is used, each image should be specified as 4 vertices, otherwise each image should be * specified as 6 vertices. */ public void add (Texture texture, float[] vertices, int offset, int length) { if (currentCache == null) throw new IllegalStateException("beginCache must be called before add."); int verticesPerImage = mesh.getNumIndices() > 0 ? 4 : 6; int count = length / (verticesPerImage * VERTEX_SIZE) * 6; int lastIndex = textures.size - 1; if (lastIndex < 0 || textures.get(lastIndex) != texture) { textures.add(texture); counts.add(count); } else counts.incr(lastIndex, count); mesh.getVerticesBuffer().put(vertices, offset, length); }
/** Starts the definition of a new cache, allowing the add and {@link #endCache()} methods to be called. */ public void beginCache () { if (drawing) throw new IllegalStateException("end must be called before beginCache"); if (currentCache != null) throw new IllegalStateException("endCache must be called before begin."); int verticesPerImage = mesh.getNumIndices() > 0 ? 4 : 6; currentCache = new Cache(caches.size, mesh.getVerticesBuffer().limit()); caches.add(currentCache); mesh.getVerticesBuffer().compact(); }
@Override public void setMesh (Mesh mesh, Model model) { super.setMesh(mesh, model); vertexSize = mesh.getVertexSize() / 4; positionOffset = mesh.getVertexAttribute(Usage.Position).offset / 4; int indicesCount = mesh.getNumIndices(); if (indicesCount > 0) { indices = new short[indicesCount]; mesh.getIndices(indices); triangleCount = indices.length / 3; } else indices = null; vertexCount = mesh.getNumVertices(); vertices = new float[vertexCount * vertexSize]; mesh.getVertices(vertices); }
@Override public void setMesh (Mesh mesh, Model model) { super.setMesh(mesh, model); vertexSize = mesh.getVertexSize() / 4; positionOffset = mesh.getVertexAttribute(Usage.Position).offset / 4; int indicesCount = mesh.getNumIndices(); if (indicesCount > 0) { indices = new short[indicesCount]; mesh.getIndices(indices); triangleCount = indices.length / 3; } else indices = null; vertexCount = mesh.getNumVertices(); vertices = new float[vertexCount * vertexSize]; mesh.getVertices(vertices); }