com.jme.scene
Class Spatial

java.lang.Object
  extended by com.jme.scene.Spatial
All Implemented Interfaces:
Savable, java.io.Serializable
Direct Known Subclasses:
Geometry, Node

public abstract class Spatial
extends java.lang.Object
implements java.io.Serializable, Savable

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 nodes, such as Node and Geometry are subclasses of Spatial.

Version:
$Revision: 4169 $, $Data$
Author:
Mark Powell, Joshua Slack
See Also:
Serialized Form

Nested Class Summary
static class Spatial.CullHint
           
static class Spatial.LightCombineMode
          Describes how to combine lights from ancestor lightstates when an updateRenderState is called on a Spatial.
static class Spatial.NormalsMode
           
static class Spatial.TextureCombineMode
          Describes how to combine textures from ancestor texturestates when an updateRenderState is called on a Spatial.
 
Field Summary
protected  Spatial.CullHint cullHint
          A flag indicating if scene culling should be done on this object by inheritance, dynamically, never, or always.
protected  Camera.FrustumIntersect frustrumIntersects
           
protected  java.util.ArrayList<Controller> geometricalControllers
          ArrayList of controllers for this spatial.
protected  boolean isCollidable
          Defines if this spatial will be used in intersection operations or not.
protected  Spatial.LightCombineMode lightCombineMode
          Flag signaling how lights are combined for this node.
protected  Quaternion localRotation
          Spatial's rotation relative to its parent.
protected  Vector3f localScale
          Spatial's scale relative to its parent.
protected  Vector3f localTranslation
          Spatial's translation relative to its parent.
static int LOCKED_BOUNDS
           
static int LOCKED_BRANCH
           
static int LOCKED_MESH_DATA
           
static int LOCKED_NONE
           
static int LOCKED_SHADOWS
           
static int LOCKED_TRANSFORMS
           
protected  int lockedMode
          Used to indicate this spatial (and any below it in the case of Node) is locked against certain changes.
protected  java.lang.String name
          This spatial's name.
protected  Spatial.NormalsMode normalsMode
          A flag indicating how normals should be treated by the renderer.
protected  Node parent
          Spatial's parent, or null if it has none.
 float queueDistance
           
protected  int renderQueueMode
           
protected  RenderState[] renderStateList
          The render states of this spatial.
protected  Spatial.TextureCombineMode textureCombineMode
          Flag signaling how textures are combined for this node.
protected  BoundingVolume worldBound
          Spatial's bounding volume relative to the world.
protected  Quaternion worldRotation
          Spatial's world absolute rotation.
protected  Vector3f worldScale
          Spatial's world absolute scale.
protected  Vector3f worldTranslation
          Spatial's world absolute translation.
protected  int zOrder
          Used to determine draw order for ortho mode rendering.
 
Constructor Summary
Spatial()
          Default Constructor.
Spatial(java.lang.String name)
          Constructor instantiates a new Spatial object setting the rotation, translation and scale value to defaults.
 
Method Summary
 void addController(Controller controller)
          Adds a Controller to this Spatial's list of controllers.
protected  void applyRenderState(java.util.Stack<? extends RenderState>[] states)
          Called during updateRenderState(Stack[]), this function determines how the render states are actually applied to the spatial and any children it may have.
 void calculateCollisions(Spatial scene, CollisionResults results)
          calculateCollisions calls findCollisions to populate the CollisionResults object then processes the collision results.
 void calculatePick(Ray ray, PickResults results)
           
 void clearControllers()
          Removes all Controllers from this Spatial's list of controllers.
 void clearRenderState(int renderStateType)
          Deprecated. As of 2.0, use clearRenderState(com.jme.scene.state.RenderState.StateType) instead.
 void clearRenderState(RenderState.StateType type)
          Clears a given render state index by setting it to null.
abstract  void draw(Renderer r)
          draw abstract method that handles drawing data to the renderer if it is geometry and passing the call to it's children if it is a node.
abstract  void findCollisions(Spatial scene, CollisionResults results)
          checks this spatial against a second spatial, any collisions are stored in the results object.
