com.jme.scene.lod
Class ClodMesh

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.lod.ClodMesh
All Implemented Interfaces:
Savable, java.io.Serializable
Direct Known Subclasses:
AreaClodMesh

public class ClodMesh
extends TriMesh

ClodMesh originally ported from David Eberly's c++, modifications and enhancements made from there.

This class is an extention of TriMesh that allows the option of rendering a trimesh at various degrees of accuracy.

Version:
$Id: ClodMesh.java 4131 2009-03-19 20:15:28Z blaine.dev $
Author:
Joshua Slack, Jack Lindamood (javadoc only)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.jme.scene.TriMesh
TriMesh.Mode
 
Nested classes/interfaces inherited from class com.jme.scene.Spatial
Spatial.CullHint, Spatial.LightCombineMode, Spatial.NormalsMode, Spatial.TextureCombineMode
 
Field Summary
(package private)  int currentRecord
           
(package private)  CollapseRecord[] records
           
(package private)  int targetRecord
           
 
Fields inherited from class com.jme.scene.TriMesh
indexBuffer, mode, triangleQuantity
 
Fields inherited from class com.jme.scene.Geometry
binormalBuf, bound, castsShadows, colorBuf, compVect, defaultColor, displayListID, enabled, fogBuf, hasDirtyVertices, normBuf, states, tangentBuf, texBuf, vboInfo, vertBuf, vertQuantity
 
Fields inherited from class com.jme.scene.Spatial
cullHint, frustrumIntersects, geometricalControllers, isCollidable, lightCombineMode, localRotation, localScale, localTranslation, LOCKED_BOUNDS, LOCKED_BRANCH, LOCKED_MESH_DATA, LOCKED_NONE, LOCKED_SHADOWS, LOCKED_TRANSFORMS, lockedMode, name, normalsMode, parent, queueDistance, renderQueueMode, renderStateList, textureCombineMode, worldBound, worldRotation, worldScale, worldTranslation, zOrder
 
Constructor Summary
ClodMesh()
          Empty Constructor to be used internally only.
ClodMesh(java.lang.String name)
          Creates a new ClodMesh without any information.
ClodMesh(java.lang.String name, java.nio.FloatBuffer vertices, java.nio.FloatBuffer normal, java.nio.FloatBuffer color, TexCoords coords, java.nio.IntBuffer indices, CollapseRecord[] records)
          Creates a clod mesh with the given information.
ClodMesh(java.lang.String name, TriMesh data, CollapseRecord[] records)
          Creates a ClodMesh that is a duplicate of the given TriMesh's geometric information.
 
Method Summary
 int chooseTargetRecord(Renderer r)
          This function should not be called manually.
 void create(CollapseRecord[] records)
          This function sets the records information for this ClodMesh.
 void draw(Renderer r)
          Called during rendering.
 int getRecordQuantity()
          Returns the number of records this ClodMesh currently uses.
 CollapseRecord[] getRecords()
          Returns the current collapse records array.
 int getTargetRecord()
          Returns the currently set target record.
 void read(JMEImporter e)
           
 void setRecords(CollapseRecord[] records)
          Sets the records this ClodMesh will use to collapse triangles.
 void setTargetRecord(int target)
          Sets the current target record to the target value.
 void write(JMEExporter e)
           
 
Methods inherited from class com.jme.scene.TriMesh
clearBuffers, findCollisions, findTriangleCollision, findTrianglePick, getIndexBuffer, getMaxIndex, getMeshAsTriangles, getMeshAsTrianglesVertices, getMode, getTriangle, getTriangle, getTriangleCount, getTriangleIndices, getVertIndex, hasCollision, hasTriangleCollision, randomPointOnTriangles, recalcTriangleQuantity, reconstruct, setIndexBuffer, setMode, setTriangleQuantity
 
Methods inherited from class com.jme.scene.Geometry
addTextureCoordinates, addTextureCoordinates, applyRenderState, checkTextureCoordinates, clearTextureBuffers, copyTextureCoordinates, copyTextureCoordinates, findPick, getBinormalBuffer, getColorBuffer, getDefaultColor, getDisplayListID, getFogBuffer, getLightState, getModelBound, getNormalBuffer, getNumberOfUnits, getTangentBuffer, getTextureCoords, getTextureCoords, getVBOInfo, getVertexBuffer, getVertexCount, getWorldCoords, getWorldNormals, hasDirtyVertices, isCastsShadows, lockMeshes, postdraw, predraw, randomVertex, reconstruct, resizeTextureIds, rotateNormals, rotatePoints, scaleTextureCoordinates, scaleTextureCoordinates, setBinormalBuffer, setCastsShadows, setColorBuffer, setDefaultColor, setDisplayListID, setFogCoordBuffer, setHasDirtyVertices, setLightState, setModelBound, setNormalBuffer, setRandomColors, setSolidColor, setTangentBuffer, setTextureCoords, setTextureCoords, setTextureCoords, setVBOInfo, setVertexBuffer, setVertexCount, sortLights, translatePoints, translatePoints, unlockMeshes, updateModelBound, updateWorldBound
 
