Class Attribute

java.lang.Object
gaiasky.util.gdx.shader.attribute.Attribute
All Implemented Interfaces:
Comparable<Attribute>
Direct Known Subclasses:
BlendingAttribute, ColorAttribute, CubemapAttribute, DepthTestAttribute, DirectionalLightsAttribute, FloatAttribute, IntAttribute, Matrix3Attribute, Matrix4Attribute, PointLightsAttribute, SpotLightsAttribute, TextureAttribute, Vector2Attribute, Vector3Attribute, Vector4Attribute

public abstract class Attribute extends Object implements Comparable<Attribute>
Extend this class to implement a material attribute. Register the attribute type by statically calling the register(String) method, whose return value should be used to instantiate the attribute. A class can implement multiple types.

Modified to use Bits instead of a long to store the attribute types. A long only allows for 64 attributes, while the solution implemented here enables an unlimited number of them.

  • Field Details

    • type

      public final Bits type
      The type of this attribute
    • index

      public final int index
  • Constructor Details

    • Attribute

      protected Attribute(int index)
  • Method Details

    • getAttributeType

      public static final Bits getAttributeType(String alias)
      Returns:
      The ID of the specified attribute type, or zero if not available
    • getAttributeAlias

      public static final String getAttributeAlias(Bits type)
      Returns:
      The alias of the specified attribute type, or null if not available.
    • getAttributeIndex

      public static final int getAttributeIndex(Bits type)
      Returns:
      The index of the specified attribute type, or -1 if not available.
    • getAttributeIndex

      public static final int getAttributeIndex(String alias)
      Returns:
      The index of the specified attribute alias, or -1 if not available.
    • register

      protected static final int register(String alias)
      Call this method to register a custom attribute type, see the wiki for an example. If the alias already exists, then that ID will be reused. The alias should be unambiguous and will by default be returned by the call to toString().
      Parameters:
      alias - The alias of the type to register, must be different for each direct type, will be used for debugging.
      Returns:
      the index of the newly registered type, or the index of the existing type if the alias was already registered.
    • getNumAttributes

      public static int getNumAttributes()
    • getTypes

      public static com.badlogic.gdx.utils.Array<String> getTypes()
    • has

      public boolean has(int index)
    • copy

      public abstract Attribute copy()
      Returns:
      An exact copy of this attribute
    • equals

      protected boolean equals(Attribute other)
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object