abstract  void findPick(Ray toTest, PickResults results)
          Tests a ray against this spatial, and stores the results in the result object.
 java.lang.Class<? extends Spatial> getClassTag()
           
 Controller getController(int i)
          Returns the controller in this list of controllers at index i.
 int getControllerCount()
           
 java.util.ArrayList<Controller> getControllers()
          Returns the ArrayList that contains this spatial's Controllers.
 Spatial.CullHint getCullHint()
           
 Camera.FrustumIntersect getLastFrustumIntersection()
          Returns this spatial's last frustum intersection result.
 Spatial.LightCombineMode getLightCombineMode()
          Returns this spatial's light combine mode.
 Spatial.CullHint getLocalCullHint()
           
 Spatial.LightCombineMode getLocalLightCombineMode()
           
 Spatial.NormalsMode getLocalNormalsMode()
           
 int getLocalRenderQueueMode()
           
 Quaternion getLocalRotation()
          getLocalRotation retrieves the local rotation of this node.
 Vector3f getLocalScale()
          getLocalScale retrieves the local scale of this node.
 Spatial.TextureCombineMode getLocalTextureCombineMode()
           
 Matrix4f getLocalToWorldMatrix(Matrix4f store)
           
 Vector3f getLocalTranslation()
          getLocalTranslation retrieves the local translation of this node.
 int getLocks()
           
 java.lang.String getName()
          Returns the name of this spatial.
 Spatial.NormalsMode getNormalsMode()
          Returns this spatial's normals mode.
 Node getParent()
          getParent retrieve's this node's parent.
 int getRenderQueueMode()
          Returns this spatial's renderqueue mode.
 RenderState getRenderState(int type)
          Deprecated. As of 2.0, use getRenderState(com.jme.scene.state.RenderState.StateType) instead.
 RenderState getRenderState(RenderState.StateType type)
          Returns the requested RenderState that this Spatial currently has set or null if none is set.
 Spatial.TextureCombineMode getTextureCombineMode()
          Returns this spatial's texture combine mode.
abstract  int getTriangleCount()
           
 Savable getUserData(java.lang.String key)
          Retrieves user data from the hashmap defined by the provided key.
abstract  int getVertexCount()
           
 BoundingVolume getWorldBound()
          getWorldBound retrieves the world bound at this node level.
 Quaternion getWorldRotation()
          getWorldRotation retrieves the absolute rotation of the Spatial.
 Vector3f getWorldScale()
          getWorldScale retrieves the absolute scale factor of the spatial.
 Vector3f getWorldTranslation()
          getWorldTranslation retrieves the absolute translation of the spatial.
 int getZOrder()
           
 boolean hasAncestor(Node ancestor)
          determines if the provided Node is the parent, or parent's parent, etc.
abstract  boolean hasCollision(Spatial scene, boolean checkTriangles)
          Checks this spatial against a second spatial for collisions.
 boolean isCollidable()
          Defines if this Spatial is to be used in intersection (collision and picking) calculations.
 Vector3f localToWorld(Vector3f in, Vector3f store)
          Convert a vector (in) from this spatials local coordinate space to world coordinate space.
 void lock()
          Convienence function for locking all aspects of a Spatial.
 void lock(Renderer r)
          Convienence function for locking all aspects of a Spatial.
 void lockBounds()
          Calling this method tells the scenegraph that it is not necessary to update bounds from this point in the scenegraph on down to the leaves.
 void lockBranch()
          Calling this method tells the scenegraph that it is not necessary to traverse this Spatial or any below it during the update phase.
 void lockMeshes()
          Flags this spatial and those below it that any meshes in the specified scenegraph location or lower will not have changes in vertex, texcoord, normal or color data.
 void lockMeshes(Renderer r)
          Flags this spatial and those below it that any meshes in the specified scenegraph location or lower will not have changes in vertex, texcoord, normal or color data.
 void lockShadows()
          Calling this method tells the scenegraph that it is not necessary to update Shadow volumes that may be associated with this Spatial.
 void lockTransforms()
          Flags this spatial and those below it in the scenegraph to not recalculate world transforms such as translation, rotation and scale on every update.
 void lookAt(Vector3f position, Vector3f upVector)
          lookAt is a convienence method for auto-setting the local rotation based on a position and an up vector.
 void onDraw(Renderer r)
          onDraw checks the spatial with the camera to see if it should be culled, if not, the node's draw method is called.
 void propagateBoundToRoot()
          propagateBoundToRoot passes the new world bound up the tree to the root.
 void propagateStatesFromRoot(java.util.Stack[] states)
          Called during updateRenderState(Stack[]), this function goes up the scene graph tree until the parent is null and pushes RenderStates onto the states Stack array.
 void read(JMEImporter im)
           
 boolean removeController(Controller controller)
          Removes a Controller from this Spatial's list of controllers, if it exist.
 Controller removeController(int index)
          Removes a Controller from this Spatial's list of controllers by index.
 boolean removeFromParent()
          removeFromParent removes this Spatial from it's parent.
 Savable removeUserData(java.lang.String key)
          Removes user data from the hashmap defined by the provided key.
 void rotateUpTo(Vector3f newUp)
          rotateUpTo is a util function that alters the localrotation to point the Y axis in the direction given by newUp.
 void setCullHint(Spatial.CullHint hint)
          setCullHint sets how scene culling should work on this spatial during drawing.
 void setIsCollidable(boolean isCollidable)
          Sets if this Spatial is to be used in intersection (collision and picking) calculations.
 void setLastFrustumIntersection(Camera.FrustumIntersect intersects)
          Overrides the last intersection result.
 void setLightCombineMode(Spatial.LightCombineMode mode)
          Sets how lights from parents should be combined for this spatial.
 void setLocalRotation(Matrix3f rotation)
          setLocalRotation sets the local rotation of this node.
 void setLocalRotation(Quaternion quaternion)
          setLocalRotation sets the local rotation of this node, using a quaterion to build the matrix.
 void setLocalScale(float localScale)
          setLocalScale sets the local scale of this node.
 void setLocalScale(Vector3f localScale)
          setLocalScale sets the local scale of this node.
 void setLocalTranslation(float x, float y, float z)
           
 void setLocalTranslation(Vector3f localTranslation)
          setLocalTranslation sets the local translation of this node.
 void setLocks(int lockedMode)
          Note: Uses the currently set Renderer to generate a display list if LOCKED_MESH_DATA is set.
 void setLocks(int locks, Renderer r)
           
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.
 void setNormalsMode(Spatial.NormalsMode mode)
           
