org.openmali.vecmath2
Class TexCoordf<T extends TexCoordf<T>>

java.lang.Object
  extended by org.openmali.vecmath2.TexCoordf<T>
Direct Known Subclasses:
TexCoord1f, TexCoord2f, TexCoord3f, TexCoord4f

public abstract class TexCoordf<T extends TexCoordf<T>>
extends java.lang.Object

A simple abstract Texture-Coordinate.
The order is (s, t, p, q).


Field Summary
protected  boolean isDirty
           
protected  int N
           
protected  int roTrick
           
protected  float[] values
           
 
Constructor Summary
TexCoordf(boolean readOnly, float[] values)
          Creates a new TexCoord1f instance.
TexCoordf(float[] values)
          Creates a new TexCoord1f instance.
 
Method Summary
 T add(T texCoord2)
          Sets the value of this tuple to the vector sum of itself and tuple t1.
 T add(T texCoord1, T texCoord2)
          Sets the value of this texCoord to the vector sum of colors texCoord1 and texCoord2.
 T clamp(float min, float max)
          Clamps this tuple to the range [min, max].
 T clamp(float min, float max, T vec)
          Clamps the tuple parameter to the range [min, max] and places the values into this tuple.
 T clampMax(float max)
          Clamps the maximum value of this tuple to the max parameter.
 T clampMax(float max, T vec)
          Clamps the maximum value of the tuple parameter to the max parameter and places the values into this tuple.
 T clampMin(float min)
          Clamps the minimum value of this tuple to the min parameter.
 T clampMin(float min, T vec)
          Clamps the minimum value of the tuple parameter to the min parameter and places the values into this tuple.
 int deserialize(int pos, byte[] buffer)
          Deserializes this instanc'es data from the byte array.
 boolean epsilonEquals(T texCoord2, float epsilon)
          Returns true if the L-infinite distance between this tuple and tuple t1 is less than or equal to the epsilon parameter, otherwise returns false.
 boolean equals(java.lang.Object o)
          Returns true if the Object t1 is of type Tuple3f and all of the data members of t1 are equal to the corresponding data members in this Tuple3f.
 boolean equals(TexCoordf<?> texCoord2)
          Returns true if all of the data members of Tuple3f t1 are equal to the corresponding data members in this
 void get(float[] buffer)
          Writes all values of this Tuple to the specified buffer.
 void get(float[] buffer, int offset)
          Writes all values of this Tuple to the specified buffer.
 void get(T buffer)
          Writes all values of this vector to the specified buffer vector.
protected  int getSerializationBufferSize()
           
 int getSize()
           
 int hashCode()
          Returns a hash number based on the data values in this object.
 void interpolate(T texCoord2, float alpha)
          Linearly interpolates between this tuple and tuple t2 and places the result into this tuple: this = (1 - alpha) * this + alpha * t1.
 void interpolate(T texCoord1, T texCoord2, float alpha)
          Linearly interpolates between tuples t1 and t2 and places the result into this tuple: this = (1 - alpha) * t1 + alpha * t2.
 boolean isDirty()
           
 boolean isReadOnly()
           
protected static float[] newArray(float[] template, int length)
           
 void readExternal(java.io.ObjectInput in)
           
 java.nio.FloatBuffer readFromBuffer(java.nio.FloatBuffer buffer)
          Reads the contents of this TexCoords from a FloatBuffer.
 java.nio.FloatBuffer readFromBuffer(java.nio.FloatBuffer buffer, int position)
          Reads the contents of this TexCoords from a FloatBuffer.
static java.nio.FloatBuffer readFromBuffer(TexCoordf<?>[] texCoords, java.nio.FloatBuffer buffer)
          Reads the contents of this TexCoords from a FloatBuffer.
