M3G 1.1 -- Jun 22, 2005

javax.microedition.m3g
Class IndexBuffer

java.lang.Object
  extended byjavax.microedition.m3g.Object3D
      extended byjavax.microedition.m3g.IndexBuffer
Direct Known Subclasses:
TriangleStripArray

public abstract class IndexBuffer
extends Object3D

An abstract class defining how to connect vertices to form a geometric object.

Each IndexBuffer object defines a submesh, which is the basic rendering primitive in this API. In order to be rendered, a submesh must be associated with a VertexBuffer, defining the vertex attributes, and an Appearance, defining the surface attributes.

IndexBuffer is an abstract class that only provides functionality for querying the stored vertex indices. The actual index values as well as their interpretation are defined in each derived class. Currently, there is only one derived class, TriangleStripArray, which defines a submesh consisting of triangle strips. Other derived classes may be added in future revisions of this API, to support, for example, triangle lists, triangle fans, line strips and quad strips.

Deferred exceptions

The indices in an IndexBuffer are only validated when rendering or picking. An exception is thrown by the render methods in Graphics3D and the pick methods in Group, if any of the indices are greater than or equal to the number of vertices in the associated VertexBuffer. The indices cannot be validated earlier, because they are allowed to be invalid at all other times except when they are used by the implementation, that is, when rendering or picking.

See Also:
Binary format

Method Summary
 int getIndexCount()
          Returns the number of indices in this buffer.
 void getIndices(int[] indices)
          Retrieves vertex indices for the rendering primitives stored in this buffer.
 
Methods inherited from class javax.microedition.m3g.Object3D
addAnimationTrack, animate, duplicate, find, getAnimationTrack, getAnimationTrackCount, getReferences, getUserID, getUserObject, removeAnimationTrack, setUserID, setUserObject
   

Method Detail

getIndexCount

public int getIndexCount()
Returns the number of indices in this buffer. This many indices will be returned in a getIndices call. The number of indices returned depends on the type of low-level rendering primitives in the buffer: Currently, only triangles are supported, and there are three indices per triangle. Triangles are counted individually, disregarding triangle strips.

Note that implementations are allowed to optimize the index data internally. Different implementations may therefore report slightly different index counts for the same set of input primitives.

Returns:
the number of indices
Since:
M3G 1.1
See Also:
getIndices

getIndices

public void getIndices(int[] indices)
Retrieves vertex indices for the rendering primitives stored in this buffer.

The indices returned describe the low-level rendering primitives in this buffer. The only such primitive currently supported is a triangle.

Triangles are returned individually, and each consecutive triplet of indices describes a single triangle. Triangle strips or implicit vs. explicit indices are not represented in the returned data. The triangles need not be in any particular order, but the order of indices in each triangle must preserve the winding of the triangle.

Parameters:
indices - array to store the returned vertex indices
Throws:
java.lang.NullPointerException - if indices is null
java.lang.IllegalArgumentException - if indices.length < getIndexCount
Since:
M3G 1.1

M3G 1.1 -- Jun 22, 2005

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