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
Modifier and TypeFieldDescriptionprotected Matrix4f
protected GeometryGroupNode
Specifies whichGeometryGroupNode
thisGeometry
is managed by.protected boolean
When true, the geometry's transform will not be applied.protected int
protected Material
protected Mesh
static final int
protected int
The start index of thisGeometry's
inside 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
associateWithGroupNode
(GeometryGroupNode node, int startIndex) Associate thisGeometry
with aGeometryGroupNode
.protected void
breadthFirstTraversal
(SceneGraphVisitor visitor, Queue<Spatial> queue) boolean
checkCulling
(Camera cam) checkCulling
checks 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.void
cloneFields
(Cloner cloner, Object original) Called internally by com.jme3.util.clone.Cloner.int
collideWith
(Collidable other, CollisionResults results) Check collision with another Collidable.void
Recomputes the matrix returned bygetWorldMatrix()
.Create a deep clone of the geometry.void
depthFirstTraversal
(SceneGraphVisitor visitor, Spatial.DFSMode mode) Visit each scene graph element ordered by DFS.int
Returns 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.float
getMorphState
(String morphTarget) Get the state of a morphint
Return the number of morph targets that can be handled on the GPU simultaneously for this geometry.int
Returns this geometry's mesh triangle count.int
Returns this geometry's mesh vertex count.boolean
Deprecated.boolean
returns true if the morph state has changed on the last frame.boolean
Determine whether thisGeometry
is managed by aGeometryGroupNode
or not.boolean
void
read
(JmeImporter im) boolean
removeFromParent
removes this Spatial from its parent.void
setDirtyMorph
(boolean dirtyMorph) Setting this to true will stop this geometry morph buffer to be updated, unless the morph state changesvoid
setFallbackMorphTarget
(MorphTarget fallbackMorphTarget) 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
Sets the mesh to use for this geometry when rendering.void
setModelBound
(BoundingVolume modelBound) Sets the model bound to use for this geometry.void
setMorphState
(float[] state) void
setMorphState
(String morphTarget, float state) Set the state of the morph with the given name.void
setNbSimultaneousGPUMorph
(int nbSimultaneousGPUMorph) Sets the number of morph targets that can be handled on the GPU simultaneously for this geometry.protected void
Called byNode.attachChild(Spatial)
andNode.detachChild(Spatial)
- don't call directly.void
Removes theGeometryGroupNode
association from thisGeometry
.void
Updates the bounding volume of the mesh.protected void
updateWorldBound
updates the bounding volume that contains this geometry.protected void
protected void
Should only be called from updateGeometricState().void
write
(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 whichGeometryGroupNode
thisGeometry
is managed by. -
startIndex
protected int startIndexThe start index of thisGeometry's
inside theGeometryGroupNode
.
-
-
Constructor Details
-
Geometry
public Geometry()Instantiate aGeometry
with 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:Spatial
checkCulling
checks 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:
checkCulling
in 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:
setLodLevel
in 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:
getVertexCount
in classSpatial
- Returns:
- this geometry's mesh vertex count.
- See Also:
-
getTriangleCount
public int getTriangleCount()Returns this geometry's mesh triangle count.- Specified by:
getTriangleCount
in 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:
setMaterial
in 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:
updateModelBound
in classSpatial
-
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 classSpatial
- See Also:
-
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 classSpatial
-
updateWorldLightList
protected void updateWorldLightList()- Overrides:
updateWorldLightList
in classSpatial
-
associateWithGroupNode
Associate thisGeometry
with aGeometryGroupNode
. Should only be called by the parentGeometryGroupNode
.- Parameters:
node
- WhichGeometryGroupNode
to associate with.startIndex
- The starting index of this geometry in the group.
-
unassociateFromGroupNode
public void unassociateFromGroupNode()Removes theGeometryGroupNode
association from thisGeometry
. Should only be called by the parentGeometryGroupNode
. -
removeFromParent
public boolean removeFromParent()Description copied from class:Spatial
removeFromParent
removes this Spatial from its parent.- Overrides:
removeFromParent
in classSpatial
- Returns:
- true if it has a parent and performed the remove.
-
setParent
Description copied from class:Spatial
Called byNode.attachChild(Spatial)
andNode.detachChild(Spatial)
- don't call directly.setParent
sets 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
Amatrix
that transforms themesh
from model space to world space. This matrix is computed based on theworld transform
of 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:
setModelBound
in classSpatial
- Parameters:
modelBound
- The model bound to set
-
collideWith
Description copied from interface:Collidable
Check collision with another Collidable.- Parameters:
other
- The object to check collision againstresults
- Will contain the list ofCollisionResult
s.- Returns:
- how many collisions were found between this and other
-
depthFirstTraversal
Description copied from class:Spatial
Visit each scene graph element ordered by DFS. There are two modes: pre order and post order.- Specified by:
depthFirstTraversal
in classSpatial
- Parameters:
visitor
- the action to take for each visited Spatialmode
- the traversal mode: pre order or post order
-
breadthFirstTraversal
- Specified by:
breadthFirstTraversal
in classSpatial
-
isGrouped
public boolean isGrouped()Determine whether thisGeometry
is managed by aGeometryGroupNode
or 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:
clone
in 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:
clone
in interfaceCloneableSmartAsset
- Overrides:
clone
in 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:
cloneFields
in interfaceJmeCloneable
- Overrides:
cloneFields
in 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:
write
in interfaceSavable
- Overrides:
write
in classSpatial
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Overrides:
read
in classSpatial
- Throws:
IOException
-
isGrouped()
instead.