protected  void setParent(Node parent)
          Called by Node.attachChild(Spatial) and Node.detachChild(Spatial) - don't call directly.
 void setRenderQueueMode(int renderQueueMode)
          setRenderQueueMode determines at what phase of the rendering proces this Spatial will rendered.
 RenderState setRenderState(RenderState rs)
          setRenderState sets a render state for this node.
 void setTextureCombineMode(Spatial.TextureCombineMode mode)
          Sets how textures from parents should be combined for this Spatial.
 void setUserData(java.lang.String key, Savable data)
          Stores user define data for this Spatial.
 void setZOrder(int zOrder)
           
 void setZOrder(int zOrder, boolean setOnChildren)
          Sets the zOrder of this Spatial and, if setOnChildren is true, all children as well.
 void sortLights()
           
 java.lang.String toString()
          Returns the Spatial's name followed by the class of the spatial
Example: "MyNode (com.jme.scene.Spatial)
 void unlock()
          Convienence function for unlocking all aspects of a Spatial.
 void unlock(Renderer r)
          Convienence function for unlocking all aspects of a Spatial.
 void unlockBounds()
          Flags this spatial and those below it to allow for bounds updating (the default).
 void unlockBranch()
          Flags this Spatial and any below it as being traversable during the update phase.
 void unlockMeshes()
          Flags this spatial and those below it to allow for mesh updating (the default).
 void unlockMeshes(Renderer r)
          Flags this spatial and those below it to allow for mesh updating (the default).
 void unlockShadows()
          Flags this spatial and those below it to allow for shadow volume updates (the default).
 void unlockTransforms()
          Flags this spatial and those below it to allow for transform updating (the default).
 void updateGeometricState(float time, boolean initiator)
          updateGeometricState updates all the geometry information for the node.
abstract  void updateModelBound()
          updateBound recalculates the bounding object for this Spatial.
 void updateRenderState()
          Updates the render state values of this Spatial and and children it has.
protected  void updateRenderState(java.util.Stack[] parentStates)
          Called internally.
abstract  void updateWorldBound()
          updateWorldBound updates the bounding volume of the world.
 void updateWorldData(float time)
          updateWorldData updates the world transforms from the parent down to the leaf.
protected  void updateWorldRotation()
           
protected  void updateWorldScale()
           
protected  void updateWorldTranslation()
           
 void updateWorldVectors()
          If not locked, updates worldscale, worldrotation and worldtranslation
 void updateWorldVectors(boolean recurse)
          If not locked, updates worldscale, worldrotation and worldtranslation
 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOCKED_NONE

public static final int LOCKED_NONE
See Also:
Constant Field Values

LOCKED_BOUNDS

public static final int LOCKED_BOUNDS
See Also:
Constant Field Values

LOCKED_MESH_DATA

public static final int LOCKED_MESH_DATA
See Also:
Constant Field Values

LOCKED_TRANSFORMS

public static final int LOCKED_TRANSFORMS
See Also:
Constant Field Values

LOCKED_SHADOWS

public static final int LOCKED_SHADOWS
See Also:
Constant Field Values

LOCKED_BRANCH

public static final int LOCKED_BRANCH
See Also:
Constant Field Values

normalsMode

protected Spatial.NormalsMode normalsMode
A flag indicating how normals should be treated by the renderer.


cullHint

protected Spatial.CullHint cullHint
A flag indicating if scene culling should be done on this object by inheritance, dynamically, never, or always.


worldBound

protected BoundingVolume worldBound
Spatial's bounding volume relative to the world.


renderStateList

protected RenderState[] renderStateList
The render states of this spatial.


renderQueueMode

