JSR-184 Public Review Draft - Apr. 30, 2003.

javax.microedition.m3d
Class VertexArray

java.lang.Object
  |
  +--javax.microedition.m3d.Object3D
        |
        +--javax.microedition.m3d.VertexArray

public class VertexArray
extends Object3D

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

- 8 or 16 bit input
- 2 to 4 components per element
- colors: only 8 bit, 3-4 components
- normals: 8/16 bit, 3 components
- texcoords: 8/16 bit, 2-3 components
- positions: 8/16 bit, 3 components
- type determined by usage in VertexBuffer
- same values can be used in multiple roles (e.g. normals as texcoords)

See Also:
Binary format

Field Summary
 
Fields inherited from class javax.microedition.m3d.Object3D
userObject
 
Constructor Summary
VertexArray(int numVertices, int numComponents, int componentSize)
          Constructs a new VertexArray with the given dimensions.
 
Method Summary
 void set(int startIndex, int length, byte[] values)
          Copies in an array of 8-bit vertex attributes.
 void set(int startIndex, int length, short[] values)
          Copies in an array of 16-bit vertex attributes.
 
Methods inherited from class javax.microedition.m3d.Object3D
addAnimationTrack, animate, clone, find, getAnimationTrack, getAnimationTrackCount, getReferences, getUserID, removeAnimationTrack, setUserID
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 startIndex,
                int length,
                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 * length, where numComponents is either 2, 3, or 4, as specified at construction time. The source array must have at least that many elements.

Parameters:
startIndex - first vertex in this VertexArray to replace
length - number of vertices in this VertexArray to replace
values - array of 16-bit integers to copy vertex attributes from
Throws:
java.lang.IllegalStateException - if this is not a 16-bit VertexArray
java.lang.IllegalArgumentException - if values is too short
java.lang.IllegalArgumentException - if length is negative
java.lang.IndexOutOfBoundsException - if startIndex or startIndex+length is out of bounds of this VertexArray

set

public void set(int startIndex,
                int length,
                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 starting from the first element of the source array. The number of elements copied in is numComponents * length, where numComponents is either 2, 3, or 4, as specified at construction time. The source array must have at least that many elements.

Parameters:
startIndex - first vertex in this VertexArray to replace
length - number of vertices in this VertexArray to replace
values - array of 8-bit integers to copy vertex attributes from
Throws:
java.lang.IllegalStateException - if this is not an 8-bit VertexArray
java.lang.IllegalArgumentException - if values is too short
java.lang.IllegalArgumentException - if length is negative
java.lang.IndexOutOfBoundsException - if startIndex or startIndex+length is out of bounds of this VertexArray

JSR-184 Public Review Draft - Apr. 30, 2003.

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