com.jme.scene
Class QuadMesh

java.lang.Object
  extended by com.jme.scene.Spatial
      extended by com.jme.scene.Geometry
          extended by com.jme.scene.QuadMesh
All Implemented Interfaces:
Savable, java.io.Serializable

public class QuadMesh
extends Geometry
implements java.io.Serializable

QuadMesh 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, creating quads based on the mode set.

Version:
$Id: QuadMesh.java 4131 2009-03-19 20:15:28Z blaine.dev $
Author:
Joshua Slack
See Also:
Serialized Form

Nested Class Summary
static class QuadMesh.Mode
           
 
Nested classes/interfaces inherited from class com.jme.scene.Spatial
Spatial.CullHint, Spatial.LightCombineMode, Spatial.NormalsMode, Spatial.TextureCombineMode
 
Field Summary
protected  java.nio.IntBuffer indexBuffer
           
protected  QuadMesh.Mode mode
           
protected  int quadQuantity
           
 
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
QuadMesh()
          Empty Constructor to be used internally only.
QuadMesh(java.lang.String name)
          Constructor instantiates a new TriMesh object.
QuadMesh(java.lang.String name, java.nio.FloatBuffer vertices, java.nio.FloatBuffer normal, java.nio.FloatBuffer color, TexCoords coords, java.nio.IntBuffer indices)
          Constructor instantiates a new TriMesh object.
 
Method Summary
 void clearBuffers()
          Clears the buffers of this QuadMesh.
 void draw(Renderer r)
          draw prepares the geometry for rendering to the display.
 void findCollisions(Spatial scene, CollisionResults results)
          checks this spatial against a second spatial, any collisions are stored in the results object.
 java.nio.IntBuffer getIndexBuffer()
           
 int getMaxIndex()
           
 Vector3f[] getMeshAsQuadsVertices(Vector3f[] verts)
          Return this mesh object as quads.
 QuadMesh.Mode getMode()
           
 void getQuad(int i, int[] storage)
          Stores in the storage array the indices of quad i.
 void getQuad(int i, Vector3f[] vertices)
          Stores in the vertices array the vertex values of quad i.
 int getQuadCount()
          Returns the number of triangles contained in this mesh.
static Vector3f[] getQuads()
           
protected  int getVertIndex(int quad, int point)
           
 boolean hasCollision(Spatial scene, boolean checkTriangles)
          Checks this spatial against a second spatial for collisions.
 void read(JMEImporter e)
           
protected  void recalcQuadQuantity()
           
 void reconstruct(java.nio.FloatBuffer vertices, java.nio.FloatBuffer normal, java.nio.FloatBuffer color, TexCoords coords, java.nio.IntBuffer indices)
          Recreates the geometric information of this TriMesh from scratch.
 void setIndexBuffer(java.nio.IntBuffer indices)
           
 void setMode(QuadMesh.Mode mode)
           
 void setQuadQuantity(int quadQuantity)
           
static void setQuads(Vector3f[] quads)
           
 void write(JMEExporter e)
           
 
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, getTriangleCount, 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

indexBuffer

protected transient java.nio.IntBuffer indexBuffer

mode

protected QuadMesh.Mode mode

quadQuantity

protected int quadQuantity
Constructor Detail

QuadMesh

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


QuadMesh

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

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

QuadMesh

public QuadMesh(java.lang.String name,
                java.nio.FloatBuffer vertices,
                java.nio.FloatBuffer normal,
                java.nio.FloatBuffer color,
                TexCoords coords,
                java.nio.IntBuffer indices)
Constructor instantiates a new TriMesh object. Provided are the attributes that make up the mesh all attributes may be null, except for vertices and indices.

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.
coords - the texture coordinates of the mesh.
indices - the indices of the vertex array.
Method Detail

reconstruct

public void reconstruct(java.nio.FloatBuffer vertices,
                        java.nio.FloatBuffer normal,
                        java.nio.FloatBuffer color,
                        TexCoords coords,
                        java.nio.IntBuffer indices)
Recreates the geometric information of this TriMesh from scratch. The index and vertex array must not be null, but the others may be. Every 3 indices define an index in the vertices array that refrences a vertex of a triangle.

Parameters:
vertices - The vertex information for this TriMesh.
normal - The normal information for this TriMesh.
color - The color information for this TriMesh.
coords - The texture information for this TriMesh.
indices - The index information for this TriMesh.

setMode

public void setMode(QuadMesh.Mode mode)

getMode

public QuadMesh.Mode getMode()

getIndexBuffer

public java.nio.IntBuffer getIndexBuffer()

setIndexBuffer

public void setIndexBuffer(java.nio.IntBuffer indices)

recalcQuadQuantity

protected void recalcQuadQuantity()

getQuadCount

public int getQuadCount()
Returns the number of triangles contained in this mesh.


setQuadQuantity

public void setQuadQuantity(int quadQuantity)

clearBuffers

public void clearBuffers()
Clears the buffers of this QuadMesh. The buffers include its indexBuffer only.

Overrides:
clearBuffers in class Geometry

getQuads

public static Vector3f[] getQuads()

setQuads

public static void setQuads(Vector3f[] quads)

getQuad

public void getQuad(int i,
                    int[] storage)
Stores in the storage array the indices of quad i. If i is an invalid index, or if storage.length<4, then nothing happens

Parameters:
i - The index of the quad to get.
storage - The array that will hold the i's indexes.

getQuad

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

Parameters:
i -
vertices -

getMeshAsQuadsVertices

public Vector3f[] getMeshAsQuadsVertices(Vector3f[] verts)
Return this mesh object as quads. Every 4 vertices returned compose a single quad.

Parameters:
verts - a storage array to place the results in
Returns:
view of current mesh as group of quad vertices

getVertIndex

protected int getVertIndex(int quad,
                           int point)

getMaxIndex

public int getMaxIndex()

write

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

read

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

draw

public void draw(Renderer r)
Description copied from class: Geometry
draw prepares the geometry for rendering to the display. The renderstate is set and the subclass is responsible for rendering the actual data.

Overrides:
draw in class Geometry
Parameters:
r - the renderer that displays to the context.
See Also:
Spatial.draw(com.jme.renderer.Renderer)

findCollisions

public void findCollisions(Spatial scene,
                           CollisionResults results)
Description copied from class: Spatial
checks this spatial against a second spatial, any collisions are stored in the results object.

Specified by:
findCollisions in class Spatial
Parameters:
scene - the scene to test against.
results - the results of the collisions.

hasCollision

public boolean hasCollision(Spatial scene,
                            boolean checkTriangles)
Description copied from class: Spatial
Checks this spatial against a second spatial for collisions.

Specified by:
hasCollision in class Spatial
Parameters:
scene - the scene to test against.
checkTriangles - check for collisions on triangle accuracy level
Returns:
true if any collision were found