protected int renderQueueMode

zOrder

protected int zOrder
Used to determine draw order for ortho mode rendering.


lockedMode

protected int lockedMode
Used to indicate this spatial (and any below it in the case of Node) is locked against certain changes.


lightCombineMode

protected Spatial.LightCombineMode lightCombineMode
Flag signaling how lights are combined for this node. By default set to INHERIT.


textureCombineMode

protected Spatial.TextureCombineMode textureCombineMode
Flag signaling how textures are combined for this node. By default set to INHERIT.


name

protected java.lang.String name
This spatial's name.


frustrumIntersects

protected Camera.FrustumIntersect frustrumIntersects

isCollidable

protected boolean isCollidable
Defines if this spatial will be used in intersection operations or not. Default is true


queueDistance

public transient float queueDistance

localRotation

protected Quaternion localRotation
Spatial's rotation relative to its parent.


worldRotation

protected Quaternion worldRotation
Spatial's world absolute rotation.


localTranslation

protected Vector3f localTranslation
Spatial's translation relative to its parent.


worldTranslation

protected Vector3f worldTranslation
Spatial's world absolute translation.


localScale

protected Vector3f localScale
Spatial's scale relative to its parent.


worldScale

protected Vector3f worldScale
Spatial's world absolute scale.


parent

protected transient Node parent
Spatial's parent, or null if it has none.


geometricalControllers

protected java.util.ArrayList<Controller> geometricalControllers
ArrayList of controllers for this spatial.

Constructor Detail

Spatial

public Spatial()
Default Constructor.


Spatial

public Spatial(java.lang.String name)
Constructor instantiates a new Spatial object setting the rotation, translation and scale value to defaults.

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

addController

public void addController(Controller controller)
Adds a Controller to this Spatial's list of controllers.

Parameters:
controller - The Controller to add
See Also:
Controller

removeController

public boolean removeController(Controller controller)
Removes a Controller from this Spatial's list of controllers, if it exist.

Parameters:
controller - The Controller to remove
Returns:
True if the Controller was in the list to remove.
See Also:
Controller

removeController

public Controller removeController(int index)
Removes a Controller from this Spatial's list of controllers by index.

Parameters:
index - The index of the controller to remove
Returns:
The Controller removed or null if nothing was removed.
See Also:
Controller

clearControllers

public void clearControllers()
Removes all Controllers from this Spatial's list of controllers.

See Also:
Controller

getController

public Controller getController(int i)
Returns the controller in this list of controllers at index i.

Parameters:
i - The index to get a controller from.
Returns:
The controller at index i.
See Also:
Controller

getControllers

public java.util.ArrayList<Controller> getControllers()
Returns the ArrayList that contains this spatial's Controllers.

Returns:
This spatial's geometricalControllers.

getControllerCount

public int getControllerCount()
Returns:
the number of controllers set on this Spatial.

onDraw

public void onDraw(Renderer r)
onDraw checks the spatial with the camera to see if it should be culled, if not, the node's draw method is called.

This method is called by the renderer. Usually it should not be called directly.

Parameters:
r - the renderer used for display.

getWorldRotation

public Quaternion getWorldRotation()
getWorldRotation retrieves the absolute rotation of the Spatial.

Returns:
the Spatial's world rotation matrix.

getWorldTranslation

public Vector3f getWorldTranslation()
getWorldTranslation retrieves the absolute translation of the spatial.

Returns:
the world's tranlsation vector.

getWorldScale

public Vector3f getWorldScale()
getWorldScale retrieves the absolute scale factor of the spatial.

Returns:
the world's scale factor.

rotateUpTo

public void rotateUpTo(Vector3f newUp)
rotateUpTo is a util function that alters the localrotation to point the Y axis in the direction given by newUp.

Parameters:
newUp - the up vector to use - assumed to be a unit vector.

lookAt

public void lookAt(Vector3f position,
                   Vector3f upVector)
lookAt is a convienence 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.jme.math.Vector3f, com.jme.math.Vector3f) this method takes a world position to look at not a relative direction.

Parameters:
position - where to look at in terms of world coordinates
upVector - a vector indicating the (local) up direction. (typically {0, 1, 0} in jME.)

updateGeometricState

public void updateGeometricState(float time,
                                 boolean initiator)
updateGeometricState updates all the geometry information for the node.

Parameters:
time - the frame time.
initiator - true if this node started the update process.

updateWorldData

public void updateWorldData(float time)
updateWorldData updates the world transforms from the parent down to the leaf.

Parameters:
time - the frame time.

updateWorldVectors

public void updateWorldVectors()
If not locked, updates worldscale, worldrotation and worldtranslation


updateWorldVectors

public void updateWorldVectors(boolean recurse)
If not locked, updates worldscale, worldrotation and worldtranslation

