M3G 1.1 -- Jun 22, 2005

javax.microedition.m3g
Class VertexArray

java.lang.Object
  extended byjavax.microedition.m3g.Object3D
      extended byjavax.microedition.m3g.VertexArray

public class VertexArray
extends Object3D

An array of integer vectors representing vertex positions, normals, colors, or texture coordinates.

VertexArray objects are referenced by VertexBuffer objects. Each VertexArray may be referenced by any number of VertexBuffers, or even multiple times by the same VertexBuffer. The role in which the array is referenced determines the interpretation of the vertex attributes contained in it. For example, if a VertexArray is referenced as a normal vector array, the array entries are interpreted as 3D vectors. If the same array is referenced as a texture coordinate array, the entries are interpreted as 3D points.

Certain restrictions exist on the types of data that can be used in each role. The restrictions are as follows:

See Also:
Binary format

Constructor Summary
VertexArray(int numVertices, int numComponents, int componentSize)
          Constructs a new VertexArray with the given dimensions.
 
Method Summary
 void get(int firstVertex, int numVertices, byte[] values)
          Returns a range of 8-bit vertex attributes.
 void get(int firstVertex, int numVertices, short[] values)
          Returns a range of 16-bit vertex attributes.
 int getComponentCount()
          Returns the number of components per vertex.
 int getComponentType()
          Returns the data type (size) of vertex components.
 int getVertexCount()
          Returns the number of vertices in this array.
 void set(int firstVertex, int numVertices, byte[] values)
          Copies in an array of 8-bit vertex attributes.
 void set(int firstVertex, int numVertices, short[] values)
          Copies in an array of 16-bit vertex attributes.
 
Methods inherited from class javax.microedition.m3g.Object3D
addAnimationTrack, animate, duplicate, find, getAnimationTrack, getAnimationTrackCount, getReferences, getUserID, getUserObject, removeAnimationTrack, setUserID, setUserObject
   

Constructor Detail

VertexArray

public VertexArray(int numVertices,
                   int numComponents,
                   int componentSize)

Constructs a new VertexArray with the given dimensions. The array elements are initialized to zero. The elements can be set later with either the 8-bit or the 16-bit version of the set method, depending on the component size selected here.

Parameters:
numVertices - number of vertices in this VertexArray; must be [1, 65535]
numComponents - number of components per vertex; must be [2, 4]
componentSize - number of bytes per component; must be [1, 2]
Throws:
java.lang.IllegalArgumentException - if any of the parameters are outside of their allowed ranges
Method Detail

set

public void set(int firstVertex,
                int numVertices,
                short[] values)

Copies in an array of 16-bit vertex attributes. Positions, normals, and texture coordinates can be set with this method, but colors must be set with 8-bit input. This method is available only if componentSize, specified in the constructor, is 2.

The vertex attributes are copied in starting from the first element of the source array. The number of elements copied in is numComponents * numVertices, where numComponents is either 2, 3, or 4, as specified at construction time. The source array must have at least that many elements.

Parameters:
firstVertex - index of the first vertex to replace
numVertices - number of vertices to replace
values - array of 16-bit integers to copy vertex attributes from
Throws:
java.lang.NullPointerException - if values is null
java.lang.IllegalStateException - if this is not a 16-bit VertexArray
java.lang.IllegalArgumentException - if numVertices < 0
java.lang.IllegalArgumentException - if values.length < numVertices * getComponentCount
java.lang.IndexOutOfBoundsException - if firstVertex < 0
java.lang.IndexOutOfBoundsException - if firstVertex + numVertices > getVertexCount

set

public void set(int firstVertex,
                int numVertices,
                byte[] values)

Copies in an array of 8-bit vertex attributes. All vertex attributes can be set with this method, including positions, normals, colors, and texture coordinates. This method is available only if componentSize, specified in the constructor, is 1.

The vertex attributes are copied in as specified in the other set variant.

Parameters:
firstVertex - index of the first vertex to replace
numVertices - number of vertices to replace
values - array of 8-bit integers to copy vertex attributes from
Throws:
java.lang.NullPointerException - if values is null
java.lang.IllegalStateException - if this is not an 8-bit VertexArray
java.lang.IllegalArgumentException - if numVertices < 0
java.lang.IllegalArgumentException - if values.length < numVertices * getComponentCount
java.lang.IndexOutOfBoundsException - if firstVertex < 0
java.lang.IndexOutOfBoundsException - if firstVertex + numVertices > getVertexCount

getVertexCount

public int getVertexCount()
Returns the number of vertices in this array.

Returns:
the number of vertices
Since:
M3G 1.1

getComponentCount

public int getComponentCount()
Returns the number of components per vertex.

Returns:
the number of components
Since:
M3G 1.1

getComponentType

public int getComponentType()
Returns the data type (size) of vertex components.

Returns:
the number of bytes per component; 1 for bytes, 2 for shorts
Since:
M3G 1.1

get

public void get(int firstVertex,
                int numVertices,
                short[] values)
Returns a range of 16-bit vertex attributes. The values are returned in the same format as in the respective set method.

Parameters:
firstVertex - index of the first vertex to get
numVertices - number of vertices to get
values - array of 16-bit integers to copy vertex attributes to
Throws:
java.lang.NullPointerException - if values is null
java.lang.IllegalStateException - if this is not a 16-bit VertexArray
java.lang.IllegalArgumentException - if numVertices < 0
java.lang.IllegalArgumentException - if values.length < numVertices * getComponentCount
java.lang.IndexOutOfBoundsException - if firstVertex < 0
java.lang.IndexOutOfBoundsException - if firstVertex + numVertices > getVertexCount
Since:
M3G 1.1

get

public void get(int firstVertex,
                int numVertices,
                byte[] values)
Returns a range of 8-bit vertex attributes. The values are returned in the same format as in the respective set method.

Parameters:
firstVertex - index of the first vertex to get
numVertices - number of vertices to get
values - array of 8-bit integers to copy vertex attributes to
Throws:
java.lang.NullPointerException - if values is null
java.lang.IllegalStateException - if this is not an 8-bit VertexArray
java.lang.IllegalArgumentException - if numVertices < 0
java.lang.IllegalArgumentException - if values.length < numVertices * getComponentCount
java.lang.IndexOutOfBoundsException - if firstVertex < 0
java.lang.IndexOutOfBoundsException - if firstVertex + numVertices > getVertexCount
Since:
M3G 1.1

M3G 1.1 -- Jun 22, 2005

Copyright © 2005 Nokia Corporation. See the Copyright Notice for details.