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

javax.microedition.m3d
Class Mesh

java.lang.Object
  |
  +--javax.microedition.m3d.Object3D
        |
        +--javax.microedition.m3d.Node
              |
              +--javax.microedition.m3d.Mesh
Direct Known Subclasses:
MorphingMesh, SkinnedMesh

public class Mesh
extends Node

Mesh is a renderable 3D geometry object, defined as a polygonal surface. Mesh is also the base class for MorphingMesh and SkinnedMesh. These extend the basic, rigid body mesh with capabilities to transform the vertices independently of each other. The structure of a basic Mesh is shown in the figure below.

A Mesh is composed of one or more submeshes. A submesh is a {VertexBuffer, IndexBuffer, Appearance} triplet that defines a set of vertices and their attributes (VertexBuffer), a set of triangle strips connecting the vertices (IndexBuffer) and the visual properties of the surface (Appearance). All submeshes in a Mesh share the same VertexBuffer. In the case of a MorphingMesh, a weighted linear combination of multiple VertexBuffers is used instead of a single VertexBuffer.

Submeshes within a Mesh are rendered in the order of ascending Appearance layers, and such that opaque submeshes are rendered before transparent submeshes on the same layer. See the setLayer method in Appearance for more discussion on layered rendering.

Deferred exceptions

Rendering and picking of a submesh is disabled if its Appearance is null. An exception is thrown if the VertexBuffer or any of the IndexBuffers are in invalid state when rendering or picking; see the respective class descriptions for more information. Note that it would be useless to check for these exception cases at construction time, because the application may freely change Appearances and VertexBuffer contents at any time. However, null IndexBuffers and VertexBuffers are blocked at the constructor, as usual, because the application is not able to set them to non-null afterwards.

See Also:
Binary format, VertexBuffer, IndexBuffer

Field Summary
 
Fields inherited from class javax.microedition.m3d.Node
NONE, ORIGIN, X_AXIS, Y_AXIS, Z_AXIS
 
Fields inherited from class javax.microedition.m3d.Object3D
userObject
 
Constructor Summary
Mesh(VertexBuffer vertices, IndexBuffer[] triangles, Appearance[] appearances)
          Constructs a new Mesh with the given VertexBuffer and submeshes.
Mesh(VertexBuffer vertices, IndexBuffer triangles, Appearance appearance)
          Constructs a new Mesh consisting of only one submesh.
 
Method Summary
 Appearance getAppearance(int index)
          Gets the current Appearance of the specified submesh.
 IndexBuffer getIndexBuffer(int index)
          Gets the IndexBuffer of the specified submesh.
 int getSubmeshCount()
          Gets the number of submeshes in this Mesh.
 VertexBuffer getVertexBuffer()
          Gets the vertex buffer of this Mesh.
 void setAppearance(int index, Appearance appearance)
          Sets the Appearance of the specified submesh.
 
Methods inherited from class javax.microedition.m3d.Node
getAlphaFactor, getOrientation, getParent, getScale, getScopeID, getTransform, getTransformTo, getTranslation, isEnabled, setAlignment, setAlphaFactor, setEnable, setOrientation, setScale, setScopeID, setTransform, setTranslation
 
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

Mesh

public Mesh(VertexBuffer vertices,
            IndexBuffer triangles,
            Appearance appearance)

Constructs a new Mesh consisting of only one submesh. Rendering and picking of the Mesh is initially disabled if the Appearance is set to null.

Parameters:
vertices - a VertexBuffer to use for this mesh
triangles - an IndexBuffer defining the triangle strips to draw
appearance - an Appearance to use for this mesh, or null

Mesh

public Mesh(VertexBuffer vertices,
            IndexBuffer[] triangles,
            Appearance[] appearances)

Constructs a new Mesh with the given VertexBuffer and submeshes. The number of submeshes is set equal to the length of triangles. The appearances array is parallel to that, and must have at least as many elements. Alternatively, it may be null, in which case all the Appearances are initialized to null.

Parameters:
vertices - a VertexBuffer to use for all submeshes in this mesh
triangles - an IndexBuffer array defining the triangle strips to draw
appearances - an Appearance array parallel to triangles; a null element disables rendering of that submesh, and a null array initializes all appearances to null
Throws:
java.lang.IllegalArgumentException - if triangles is empty
java.lang.IllegalArgumentException - if appearances.length < triangles.length
Method Detail

setAppearance

public void setAppearance(int index,
                          Appearance appearance)

Sets the Appearance of the specified submesh.

Parameters:
index - index of the submesh to set the Appearance of
appearance - Appearance to set for the submesh at index, or null to disable the submesh
Throws:
java.lang.IndexOutOfBoundsException - if index is not between [0, N-1], where N is the number of submeshes
See Also:
getAppearance

getAppearance

public Appearance getAppearance(int index)

Gets the current Appearance of the specified submesh.

Parameters:
index - index of the submesh to get the Appearance of
Returns:
current Appearance of the submesh at index
Throws:
java.lang.IndexOutOfBoundsException - if index is not between [0, N-1], where N is the number of submeshes
See Also:
setAppearance

getIndexBuffer

public IndexBuffer getIndexBuffer(int index)

Gets the IndexBuffer of the specified submesh.

Parameters:
index - index of the submesh to get the IndexBuffer of
Returns:
current IndexBuffer for the submesh at index
Throws:
java.lang.IndexOutOfBoundsException - if index is not between [0, N-1], where N is the number of submeshes

getVertexBuffer

public VertexBuffer getVertexBuffer()

Gets the vertex buffer of this Mesh. In the case of a MorphingMesh, this represents the base mesh; the morph targets can be obtained with a separate method in MorphingMesh.

Returns:
the VertexBuffer of this Mesh

getSubmeshCount

public int getSubmeshCount()

Gets the number of submeshes in this Mesh. This is always at least 1.

Returns:
the number of submeshes in this Mesh

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

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