Parameters:
recurse - usually false when updating the tree. Set to true when you just want to update the world transforms for a branch without updating geometric state.

updateWorldTranslation

protected void updateWorldTranslation()

updateWorldRotation

protected void updateWorldRotation()

updateWorldScale

protected void updateWorldScale()

localToWorld

public Vector3f localToWorld(Vector3f in,
                             Vector3f store)
Convert a vector (in) from this spatials local coordinate space to world coordinate space.

Parameters:
in - vector to read from
store - where to write the result (null to create a new vector, may be same as in)
Returns:
the result (store)

worldToLocal

public Vector3f worldToLocal(Vector3f in,
                             Vector3f store)
Convert a vector (in) from world coordinate space to this spatials local coordinate space.

Parameters:
in - vector to read from
store - where to write the result
Returns:
the result (store)

getParent

public Node getParent()
getParent retrieve's this node's parent. If the parent is null this is the root node.

Returns:
the parent of this node.

setParent

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

Parameters:
parent - the parent of this node.

removeFromParent

public boolean removeFromParent()
removeFromParent removes this Spatial from it's parent.

Returns:
true if it has a parent and performed the remove.

hasAncestor

public boolean hasAncestor(Node ancestor)
determines if the provided Node is the parent, or parent's parent, etc. of this Spatial.

Parameters:
ancestor - the ancestor object to look for.
Returns:
true if the ancestor is found, false otherwise.

getLocalRotation

public Quaternion getLocalRotation()
getLocalRotation retrieves the local rotation of this node.

Returns:
the local rotation of this node.

setLocalRotation

public void setLocalRotation(Matrix3f rotation)
setLocalRotation sets the local rotation of this node.

Parameters:
rotation - the new local rotation.

setLocalRotation

public void setLocalRotation(Quaternion quaternion)
setLocalRotation sets the local rotation of this node, using a quaterion to build the matrix.

Parameters:
quaternion - the quaternion that defines the matrix.

getLocalScale

public Vector3f getLocalScale()
getLocalScale retrieves the local scale of this node.

Returns:
the local scale of this node.

setLocalScale

public void setLocalScale(float localScale)
setLocalScale sets the local scale of this node.

Parameters:
localScale - the new local scale, applied to x, y and z

setLocalScale

public void setLocalScale(Vector3f localScale)
setLocalScale sets the local scale of this node.

Parameters:
localScale - the new local scale.

getLocalTranslation

public Vector3f getLocalTranslation()
getLocalTranslation retrieves the local translation of this node.

Returns:
the local translation of this node.

setLocalTranslation

public void setLocalTranslation(Vector3f localTranslation)
setLocalTranslation sets the local translation of this node.

Parameters:
localTranslation - the local translation of this node.

setLocalTranslation

public void setLocalTranslation(float x,
                                float y,
                                float z)

setZOrder

public void setZOrder(int zOrder,
                      boolean setOnChildren)
Sets the zOrder of this Spatial and, if setOnChildren is true, all children as well. This value is used in conjunction with the RenderQueue and QUEUE_ORTHO for determining draw order.

Parameters:
zOrder - the new zOrder.
setOnChildren - if true, children will also have their zOrder set to the given value.

getCullHint

public Spatial.CullHint getCullHint()
Returns:
the cull mode of this spatial, or if set to INHERIT, the cullmode of it's parent.
See Also:
setCullHint(CullHint)

getTextureCombineMode

public Spatial.TextureCombineMode getTextureCombineMode()
Returns this spatial's texture combine mode. If the mode is set to inherit, then the spatial gets its combine mode from its parent.

Returns:
The spatial's texture current combine mode.

getLightCombineMode

public Spatial.LightCombineMode getLightCombineMode()
Returns this spatial's light combine mode. If the mode is set to inherit, then the spatial gets its combine mode from its parent.

Returns:
The spatial's light current combine mode.

getRenderQueueMode

public int getRenderQueueMode()
Returns this spatial's renderqueue mode. If the mode is set to inherit, then the spatial gets its renderqueue mode from its parent.

Returns:
The spatial's current renderqueue mode.

getNormalsMode

public Spatial.NormalsMode getNormalsMode()
Returns this spatial's normals mode. If the mode is set to inherit, then the spatial gets its normals mode from its parent.

Returns:
The spatial's current normals mode.

propagateStatesFromRoot

public void propagateStatesFromRoot(java.util.Stack[] states)
Called during updateRenderState(Stack[]), this function goes up the scene graph tree until the parent is null and pushes RenderStates onto the states Stack array.

Parameters:
states - The Stack[] to push states onto.

propagateBoundToRoot

public void propagateBoundToRoot()
propagateBoundToRoot passes the new world bound up the tree to the root.


calculateCollisions