static java.nio.FloatBuffer readFromBuffer(TexCoordf<?>[] texCoords, java.nio.FloatBuffer buffer, int position)
          Reads the contents of this TexCoords from a FloatBuffer.
 T scaleAdd(float factor, T texCoord2)
          Sets the value of this tuple to the scalar multiplication of itself and then adds tuple t1 (this = s*this + t1).
 T scaleAdd(float factor, T texCoord1, T texCoord2)
          Sets the value of this tuple to the scalar multiplication of tuple t1 and then adds tuple t2 (this = s*t1 + t2).
 int serialize(int pos, byte[] buffer)
          Serializes this instanc'es data into the byte array.
 T set(float[] values)
          Sets all values of this TexCoord to the specified ones.
 T set(float[] values, int offset)
          Sets all values of this TexCoord to the specified ones.
 T set(T texCoord)
          Sets all values of this Tuple to the specified ones.
 boolean setClean()
          Marks this tuple non-dirty.
 T setZero()
          Sets all components to zero.
 T sub(T texCoord2)
          Sets the value of this texCoord to the vector difference of itself and texCoord2 (this = this - texCoord2).
 T sub(T texCoord1, T texCoord2)
          Sets the value of this texCoord to the vector difference of texCoord texCoord1 and texCoord2 (this = texCoord1 - texCoord2).
 java.lang.String toString()
          Returns a string that contains the values of this TexCoordf.
 void writeExternal(java.io.ObjectOutput out)
           
 java.nio.FloatBuffer writeToBuffer(java.nio.FloatBuffer buffer, boolean clear, boolean flip)
          Writes the contents of this TexCoords to a FloatBuffer.
 java.nio.FloatBuffer writeToBuffer(java.nio.FloatBuffer buffer, int position, boolean clear, boolean flip)
          Writes the contents of this TexCoords to a FloatBuffer.
static java.nio.FloatBuffer writeToBuffer(TexCoordf<?>[] texCoords, java.nio.FloatBuffer buffer, boolean clear, boolean flip)
          Writes the contents of this TexCoords to a FloatBuffer.
static java.nio.FloatBuffer writeToBuffer(TexCoordf<?>[] texCoords, java.nio.FloatBuffer buffer, int position, boolean clear, boolean flip)
          Writes the contents of this TexCoords to a FloatBuffer.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

N

protected final int N

values

protected final float[] values

roTrick

protected final int roTrick

isDirty

protected boolean isDirty
Constructor Detail

TexCoordf

public TexCoordf(boolean readOnly,
                 float[] values)
Creates a new TexCoord1f instance.

Parameters:
values - the values array (must be at least size 1)

TexCoordf

public TexCoordf(float[] values)
Creates a new TexCoord1f instance.

Parameters:
values - the values array (must be at least size 1)
Method Detail

isReadOnly

public final boolean isReadOnly()
Returns:
Is this tuple a read-only one?

setClean

public final boolean setClean()
Marks this tuple non-dirty. Any value-manipulation will mark it dirty again.

Returns:
the old value

isDirty

public final boolean isDirty()
Returns:
This tuple's dirty-flag

getSize

public final int getSize()
Returns:
this Vector's size().

set

public final T set(float[] values,
                   int offset)
Sets all values of this TexCoord to the specified ones.

Parameters:
values - the values array (must be at least size n)
offset - the offset in the (source) values array
Returns:
itself

set

public final T set(float[] values)
Sets all values of this TexCoord to the specified ones.

Parameters:
values - the values array (must be at least size 1)
Returns:
itself

set

public final T set(T texCoord)
Sets all values of this Tuple to the specified ones.

Parameters:
texCoord - the texCoord to be copied
Returns:
itself

get

public final void get(float[] buffer,
                      int offset)
Writes all values of this Tuple to the specified buffer.

Parameters:
buffer - the buffer array to write the values to
offset - the offset in the (target) buffer array

get

public final void get(float[] buffer)
Writes all values of this Tuple to the specified buffer.

Parameters:
buffer - the buffer array to write the values to

get

public final void get(T buffer)
Writes all values of this vector to the specified buffer vector.

Parameters:
buffer - the buffer vector to write the values to

writeToBuffer

public final java.nio.FloatBuffer writeToBuffer(java.nio.FloatBuffer buffer,
                                                boolean clear,
                                                boolean flip)
