com.jme3.scene
Class Geometry

java.lang.Object
  extended by com.jme3.scene.Spatial
      extended by com.jme3.scene.Geometry
All Implemented Interfaces:
CloneableSmartAsset, Collidable, Savable, java.lang.Cloneable
Direct Known Subclasses:
ParticleEmitter, Picture, TerrainPatch

public class Geometry
extends Spatial

Geometry defines a leaf node of the scene graph. The leaf node contains the geometric data for rendering objects. It manages all rendering information such as a Material object to define how the surface should be shaded and the Mesh data to contain the actual geometry.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.jme3.scene.Spatial
Spatial.BatchHint, Spatial.CullHint
 
Field Summary
protected  BatchNode batchNode
          used when geometry is batched
protected  Matrix4f cachedOffsetMat
          the cached offset matrix used when the geometry is batched
protected  Matrix4f cachedWorldMat
           
protected  boolean ignoreTransform
          When true, the geometry's transform will not be applied.
protected  int lodLevel
           
protected  Material material
           
protected  Mesh mesh
           
protected  Transform prevBatchTransforms
          the previous transforms of the geometry used to compute world transforms
static int SAVABLE_VERSION
           
protected  int startIndex
          the start index of this geom's mesh in the batchNode mesh
 
Fields inherited from class com.jme3.scene.Spatial
batchHint, controls, cullHint, frustrumIntersects, key, localLights, localTransform, name, parent, queueBucket, queueDistance, refreshFlags, RF_BOUND, RF_LIGHTLIST, RF_TRANSFORM, shadowMode, userData, worldBound, worldLights, worldTransform
 
Constructor Summary
Geometry()
          Serialization only.
Geometry(java.lang.String name)
          Create a geometry node without any mesh data.
Geometry(java.lang.String name, Mesh mesh)
          Create a geometry node with mesh data.
 
Method Summary
protected  void batch(BatchNode node, int startIndex)
          Batch this geometry, should only be called by the BatchNode.
protected  void breadthFirstTraversal(SceneGraphVisitor visitor, java.util.Queue<Spatial> queue)
           
 Geometry clone()
          This version of clone is a shallow clone, in other words, the same mesh is referenced as the original geometry.
 Geometry clone(boolean cloneMaterial)
          This version of clone is a shallow clone, in other words, the same mesh is referenced as the original geometry.
 int collideWith(Collidable other, CollisionResults results)
          Check collision with another Collidable.
 void computeOffsetTransform()
          Recomputes the cached offset matrix used when the geometry is batched *
 void computeWorldMatrix()
          Recomputes the matrix returned by getWorldMatrix().
 Spatial deepClone()
          Creates a deep clone of the geometry, this creates an identical copy of the mesh with the vertexbuffer data duplicated.
 void depthFirstTraversal(SceneGraphVisitor visitor)
          Visit each scene graph element ordered by DFS
 int getLodLevel()
          Returns the LOD level set with setLodLevel(int).
 Material getMaterial()
          Returns the material that is used for this geometry.
 Mesh getMesh()
          Returns the mseh to use for this geometry
 BoundingVolume getModelBound()
           
 int getTriangleCount()
          Returns this geometry's mesh triangle count.
 int getVertexCount()
          Returns this geometry's mesh vertex count.
 Matrix4f getWorldMatrix()
          A matrix that transforms the mesh from model space to world space.
 boolean isBatched()
           
 boolean isIgnoreTransform()
           
 void read(JmeImporter im)
           
 boolean removeFromParent()
          removeFromParent removes this Spatial from it's parent.
 void setIgnoreTransform(boolean ignoreTransform)
           
 void setLodLevel(int lod)
          Sets the LOD level to use when rendering the mesh of this geometry.
 void setMaterial(Material material)
          Sets the material to use for this geometry.
 void setMesh(Mesh mesh)
          Sets the mesh to use for this geometry when rendering.
 void setModelBound(BoundingVolume modelBound)
          Sets the model bound to use for this geometry.
protected  void setParent(Node parent)
          Called by Node.attachChild(Spatial) and Node.detachChild(Spatial) - don't call directly.
protected  void unBatch()
          unBatch this geometry.
 void updateModelBound()
          Updates the bounding volume of the mesh.
protected  void updateWorldBound()
          updateWorldBound updates the bounding volume that contains this geometry.
protected  void updateWorldTransforms()
          Should only be called from updateGeometricState().
 void write(JmeExporter ex)
           
 