public void calculateCollisions(Spatial scene,
                                CollisionResults results)
calculateCollisions calls findCollisions to populate the CollisionResults object then processes the collision results.

Parameters:
scene - the scene to test against.
results - the results object.

updateModelBound

public abstract void updateModelBound()
updateBound recalculates the bounding object for this Spatial.


setModelBound

public abstract void setModelBound(BoundingVolume modelBound)
setModelBound sets the bounding object for this Spatial.

Parameters:
modelBound - the bounding object for this spatial.

findCollisions

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

Parameters:
scene - the scene to test against.
results - the results of the collisions.

hasCollision

public abstract boolean hasCollision(Spatial scene,
                                     boolean checkTriangles)
Checks this spatial against a second spatial for collisions.

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

calculatePick

public void calculatePick(Ray ray,
                          PickResults results)

findPick

public abstract void findPick(Ray toTest,
                              PickResults results)
Tests a ray against this spatial, and stores the results in the result object.

Parameters:
toTest - ray to test picking against
results - the results of the picking

setUserData

public void setUserData(java.lang.String key,
                        Savable data)
Stores user define data for this Spatial.

Parameters:
key - the key component to retrieve the data from the hash map.
data - the data to store.

getUserData

public Savable getUserData(java.lang.String key)
Retrieves user data from the hashmap defined by the provided key.

Parameters:
key - the key of the data to obtain.
Returns:
the data referenced by the key. If the key is invalid, null is returned.

removeUserData

public Savable removeUserData(java.lang.String key)
Removes user data from the hashmap defined by the provided key.

Parameters:
key - the key of the data to remove.
Returns:
the data that has been removed, null if no data existed.

getVertexCount

public abstract int getVertexCount()

getTriangleCount

public abstract int getTriangleCount()

write

public void write(JMEExporter ex)
           throws java.io.IOException
Specified by:
write in interface Savable
Throws:
java.io.IOException

read

public void read(JMEImporter im)
          throws java.io.IOException
Specified by:
read in interface Savable
Throws:
java.io.IOException

setName

public void setName(java.lang.String name)
Sets the name of this spatial.

Parameters:
name - The spatial's new name.

getName

public java.lang.String getName()
Returns the name of this spatial.

Returns:
This spatial's name.

setIsCollidable

public void setIsCollidable(boolean isCollidable)
Sets if this Spatial is to be used in intersection (collision and picking) calculations. By default this is true.

Parameters:
isCollidable - true if this Spatial is to be used in intersection calculations, false otherwise.

isCollidable

public boolean isCollidable()
Defines if this Spatial is to be used in intersection (collision and picking) calculations. By default this is true.

Returns:
true if this Spatial is to be used in intersection calculations, false otherwise.

getWorldBound

public BoundingVolume getWorldBound()
getWorldBound retrieves the world bound at this node level.

Returns:
the world bound at this level.

draw

public abstract void draw(Renderer r)
draw abstract method that handles drawing data to the renderer if it is geometry and passing the call to it's children if it is a node.

Parameters:
r - the renderer used for display.

setCullHint

public void setCullHint(Spatial.CullHint hint)
setCullHint sets how scene culling should work on this spatial during drawing. CullHint.Dynamic: Determine via the defined Camera planes whether or not this Spatial should be culled. CullHint.Always: Always throw away this object and any children during draw commands. CullHint.Never: Never throw away this object (always draw it) CullHint.Inherit: Look for a non-inherit parent and use its cull mode. NOTE: You must set this AFTER attaching to a parent or it will be reset with the parent's cullMode value.

Parameters:
hint - one of CullHint.Dynamic, CullHint.Always, CullHint.Inherit or CullHint.Never

getLocalCullHint

public Spatial.CullHint getLocalCullHint()
Returns:
the cullmode set on this Spatial

lockBounds

public void lockBounds()
Calling this method tells the scenegraph that it is not necessary to update bounds from this point in the scenegraph on down to the leaves. This is useful for performance gains where you have scene items that do not move (at all) or change shape and thus do not need constant re-calculation of boundaries. When you call lock, the bounds are first updated to ensure current bounds are accurate.

See Also:
unlockBounds()

lockShadows

public void lockShadows()
Calling this method tells the scenegraph that it is not necessary to update Shadow volumes that may be associated with this Spatial. This is useful for skipping various checks for spatial transformation when deciding whether or not to recalc a shadow volume for a Spatial.

See Also:
unlockShadows()

lockBranch

public void lockBranch()
Calling this method tells the scenegraph that it is not necessary to traverse this Spatial or any below it during the update phase. This should be called *after* any other lock call to ensure they are able to update any bounds or vectors they might need to update.

See Also:
unlockBranch()

lockTransforms

public void lockTransforms()
Flags this spatial and those below it in the scenegraph to not recalculate world transforms such as translation, rotation and scale on every update. This is useful for efficiency when you have scene items that stay in one place all the time as it avoids needless recalculation of transforms.

See Also:
unlockTransforms()

lockMeshes

public void lockMeshes(Renderer r)
Flags this spatial and those below it that any meshes in the specified scenegraph location or lower will not have changes in vertex, texcoord, normal or color data. This allows optimizations by the engine such as creating display lists from the data. Calling this method does not provide a guarentee that data changes will not be allowed or will/won't show up in the scene. It is merely a hint to the engine.

Parameters:
r - A renderer to lock against.
See Also:
unlockMeshes(Renderer)

lockMeshes

public void lockMeshes()
Flags this spatial and those below it that any meshes in the specified scenegraph location or lower will not have changes in vertex, texcoord, normal or color data. This allows optimizations by the engine such as creating display lists from the data. Calling this method does not provide a guarentee that data changes will not be allowed or will/won't show up in the scene. It is merely a hint to the engine. Calls lockMeshes(Renderer) with the current display system's renderer.

See Also:
lockMeshes(Renderer)

lock

public void lock(Renderer r)
Convienence function for locking all aspects of a Spatial.

See Also:
lockBounds(), lockTransforms(), lockMeshes(Renderer), lockShadows()

lock

public void lock()
Convienence function for locking all aspects of a Spatial. For lockMeshes it calls: lockMeshes(DisplaySystem.getDisplaySystem().getRenderer());

See Also:
lockBounds(), lockTransforms(), lockMeshes(), lockShadows()

unlockBounds

public void unlockBounds()
Flags this spatial and those below it to allow for bounds updating (the default).

See Also:
lockBounds()

unlockShadows

public void unlockShadows()
Flags this spatial and those below it to allow for shadow volume updates (the default).

See Also:
lockShadows()

unlockBranch

public void unlockBranch()
Flags this Spatial and any below it as being traversable during the update phase.

See Also:
lockBranch()

unlockTransforms

public void unlockTransforms()
Flags this spatial and those below it to allow for transform updating (the default).

See Also:
lockTransforms()

unlockMeshes

public void unlockMeshes()
Flags this spatial and those below it to allow for mesh updating (the default). Generally this means that any display lists setup will be erased and released. Calls unlockMeshes(Renderer) with the current display system's renderer.

See Also:
unlockMeshes(Renderer)

unlockMeshes

public void unlockMeshes(Renderer r)
Flags this spatial and those below it to allow for mesh updating (the default). Generally this means that any display lists setup will be erased and released.

Parameters:
r - The renderer used to lock against.
See Also:
lockMeshes(Renderer)

unlock

public void unlock(Renderer r)
Convienence function for unlocking all aspects of a Spatial.

See Also:
unlockBounds(), unlockTransforms(), unlockMeshes(Renderer), unlockShadows(), unlockBranch()

unlock

public void unlock()
Convienence function for unlocking all aspects of a Spatial. For unlockMeshes it calls: unlockMeshes(DisplaySystem.getDisplaySystem().getRenderer());

See Also:
unlockBounds(), unlockTransforms(), unlockMeshes(), unlockShadows(), unlockBranch()

getLocks

public int getLocks()
Returns:
a bitwise combination of the current locks established on this Spatial.

setLocks

public void setLocks(int lockedMode)
Note: Uses the currently set Renderer to generate a display list if LOCKED_MESH_DATA is set.

Parameters:
locks - a bitwise combination of the locks to establish on this Spatial.

setLocks

public void setLocks(int locks,
                     Renderer r)
Parameters:
locks - a bitwise combination of the locks to establish on this Spatial.
r - the renderer to create display lists with if LOCKED_MESH_DATA is set.

updateWorldBound

public abstract void updateWorldBound()
updateWorldBound updates the bounding volume of the world. Abstract, geometry transforms the bound while node merges the children's bound. In most cases, users will want to call updateModelBound() and let this function be called automatically during updateGeometricState().


updateRenderState

public void updateRenderState()
Updates the render state values of this Spatial and and children it has. Should be called whenever render states change.


updateRenderState

protected void updateRenderState(java.util.Stack[] parentStates)
Called internally. Updates the render states of this Spatial. The stack contains parent render states.

Parameters:
parentStates - The list of parent renderstates.

applyRenderState

protected void applyRenderState(java.util.Stack<? extends RenderState>[] states)
Called during updateRenderState(Stack[]), this function determines how the render states are actually applied to the spatial and any children it may have. By default, this function does nothing.

Parameters:
states - An array of stacks for each state.

sortLights

public void sortLights()

setRenderState

