Package com.jme3.scene
Class Geometry
java.lang.Object
com.jme3.scene.Spatial
com.jme3.scene.Geometry
- All Implemented Interfaces:
HasLocalTransform,CloneableSmartAsset,Collidable,Savable,JmeCloneable,Cloneable
- Direct Known Subclasses:
InstancedGeometry,ParticleEmitter,Picture,TerrainPatch
-
Nested Class Summary
Nested classes/interfaces inherited from class com.jme3.scene.Spatial
Spatial.BatchHint, Spatial.CullHint, Spatial.DFSMode -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Matrix4fprotected GeometryGroupNodeSpecifies whichGeometryGroupNodethisGeometryis managed by.protected booleanWhen true, the geometry's transform will not be applied.protected intprotected Materialprotected Meshstatic final intprotected intThe start index of thisGeometry'sinside theGeometryGroupNode.Fields inherited from class com.jme3.scene.Spatial
batchHint, controls, cullHint, frustrumIntersects, key, localLights, localOverrides, localTransform, name, parent, queueBucket, queueDistance, refreshFlags, RF_BOUND, RF_CHILD_LIGHTLIST, RF_LIGHTLIST, RF_MATPARAM_OVERRIDE, RF_TRANSFORM, shadowMode, userData, worldBound, worldLights, worldOverrides, worldTransform -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidassociateWithGroupNode(GeometryGroupNode node, int startIndex) Associate thisGeometrywith aGeometryGroupNode.protected voidbreadthFirstTraversal(SceneGraphVisitor visitor, Queue<Spatial> queue) booleancheckCulling(Camera cam) checkCullingchecks the spatial with the camera to see if it should be culled.clone()This version of clone is a shallow clone, in other words, the same mesh is referenced as the original geometry.clone(boolean cloneMaterial) This version of clone is a shallow clone, in other words, the same mesh is referenced as the original geometry.voidcloneFields(Cloner cloner, Object original) Called internally by com.jme3.util.clone.Cloner.intcollideWith(Collidable other, CollisionResults results) Check collision with another Collidable.voidRecomputes the matrix returned bygetWorldMatrix().Create a deep clone of the geometry.voiddepthFirstTraversal(SceneGraphVisitor visitor, Spatial.DFSMode mode) Visit each scene graph element ordered by DFS.intReturns the LOD level set withsetLodLevel(int).Returns the material that is used for this geometry.getMesh()Returns the mesh to use for this geometryfloat[]returns the morph state of this Geometry.floatgetMorphState(String morphTarget) Get the state of a morphintReturn the number of morph targets that can be handled on the GPU simultaneously for this geometry.intReturns this geometry's mesh triangle count.intReturns this geometry's mesh vertex count.booleanDeprecated.booleanreturns true if the morph state has changed on the last frame.booleanDetermine whether thisGeometryis managed by aGeometryGroupNodeor not.booleanvoidread(JmeImporter im) booleanremoveFromParentremoves this Spatial from its parent.voidsetDirtyMorph(boolean dirtyMorph) Setting this to true will stop this geometry morph buffer to be updated, unless the morph state changesvoidsetFallbackMorphTarget(MorphTarget fallbackMorphTarget) voidsetIgnoreTransform(boolean ignoreTransform) voidsetLodLevel(int lod) Sets the LOD level to use when rendering the mesh of this geometry.voidsetMaterial(Material material) Sets the material to use for this geometry.voidSets the mesh to use for this geometry when rendering.voidsetModelBound(BoundingVolume modelBound) Sets the model bound to use for this geometry.voidsetMorphState(float[] state) voidsetMorphState(String morphTarget, float state) Set the state of the morph with the given name.voidsetNbSimultaneousGPUMorph(int nbSimultaneousGPUMorph) Sets the number of morph targets that can be handled on the GPU simultaneously for this geometry.protected voidCalled byNode.attachChild(Spatial)andNode.detachChild(Spatial)- don't call directly.voidRemoves theGeometryGroupNodeassociation from thisGeometry.voidUpdates the bounding volume of the mesh.protected voidupdateWorldBoundupdates the bounding volume that contains this geometry.protected voidprotected voidShould only be called from updateGeometricState().voidwrite(JmeExporter ex) Methods inherited from class com.jme3.scene.Spatial
addControl, addControlAt, addLight, addMatParamOverride, breadthFirstTraversal, center, clearMatParamOverrides, depthFirstTraversal, forceRefresh, getBatchHint, getControl, getControl, getCullHint, getKey, getLastFrustumIntersection, getLocalBatchHint, getLocalCullHint, getLocalLightList, getLocalMatParamOverrides, getLocalQueueBucket, getLocalRotation, getLocalScale, getLocalShadowMode, getLocalToWorldMatrix, getLocalTransform, getLocalTranslation, getName, getNumControls, getParent, getQueueBucket, getShadowMode, getUserData, getUserDataKeys, getWorldBound, getWorldLightList, getWorldMatParamOverrides, getWorldRotation, getWorldScale, getWorldTransform, getWorldTranslation, hasAncestor, jmeClone, localToWorld, lookAt, matches, move, move, oldClone, removeControl, removeControl, removeLight, removeMatParamOverride, rotate, rotate, rotateUpTo, runControlRender, scale, scale, setBatchHint, setBoundRefresh, setCullHint, setKey, setLastFrustumIntersection, setLightListRefresh, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalScale, setLocalTransform, setLocalTranslation, setLocalTranslation, setMatParamOverrideRefresh, setName, setQueueBucket, setRequiresUpdates, setShadowMode, setTransformRefresh, setUserData, toString, updateGeometricState, updateLogicalState, updateMatParamOverrides, worldToLocal
-
Field Details
-
SAVABLE_VERSION
public static final int SAVABLE_VERSION- See Also:
-
mesh
-
lodLevel
protected transient int lodLevel -
material
-
ignoreTransform
protected boolean ignoreTransformWhen true, the geometry's transform will not be applied. -
cachedWorldMat
-
groupNode
Specifies whichGeometryGroupNodethisGeometryis managed by. -
startIndex
protected int startIndexThe start index of thisGeometry'sinside theGeometryGroupNode.
-
-
Constructor Details
-
Geometry
public Geometry()Instantiate aGeometrywith no name, no mesh, and no material. The mesh and material must be set prior to rendering. -
Geometry
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
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 geometrymesh- The mesh data for this geometry
-
-
Method Details
-
checkCulling
Description copied from class:SpatialcheckCullingchecks the spatial with the camera to see if it should be culled.This method is called by the renderer. Usually it should not be called directly.
- Overrides:
checkCullingin classSpatial- Parameters:
cam- The camera to check against.- Returns:
- true if inside or intersecting camera frustum (should be rendered), false if outside.
-
isIgnoreTransform
public boolean isIgnoreTransform()- Returns:
- If ignoreTransform mode is set.
- See Also:
-
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 withMesh.setLodLevels(com.jme3.scene.VertexBuffer[]).- Overrides:
setLodLevelin classSpatial- Parameters:
lod- The lod level to set
-
getLodLevel
public int getLodLevel()Returns the LOD level set withsetLodLevel(int).- Returns:
- the LOD level set
-
getVertexCount
public int getVertexCount()Returns this geometry's mesh vertex count.- Specified by:
getVertexCountin classSpatial- Returns:
- this geometry's mesh vertex count.
- See Also:
-
getTriangleCount
public int getTriangleCount()Returns this geometry's mesh triangle count.- Specified by:
getTriangleCountin classSpatial- Returns:
- this geometry's mesh triangle count.
- See Also:
-
setMesh
Sets the mesh to use for this geometry when rendering.- Parameters:
mesh- the mesh to use for this geometry- Throws:
IllegalArgumentException- If mesh is null
-
getMesh
Returns the mesh to use for this geometry- Returns:
- the mesh to use for this geometry
- See Also:
-
setMaterial
Sets the material to use for this geometry.- Overrides:
setMaterialin classSpatial- Parameters:
material- the material to use for this geometry
-
getMaterial
Returns the material that is used for this geometry.- Returns:
- the material that is used for this geometry
- See Also:
-
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:
updateModelBoundin classSpatial
-
updateWorldBound
protected void updateWorldBound()updateWorldBoundupdates the bounding volume that contains this geometry. The location of the geometry is based on the location of all this node's parents.- Overrides:
updateWorldBoundin classSpatial- See Also:
-
updateWorldTransforms
protected void updateWorldTransforms()Description copied from class:SpatialShould only be called from updateGeometricState(). In most cases should not be subclassed.- Overrides:
updateWorldTransformsin classSpatial
-
updateWorldLightList
protected void updateWorldLightList()- Overrides:
updateWorldLightListin classSpatial
-
associateWithGroupNode
Associate thisGeometrywith aGeometryGroupNode. Should only be called by the parentGeometryGroupNode.- Parameters:
node- WhichGeometryGroupNodeto associate with.startIndex- The starting index of this geometry in the group.
-
unassociateFromGroupNode
public void unassociateFromGroupNode()Removes theGeometryGroupNodeassociation from thisGeometry. Should only be called by the parentGeometryGroupNode. -
removeFromParent
public boolean removeFromParent()Description copied from class:SpatialremoveFromParentremoves this Spatial from its parent.- Overrides:
removeFromParentin classSpatial- Returns:
- true if it has a parent and performed the remove.
-
setParent
Description copied from class:SpatialCalled byNode.attachChild(Spatial)andNode.detachChild(Spatial)- don't call directly.setParentsets the parent of this node. -
computeWorldMatrix
public void computeWorldMatrix()Recomputes the matrix returned bygetWorldMatrix(). This will require a localized transform update for this geometry. -
getWorldMatrix
Amatrixthat transforms themeshfrom model space to world space. This matrix is computed based on theworld transformof this geometry. In order to receive updated values, you must callcomputeWorldMatrix()before using this method.- Returns:
- Matrix to transform from local space to world space
-
setModelBound
Sets the model bound to use for this geometry. This alters the bound used on the mesh as well viaMesh.setBound(com.jme3.bounding.BoundingVolume)and forces the world bounding volume to be recomputed.- Specified by:
setModelBoundin classSpatial- Parameters:
modelBound- The model bound to set
-
collideWith
Description copied from interface:CollidableCheck collision with another Collidable.- Parameters:
other- The object to check collision againstresults- Will contain the list ofCollisionResults.- Returns:
- how many collisions were found between this and other
-
depthFirstTraversal
Description copied from class:SpatialVisit each scene graph element ordered by DFS. There are two modes: pre order and post order.- Specified by:
depthFirstTraversalin classSpatial- Parameters:
visitor- the action to take for each visited Spatialmode- the traversal mode: pre order or post order
-
breadthFirstTraversal
- Specified by:
breadthFirstTraversalin classSpatial
-
isGrouped
public boolean isGrouped()Determine whether thisGeometryis managed by aGeometryGroupNodeor not.- Returns:
- True if managed by a
GeometryGroupNode.
-
isBatched
Deprecated.UseisGrouped()instead.- Returns:
- true if managed by a
GeometryGroupNode
-
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.- Overrides:
clonein classSpatial- Parameters:
cloneMaterial- true to clone materials, false to share them- 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.
- See Also:
-
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:
clonein interfaceCloneableSmartAsset- Overrides:
clonein classSpatial- 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.
- See Also:
-
deepClone
Create a deep clone of the geometry. This creates an identical copy of the mesh with the vertex buffer data duplicated. -
oldDeepClone
-
cloneFields
Called internally by com.jme3.util.clone.Cloner. Do not call directly.- Specified by:
cloneFieldsin interfaceJmeCloneable- Overrides:
cloneFieldsin classSpatial- Parameters:
cloner- The cloner that is performing the cloning operation. The cloneFields method can call back into the cloner to make clones of its subordinate fields.original- The original object from which this object was cloned. This is provided for the very rare case that this object needs to refer to its original for some reason. In general, all of the relevant values should have been transferred during the shallow clone, and this object need only clone what it wants.
-
setMorphState
public void setMorphState(float[] state) -
setMorphState
Set the state of the morph with the given name. If the name of the morph is not found, no state will be set.- Parameters:
morphTarget- The name of the morph to set the state ofstate- The state to set the morph to
-
isDirtyMorph
public boolean isDirtyMorph()returns true if the morph state has changed on the last frame.- Returns:
- true if changed, otherwise false
-
setDirtyMorph
public void setDirtyMorph(boolean dirtyMorph) Setting this to true will stop this geometry morph buffer to be updated, unless the morph state changes- Parameters:
dirtyMorph- true→prevent updating, false→allow updating
-
getMorphState
public float[] getMorphState()returns the morph state of this Geometry. Used internally by the MorphControl.- Returns:
- an array
-
getMorphState
Get the state of a morph- Parameters:
morphTarget- the name of the morph to get the state of- Returns:
- the state of the morph, or -1 if the morph is not found
-
getNbSimultaneousGPUMorph
public int getNbSimultaneousGPUMorph()Return the number of morph targets that can be handled on the GPU simultaneously for this geometry. Note that it depends on the material set on this geometry. This number is computed and set by the MorphControl, so it might be available only after the first frame. Else it's set to -1.- Returns:
- the number of simultaneous morph targets handled on the GPU
-
setNbSimultaneousGPUMorph
public void setNbSimultaneousGPUMorph(int nbSimultaneousGPUMorph) Sets the number of morph targets that can be handled on the GPU simultaneously for this geometry. Note that it depends on the material set on this geometry. This number is computed and set by the MorphControl, so it might be available only after the first frame. Else it's set to -1. WARNING: setting this manually might crash the shader compilation if set too high. Do it at your own risk.- Parameters:
nbSimultaneousGPUMorph- the number of simultaneous morph targets to be handled on the GPU.
-
getFallbackMorphTarget
-
setFallbackMorphTarget
-
write
- Specified by:
writein interfaceSavable- Overrides:
writein classSpatial- Throws:
IOException
-
read
- Specified by:
readin interfaceSavable- Overrides:
readin classSpatial- Throws:
IOException
-
isGrouped()instead.