Writes the contents of this TexCoords to a FloatBuffer.

Parameters:
buffer -
clear - clear the buffer before writing data?
flip - flip the buffer after writing data?

writeToBuffer

public final java.nio.FloatBuffer writeToBuffer(java.nio.FloatBuffer buffer,
                                                int position,
                                                boolean clear,
                                                boolean flip)
Writes the contents of this TexCoords to a FloatBuffer.

Parameters:
buffer -
position - position in the buffer
clear - clear the buffer before writing data?
flip - flip the buffer after writing data?

writeToBuffer

public static final java.nio.FloatBuffer writeToBuffer(TexCoordf<?>[] texCoords,
                                                       java.nio.FloatBuffer buffer,
                                                       boolean clear,
                                                       boolean flip)
Writes the contents of this TexCoords to a FloatBuffer.

Parameters:
buffer -
clear - clear the buffer before writing data?
flip - flip the buffer after writing data?

writeToBuffer

public static final java.nio.FloatBuffer writeToBuffer(TexCoordf<?>[] texCoords,
                                                       java.nio.FloatBuffer buffer,
                                                       int position,
                                                       boolean clear,
                                                       boolean flip)
Writes the contents of this TexCoords to a FloatBuffer.

Parameters:
buffer -
position - position in the buffer
clear - clear the buffer before writing data?
flip - flip the buffer after writing data?

readFromBuffer

public final java.nio.FloatBuffer readFromBuffer(java.nio.FloatBuffer buffer)
Reads the contents of this TexCoords from a FloatBuffer.

Parameters:
buffer -

readFromBuffer

public final java.nio.FloatBuffer readFromBuffer(java.nio.FloatBuffer buffer,
                                                 int position)
Reads the contents of this TexCoords from a FloatBuffer.

Parameters:
buffer -
position - position in the buffer

readFromBuffer

public static final java.nio.FloatBuffer readFromBuffer(TexCoordf<?>[] texCoords,
                                                        java.nio.FloatBuffer buffer)
Reads the contents of this TexCoords from a FloatBuffer.

Parameters:
buffer -

readFromBuffer

public static final java.nio.FloatBuffer readFromBuffer(TexCoordf<?>[] texCoords,
                                                        java.nio.FloatBuffer buffer,
                                                        int position)
Reads the contents of this TexCoords from a FloatBuffer.

Parameters:
buffer -
position - position in the buffer

setZero

public final T setZero()
Sets all components to zero.

Returns:
itself

add

public final T add(T texCoord1,
                   T texCoord2)
Sets the value of this texCoord to the vector sum of colors texCoord1 and texCoord2.

Parameters:
texCoord1 - the first texCoord
texCoord2 - the second texCoord
Returns:
itself

add

public final T add(T texCoord2)
Sets the value of this tuple to the vector sum of itself and tuple t1.

Parameters:
texCoord2 - the other tuple
Returns:
itself

sub

public final T sub(T texCoord1,
                   T texCoord2)
Sets the value of this texCoord to the vector difference of texCoord texCoord1 and texCoord2 (this = texCoord1 - texCoord2).

Parameters:
texCoord1 - the first texCoord
texCoord2 - the second texCoord
Returns:
itself

sub

public final T sub(T texCoord2)
Sets the value of this texCoord to the vector difference of itself and texCoord2 (this = this - texCoord2).

Parameters:
texCoord2 - the other texCoord
Returns:
itself

scaleAdd

public final T scaleAdd(float factor,
                        T texCoord1,
                        T texCoord2)
Sets the value of this tuple to the scalar multiplication of tuple t1 and then adds tuple t2 (this = s*t1 + t2).

Parameters:
factor - the scalar value
texCoord1 - the tuple to be multipled
texCoord2 - the tuple to be added
Returns:
itself

scaleAdd

public final T scaleAdd(float factor,
                        T texCoord2)
Sets the value of this tuple to the scalar multiplication of itself and then adds tuple t1 (this = s*this + t1).

