com.jme.scene
Class CompositeMesh

java.lang.Object
  extended by com.jme.scene.Spatial
      extended by com.jme.scene.Geometry
          extended by com.jme.scene.TriMesh
              extended by com.jme.scene.CompositeMesh
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
CompositeSphere

public class CompositeMesh
extends TriMesh
implements java.io.Serializable

Composite defines a geometry mesh. This mesh defines a three dimensional object via a collection of points, colors, normals and textures. The points are referenced via a indices array. This array instructs the renderer the order in which to draw the points, with exact meaning of indices being defined by IndexRange collection. Index ranges are interpreted one after another, consuming their 'count' indices each time. Every range use same vertex data, so it is perfectly possible to reference already used indices from different kind of range.

Author:
Artur Biesiadowski
See Also:
Serialized Form

Nested Class Summary
static class CompositeMesh.IndexRange
          This class represents range of indexes to be interpreted in a way depending on 'kind' attribute.
 
Field Summary
 
Fields inherited from class com.jme.scene.Spatial
defaultStateList, queueDistance
 
Constructor Summary
CompositeMesh(java.lang.String name)
          Constructor instantiates a new CompositeMesh object.
CompositeMesh(java.lang.String name, Vector3f[] vertices, Vector3f[] normal, ColorRGBA[] color, Vector2f[] texture, int[] indices, CompositeMesh.IndexRange[] ranges)
          Constructor instantiates a new CompositeMesh object.
 
Method Summary
static CompositeMesh.IndexRange createQuadRange(int count)
          Create index range representing free, unconnected quads.
static CompositeMesh.IndexRange createQuadStrip(int count)
          Create index range representing quad strip
static CompositeMesh.IndexRange createTriangleFan(int count)
          Create index range representing triangle fan
static CompositeMesh.IndexRange createTriangleRange(int count)
          Create index range representing free, unconnected triangles.
static CompositeMesh.IndexRange createTriangleStrip(int count)
          Create index range representing triangle strip
 void draw(Renderer r)
          draw calls super to set the render state then passes itself to the renderer.
 void drawBounds(Renderer r)
          drawBounds calls super to set the render state then passes itself to the renderer.
 CompositeMesh.IndexRange[] getIndexRanges()
           
 Vector3f[] getMeshAsTriangles()
          Return this mesh object as triangles.
 void getTriangle(int i, int[] storage)
          Stores in the storage array the indices of triangle i.
 void getTriangle(int i, Vector3f[] vertices)
          Stores in the vertices array the vertex values of triangle i.
 int getTriangleQuantity()
          Returns the number of triangles this TriMesh contains.
 void reconstruct(Vector3f[] vertices, Vector3f[] normal, ColorRGBA[] color, Vector2f[] texture, int[] indices, CompositeMesh.IndexRange[] ranges)
          Recreates the geometric information of this CompositeMesh from scratch.
 void setIndexRanges(CompositeMesh.IndexRange[] ranges)
          Sets new index ranges - be sure to match it with updates to indices array if needed
 void updateIndexBuffer()
          setIndexBuffers creates the IntBuffer that contains the indices array.
 
Methods inherited from class com.jme.scene.TriMesh
clearBuffers, findCollisions, findTriangleCollision, findTrianglePick, findWorldRotMat, getIndexAsBuffer, getIndices, hasCollision, hasTriangleCollision, putClone, reconstruct, setIndexBuffer, setIndices, updateCollisionTree
 
Methods inherited from class com.jme.scene.Geometry
applyStates, copyTextureCoords, findPick, getAllTextures, getCloneID, getColorAsFloatBuffer, getColors, getModelBound, getNormalAsFloatBuffer, getNormals, getNumberOfUnits, getTextureAsFloatBuffer, getTextureAsFloatBuffer, getTextures, getTextures, getVBOColorID, getVBONormalID, getVBOTextureID, getVBOVertexID, getVerticeAsFloatBuffer, getVertices, getVertQuantity, isVBOColorEnabled, isVBONormalEnabled, isVBOTextureEnabled, isVBOVertexEnabled, randomVertice, reconstruct, setAllTextures, setColor, setColors, setForceView, setModelBound, setNormal, setNormals, setRandomColors, setSolidColor, setTexture, setTexture, setTextureCoord, setTextures, setTextures, setVBOColorEnabled, setVBOColorID, setVBONormalEnabled, setVBONormalID, setVBOTextureEnabled, setVBOTextureID, setVBOVertexEnabled, setVBOVertexID, setVertex, setVertices, updateColorBuffer, updateModelBound, updateNormalBuffer, updateTextureBuffer, updateTextureBuffer, updateVertexBuffer, updateWorldBound
 
Methods inherited from class com.jme.scene.Spatial
addController, applyDefaultStates, calculateCollisions, calculatePick, clearCurrentState, clearCurrentStates, clearRenderState, getController, getControllers, getCurrentState, getLastFrustumIntersection, getLightCombineMode, getLocalRotation, getLocalScale, getLocalTranslation, getName, getParent, getRenderQueueMode, getRenderStateList, getTextureCombineMode, getWorldBound, getWorldRotation, getWorldScale, getWorldTranslation, getZOrder, isForceCulled, isForceView, onDraw, onDrawBounds, propagateBoundToRoot, removeController, setForceCull, setLightCombineMode, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalTranslation, setName, setParent, setRenderQueueMode, setRenderState, setTextureCombineMode, setWorldBound, setZOrder, toString, updateGeometricState, updateRenderState
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompositeMesh

public CompositeMesh(java.lang.String name)
Constructor instantiates a new CompositeMesh object.

Parameters:
name - the name of the scene element. This is required for identification and comparision purposes.

CompositeMesh

public CompositeMesh(java.lang.String name,
                     Vector3f[] vertices,
                     Vector3f[] normal,
                     ColorRGBA[] color,
                     Vector2f[] texture,
                     int[] indices,
                     CompositeMesh.IndexRange[] ranges)
Constructor instantiates a new CompositeMesh object. Provided are the attributes that make up the mesh all attributes may be null, except for vertices,indices and ranges

Parameters:
name - the name of the scene element. This is required for identification and comparision purposes.
vertices - the vertices of the geometry.
normal - the normals of the geometry.
color - the colors of the geometry.
texture - the texture coordinates of the mesh.
indices - the indices of the vertex array.
ranges - the list of index ranges to be used in rendering
Method Detail

reconstruct

public void reconstruct(Vector3f[] vertices,
                        Vector3f[] normal,
                        ColorRGBA[] color,
                        Vector2f[] texture,
                        int[] indices,
                        CompositeMesh.IndexRange[] ranges)
Recreates the geometric information of this CompositeMesh from scratch. The index,vertex and ranges array must not be null, but the others may be.

Parameters:
vertices - the vertices of the geometry.
normal - the normals of the geometry.
color - the colors of the geometry.
texture - the texture coordinates of the mesh.
indices - the indices of the vertex array.
ranges - the list of index ranges to be used in rendering

getIndexRanges

public CompositeMesh.IndexRange[] getIndexRanges()
Returns:
currently set index ranges

setIndexRanges

public void setIndexRanges(CompositeMesh.IndexRange[] ranges)
Sets new index ranges - be sure to match it with updates to indices array if needed

Parameters:
ranges -

draw

public void draw(Renderer r)
draw calls super to set the render state then passes itself to the renderer.

Overrides:
draw in class TriMesh
Parameters:
r - the renderer to display
See Also:
Spatial.draw(com.jme.renderer.Renderer)

drawBounds

public void drawBounds(Renderer r)
drawBounds calls super to set the render state then passes itself to the renderer.

Overrides:
drawBounds in class TriMesh
Parameters:
r - the renderer to display

getTriangleQuantity

public int getTriangleQuantity()
Description copied from class: TriMesh
Returns the number of triangles this TriMesh contains.

Overrides:
getTriangleQuantity in class TriMesh
Returns:
equivalent number of triangles - each quad counts as two triangles

updateIndexBuffer

public void updateIndexBuffer()
setIndexBuffers creates the IntBuffer that contains the indices array.

Overrides:
updateIndexBuffer in class TriMesh

createTriangleRange

public static CompositeMesh.IndexRange createTriangleRange(int count)
Create index range representing free, unconnected triangles.

Parameters:
count - number of indexes to be put in this range
Returns:
new IndexRange for unconnected triangles

createTriangleStrip

public static CompositeMesh.IndexRange createTriangleStrip(int count)
Create index range representing triangle strip

Parameters:
count - number of indexes to be put in this range
Returns:
new IndexRange for triangle strip

createTriangleFan

public static CompositeMesh.IndexRange createTriangleFan(int count)
Create index range representing triangle fan

Parameters:
count - number of indexes to be put in this range
Returns:
new IndexRange for triangle fan

createQuadRange

public static CompositeMesh.IndexRange createQuadRange(int count)
Create index range representing free, unconnected quads.

Parameters:
count - number of indexes to be put in this range
Returns:
new IndexRange for unconnected quads

createQuadStrip

public static CompositeMesh.IndexRange createQuadStrip(int count)
Create index range representing quad strip

Parameters:
count - number of indexes to be put in this range
Returns:
new IndexRange for quad strip

getMeshAsTriangles

public Vector3f[] getMeshAsTriangles()
Return this mesh object as triangles. Every 3 vertices returned compose single triangle. Vertices are returned by reference for efficiency, so it is required that they won't be modified by caller.

Overrides:
getMeshAsTriangles in class TriMesh
Returns:
view of current mesh as group of triangle vertices

getTriangle

public void getTriangle(int i,
                        int[] storage)
Stores in the storage array the indices of triangle i. If i is an invalid index, or if storage.length<3, then nothing happens For composite mesh, this operation is more costly than for Trimesh.

Overrides:
getTriangle in class TriMesh
Parameters:
i - The index of the triangle to get.
storage - The array that will hold the i's indexes.

getTriangle

public void getTriangle(int i,
                        Vector3f[] vertices)
Stores in the vertices array the vertex values of triangle i. If i is an invalid triangle index, nothing happens.

Overrides:
getTriangle in class TriMesh
Parameters:
i -
vertices -