Methods inherited from class com.jme.scene.Spatial
addController, calculateCollisions, calculatePick, clearControllers, clearRenderState, clearRenderState, getClassTag, getController, getControllerCount, getControllers, getCullHint, getLastFrustumIntersection, getLightCombineMode, getLocalCullHint, getLocalLightCombineMode, getLocalNormalsMode, getLocalRenderQueueMode, getLocalRotation, getLocalScale, getLocalTextureCombineMode, getLocalToWorldMatrix, getLocalTranslation, getLocks, getName, getNormalsMode, getParent, getRenderQueueMode, getRenderState, getRenderState, getTextureCombineMode, getUserData, getWorldBound, getWorldRotation, getWorldScale, getWorldTranslation, getZOrder, hasAncestor, isCollidable, localToWorld, lock, lock, lockBounds, lockBranch, lockMeshes, lockShadows, lockTransforms, lookAt, onDraw, propagateBoundToRoot, propagateStatesFromRoot, removeController, removeController, removeFromParent, removeUserData, rotateUpTo, setCullHint, setIsCollidable, setLastFrustumIntersection, setLightCombineMode, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalTranslation, setLocalTranslation, setLocks, setLocks, setName, setNormalsMode, setParent, setRenderQueueMode, setRenderState, setTextureCombineMode, setUserData, setZOrder, setZOrder, toString, unlock, unlock, unlockBounds, unlockBranch, unlockMeshes, unlockShadows, unlockTransforms, updateGeometricState, updateRenderState, updateRenderState, updateWorldData, updateWorldRotation, updateWorldScale, updateWorldTranslation, updateWorldVectors, updateWorldVectors, worldToLocal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.jme.util.export.Savable
getClassTag
 

Field Detail

currentRecord

int currentRecord

targetRecord

int targetRecord

records

CollapseRecord[] records
Constructor Detail

ClodMesh

public ClodMesh()
Empty Constructor to be used internally only.


ClodMesh

public ClodMesh(java.lang.String name)
Creates a new ClodMesh without any information. It is assumed a call to reconstruct and create will be called before this ClodMesh is used.

Parameters:
name - The name of the ClodMesh.
See Also:
#reconstruct(com.jme.math.Vector3f[], com.jme.math.Vector3f[], com.jme.renderer.ColorRGBA[], com.jme.math.Vector2f[], int[]), create(com.jme.scene.lod.CollapseRecord[])

ClodMesh

public ClodMesh(java.lang.String name,
                TriMesh data,
                CollapseRecord[] records)
Creates a ClodMesh that is a duplicate of the given TriMesh's geometric information. RenderState and Controller information is not used and should be set manually if those are to be copied as well. The records parameter defines how the ClodMesh should collapse vertices. If null is given, records are generated by the ClodMesh automatically.

Parameters:
name - The name of the ClodMesh.
data - The TriMesh to copy information into for this mesh.
records - The collapse record(s) this ClodMesh should use. These modify how the ClodMesh collapses vertexes.

ClodMesh

public ClodMesh(java.lang.String name,
                java.nio.FloatBuffer vertices,
                java.nio.FloatBuffer normal,
                java.nio.FloatBuffer color,
                TexCoords coords,
                java.nio.IntBuffer indices,
                CollapseRecord[] records)
Creates a clod mesh with the given information. A null for records causes the ClodMesh to generate its own records information.

Parameters:
name - The name of the ClodMesh.
vertices - The vertex information of this clod mesh.
normal - The per vertex normal information of this clod mesh.
color - The per vertex color information of this clod mesh.
coords - The per vertex texture information of this clod mesh.
indices - The index array of this TriMesh's triangles.
records - The collapse record(s) this ClodMesh should use. These modify how the ClodMesh collapses vertexes.
Method Detail

create

public void create(CollapseRecord[] records)
This function sets the records information for this ClodMesh. If non-null is passed, then the ClodMesh uses the passed CollapseRecord(s) to determine how the TriMesh's triangles should collapse. If null is passed, then the collapse records are created automatically with ClodCreator. In most cases, null will be passed.

Parameters:
records - The records for this ClodMesh to use, or null if it should generate its own.
See Also:
ClodCreator

draw

public void draw(Renderer r)
Called during rendering. Should not be called directly.

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

getRecordQuantity

public int getRecordQuantity()
Returns the number of records this ClodMesh currently uses.

Returns:
The current length of the records array.

chooseTargetRecord

public int chooseTargetRecord(Renderer r)
This function should not be called manually. It selects the correct target record based on the renderer used. For a basic ClodMesh, simply the currently set target record is used. The target record signals how to collapse this mesh's triangle information.

Parameters:
r - A renderer which aids in choosing the correct target record.
Returns:
The integer position in the records array for the target collapse record.

getTargetRecord

public int getTargetRecord()
Returns the currently set target record.

Returns:
The currently set target record.

getRecords

public CollapseRecord[] getRecords()
Returns the current collapse records array. This array is created in create()

Returns:
The current collapse records array.
See Also:
create(com.jme.scene.lod.CollapseRecord[])

setTargetRecord

public void setTargetRecord(int target)
Sets the current target record to the target value. If less than 0 is passed, 0 is used. If a value greater than the current records length is passed, then the maximum records length value is used.

Parameters:
target - The new target record to use.

setRecords

public void setRecords(CollapseRecord[] records)
Sets the records this ClodMesh will use to collapse triangles.

Parameters:
records - The new records information of this ClodMesh.

write

public void write(JMEExporter e)
           throws java.io.IOException
Specified by:
write in interface Savable
Overrides:
write in class TriMesh
Throws:
java.io.IOException

read

public void read(JMEImporter e)
          throws java.io.IOException
Specified by:
read in interface Savable
Overrides:
read in class TriMesh
Throws:
java.io.IOException