public RenderState setRenderState(RenderState rs)
setRenderState sets a render state for this node. Note, there can only be one render state per type per node. That is, there can only be a single BlendState a single TextureState, etc. If there is already a render state for a type set the old render state will be returned. Otherwise, null is returned.

Parameters:
rs - the render state to add.
Returns:
the old render state.

getRenderState

public RenderState getRenderState(int type)
Deprecated. As of 2.0, use getRenderState(com.jme.scene.state.RenderState.StateType) instead.

Returns the requested RenderState that this Spatial currently has set or null if none is set.

Parameters:
type - the renderstate type to retrieve
Returns:
a renderstate at the given position or null

getRenderState

public RenderState getRenderState(RenderState.StateType type)
Returns the requested RenderState that this Spatial currently has set or null if none is set.

Parameters:
type - the RenderState.StateType to return
Returns:
a RenderState that matches the given RenderState.StateType or null

clearRenderState

public void clearRenderState(int renderStateType)
Deprecated. As of 2.0, use clearRenderState(com.jme.scene.state.RenderState.StateType) instead.

Clears a given render state index by setting it to null.

Parameters:
renderStateType - The index of a RenderState to clear
See Also:
RenderState.getType()

clearRenderState

public void clearRenderState(RenderState.StateType type)
Clears a given render state index by setting it to null.

Parameters:
renderStateType - The index of a RenderState to clear
See Also:
RenderState.getType()

setRenderQueueMode

public void setRenderQueueMode(int renderQueueMode)
setRenderQueueMode determines at what phase of the rendering proces this Spatial will rendered. There are 4 different phases: QUEUE_SKIP - The spatial will be drawn as soon as possible, before the other phases of rendering. QUEUE_OPAQUE - The renderer will try to find the optimal order for rendering all objects using this mode. You should use this mode for most normal objects, except transparant ones, as it could give a nice performance boost to your application. QUEUE_TRANSPARENT - This is the mode you should use for object with transparancy in them. It will ensure the objects furthest away are rendered first. That ensures when another transparent object is drawn on top of previously drawn objects, you can see those (and the object drawn using SKIP and OPAQUE) through the tranparant parts of the newly drawn object. QUEUE_ORTHO - This is a special mode, for drawing 2D object without prespective (such as GUI or HUD parts) Lastly, there is a special mode, QUEUE_INHERIT, that will ensure that this spatial uses the same mode as the parent Node does.

Parameters:
renderQueueMode - The mode to use for this Spatial.

getLocalRenderQueueMode

public int getLocalRenderQueueMode()
Returns:

setZOrder

public void setZOrder(int zOrder)
Parameters:
zOrder -

getZOrder

public int getZOrder()
Returns:

getLocalNormalsMode

public Spatial.NormalsMode getLocalNormalsMode()
Returns:

setNormalsMode

public void setNormalsMode(Spatial.NormalsMode mode)
Parameters:
mode -

setLightCombineMode

public void setLightCombineMode(Spatial.LightCombineMode mode)
Sets how lights from parents should be combined for this spatial.

Parameters:
mode - The light combine mode for this spatial
Throws:
java.lang.IllegalArgumentException - if mode is null

getLocalLightCombineMode

public Spatial.LightCombineMode getLocalLightCombineMode()
Returns:
the lightCombineMode set on this Spatial

setTextureCombineMode

public void setTextureCombineMode(Spatial.TextureCombineMode mode)
Sets how textures from parents should be combined for this Spatial.

Parameters:
mode - The new texture combine mode for this spatial.
Throws:
java.lang.IllegalArgumentException - if mode is null

getLocalTextureCombineMode

public Spatial.TextureCombineMode getLocalTextureCombineMode()
Returns:
the textureCombineMode set on this Spatial

getLastFrustumIntersection

public Camera.FrustumIntersect getLastFrustumIntersection()
Returns this spatial's last frustum intersection result. This int is set when a check is made to determine if the bounds of the object fall inside a camera's frustum. If a parent is found to fall outside the frustum, the value for this spatial will not be updated.

Returns:
The spatial's last frustum intersection result.

setLastFrustumIntersection

public void setLastFrustumIntersection(Camera.FrustumIntersect intersects)
Overrides the last intersection result. This is useful for operations that want to start rendering at the middle of a scene tree and don't want the parent of that node to influence culling. (See texture renderer code for example.)

Parameters:
intersects - the new value

toString

public java.lang.String toString()
Returns the Spatial's name followed by the class of the spatial
Example: "MyNode (com.jme.scene.Spatial)

Overrides:
toString in class java.lang.Object
Returns:
Spatial's name followed by the class of the Spatial

getLocalToWorldMatrix

public Matrix4f getLocalToWorldMatrix(Matrix4f store)

getClassTag

public java.lang.Class<? extends Spatial> getClassTag()
Specified by:
getClassTag in interface Savable