Package com.badlogic.gdx.graphics
Class VertexAttribute
- java.lang.Object
-
- com.badlogic.gdx.graphics.VertexAttribute
-
public final class VertexAttribute extends java.lang.Object
A single vertex attribute defined by itsVertexAttributes.Usage
, its number of components and its shader alias. The Usage is used for uniquely identifying the vertex attribute from among its VertexAttributes siblings. The number of components defines how many components the attribute has. The alias defines to which shader attribute this attribute should bind. The alias is used by aMesh
when drawing with aShaderProgram
. The alias can be changed at any time.
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.String
alias
the alias for the attribute used in aShaderProgram
boolean
normalized
For fixed types, whether the values are normalized to either -1f and +1f (signed) or 0f and +1f (unsigned)int
numComponents
the number of components this attribute hasint
offset
the offset of this attribute in bytes, don't change this!int
type
the OpenGL type of each component, e.g.int
unit
optional unit/index specifier, used for texture coordinates and bone weightsint
usage
The attributeVertexAttributes.Usage
, used for identification.
-
Constructor Summary
Constructors Constructor Description VertexAttribute(int usage, int numComponents, int type, boolean normalized, java.lang.String alias)
Constructs a new VertexAttribute.VertexAttribute(int usage, int numComponents, int type, boolean normalized, java.lang.String alias, int unit)
Constructs a new VertexAttribute.VertexAttribute(int usage, int numComponents, java.lang.String alias)
Constructs a new VertexAttribute.VertexAttribute(int usage, int numComponents, java.lang.String alias, int unit)
Constructs a new VertexAttribute.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static VertexAttribute
Binormal()
static VertexAttribute
BoneWeight(int unit)
static VertexAttribute
ColorPacked()
static VertexAttribute
ColorUnpacked()
VertexAttribute
copy()
boolean
equals(VertexAttribute other)
boolean
equals(java.lang.Object obj)
Tests to determine if the passed object was created with the same parametersint
getKey()
int
getSizeInBytes()
int
hashCode()
static VertexAttribute
Normal()
static VertexAttribute
Position()
static VertexAttribute
Tangent()
static VertexAttribute
TexCoords(int unit)
-
-
-
Field Detail
-
usage
public final int usage
The attributeVertexAttributes.Usage
, used for identification.
-
numComponents
public final int numComponents
the number of components this attribute has
-
normalized
public final boolean normalized
For fixed types, whether the values are normalized to either -1f and +1f (signed) or 0f and +1f (unsigned)
-
type
public final int type
the OpenGL type of each component, e.g.GL20.GL_FLOAT
orGL20.GL_UNSIGNED_BYTE
-
offset
public int offset
the offset of this attribute in bytes, don't change this!
-
alias
public java.lang.String alias
the alias for the attribute used in aShaderProgram
-
unit
public int unit
optional unit/index specifier, used for texture coordinates and bone weights
-
-
Constructor Detail
-
VertexAttribute
public VertexAttribute(int usage, int numComponents, java.lang.String alias)
Constructs a new VertexAttribute. The GL data type is automatically selected based on the usage.- Parameters:
usage
- The attributeVertexAttributes.Usage
, used to select thetype
and for identification.numComponents
- the number of components of this attribute, must be between 1 and 4.alias
- the alias used in a shader for this attribute. Can be changed after construction.
-
VertexAttribute
public VertexAttribute(int usage, int numComponents, java.lang.String alias, int unit)
Constructs a new VertexAttribute. The GL data type is automatically selected based on the usage.- Parameters:
usage
- The attributeVertexAttributes.Usage
, used to select thetype
and for identification.numComponents
- the number of components of this attribute, must be between 1 and 4.alias
- the alias used in a shader for this attribute. Can be changed after construction.unit
- Optional unit/index specifier, used for texture coordinates and bone weights
-
VertexAttribute
public VertexAttribute(int usage, int numComponents, int type, boolean normalized, java.lang.String alias)
Constructs a new VertexAttribute.- Parameters:
usage
- The attributeVertexAttributes.Usage
, used for identification.numComponents
- the number of components of this attribute, must be between 1 and 4.type
- the OpenGL type of each component, e.g.GL20.GL_FLOAT
orGL20.GL_UNSIGNED_BYTE
. SinceMesh
stores vertex data in 32bit floats, the total size of this attribute (type size times number of components) must be a multiple of four.normalized
- For fixed types, whether the values are normalized to either -1f and +1f (signed) or 0f and +1f (unsigned)alias
- The alias used in a shader for this attribute. Can be changed after construction.
-
VertexAttribute
public VertexAttribute(int usage, int numComponents, int type, boolean normalized, java.lang.String alias, int unit)
Constructs a new VertexAttribute.- Parameters:
usage
- The attributeVertexAttributes.Usage
, used for identification.numComponents
- the number of components of this attribute, must be between 1 and 4.type
- the OpenGL type of each component, e.g.GL20.GL_FLOAT
orGL20.GL_UNSIGNED_BYTE
. SinceMesh
stores vertex data in 32bit floats, the total size of this attribute (type size times number of components) must be a multiple of four bytes.normalized
- For fixed types, whether the values are normalized to either -1f and +1f (signed) or 0f and +1f (unsigned)alias
- The alias used in a shader for this attribute. Can be changed after construction.unit
- Optional unit/index specifier, used for texture coordinates and bone weights
-
-
Method Detail
-
copy
public VertexAttribute copy()
- Returns:
- A copy of this VertexAttribute with the same parameters. The
offset
is not copied and must be recalculated, as is typically done by the VertexAttributes that owns the VertexAttribute.
-
Position
public static VertexAttribute Position()
-
TexCoords
public static VertexAttribute TexCoords(int unit)
-
Normal
public static VertexAttribute Normal()
-
ColorPacked
public static VertexAttribute ColorPacked()
-
ColorUnpacked
public static VertexAttribute ColorUnpacked()
-
Tangent
public static VertexAttribute Tangent()
-
Binormal
public static VertexAttribute Binormal()
-
BoneWeight
public static VertexAttribute BoneWeight(int unit)
-
equals
public boolean equals(java.lang.Object obj)
Tests to determine if the passed object was created with the same parameters- Overrides:
equals
in classjava.lang.Object
-
equals
public boolean equals(VertexAttribute other)
-
getKey
public int getKey()
- Returns:
- A unique number specifying the usage index (3 MSB) and unit (1 LSB).
-
getSizeInBytes
public int getSizeInBytes()
- Returns:
- How many bytes this attribute uses.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-