Class VertexAttribute


  • public final class VertexAttribute
    extends java.lang.Object
    A single vertex attribute defined by its VertexAttributes.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 a Mesh when drawing with a ShaderProgram. The alias can be changed at any time.
    • Field Detail

      • 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)
      • 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 a ShaderProgram
      • 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 attribute VertexAttributes.Usage, used to select the type 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 attribute VertexAttributes.Usage, used to select the type 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 attribute VertexAttributes.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 or GL20.GL_UNSIGNED_BYTE. Since Mesh 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 attribute VertexAttributes.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 or GL20.GL_UNSIGNED_BYTE. Since Mesh 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.
      • equals

        public boolean equals​(java.lang.Object obj)
        Tests to determine if the passed object was created with the same parameters
        Overrides:
        equals in class java.lang.Object
      • 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 class java.lang.Object