Parameters:
factor - the scalar value
texCoord2 - the tuple to be added
Returns:
itself

clampMin

public final T clampMin(float min)
Clamps the minimum value of this tuple to the min parameter.

Parameters:
min - the lowest value in this tuple after clamping
Returns:
itself

clampMax

public final T clampMax(float max)
Clamps the maximum value of this tuple to the max parameter.

Parameters:
max - the highest value in the tuple after clamping
Returns:
itself

clamp

public final T clamp(float min,
                     float max)
Clamps this tuple to the range [min, max].

Parameters:
min - the lowest value in this tuple after clamping
max - the highest value in this tuple after clamping
Returns:
itself

clamp

public final T clamp(float min,
                     float max,
                     T vec)
Clamps the tuple parameter to the range [min, max] and places the values into this tuple.

Parameters:
min - the lowest value in the tuple after clamping
max - the highest value in the tuple after clamping
vec - the source tuple, which will not be modified
Returns:
itself

clampMin

public final T clampMin(float min,
                        T vec)
Clamps the minimum value of the tuple parameter to the min parameter and places the values into this tuple.

Parameters:
min - the lowest value in the tuple after clamping
vec - the source tuple, which will not be modified
Returns:
itself

clampMax

public final T clampMax(float max,
                        T vec)
Clamps the maximum value of the tuple parameter to the max parameter and places the values into this tuple.

Parameters:
max - the highest value in the tuple after clamping
vec - the source tuple, which will not be modified
Returns:
itself

interpolate

public final void interpolate(T texCoord2,
                              float alpha)
Linearly interpolates between this tuple and tuple t2 and places the result into this tuple: this = (1 - alpha) * this + alpha * t1.

Parameters:
texCoord2 - the first tuple
alpha - the alpha interpolation parameter

interpolate

public final void interpolate(T texCoord1,
                              T texCoord2,
                              float alpha)
Linearly interpolates between tuples t1 and t2 and places the result into this tuple: this = (1 - alpha) * t1 + alpha * t2.

Parameters:
texCoord1 - the first tuple
texCoord2 - the second tuple
alpha - the interpolation parameter

hashCode

public int hashCode()
Returns a hash number based on the data values in this object. Two different Tuple3f objects with identical data values (ie, returns true for equals(Tuple3f) ) will return the same hash number. Two vectors with different data members may return the same hash value, although this is not likely.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(TexCoordf<?> texCoord2)
Returns true if all of the data members of Tuple3f t1 are equal to the corresponding data members in this

Parameters:
texCoord2 - the texCoord with which the comparison is made.

equals

public boolean equals(java.lang.Object o)
Returns true if the Object t1 is of type Tuple3f and all of the data members of t1 are equal to the corresponding data members in this Tuple3f.

Overrides:
equals in class java.lang.Object
Parameters:
o - the Object with which the comparison is made
Returns:
true or false

epsilonEquals

public boolean epsilonEquals(T texCoord2,
                             float epsilon)
Returns true if the L-infinite distance between this tuple and tuple t1 is less than or equal to the epsilon parameter, otherwise returns false. The L-infinite distance is equal to MAX[abs(x1-x2), abs(y1-y2)].

Parameters:
texCoord2 - the texCoord to be compared to this texCoord
epsilon - the threshold value

toString

public java.lang.String toString()
Returns a string that contains the values of this TexCoordf. The form is ( S = s, T = t, blue = p, Q = q ).

Overrides:
toString in class java.lang.Object
Returns:
the String representation

newArray

protected static final float[] newArray(float[] template,
                                        int length)

serialize

public int serialize(int pos,
                     byte[] buffer)
Serializes this instanc'es data into the byte array.

Parameters:
pos -
buffer -
Returns:
the incremented position

deserialize

public int deserialize(int pos,
                       byte[] buffer)
Deserializes this instanc'es data from the byte array.

Parameters:
pos -
buffer -
Returns:
the incremented position

getSerializationBufferSize

protected int getSerializationBufferSize()
Returns:
the necessary size for a serialization byte array.

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException