com.threed.jpct
Class VertexAttributes

java.lang.Object
  extended bycom.threed.jpct.VertexAttributes

public class VertexAttributes
extends java.lang.Object

This class can be used to assign additional vertex attributes to meshes. This is only useful when using shaders. You can still assign them when not using shaders, but all it does is to consume memory and processing power. The attributes will be injected into the shader used by an object that uses this mesh, if the shader provides an attribute variable with the correct name.


Field Summary
static int TYPE_FOUR_FLOATS
          Type for assigning four floats to each vertex
static int TYPE_SINGLE_FLOATS
          Type for assigning a single float to each vertex
static int TYPE_THREE_FLOATS
          Type for assigning three floats to each vertex
static int TYPE_TWO_FLOATS
          Type for assigning two floats to each vertex
 
Constructor Summary
VertexAttributes(java.lang.String name, float[] data, int type)
          Cretes new vertex attributes.
 
Method Summary
 java.lang.String getName()
          Returns the name of the vertex attributes in your shader's code.
 int getType()
          Returns the type, i.e. the number of floats per vertex (1 to 4)
 boolean isDynamic()
          Are these attributes dynamic?
 boolean matches(int vertexCount)
          Returns true, if these vertex attributes are matching a given vertex count, i.e. if these attributes can be used on a mesh with that vertex count.
 void setDynamic(boolean dynamic)
          Sets these attributes as dynamic, i.e. you are allowed to update their data.
 void update(float[] data, int start)
          Updates the attributes' data.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_SINGLE_FLOATS

public static final int TYPE_SINGLE_FLOATS
Type for assigning a single float to each vertex

See Also:
Constant Field Values

TYPE_TWO_FLOATS

public static final int TYPE_TWO_FLOATS
Type for assigning two floats to each vertex

See Also:
Constant Field Values

TYPE_THREE_FLOATS

public static final int TYPE_THREE_FLOATS
Type for assigning three floats to each vertex

See Also:
Constant Field Values

TYPE_FOUR_FLOATS

public static final int TYPE_FOUR_FLOATS
Type for assigning four floats to each vertex

See Also:
Constant Field Values
Constructor Detail

VertexAttributes

public VertexAttributes(java.lang.String name,
                        float[] data,
                        int type)
Cretes new vertex attributes. Once created, you can add them to an Object3D's Mesh instance.

Parameters:
name - the name. This is the name the attribute in your shader has to have.
data - the data
type - the type, i.e. the number of floats per vertex (1 to 4)
Method Detail

isDynamic

public boolean isDynamic()
Are these attributes dynamic? Dynamic attributes can be changed at runtime, but processing can be slower if they will be updated a lot. Default is false. If this is true, the Object3D has be compiled as dynamic to actually see the updated attributes.

Returns:
is it dynamic

setDynamic

public void setDynamic(boolean dynamic)
Sets these attributes as dynamic, i.e. you are allowed to update their data. Updating vertex attributes often can slow down your app.

Parameters:
dynamic - dynamic or not?

update

public void update(float[] data,
                   int start)
Updates the attributes' data. This is allowed only if setDynamic(true); has been called before. Otherwise, it will raise an error. It's possible to update only a fraction of the data.

Parameters:
data - the new data
start - the start index of the data.

matches

public boolean matches(int vertexCount)
Returns true, if these vertex attributes are matching a given vertex count, i.e. if these attributes can be used on a mesh with that vertex count. If this method returns false, you can't assign this instance to a mesh with that vertex count.

Parameters:
vertexCount - the vertex count
Returns:
does it match?

getType

public int getType()
Returns the type, i.e. the number of floats per vertex (1 to 4)

Returns:
the type

getName

public java.lang.String getName()
Returns the name of the vertex attributes in your shader's code.

Returns:
the name