Package com.badlogic.gdx.graphics.g3d
Class Attributes
- java.lang.Object
-
- com.badlogic.gdx.graphics.g3d.Attributes
-
- All Implemented Interfaces:
java.lang.Comparable<Attributes>,java.lang.Iterable<Attribute>,java.util.Comparator<Attribute>
- Direct Known Subclasses:
Environment,Material
public class Attributes extends java.lang.Object implements java.lang.Iterable<Attribute>, java.util.Comparator<Attribute>, java.lang.Comparable<Attributes>
-
-
Field Summary
Fields Modifier and Type Field Description protected Array<Attribute>attributesprotected longmaskprotected booleansorted
-
Constructor Summary
Constructors Constructor Description Attributes()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intattributesHash()voidclear()Removes all attributesintcompare(Attribute arg0, Attribute arg1)Used for sorting attributes by type (not by value)intcompareTo(Attributes other)booleanequals(java.lang.Object other)Attributeget(long type)Example usage: ((BlendingAttribute)material.get(BlendingAttribute.ID)).sourceFunction;Array<Attribute>get(Array<Attribute> out, long type)Get multiple attributes at once.<T extends Attribute>
Tget(java.lang.Class<T> clazz, long type)Example usage: ((BlendingAttribute)material.get(BlendingAttribute.ID)).sourceFunction;longgetMask()booleanhas(long type)inthashCode()protected intindexOf(long type)java.util.Iterator<Attribute>iterator()Used for iterating through the attributesvoidremove(long mask)Removes the attribute from the material, i.e.: material.remove(BlendingAttribute.ID); Can also be used to remove multiple attributes also, i.e.booleansame(Attributes other)booleansame(Attributes other, boolean compareValues)Check if this collection has the same attributes as the other collection.voidset(Attribute attribute)Add a attribute to this material.voidset(Attribute... attributes)Add an array of attributes to this material.voidset(Attribute attribute1, Attribute attribute2)Add multiple attributes to this material.voidset(Attribute attribute1, Attribute attribute2, Attribute attribute3)Add multiple attributes to this material.voidset(Attribute attribute1, Attribute attribute2, Attribute attribute3, Attribute attribute4)Add multiple attributes to this material.voidset(java.lang.Iterable<Attribute> attributes)Add an array of attributes to this material.intsize()voidsort()Sort the attributes by their ID-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Method Detail
-
sort
public final void sort()
Sort the attributes by their ID
-
getMask
public final long getMask()
- Returns:
- Bitwise mask of the ID's of all the containing attributes
-
get
public final Attribute get(long type)
Example usage: ((BlendingAttribute)material.get(BlendingAttribute.ID)).sourceFunction;- Returns:
- The attribute (which can safely be cast) if any, otherwise null
-
get
public final <T extends Attribute> T get(java.lang.Class<T> clazz, long type)
Example usage: ((BlendingAttribute)material.get(BlendingAttribute.ID)).sourceFunction;- Returns:
- The attribute if any, otherwise null
-
get
public final Array<Attribute> get(Array<Attribute> out, long type)
Get multiple attributes at once. Example: material.get(out, ColorAttribute.Diffuse | ColorAttribute.Specular | TextureAttribute.Diffuse);
-
clear
public void clear()
Removes all attributes
-
size
public int size()
- Returns:
- The amount of attributes this material contains.
-
set
public final void set(Attribute attribute)
Add a attribute to this material. If the material already contains an attribute of the same type it is overwritten.
-
set
public final void set(Attribute attribute1, Attribute attribute2)
Add multiple attributes to this material. If the material already contains an attribute of the same type it is overwritten.
-
set
public final void set(Attribute attribute1, Attribute attribute2, Attribute attribute3)
Add multiple attributes to this material. If the material already contains an attribute of the same type it is overwritten.
-
set
public final void set(Attribute attribute1, Attribute attribute2, Attribute attribute3, Attribute attribute4)
Add multiple attributes to this material. If the material already contains an attribute of the same type it is overwritten.
-
set
public final void set(Attribute... attributes)
Add an array of attributes to this material. If the material already contains an attribute of the same type it is overwritten.
-
set
public final void set(java.lang.Iterable<Attribute> attributes)
Add an array of attributes to this material. If the material already contains an attribute of the same type it is overwritten.
-
remove
public final void remove(long mask)
Removes the attribute from the material, i.e.: material.remove(BlendingAttribute.ID); Can also be used to remove multiple attributes also, i.e. remove(AttributeA.ID | AttributeB.ID);
-
has
public final boolean has(long type)
- Returns:
- True if this collection has the specified attribute, i.e. attributes.has(ColorAttribute.Diffuse); Or when multiple attribute types are specified, true if this collection has all specified attributes, i.e. attributes.has(out, ColorAttribute.Diffuse | ColorAttribute.Specular | TextureAttribute.Diffuse);
-
indexOf
protected int indexOf(long type)
- Returns:
- the index of the attribute with the specified type or negative if not available.
-
same
public final boolean same(Attributes other, boolean compareValues)
Check if this collection has the same attributes as the other collection. If compareValues is true, it also compares the values of each attribute.- Parameters:
compareValues- True to compare attribute values, false to only compare attribute types- Returns:
- True if this collection contains the same attributes (and optionally attribute values) as the other.
-
same
public final boolean same(Attributes other)
- Returns:
- True if this collection contains the same attributes (but not values) as the other.
-
compare
public final int compare(Attribute arg0, Attribute arg1)
Used for sorting attributes by type (not by value)- Specified by:
comparein interfacejava.util.Comparator<Attribute>
-
iterator
public final java.util.Iterator<Attribute> iterator()
Used for iterating through the attributes- Specified by:
iteratorin interfacejava.lang.Iterable<Attribute>
-
attributesHash
public int attributesHash()
- Returns:
- A hash code based on only the attribute values, which might be different compared to
hashCode()because the latter might include other properties as well, i.e. the material id.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Specified by:
equalsin interfacejava.util.Comparator<Attribute>- Overrides:
equalsin classjava.lang.Object
-
compareTo
public int compareTo(Attributes other)
- Specified by:
compareToin interfacejava.lang.Comparable<Attributes>
-
-