/** Construct a ModelBatch, using this constructor makes you responsible for calling context.begin() and context.end() yourself. * @param context The {@link RenderContext} to use. * @param shaderProvider The {@link ShaderProvider} to use, will be disposed when this ModelBatch is disposed. * @param sorter The {@link RenderableSorter} to use. */ public ModelBatch (final RenderContext context, final ShaderProvider shaderProvider, final RenderableSorter sorter) { this.sorter = (sorter == null) ? new DefaultRenderableSorter() : sorter; this.ownContext = (context == null); this.context = (context == null) ? new RenderContext(new DefaultTextureBinder(DefaultTextureBinder.WEIGHTED, 1)) : context; this.shaderProvider = (shaderProvider == null) ? new DefaultShaderProvider() : shaderProvider; }
/** Convenience method to create a model with a single node containing a cylinder shape. The resources the Material might * contain are not managed, use {@link Model#manageDisposable(Disposable)} to add those to the model. * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal * and TextureCoordinates is supported. */ public Model createCylinder (float width, float height, float depth, int divisions, int primitiveType, final Material material, final long attributes, float angleFrom, float angleTo) { begin(); part("cylinder", primitiveType, attributes, material).cylinder(width, height, depth, divisions, angleFrom, angleTo); return end(); }
@Override public void rect (float x00, float y00, float z00, float x10, float y10, float z10, float x11, float y11, float z11, float x01, float y01, float z01, float normalX, float normalY, float normalZ) { rect(vertTmp1.set(null, null, null, null).setPos(x00, y00, z00).setNor(normalX, normalY, normalZ).setUV(0f, 1f), vertTmp2 .set(null, null, null, null).setPos(x10, y10, z10).setNor(normalX, normalY, normalZ).setUV(1f, 1f), vertTmp3.set(null, null, null, null).setPos(x11, y11, z11).setNor(normalX, normalY, normalZ).setUV(1f, 0f), vertTmp4 .set(null, null, null, null).setPos(x01, y01, z01).setNor(normalX, normalY, normalZ).setUV(0f, 0f)); }
/** Convenience method to create a model with a single node containing a rectangle shape. The resources the Material might * contain are not managed, use {@link Model#manageDisposable(Disposable)} to add those to the model. * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal * and TextureCoordinates is supported. */ public Model createRect (float x00, float y00, float z00, float x10, float y10, float z10, float x11, float y11, float z11, float x01, float y01, float z01, float normalX, float normalY, float normalZ, int primitiveType, final Material material, final long attributes) { begin(); part("rect", primitiveType, attributes, material).rect(x00, y00, z00, x10, y10, z10, x11, y11, z11, x01, y01, z01, normalX, normalY, normalZ); return end(); }
/** Convenience method to create a model with a single node containing a box shape. The resources the Material might contain are * not managed, use {@link Model#manageDisposable(Disposable)} to add those to the model. * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal * and TextureCoordinates is supported. */ public Model createBox (float width, float height, float depth, int primitiveType, final Material material, final long attributes) { begin(); part("box", primitiveType, attributes, material).box(width, height, depth); return end(); }
/** Convenience method to create a model with a single node containing a cone shape. The resources the Material might contain * are not managed, use {@link Model#manageDisposable(Disposable)} to add those to the model. * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal * and TextureCoordinates is supported. */ public Model createCone (float width, float height, float depth, int divisions, int primitiveType, final Material material, final long attributes, float angleFrom, float angleTo) { begin(); part("cone", primitiveType, attributes, material).cone(width, height, depth, divisions, angleFrom, angleTo); return end(); }
/** Convenience method to create a model with a single node containing a sphere shape. The resources the Material might contain * are not managed, use {@link Model#manageDisposable(Disposable)} to add those to the model. * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal * and TextureCoordinates is supported. */ public Model createSphere (float width, float height, float depth, int divisionsU, int divisionsV, int primitiveType, final Material material, final long attributes, float angleUFrom, float angleUTo, float angleVFrom, float angleVTo) { begin(); part("cylinder", primitiveType, attributes, material).sphere(width, height, depth, divisionsU, divisionsV, angleUFrom, angleUTo, angleVFrom, angleVTo); return end(); }
/** Convenience method to create a model with an arrow. The resources the Material might contain are not managed, use * {@link Model#manageDisposable(Disposable)} to add those to the model. * @param material * @param capLength is the height of the cap in percentage, must be in (0,1) * @param stemThickness is the percentage of stem diameter compared to cap diameter, must be in (0,1] * @param divisions the amount of vertices used to generate the cap and stem ellipsoidal bases */ public Model createArrow (float x1, float y1, float z1, float x2, float y2, float z2, float capLength, float stemThickness, int divisions, int primitiveType, Material material, long attributes) { begin(); part("arrow", primitiveType, attributes, material).arrow(x1, y1, z1, x2, y2, z2, capLength, stemThickness, divisions); return end(); }
/** Creates a new MeshPart within the current Node and returns a {@link MeshPartBuilder} which can be used to build the shape of * the part. If possible a previously used {@link MeshPartBuilder} will be reused, to reduce the number of mesh binds. * Therefore you can only build one part at a time. The resources the Material might contain are not managed, use * {@link #manage(Disposable)} to add those to the model. * @return The {@link MeshPartBuilder} you can use to build the MeshPart. */ public MeshPartBuilder part (final String id, int primitiveType, final VertexAttributes attributes, final Material material) { final MeshBuilder builder = getBuilder(attributes); part(builder.part(id, primitiveType), material); return builder; }
/** Creates a new MeshPart within the current Node and returns a {@link MeshPartBuilder} which can be used to build the shape of * the part. If possible a previously used {@link MeshPartBuilder} will be reused, to reduce the number of mesh binds. * Therefore you can only build one part at a time. The resources the Material might contain are not managed, use * {@link #manage(Disposable)} to add those to the model. * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal * and TextureCoordinates is supported. * @return The {@link MeshPartBuilder} you can use to build the MeshPart. */ public MeshPartBuilder part (final String id, int primitiveType, final long attributes, final Material material) { return part(id, primitiveType, MeshBuilder.createAttributes(attributes), material); }
@Override public void rect (Vector3 corner00, Vector3 corner10, Vector3 corner11, Vector3 corner01, Vector3 normal) { rect(vertTmp1.set(corner00, normal, null, null).setUV(0f, 1f), vertTmp2.set(corner10, normal, null, null).setUV(1f, 1f), vertTmp3.set(corner11, normal, null, null).setUV(1f, 0f), vertTmp4.set(corner01, normal, null, null).setUV(0f, 0f)); }
@Override public final int bind (final GLTexture texture) { tempDesc.set(texture, null, null, null, null); return bindTexture(tempDesc, false); }
private final static void applyNodeAnimationDirectly (final NodeAnimation nodeAnim, final float time) { final Node node = nodeAnim.node; node.isAnimated = true; final Transform transform = getNodeAnimationTransform(nodeAnim, time); transform.toMatrix4(node.localTransform); }
/** Convenience method to create a model with a single node containing a box shape. The resources the Material might contain are * not managed, use {@link Model#manageDisposable(Disposable)} to add those to the model. * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal * and TextureCoordinates is supported. */ public Model createBox (float width, float height, float depth, int primitiveType, final Material material, final long attributes) { begin(); part("box", primitiveType, attributes, material).box(width, height, depth); return end(); }
/** Convenience method to create a model with a single node containing a cylinder shape. The resources the Material might * contain are not managed, use {@link Model#manageDisposable(Disposable)} to add those to the model. * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal * and TextureCoordinates is supported. */ public Model createCylinder (float width, float height, float depth, int divisions, int primitiveType, final Material material, final long attributes, float angleFrom, float angleTo) { begin(); part("cylinder", primitiveType, attributes, material).cylinder(width, height, depth, divisions, angleFrom, angleTo); return end(); }
/** Convenience method to create a model with an arrow. The resources the Material might contain are not managed, use * {@link Model#manageDisposable(Disposable)} to add those to the model. * @param material * @param capLength is the height of the cap in percentage, must be in (0,1) * @param stemThickness is the percentage of stem diameter compared to cap diameter, must be in (0,1] * @param divisions the amount of vertices used to generate the cap and stem ellipsoidal bases */ public Model createArrow (float x1, float y1, float z1, float x2, float y2, float z2, float capLength, float stemThickness, int divisions, int primitiveType, Material material, long attributes) { begin(); part("arrow", primitiveType, attributes, material).arrow(x1, y1, z1, x2, y2, z2, capLength, stemThickness, divisions); return end(); }
/** Construct a ModelBatch, using this constructor makes you responsible for calling context.begin() and context.end() yourself. * @param context The {@link RenderContext} to use. * @param shaderProvider The {@link ShaderProvider} to use, will be disposed when this ModelBatch is disposed. * @param sorter The {@link RenderableSorter} to use. */ public ModelBatch (final RenderContext context, final ShaderProvider shaderProvider, final RenderableSorter sorter) { this.sorter = (sorter == null) ? new DefaultRenderableSorter() : sorter; this.ownContext = (context == null); this.context = (context == null) ? new RenderContext(new DefaultTextureBinder(DefaultTextureBinder.WEIGHTED, 1)) : context; this.shaderProvider = (shaderProvider == null) ? new DefaultShaderProvider() : shaderProvider; }
@Override public void rect (float x00, float y00, float z00, float x10, float y10, float z10, float x11, float y11, float z11, float x01, float y01, float z01, float normalX, float normalY, float normalZ) { rect(vertTmp1.set(null, null, null, null).setPos(x00, y00, z00).setNor(normalX, normalY, normalZ).setUV(0f, 1f), vertTmp2 .set(null, null, null, null).setPos(x10, y10, z10).setNor(normalX, normalY, normalZ).setUV(1f, 1f), vertTmp3.set(null, null, null, null).setPos(x11, y11, z11).setNor(normalX, normalY, normalZ).setUV(1f, 0f), vertTmp4 .set(null, null, null, null).setPos(x01, y01, z01).setNor(normalX, normalY, normalZ).setUV(0f, 0f)); }
/** Creates a new MeshPart within the current Node and returns a {@link MeshPartBuilder} which can be used to build the shape of * the part. If possible a previously used {@link MeshPartBuilder} will be reused, to reduce the number of mesh binds. * Therefore you can only build one part at a time. The resources the Material might contain are not managed, use * {@link #manage(Disposable)} to add those to the model. * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal * and TextureCoordinates is supported. * @return The {@link MeshPartBuilder} you can use to build the MeshPart. */ public MeshPartBuilder part (final String id, int primitiveType, final long attributes, final Material material) { return part(id, primitiveType, MeshBuilder.createAttributes(attributes), material); }
@Override public final int bind (final GLTexture texture) { tempDesc.set(texture, null, null, null, null); return bindTexture(tempDesc, false); }