com.jme.scene.lod
Class AreaClodMesh

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
                  extended by com.jme.scene.lod.AreaClodMesh
All Implemented Interfaces:
Savable, java.io.Serializable

public class AreaClodMesh
extends ClodMesh

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

This class is an automatically updating ClodMesh that updates records acording to how much area the bounding volume takes up on the screen. Use it just like a normal ClodMesh, but allow it to update itself.

Version:
$Id: AreaClodMesh.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
 
Fields inherited from class com.jme.scene.lod.ClodMesh
currentRecord, records, 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
AreaClodMesh()
          Empty Constructor to be used internally only.
AreaClodMesh(java.lang.String name)
          Creates a new AreaClodMesh with the given name.
AreaClodMesh(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.
AreaClodMesh(java.lang.String name, TriMesh data, CollapseRecord[] records)
          Creates a clod mesh that mimics the given TriMesh's geometry information.
 
Method Summary
 int chooseTargetRecord(Renderer r)
          This function is used during rendering to choose the correct target record for the AreaClodMesh acording to the information in the renderer.
 float getDistanceTolerance()
          Returns the amount of distance the camera must move from the center of this AreaClodMesh's bounding volume before a collapse is initiated.
 float getTrisPerPixel()
          Returns the currently set number of triangles per pixel this AreaClodMesh should fit on the screen.
 void read(JMEImporter e)
           
 void setDistanceTolerance(float tolerance)
          Sets the amount of distance the camera must move from the center of this AreaClodMesh's bounding volume before a collapse is initiated.
 void setTargetRecord(int target)
          This function is ignored by AreaClodMesh because target records are updated automatically during draw.
 void setTrisPerPixel(float trisPerPixel)
          Sets the number of triangles per pixel this AreaClodMesh should try to fit on the screen.
 void write(JMEExporter e)
           
 
Methods inherited from class com.jme.scene.lod.ClodMesh
create, draw, getRecordQuantity, getRecords, getTargetRecord, setRecords
 
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
 

Constructor Detail

AreaClodMesh

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


AreaClodMesh

public AreaClodMesh(java.lang.String name)
Creates a new AreaClodMesh with the given name. This should only be used if the users is going to call reconstruct and create on the clod mesh.

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

AreaClodMesh

public AreaClodMesh(java.lang.String name,
                    TriMesh data,
                    CollapseRecord[] records)
Creates a clod mesh that mimics the given TriMesh's geometry information. More specificly, RenderState and Controller information is not absorbed by this AreaClodMesh. A null for records causes the AreaClodMesh to generate its own records information.

Parameters:
name - The name of this new mesh.
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.

AreaClodMesh

public AreaClodMesh(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 AreaClodMesh 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

chooseTargetRecord

public int chooseTargetRecord(Renderer r)
This function is used during rendering to choose the correct target record for the AreaClodMesh acording to the information in the renderer. This should not be called manually. Instead, allow it to be called automatically during rendering.

Overrides:
chooseTargetRecord in class ClodMesh
Parameters:
r - The Renderer to use.
Returns:
the target record this AreaClodMesh will use to collapse vertexes.

setTargetRecord

public void setTargetRecord(int target)
This function is ignored by AreaClodMesh because target records are updated automatically during draw.

Overrides:
setTargetRecord in class ClodMesh
Parameters:
target - Ignored.

getTrisPerPixel

public float getTrisPerPixel()
Returns the currently set number of triangles per pixel this AreaClodMesh should fit on the screen. The default value is 1.

Returns:
The current Triangles per pixel.

setTrisPerPixel

public void setTrisPerPixel(float trisPerPixel)
Sets the number of triangles per pixel this AreaClodMesh should try to fit on the screen. The default value is 1.

Parameters:
trisPerPixel - The new value for Triangles per pixel.

getDistanceTolerance

public float getDistanceTolerance()
Returns the amount of distance the camera must move from the center of this AreaClodMesh's bounding volume before a collapse is initiated. The default is 1.

Returns:
The current distance tolerance of collapsing.

setDistanceTolerance

public void setDistanceTolerance(float tolerance)
Sets the amount of distance the camera must move from the center of this AreaClodMesh's bounding volume before a collapse is initiated. The default is 1.

Parameters:
tolerance - The new distance tolerance.

write

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

read

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