Methods inherited from class com.jme3.scene.Spatial
addControl, addLight, breadthFirstTraversal, center, checkCulling, getBatchHint, getControl, getControl, getCullHint, getKey, getLastFrustumIntersection, getLocalBatchHint, getLocalCullHint, getLocalLightList, getLocalQueueBucket, getLocalRotation, getLocalScale, getLocalShadowMode, getLocalToWorldMatrix, getLocalTransform, getLocalTranslation, getName, getNumControls, getParent, getQueueBucket, getShadowMode, getUserData, getUserDataKeys, getWorldBound, getWorldLightList, getWorldRotation, getWorldScale, getWorldTransform, getWorldTranslation, hasAncestor, localToWorld, lookAt, matches, move, move, removeControl, removeControl, removeLight, rotate, rotate, rotateUpTo, runControlRender, scale, scale, setBatchHint, setBoundRefresh, setCullHint, setKey, setLastFrustumIntersection, setLightListRefresh, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalScale, setLocalTransform, setLocalTranslation, setLocalTranslation, setName, setQueueBucket, setShadowMode, setTransformRefresh, setUserData, toString, updateGeometricState, updateLogicalState, updateWorldLightList, worldToLocal
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SAVABLE_VERSION

public static final int SAVABLE_VERSION
See Also:
Constant Field Values

mesh

protected Mesh mesh

lodLevel

protected transient int lodLevel

material

protected Material material

ignoreTransform

protected boolean ignoreTransform
When true, the geometry's transform will not be applied.


cachedWorldMat

protected transient Matrix4f cachedWorldMat

batchNode

protected BatchNode batchNode
used when geometry is batched


startIndex

protected int startIndex
the start index of this geom's mesh in the batchNode mesh


prevBatchTransforms

protected Transform prevBatchTransforms
the previous transforms of the geometry used to compute world transforms


cachedOffsetMat

protected Matrix4f cachedOffsetMat
the cached offset matrix used when the geometry is batched

Constructor Detail

Geometry

public Geometry()
Serialization only. Do not use.


Geometry

public Geometry(java.lang.String name)
Create a geometry node without any mesh data. Both the mesh and the material are null, the geometry cannot be rendered until those are set.

Parameters:
name - The name of this geometry

Geometry

public Geometry(java.lang.String name,
                Mesh mesh)
Create a geometry node with mesh data. The material of the geometry is null, it cannot be rendered until it is set.

Parameters:
name - The name of this geometry
mesh - The mesh data for this geometry
Method Detail

isIgnoreTransform

public boolean isIgnoreTransform()
Returns:
If ignoreTransform mode is set.
See Also:
setIgnoreTransform(boolean)

setIgnoreTransform

public void setIgnoreTransform(boolean ignoreTransform)
Parameters:
ignoreTransform - If true, the geometry's transform will not be applied.

setLodLevel

public void setLodLevel(int lod)
Sets the LOD level to use when rendering the mesh of this geometry. Level 0 indicates that the default index buffer should be used, levels [1, LodLevels + 1] represent the levels set on the mesh with Mesh.setLodLevels(com.jme3.scene.VertexBuffer[]).

Overrides:
setLodLevel in class Spatial
Parameters:
lod - The lod level to set

getLodLevel

public int getLodLevel()
Returns the LOD level set with setLodLevel(int).

Returns:
the LOD level set

getVertexCount

public int getVertexCount()
Returns this geometry's mesh vertex count.

Specified by:
getVertexCount in class Spatial
Returns:
this geometry's mesh vertex count.
See Also:
Mesh.getVertexCount()

getTriangleCount

public int getTriangleCount()
Returns this geometry's mesh triangle count.

Specified by:
getTriangleCount in class Spatial
Returns:
this geometry's mesh triangle count.
See Also:
Mesh.getTriangleCount()

setMesh

public void setMesh(Mesh mesh)
Sets the mesh to use for this geometry when rendering.

Parameters:
mesh - the mesh to use for this geometry
Throws:
java.lang.IllegalArgumentException - If mesh is null

getMesh

public Mesh getMesh()
Returns the mseh to use for this geometry

Returns:
the mseh to use for this geometry
See Also:
setMesh(com.jme3.scene.Mesh)

setMaterial

public void setMaterial(Material material)
Sets the material to use for this geometry.

Overrides:
setMaterial in class Spatial
Parameters:
material - the material to use for this geometry

getMaterial

public Material getMaterial()
Returns the material that is used for this geometry.

Returns:
the material that is used for this geometry
See Also:
setMaterial(com.jme3.material.Material)

getModelBound

public BoundingVolume getModelBound()
Returns:
The bounding volume of the mesh, in model space.

updateModelBound

public void updateModelBound()
Updates the bounding volume of the mesh. Should be called when the mesh has been modified.

Specified by:
updateModelBound in class Spatial

updateWorldBound

protected void updateWorldBound()
updateWorldBound updates the bounding volume that contains this geometry. The location of the geometry is based on the location of all this node's parents.

