|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jme3.scene.Spatial
public abstract class Spatial
Spatial
defines the base class for scene graph nodes. It
maintains a link to a parent, it's local transforms and the world's
transforms. All other scene graph elements, such as Node
and
Geometry
are subclasses of Spatial
.
Nested Class Summary | |
---|---|
static class |
Spatial.BatchHint
Specifies if this spatial should be batched |
static class |
Spatial.CullHint
Specifies how frustum culling should be handled by this spatial. |
Field Summary | |
---|---|
protected Spatial.BatchHint |
batchHint
|
protected SafeArrayList<Control> |
controls
|
protected Spatial.CullHint |
cullHint
|
protected Camera.FrustumIntersect |
frustrumIntersects
|
protected AssetKey |
key
Used for smart asset caching |
protected LightList |
localLights
LightList |
protected Transform |
localTransform
|
protected java.lang.String |
name
This spatial's name. |
protected Node |
parent
Spatial's parent, or null if it has none. |
protected RenderQueue.Bucket |
queueBucket
|
float |
queueDistance
|
protected int |
refreshFlags
Refresh flags. |
protected static int |
RF_BOUND
Refresh flag types |
protected static int |
RF_LIGHTLIST
Refresh flag types |
protected static int |
RF_TRANSFORM
Refresh flag types |
protected RenderQueue.ShadowMode |
shadowMode
|
protected java.util.HashMap<java.lang.String,Savable> |
userData
|
protected BoundingVolume |
worldBound
Spatial's bounding volume relative to the world. |
protected LightList |
worldLights
|
protected Transform |
worldTransform
|
Constructor Summary | |
---|---|
Spatial()
Serialization only. |
|
Spatial(java.lang.String name)
Constructor instantiates a new Spatial object setting the
rotation, translation and scale value to defaults. |
Method Summary | ||
---|---|---|
void |
addControl(Control control)
Add a control to the list of controls. |
|
void |
addLight(Light light)
addLight adds the given light to the Spatial; causing
all child Spatials to be effected by it. |
|
void |
breadthFirstTraversal(SceneGraphVisitor visitor)
Visit each scene graph element ordered by BFS |
|
protected abstract void |
breadthFirstTraversal(SceneGraphVisitor visitor,
java.util.Queue<Spatial> queue)
|
|
Spatial |
center()
Centers the spatial in the origin of the world bound. |
|
boolean |
checkCulling(Camera cam)
checkCulling checks the spatial with the camera to see if it
should be culled. |
|
Spatial |
clone()
Creates a clone of the asset. |
|
Spatial |
clone(boolean cloneMaterial)
|
|
abstract Spatial |
deepClone()
|
|
abstract void |
depthFirstTraversal(SceneGraphVisitor visitor)
Visit each scene graph element ordered by DFS |
|
Spatial.BatchHint |
getBatchHint()
|
|
|
getControl(java.lang.Class<T> controlType)
Returns the first control that is an instance of the given class, or null if no such control exists. |
|
Control |
getControl(int index)
Returns the control at the given index in the list. |
|
Spatial.CullHint |
getCullHint()
|
|
AssetKey |
getKey()
Returns the asset key that is used to track this asset for garbage collection. |
|
Camera.FrustumIntersect |
getLastFrustumIntersection()
Returns this spatial's last frustum intersection result. |
|
Spatial.BatchHint |
getLocalBatchHint()
|
|
Spatial.CullHint |
getLocalCullHint()
|
|
LightList |
getLocalLightList()
Returns the local LightList , which are the lights
that were directly attached to this Spatial through the
addLight(com.jme3.light.Light) and
removeLight(com.jme3.light.Light) methods. |
|
RenderQueue.Bucket |
getLocalQueueBucket()
|
|
Quaternion |
getLocalRotation()
getLocalRotation retrieves the local rotation of this
node. |
|
Vector3f |
getLocalScale()
getLocalScale retrieves the local scale of this node. |
|
RenderQueue.ShadowMode |
getLocalShadowMode()
|
|
Matrix4f |
getLocalToWorldMatrix(Matrix4f store)
Creates a transform matrix that will convert from this spatials' local coordinate space to the world coordinate space based on the world transform. |
|
Transform |
getLocalTransform()
getLocalTransform retrieves the local transform of
this spatial. |
|
Vector3f |
getLocalTranslation()
getLocalTranslation retrieves the local translation of
this node. |
|
java.lang.String |
getName()
Returns the name of this spatial. |
|
int |
getNumControls()
|
|
Node |
getParent()
getParent retrieves this node's parent. |
|
RenderQueue.Bucket |
getQueueBucket()
Returns this spatial's renderqueue bucket. |
|
RenderQueue.ShadowMode |
getShadowMode()
|
|
abstract int |
getTriangleCount()
|
|
|
getUserData(java.lang.String key)
|
|
java.util.Collection<java.lang.String> |
getUserDataKeys()
|
|
abstract int |
getVertexCount()
|
|
BoundingVolume |
getWorldBound()
getWorldBound retrieves the world bound at this node
level. |
|
LightList |
getWorldLightList()
Returns the world LightList , containing the lights
combined from all this Spatial's parents up to and including
this Spatial 's lights. |
|
Quaternion |
getWorldRotation()
getWorldRotation retrieves the absolute rotation of the
Spatial. |
|
Vector3f |
getWorldScale()
getWorldScale retrieves the absolute scale factor of the
spatial. |
|
Transform |
getWorldTransform()
getWorldTransform retrieves the world transformation
of the spatial. |
|
Vector3f |
getWorldTranslation()
getWorldTranslation retrieves the absolute translation of
the spatial. |
|
boolean |
hasAncestor(Node ancestor)
determines if the provided Node is the parent, or parent's parent, etc. |
|
Vector3f |
localToWorld(Vector3f in,
Vector3f store)
Convert a vector (in) from this spatials' local coordinate space to world coordinate space. |
|
void |
lookAt(Vector3f position,
Vector3f upVector)
lookAt is a convenience method for auto-setting the local
rotation based on a position and an up vector. |
|
boolean |
matches(java.lang.Class<? extends Spatial> spatialSubclass,
java.lang.String nameRegex)
Note that we are matching the pattern, therefore the pattern must match the entire pattern (i.e. |
|
Spatial |
move(float x,
float y,
float z)
Translates the spatial by the given translation vector. |
|
Spatial |
move(Vector3f offset)
Translates the spatial by the given translation vector. |
|
void |
read(JmeImporter im)
|
|
void |
removeControl(java.lang.Class<? extends Control> controlType)
Removes the first control that is an instance of the given class. |
|
boolean |
removeControl(Control control)
Removes the given control from this spatial's controls. |
|
boolean |
removeFromParent()
removeFromParent removes this Spatial from it's parent. |
|
void |
removeLight(Light light)
removeLight removes the given light from the Spatial. |
|
Spatial |
rotate(float xAngle,
float yAngle,
float zAngle)
Rotates the spatial by the xAngle, yAngle and zAngle angles (in radians), (aka pitch, yaw, roll) in the local coordinate space. |
|
Spatial |
rotate(Quaternion rot)
Rotates the spatial by the given rotation. |
|
void |
rotateUpTo(Vector3f newUp)
rotateUpTo is a utility function that alters the
local rotation to point the Y axis in the direction given by newUp. |
|
void |
runControlRender(RenderManager rm,
ViewPort vp)
Called when the Spatial is about to be rendered, to notify controls attached to this Spatial using the Control.render() method. |
|
Spatial |
scale(float s)
Scales the spatial by the given value |
|
Spatial |
scale(float x,
float y,
float z)
Scales the spatial by the given scale vector. |
|
void |
setBatchHint(Spatial.BatchHint hint)
setBatchHint sets how batching should work on this
spatial. |
|
protected void |
setBoundRefresh()
Indicate that the bounding of this spatial has changed and that a refresh is required. |
|
void |
setCullHint(Spatial.CullHint hint)
setCullHint sets how scene culling should work on this
spatial during drawing. |
|
void |
setKey(AssetKey key)
Set by the AssetManager to track this asset. |
|
void |
setLastFrustumIntersection(Camera.FrustumIntersect intersects)
Overrides the last intersection result. |
|
protected void |
setLightListRefresh()
|
|
void |
setLocalRotation(Matrix3f rotation)
setLocalRotation sets the local rotation of this node
by using a Matrix3f . |
|
void |
setLocalRotation(Quaternion quaternion)
setLocalRotation sets the local rotation of this node. |
|
void |
setLocalScale(float localScale)
setLocalScale sets the local scale of this node. |
|
void |
setLocalScale(float x,
float y,
float z)
setLocalScale sets the local scale of this node. |
|
void |
setLocalScale(Vector3f localScale)
setLocalScale sets the local scale of this node. |
|
void |
setLocalTransform(Transform t)
setLocalTransform sets the local transform of this
spatial. |
|
void |
setLocalTranslation(float x,
float y,
float z)
setLocalTranslation sets the local translation of this
spatial. |
|
void |
setLocalTranslation(Vector3f localTranslation)
setLocalTranslation sets the local translation of this
spatial. |
|
void |
setLodLevel(int lod)
Sets the level of detail to use when rendering this Spatial, this call propagates to all geometries under this Spatial. |
|
void |
setMaterial(Material material)
Applies the given material to the Spatial, this will propagate the material down to the geometries in the scene graph. |
|
abstract void |
setModelBound(BoundingVolume modelBound)
setModelBound sets the bounding object for this Spatial. |
|
void |
setName(java.lang.String name)
Sets the name of this spatial. |
|
protected void |
setParent(Node parent)
Called by Node.attachChild(Spatial) and
Node.detachChild(Spatial) - don't call directly. |
|
void |
setQueueBucket(RenderQueue.Bucket queueBucket)
setQueueBucket determines at what phase of the
rendering process this Spatial will rendered. |
|
void |
setShadowMode(RenderQueue.ShadowMode shadowMode)
Sets the shadow mode of the spatial The shadow mode determines how the spatial should be shadowed, when a shadowing technique is used. |
|
protected void |
setTransformRefresh()
Indicate that the transform of this spatial has changed and that a refresh is required. |
|
void |
setUserData(java.lang.String key,
java.lang.Object data)
|
|
java.lang.String |
toString()
Returns the Spatial's name followed by the class of the spatial Example: "MyNode (com.jme3.scene.Spatial) |
|
void |
updateGeometricState()
updateGeometricState updates the lightlist,
computes the world transforms, and computes the world bounds
for this Spatial. |
|
void |
updateLogicalState(float tpf)
updateLogicalState calls the update() method
for all controls attached to this Spatial. |
|
abstract void |
updateModelBound()
updateModelBound recalculates the bounding object for this
Spatial. |
|
protected void |
updateWorldBound()
Should be overridden by Node and Geometry. |
|
protected void |
updateWorldLightList()
|
|
protected void |
updateWorldTransforms()
Should only be called from updateGeometricState(). |
|
Vector3f |
worldToLocal(Vector3f in,
Vector3f store)
Convert a vector (in) from world coordinate space to this spatials' local coordinate space. |
|
void |
write(JmeExporter ex)
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.jme3.collision.Collidable |
---|
collideWith |
Field Detail |
---|
protected static final int RF_TRANSFORM
protected static final int RF_BOUND
protected static final int RF_LIGHTLIST
protected Spatial.CullHint cullHint
protected Spatial.BatchHint batchHint
protected BoundingVolume worldBound
protected LightList localLights
protected transient LightList worldLights
protected java.lang.String name
protected transient Camera.FrustumIntersect frustrumIntersects
protected RenderQueue.Bucket queueBucket
protected RenderQueue.ShadowMode shadowMode
public transient float queueDistance
protected Transform localTransform
protected Transform worldTransform
protected SafeArrayList<Control> controls
protected java.util.HashMap<java.lang.String,Savable> userData
protected AssetKey key
AssetKey#useSmartCache()
protected transient Node parent
protected transient int refreshFlags
Constructor Detail |
---|
public Spatial()
public Spatial(java.lang.String name)
Spatial
object setting the
rotation, translation and scale value to defaults.
name
- the name of the scene element. This is required for
identification and comparison purposes.Method Detail |
---|
public void setKey(AssetKey key)
CloneableSmartAsset
AssetManager
to track this asset.
Only clones of the asset has this set, the original copy that
was loaded has this key set to null so that only the clones are tracked
for garbage collection.
setKey
in interface CloneableSmartAsset
key
- The AssetKey to setpublic AssetKey getKey()
CloneableSmartAsset
getKey
in interface CloneableSmartAsset
protected void setTransformRefresh()
protected void setLightListRefresh()
protected void setBoundRefresh()
public boolean checkCulling(Camera cam)
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.
cam
- The camera to check against.
public void setName(java.lang.String name)
name
- The spatial's new name.public java.lang.String getName()
public LightList getLocalLightList()
LightList
, which are the lights
that were directly attached to this Spatial
through the
addLight(com.jme3.light.Light)
and
removeLight(com.jme3.light.Light)
methods.
public LightList getWorldLightList()
LightList
, containing the lights
combined from all this Spatial's
parents up to and including
this Spatial
's lights.
public Quaternion getWorldRotation()
getWorldRotation
retrieves the absolute rotation of the
Spatial.
public Vector3f getWorldTranslation()
getWorldTranslation
retrieves the absolute translation of
the spatial.
public Vector3f getWorldScale()
getWorldScale
retrieves the absolute scale factor of the
spatial.
public Transform getWorldTransform()
getWorldTransform
retrieves the world transformation
of the spatial.
public void rotateUpTo(Vector3f newUp)
rotateUpTo
is a utility function that alters the
local rotation to point the Y axis in the direction given by newUp.
newUp
- the up vector to use - assumed to be a unit vector.public void lookAt(Vector3f position, Vector3f upVector)
lookAt
is a convenience method for auto-setting the local
rotation based on a position and an up vector. It computes the rotation
to transform the z-axis to point onto 'position' and the y-axis to 'up'.
Unlike Quaternion.lookAt(com.jme3.math.Vector3f, com.jme3.math.Vector3f)
this method takes a world position to look at and not a relative direction.
position
- where to look at in terms of world coordinatesupVector
- a vector indicating the (local) up direction. (typically {0,
1, 0} in jME.)protected void updateWorldBound()
protected void updateWorldLightList()
protected void updateWorldTransforms()
public void runControlRender(RenderManager rm, ViewPort vp)
rm
- The RenderManager rendering the Spatial.vp
- The ViewPort to which the Spatial is being rendered to.addControl(com.jme3.scene.control.Control)
,
getControl(java.lang.Class)
public void addControl(Control control)
control
- The control to add.removeControl(java.lang.Class)
public void removeControl(java.lang.Class<? extends Control> controlType)
addControl(com.jme3.scene.control.Control)
public boolean removeControl(Control control)
control
- The control to remove
addControl(com.jme3.scene.control.Control)
public <T extends Control> T getControl(java.lang.Class<T> controlType)
controlType
- The superclass of the control to look for.
addControl(com.jme3.scene.control.Control)
public Control getControl(int index)
index
- The index of the control in the list to find.
java.lang.IndexOutOfBoundsException
- If the index is outside the range [0, getNumControls()-1]addControl(com.jme3.scene.control.Control)
public int getNumControls()
addControl(com.jme3.scene.control.Control)
,
removeControl(java.lang.Class)
public void updateLogicalState(float tpf)
updateLogicalState
calls the update()
method
for all controls attached to this Spatial.
tpf
- Time per frame.addControl(com.jme3.scene.control.Control)
public void updateGeometricState()
updateGeometricState
updates the lightlist,
computes the world transforms, and computes the world bounds
for this Spatial.
Calling this when the Spatial is attached to a node
will cause undefined results. User code should only call this
method on Spatials having no parent.
getWorldLightList()
,
getWorldTransform()
,
getWorldBound()
public Vector3f localToWorld(Vector3f in, Vector3f store)
in
- vector to read fromstore
- where to write the result (null to create a new vector, may be
same as in)
public Vector3f worldToLocal(Vector3f in, Vector3f store)
in
- vector to read fromstore
- where to write the result
public Node getParent()
getParent
retrieves this node's parent. If the parent is
null this is the root node.
protected void setParent(Node parent)
Node.attachChild(Spatial)
and
Node.detachChild(Spatial)
- don't call directly.
setParent
sets the parent of this node.
parent
- the parent of this node.public boolean removeFromParent()
removeFromParent
removes this Spatial from it's parent.
public boolean hasAncestor(Node ancestor)
ancestor
- the ancestor object to look for.
public Quaternion getLocalRotation()
getLocalRotation
retrieves the local rotation of this
node.
public void setLocalRotation(Matrix3f rotation)
setLocalRotation
sets the local rotation of this node
by using a Matrix3f
.
rotation
- the new local rotation.public void setLocalRotation(Quaternion quaternion)
setLocalRotation
sets the local rotation of this node.
quaternion
- the new local rotation.public Vector3f getLocalScale()
getLocalScale
retrieves the local scale of this node.
public void setLocalScale(float localScale)
setLocalScale
sets the local scale of this node.
localScale
- the new local scale, applied to x, y and zpublic void setLocalScale(float x, float y, float z)
setLocalScale
sets the local scale of this node.
public void setLocalScale(Vector3f localScale)
setLocalScale
sets the local scale of this node.
localScale
- the new local scale.public Vector3f getLocalTranslation()
getLocalTranslation
retrieves the local translation of
this node.
public void setLocalTranslation(Vector3f localTranslation)
setLocalTranslation
sets the local translation of this
spatial.
localTranslation
- the local translation of this spatial.public void setLocalTranslation(float x, float y, float z)
setLocalTranslation
sets the local translation of this
spatial.
public void setLocalTransform(Transform t)
setLocalTransform
sets the local transform of this
spatial.
public Transform getLocalTransform()
getLocalTransform
retrieves the local transform of
this spatial.
public void setMaterial(Material material)
material
- The material to set.public void addLight(Light light)
addLight
adds the given light to the Spatial; causing
all child Spatials to be effected by it.
light
- The light to add.public void removeLight(Light light)
removeLight
removes the given light from the Spatial.
light
- The light to remove.addLight(com.jme3.light.Light)
public Spatial move(float x, float y, float z)
this
.public Spatial move(Vector3f offset)
this
.public Spatial scale(float s)
this
.public Spatial scale(float x, float y, float z)
this
.public Spatial rotate(Quaternion rot)
this
.public Spatial rotate(float xAngle, float yAngle, float zAngle)
this
.public Spatial center()
this
.public Spatial.CullHint getCullHint()
setCullHint(CullHint)
public Spatial.BatchHint getBatchHint()
public RenderQueue.Bucket getQueueBucket()
public RenderQueue.ShadowMode getShadowMode()
setShadowMode(com.jme3.renderer.queue.RenderQueue.ShadowMode)
,
RenderQueue.ShadowMode
public void setLodLevel(int lod)
lod
- The lod level to set.public abstract void updateModelBound()
updateModelBound
recalculates the bounding object for this
Spatial.
public abstract void setModelBound(BoundingVolume modelBound)
setModelBound
sets the bounding object for this Spatial.
modelBound
- the bounding object for this spatial.public abstract int getVertexCount()
public abstract int getTriangleCount()
public Spatial clone(boolean cloneMaterial)
Mesh.cloneForAnim()
public Spatial clone()
CloneableSmartAsset
Object.clone()
for more info on how this method
should be implemented.
clone
in interface CloneableSmartAsset
clone
in class java.lang.Object
Mesh.cloneForAnim()
public abstract Spatial deepClone()
clone()
public void setUserData(java.lang.String key, java.lang.Object data)
public <T> T getUserData(java.lang.String key)
public java.util.Collection<java.lang.String> getUserDataKeys()
public boolean matches(java.lang.Class<? extends Spatial> spatialSubclass, java.lang.String nameRegex)
spatialSubclass
- Subclass which this must implement.
Null causes all Spatials to qualify.nameRegex
- Regular expression to match this name against.
Null causes all Names to qualify.
Pattern
public void write(JmeExporter ex) throws java.io.IOException
write
in interface Savable
java.io.IOException
public void read(JmeImporter im) throws java.io.IOException
read
in interface Savable
java.io.IOException
public BoundingVolume getWorldBound()
getWorldBound
retrieves the world bound at this node
level.
public void setCullHint(Spatial.CullHint hint)
setCullHint
sets how scene culling should work on this
spatial during drawing. NOTE: You must set this AFTER attaching to a
parent or it will be reset with the parent's cullMode value.
hint
- one of CullHint.Dynamic, CullHint.Always, CullHint.Inherit or
CullHint.Neverpublic void setBatchHint(Spatial.BatchHint hint)
setBatchHint
sets how batching should work on this
spatial. NOTE: You must set this AFTER attaching to a
parent or it will be reset with the parent's cullMode value.
hint
- one of BatchHint.Never, BatchHint.Always, BatchHint.Inheritpublic Spatial.CullHint getLocalCullHint()
public Spatial.BatchHint getLocalBatchHint()
public void setQueueBucket(RenderQueue.Bucket queueBucket)
setQueueBucket
determines at what phase of the
rendering process this Spatial will rendered. See the
RenderQueue.Bucket
enum for an explanation of the various
render queue buckets.
queueBucket
- The bucket to use for this Spatial.public void setShadowMode(RenderQueue.ShadowMode shadowMode)
RenderQueue.ShadowMode
for more information.
shadowMode
- The local shadow mode to set.RenderQueue.ShadowMode
public RenderQueue.Bucket getLocalQueueBucket()
setQueueBucket(com.jme3.renderer.queue.RenderQueue.Bucket)
public RenderQueue.ShadowMode getLocalShadowMode()
setShadowMode(com.jme3.renderer.queue.RenderQueue.ShadowMode)
public Camera.FrustumIntersect getLastFrustumIntersection()
public void setLastFrustumIntersection(Camera.FrustumIntersect intersects)
intersects
- the new valuepublic java.lang.String toString()
toString
in class java.lang.Object
public Matrix4f getLocalToWorldMatrix(Matrix4f store)
store
- Matrix where to store the result, if null, a new one
will be created and returned.
getWorldTransform()
public abstract void depthFirstTraversal(SceneGraphVisitor visitor)
visitor
- public void breadthFirstTraversal(SceneGraphVisitor visitor)
visitor
- protected abstract void breadthFirstTraversal(SceneGraphVisitor visitor, java.util.Queue<Spatial> queue)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |