public class Quad3D extends Quad implements SortableBatchable<Quad3D>
Quad Batchable that supports a single texture at a time, with
two-dimensional position and color. It is designed to be drawn in 3D space, and is commonly called a decal.
The default origin of a Quad3D is its center. Its origin is used for positioning, and as the center of rotation and scaling.
Quad3D manages its own blending, so calls to the FlexBatch's blend function setters will be ineffective.
It may be subclassed to create a Batchable class that supports multiple textures and additional attributes--see
Quad.getNumberOfTextures() and addVertexAttributes(). Such a
subclass would not be compatible with a FlexBatch that was instantiated for the base Sprite type.
| Modifier and Type | Class and Description |
|---|---|
static class |
Quad3D.Blending
Commonly used blend function factor pairs, for convenience.
|
Batchable.FixedSizeBatchable| Modifier and Type | Field and Description |
|---|---|
int |
dstBlendFactor |
boolean |
opaque |
com.badlogic.gdx.math.Quaternion |
rotation |
int |
srcBlendFactor |
float |
z |
| Constructor and Description |
|---|
Quad3D()
A Quad3D that starts opaque.
|
Quad3D(int srcBlendFactor,
int dstBlendFactor)
A Quad3D that starts with blending enabled, with the specified blend factors.
|
Quad3D(Quad3D.Blending blending)
A Quad3D that starts with blending enabled, and a common set of blend factors.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
apply(float[] vertices,
int vertexStartingIndex,
AttributeOffsets offsets,
int vertexSize)
Called by FlexBatch.
|
Quad3D |
billboard(com.badlogic.gdx.graphics.Camera camera)
Sets the rotation to look at the camera, relative to the current position.
|
Quad3D |
billboard(com.badlogic.gdx.graphics.Camera camera,
com.badlogic.gdx.math.Vector3 up)
Sets the rotation to look at the camera, relative to the current position.
|
Quad3D |
blend()
Enables blending.
|
Quad3D |
blend(int srcBlendFactor,
int dstBlendFactor)
Enables blending and sets the blend function parameters.
|
Quad3D |
blend(Quad3D.Blending blending)
Enables blending and sets the blend function parameters to a commonly used pair.
|
float |
calculateDistanceSquared(com.badlogic.gdx.math.Vector3 camPosition) |
Quad3D |
color(com.badlogic.gdx.graphics.Color color) |
Quad3D |
color(float floatBits) |
Quad3D |
color(float r,
float g,
float b,
float a) |
Quad3D |
flip(boolean flipX,
boolean flipY)
Flips the UV region of the most recently applied texture.
|
boolean |
hasEquivalentTextures(Quad3D other) |
boolean |
isOpaque() |
protected boolean |
isPosition3D()
Determines whether the position data has a Z component.
|
protected boolean |
isTextureCoordinate3D()
Determines whether the texture coordinate data has a third component (for TextureArray layers).
|
Quad3D |
lookAt(com.badlogic.gdx.math.Vector3 position,
com.badlogic.gdx.math.Vector3 up)
Sets the rotation to look at the give position, relative to the current position.
|
Quad3D |
opaque()
Disables blending.
|
Quad3D |
origin(float originX,
float originY)
Sets the center point for transformations (rotation and scale).
|
Quad3D |
position(float x,
float y,
float z)
Sets the position of the center (plus current origin offset) of the texture region in world space.
|
Quad3D |
position(com.badlogic.gdx.math.Vector3 position)
Sets the position of the center (plus current origin offset) of the texture region in world space.
|
protected boolean |
prepareContext(RenderContextAccumulator renderContext,
int remainingVertices,
int remainingTriangles)
Called before
Batchable.apply(float[], int, AttributeOffsets, int) to set render context states and texture bindings, and to
determine if a flush is necessary before this Batchable can be drawn. |
protected void |
prepareSharedContext(RenderContextAccumulator renderContext)
Prepares the rendering context for this type of Batchable to be drawn.
|
void |
refresh()
Resets the state and default parameters of the Batchable so it can be reused for an entirely new image.
|
Quad3D |
region(float u,
float v,
float u2,
float v2)
Sets the UV region of the most recently applied texture.
|
Quad3D |
rotate(com.badlogic.gdx.math.Quaternion rotation)
Rotates the current orientation by a specific Quaternion.
|
Quad3D |
rotateCoordinates90(boolean clockwise)
Rotates the texture region(s) 90 degrees in place by rotating the texture coordinates.
|
Quad3D |
rotateX(float angle)
Rotates from the current orientation by a specific angle about the X axis.
|
Quad3D |
rotateY(float angle)
Rotates from the current orientation by a specific angle about the Y axis.
|
Quad3D |
rotateZ(float angle)
Rotates from the current orientation by a specific angle about the Z axis.
|
Quad3D |
rotation(float yaw,
float pitch,
float roll)
Sets the rotation to specific Euler angles.
|
Quad3D |
rotation(float x,
float y,
float z,
float w)
Sets the rotation to a specific Quaternion.
|
Quad3D |
rotation(float directionX,
float directionY,
float directionZ,
float upX,
float upY,
float upZ)
Sets the rotation based on a direction vector and up vector.
|
Quad3D |
rotation(com.badlogic.gdx.math.Quaternion rotation)
Sets the rotation to a specific Quaternion.
|
Quad3D |
rotation(com.badlogic.gdx.math.Vector3 axis,
float angle)
Sets the rotation to a specific angle about an axis.
|
Quad3D |
rotation(com.badlogic.gdx.math.Vector3 direction,
com.badlogic.gdx.math.Vector3 up)
Sets the rotation based on a direction vector and up vector.
|
Quad3D |
scale(float scaleX,
float scaleY) |
Quad3D |
size(float width,
float height) |
Quad3D |
texture(com.badlogic.gdx.graphics.Texture texture) |
Quad3D |
textureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion region)
Sets the texture region.
|
Quad3D |
translate(float x,
float y,
float z)
Translates the current position by the given amount.
|
Quad3D |
translate(com.badlogic.gdx.math.Vector3 amount)
Translates the current position by the given amount.
|
addVertexAttributes, flipAll, getNumberOfTextures, getTrianglesPerBatchable, getVerticesPerBatchable, populateTriangleIndices, regionTexels, reset, textureapply, prepareIndicespublic float z
public final com.badlogic.gdx.math.Quaternion rotation
public boolean opaque
public int srcBlendFactor
public int dstBlendFactor
public Quad3D()
public Quad3D(int srcBlendFactor,
int dstBlendFactor)
public Quad3D(Quad3D.Blending blending)
protected final boolean isPosition3D()
QuadOverriding this method will produce a subclass that is incompatible with a FlexBatch that was instantiated for the superclass type.
isPosition3D in class Quadprotected boolean isTextureCoordinate3D()
QuadOverriding this method will produce a subclass that is incompatible with a FlexBatch that was instantiated for the superclass type.
isTextureCoordinate3D in class Quadpublic boolean isOpaque()
isOpaque in interface SortableBatchable<Quad3D>public float calculateDistanceSquared(com.badlogic.gdx.math.Vector3 camPosition)
calculateDistanceSquared in interface SortableBatchable<Quad3D>protected void prepareSharedContext(RenderContextAccumulator renderContext)
Batchablebegin(),
executeChanges(), or end() on
renderContext, as these are handled by the FlexBatch. It should not change anything in a way that is unique to any
particular instance of this Batchable type.prepareSharedContext in class BatchablerenderContext - The FlexBatch's manager of GL state changes and texture bindings.protected boolean prepareContext(RenderContextAccumulator renderContext, int remainingVertices, int remainingTriangles)
BatchableBatchable.apply(float[], int, AttributeOffsets, int) to set render context states and texture bindings, and to
determine if a flush is necessary before this Batchable can be drawn.
Overriding this method may produce a subclass that is incompatible with a FlexBatch that was instantiated for the superclass
type.prepareContext in class QuadrenderContext - The FlexBatch's manager of GL state changes and texture bindings. Pending state changes and texture
bindings can be made on this context, and the context will return whether the context is now changed, which means
a flush is required and this method needs to return true.remainingVertices - The number of vertices that can be drawn before the next flush is required.remainingTriangles - The number of triangle indices that can be drawn before the next flush is required. This value is
undefined for Batchable.FixedSizeBatchable and should not be used or checked against.public boolean hasEquivalentTextures(Quad3D other)
hasEquivalentTextures in interface SortableBatchable<Quad3D>other - Another instance of the same class type as this one, for comparison.public void refresh()
Batchablepublic Quad3D opaque()
public Quad3D blend()
public Quad3D blend(int srcBlendFactor, int dstBlendFactor)
public Quad3D blend(Quad3D.Blending blending)
public Quad3D position(float x, float y, float z)
public Quad3D position(com.badlogic.gdx.math.Vector3 position)
public Quad3D translate(float x, float y, float z)
public Quad3D translate(com.badlogic.gdx.math.Vector3 amount)
public Quad3D rotation(com.badlogic.gdx.math.Quaternion rotation)
public Quad3D rotation(float x, float y, float z, float w)
public Quad3D rotation(com.badlogic.gdx.math.Vector3 axis, float angle)
public Quad3D rotation(float yaw, float pitch, float roll)
public Quad3D rotation(float directionX, float directionY, float directionZ, float upX, float upY, float upZ)
public Quad3D rotation(com.badlogic.gdx.math.Vector3 direction, com.badlogic.gdx.math.Vector3 up)
public Quad3D lookAt(com.badlogic.gdx.math.Vector3 position, com.badlogic.gdx.math.Vector3 up)
up - The direction the top of the quad should be pointing.public Quad3D billboard(com.badlogic.gdx.graphics.Camera camera)
public Quad3D billboard(com.badlogic.gdx.graphics.Camera camera, com.badlogic.gdx.math.Vector3 up)
up - The direction the top of the quad should be pointing.public Quad3D rotate(com.badlogic.gdx.math.Quaternion rotation)
public Quad3D rotateX(float angle)
public Quad3D rotateY(float angle)
public Quad3D rotateZ(float angle)
protected int apply(float[] vertices,
int vertexStartingIndex,
AttributeOffsets offsets,
int vertexSize)
Batchableapply in class Quadoffsets - The offsets of the vertex attributes.vertexSize - The size of a vertex in floats.Batchable.FixedSizeBatchable, as it is
assumed to match Batchable.FixedSizeBatchable.getVerticesPerBatchable().public Quad3D texture(com.badlogic.gdx.graphics.Texture texture)
public Quad3D region(float u, float v, float u2, float v2)
QuadQuad.texture(GLTexture) or Quad.textureRegion(TextureRegion). Note that TextureRegions have a Y-down coordinate
system for UVs.
This method must not be called in a Batchable that supports zero textures.
public Quad3D textureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion region)
QuadQuad.texture(GLTexture) will sequentially set the textures in order.
This method must not be called in a Batchable that supports zero textures.
textureRegion in class Quadpublic Quad3D flip(boolean flipX, boolean flipY)
QuadQuad.texture(GLTexture) or Quad.textureRegion(TextureRegion).public Quad3D rotateCoordinates90(boolean clockwise)
QuadrotateCoordinates90 in class Quad