Overrides:
updateWorldBound in class Spatial
See Also:
Spatial.updateWorldBound()

updateWorldTransforms

protected void updateWorldTransforms()
Description copied from class: Spatial
Should only be called from updateGeometricState(). In most cases should not be subclassed.

Overrides:
updateWorldTransforms in class Spatial

batch

protected void batch(BatchNode node,
                     int startIndex)
Batch this geometry, should only be called by the BatchNode.

Parameters:
node - the batchNode
startIndex - the starting index of this geometry in the batched mesh

unBatch

protected void unBatch()
unBatch this geometry.


removeFromParent

public boolean removeFromParent()
Description copied from class: Spatial
removeFromParent removes this Spatial from it's parent.

Overrides:
removeFromParent in class Spatial
Returns:
true if it has a parent and performed the remove.

setParent

protected void setParent(Node parent)
Description copied from class: Spatial
Called by Node.attachChild(Spatial) and Node.detachChild(Spatial) - don't call directly. setParent sets the parent of this node.

Overrides:
setParent in class Spatial
Parameters:
parent - the parent of this node.

computeOffsetTransform

public void computeOffsetTransform()
Recomputes the cached offset matrix used when the geometry is batched *


computeWorldMatrix

public void computeWorldMatrix()
Recomputes the matrix returned by getWorldMatrix(). This will require a localized transform update for this geometry.


getWorldMatrix

public Matrix4f getWorldMatrix()
A matrix that transforms the mesh from model space to world space. This matrix is computed based on the world transform of this geometry. In order to receive updated values, you must call computeWorldMatrix() before using this method.

Returns:
Matrix to transform from local space to world space

setModelBound

public void setModelBound(BoundingVolume modelBound)
Sets the model bound to use for this geometry. This alters the bound used on the mesh as well via Mesh.setBound(com.jme3.bounding.BoundingVolume) and forces the world bounding volume to be recomputed.

Specified by:
setModelBound in class Spatial
Parameters:
modelBound - The model bound to set

collideWith

public int collideWith(Collidable other,
                       CollisionResults results)
Description copied from interface: Collidable
Check collision with another Collidable.

Parameters:
other - The object to check collision against
results - Will contain the list of CollisionResults.
Returns:
how many collisions were found between this and other

depthFirstTraversal

public void depthFirstTraversal(SceneGraphVisitor visitor)
Description copied from class: Spatial
Visit each scene graph element ordered by DFS

Specified by:
depthFirstTraversal in class Spatial

breadthFirstTraversal

protected void breadthFirstTraversal(SceneGraphVisitor visitor,
                                     java.util.Queue<Spatial> queue)
Specified by:
breadthFirstTraversal in class Spatial

isBatched

public boolean isBatched()

clone

public Geometry clone(boolean cloneMaterial)
This version of clone is a shallow clone, in other words, the same mesh is referenced as the original geometry. Exception: if the mesh is marked as being a software animated mesh, (bind pose is set) then the positions and normals are deep copied.

Overrides:
clone in class Spatial
Returns:
A clone of this Spatial, the scene graph in its entirety is cloned and can be altered independently of the original scene graph. Note that meshes of geometries are not cloned explicitly, they are shared if static, or specially cloned if animated. All controls will be cloned using the Control.cloneForSpatial method on the clone.
See Also:
Mesh.cloneForAnim()

clone

public Geometry clone()
This version of clone is a shallow clone, in other words, the same mesh is referenced as the original geometry. Exception: if the mesh is marked as being a software animated mesh, (bind pose is set) then the positions and normals are deep copied.

Specified by:
clone in interface CloneableSmartAsset
Overrides:
clone in class Spatial
Returns:
A clone of this Spatial, the scene graph in its entirety is cloned and can be altered independently of the original scene graph. Note that meshes of geometries are not cloned explicitly, they are shared if static, or specially cloned if animated. All controls will be cloned using the Control.cloneForSpatial method on the clone.
See Also:
Mesh.cloneForAnim()

deepClone

public Spatial deepClone()
Creates a deep clone of the geometry, this creates an identical copy of the mesh with the vertexbuffer data duplicated.

Specified by:
deepClone in class Spatial
Returns:
Similar to Spatial.clone() except will create a deep clone of all geometry's meshes, normally this method shouldn't be used instead use Spatial.clone()
See Also:
Spatial.clone()

write

public void write(JmeExporter ex)
           throws java.io.IOException
Specified by:
write in interface Savable
Overrides:
write in class Spatial
Throws:
java.io.IOException

read

public void read(JmeImporter im)
          throws java.io.IOException
Specified by:
read in interface Savable
Overrides:
read in class Spatial
Throws:
java.io.IOException