|
|
@ -66,8 +66,8 @@ import java.util.logging.Logger; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* <code>Spatial</code> defines the base class for scene graph nodes. It |
|
|
|
* <code>Spatial</code> defines the base class for scene graph nodes. It |
|
|
|
* maintains a link to a parent, it's local transforms and the world's |
|
|
|
* maintains a link to a parent, it's local transforms and the world's |
|
|
|
* transforms. All other nodes, such as <code>Node</code> and |
|
|
|
* transforms. All other scene graph elements, such as {@link Node} and |
|
|
|
* <code>Geometry</code> are subclasses of <code>Spatial</code>. |
|
|
|
* {@link Geometry} are subclasses of <code>Spatial</code>. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Mark Powell |
|
|
|
* @author Mark Powell |
|
|
|
* @author Joshua Slack |
|
|
|
* @author Joshua Slack |
|
|
@ -77,24 +77,30 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
|
|
|
|
|
|
|
|
private static final Logger logger = Logger.getLogger(Spatial.class.getName()); |
|
|
|
private static final Logger logger = Logger.getLogger(Spatial.class.getName()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Specifies how frustum culling should be handled by |
|
|
|
|
|
|
|
* this spatial. |
|
|
|
|
|
|
|
*/ |
|
|
|
public enum CullHint { |
|
|
|
public enum CullHint { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Do whatever our parent does. If no parent, we'll default to dynamic. |
|
|
|
* Do whatever our parent does. If no parent, default to {@link #Dynamic}. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
Inherit, |
|
|
|
Inherit, |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Do not draw if we are not at least partially within the view frustum |
|
|
|
* Do not draw if we are not at least partially within the view frustum |
|
|
|
* of the renderer's camera. |
|
|
|
* of the camera. This is determined via the defined |
|
|
|
|
|
|
|
* Camera planes whether or not this Spatial should be culled. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
Dynamic, |
|
|
|
Dynamic, |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Always cull this from view. |
|
|
|
* Always cull this from the view, throwing away this object |
|
|
|
|
|
|
|
* and any children from rendering commands. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
Always, |
|
|
|
Always, |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Never cull this from view. Note that we will still get culled if our |
|
|
|
* Never cull this from view, always draw it. |
|
|
|
* parent is culled. |
|
|
|
* Note that we will still get culled if our parent is culled. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
Never; |
|
|
|
Never; |
|
|
|
} |
|
|
|
} |
|
|
@ -138,7 +144,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
protected transient int refreshFlags = 0; |
|
|
|
protected transient int refreshFlags = 0; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Default Constructor. |
|
|
|
* Serialization only. Do not use. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Spatial() { |
|
|
|
public Spatial() { |
|
|
|
localTransform = new Transform(); |
|
|
|
localTransform = new Transform(); |
|
|
@ -156,7 +162,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
* |
|
|
|
* |
|
|
|
* @param name |
|
|
|
* @param name |
|
|
|
* the name of the scene element. This is required for |
|
|
|
* the name of the scene element. This is required for |
|
|
|
* identification and comparision purposes. |
|
|
|
* identification and comparison purposes. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Spatial(String name) { |
|
|
|
public Spatial(String name) { |
|
|
|
this(); |
|
|
|
this(); |
|
|
@ -232,12 +238,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
if (getQueueBucket() == Bucket.Gui) { |
|
|
|
if (getQueueBucket() == Bucket.Gui) { |
|
|
|
return cam.containsGui(getWorldBound()); |
|
|
|
return cam.containsGui(getWorldBound()); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
// int state = cam.getPlaneState();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
frustrumIntersects = cam.contains(getWorldBound()); |
|
|
|
frustrumIntersects = cam.contains(getWorldBound()); |
|
|
|
|
|
|
|
|
|
|
|
// cam.setPlaneState(state);
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -263,10 +264,25 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
return name; |
|
|
|
return name; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the local {@link LightList}, which are the lights |
|
|
|
|
|
|
|
* that were directly attached to this <code>Spatial</code> through the |
|
|
|
|
|
|
|
* {@link #addLight(com.jme3.light.Light) } and |
|
|
|
|
|
|
|
* {@link #removeLight(com.jme3.light.Light) } methods. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return The local light list |
|
|
|
|
|
|
|
*/ |
|
|
|
public LightList getLocalLightList() { |
|
|
|
public LightList getLocalLightList() { |
|
|
|
return localLights; |
|
|
|
return localLights; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the world {@link LightList}, containing the lights |
|
|
|
|
|
|
|
* combined from all this <code>Spatial's</code> parents up to and including |
|
|
|
|
|
|
|
* this <code>Spatial</code>'s lights. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return The combined world light list |
|
|
|
|
|
|
|
*/ |
|
|
|
public LightList getWorldLightList() { |
|
|
|
public LightList getWorldLightList() { |
|
|
|
return worldLights; |
|
|
|
return worldLights; |
|
|
|
} |
|
|
|
} |
|
|
@ -275,7 +291,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
* <code>getWorldRotation</code> retrieves the absolute rotation of the |
|
|
|
* <code>getWorldRotation</code> retrieves the absolute rotation of the |
|
|
|
* Spatial. |
|
|
|
* Spatial. |
|
|
|
* |
|
|
|
* |
|
|
|
* @return the Spatial's world rotation matrix. |
|
|
|
* @return the Spatial's world rotation quaternion. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Quaternion getWorldRotation() { |
|
|
|
public Quaternion getWorldRotation() { |
|
|
|
checkDoTransformUpdate(); |
|
|
|
checkDoTransformUpdate(); |
|
|
@ -286,7 +302,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
* <code>getWorldTranslation</code> retrieves the absolute translation of |
|
|
|
* <code>getWorldTranslation</code> retrieves the absolute translation of |
|
|
|
* the spatial. |
|
|
|
* the spatial. |
|
|
|
* |
|
|
|
* |
|
|
|
* @return the world's tranlsation vector. |
|
|
|
* @return the Spatial's world tranlsation vector. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Vector3f getWorldTranslation() { |
|
|
|
public Vector3f getWorldTranslation() { |
|
|
|
checkDoTransformUpdate(); |
|
|
|
checkDoTransformUpdate(); |
|
|
@ -297,7 +313,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
* <code>getWorldScale</code> retrieves the absolute scale factor of the |
|
|
|
* <code>getWorldScale</code> retrieves the absolute scale factor of the |
|
|
|
* spatial. |
|
|
|
* spatial. |
|
|
|
* |
|
|
|
* |
|
|
|
* @return the world's scale factor. |
|
|
|
* @return the Spatial's world scale factor. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Vector3f getWorldScale() { |
|
|
|
public Vector3f getWorldScale() { |
|
|
|
checkDoTransformUpdate(); |
|
|
|
checkDoTransformUpdate(); |
|
|
@ -316,8 +332,8 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* <code>rotateUpTo</code> is a util function that alters the |
|
|
|
* <code>rotateUpTo</code> is a utility function that alters the |
|
|
|
* localrotation to point the Y axis in the direction given by newUp. |
|
|
|
* local rotation to point the Y axis in the direction given by newUp. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param newUp |
|
|
|
* @param newUp |
|
|
|
* the up vector to use - assumed to be a unit vector. |
|
|
|
* the up vector to use - assumed to be a unit vector. |
|
|
@ -350,11 +366,11 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* <code>lookAt</code> is a convienence method for auto-setting the local |
|
|
|
* <code>lookAt</code> is a convenience method for auto-setting the local |
|
|
|
* rotation based on a position and an up vector. It computes the rotation |
|
|
|
* 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'. |
|
|
|
* to transform the z-axis to point onto 'position' and the y-axis to 'up'. |
|
|
|
* Unlike {@link Quaternion#lookAt} this method takes a world position to |
|
|
|
* Unlike {@link Quaternion#lookAt(com.jme3.math.Vector3f, com.jme3.math.Vector3f) } |
|
|
|
* look at not a relative direction. |
|
|
|
* this method takes a world position to look at and not a relative direction. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param position |
|
|
|
* @param position |
|
|
|
* where to look at in terms of world coordinates |
|
|
|
* where to look at in terms of world coordinates |
|
|
@ -377,7 +393,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Should be overriden by Node and Geometry. |
|
|
|
* Should be overridden by Node and Geometry. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected void updateWorldBound() { |
|
|
|
protected void updateWorldBound() { |
|
|
|
// the world bound of a leaf is the same as it's model bound
|
|
|
|
// the world bound of a leaf is the same as it's model bound
|
|
|
@ -418,6 +434,10 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Computes the world transform of this Spatial in the most |
|
|
|
|
|
|
|
* efficient manner possible. |
|
|
|
|
|
|
|
*/ |
|
|
|
void checkDoTransformUpdate() { |
|
|
|
void checkDoTransformUpdate() { |
|
|
|
if ((refreshFlags & RF_TRANSFORM) == 0) { |
|
|
|
if ((refreshFlags & RF_TRANSFORM) == 0) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -464,6 +484,10 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Computes this Spatial's world bounding volume in the most efficient |
|
|
|
|
|
|
|
* manner possible. |
|
|
|
|
|
|
|
*/ |
|
|
|
void checkDoBoundUpdate() { |
|
|
|
void checkDoBoundUpdate() { |
|
|
|
if ((refreshFlags & RF_BOUND) == 0) { |
|
|
|
if ((refreshFlags & RF_BOUND) == 0) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -675,7 +699,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* <code>getParent</code> retrieve's this node's parent. If the parent is |
|
|
|
* <code>getParent</code> retrieves this node's parent. If the parent is |
|
|
|
* null this is the root node. |
|
|
|
* null this is the root node. |
|
|
|
* |
|
|
|
* |
|
|
|
* @return the parent of this node. |
|
|
|
* @return the parent of this node. |
|
|
@ -737,7 +761,8 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* <code>setLocalRotation</code> sets the local rotation of this node. |
|
|
|
* <code>setLocalRotation</code> sets the local rotation of this node |
|
|
|
|
|
|
|
* by using a {@link Matrix3f}. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param rotation |
|
|
|
* @param rotation |
|
|
|
* the new local rotation. |
|
|
|
* the new local rotation. |
|
|
@ -749,11 +774,10 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* <code>setLocalRotation</code> sets the local rotation of this node, |
|
|
|
* <code>setLocalRotation</code> sets the local rotation of this node. |
|
|
|
* using a quaterion to build the matrix. |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* @param quaternion |
|
|
|
* @param quaternion |
|
|
|
* the quaternion that defines the matrix. |
|
|
|
* the new local rotation. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setLocalRotation(Quaternion quaternion) { |
|
|
|
public void setLocalRotation(Quaternion quaternion) { |
|
|
|
localTransform.setRotation(quaternion); |
|
|
|
localTransform.setRotation(quaternion); |
|
|
@ -1261,13 +1285,8 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* <code>setCullHint</code> sets how scene culling should work on this |
|
|
|
* <code>setCullHint</code> sets how scene culling should work on this |
|
|
|
* spatial during drawing. CullHint.Dynamic: Determine via the defined |
|
|
|
* spatial during drawing. NOTE: You must set this AFTER attaching to a |
|
|
|
* Camera planes whether or not this Spatial should be culled. |
|
|
|
* parent or it will be reset with the parent's cullMode value. |
|
|
|
* 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. |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* @param hint |
|
|
|
* @param hint |
|
|
|
* one of CullHint.Dynamic, CullHint.Always, CullHint.Inherit or |
|
|
|
* one of CullHint.Dynamic, CullHint.Always, CullHint.Inherit or |
|
|
@ -1286,20 +1305,9 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* <code>setQueueBucket</code> determines at what phase of the |
|
|
|
* <code>setQueueBucket</code> determines at what phase of the |
|
|
|
* rendering proces this Spatial will rendered. There are 4 different |
|
|
|
* rendering process this Spatial will rendered. See the |
|
|
|
* phases: Bucket.Opaque - The renderer will |
|
|
|
* {@link Bucket} enum for an explanation of the various |
|
|
|
* try to find the optimal order for rendering all objects using this mode. |
|
|
|
* render queue buckets. |
|
|
|
* You should use this mode for most normal objects, except transparant |
|
|
|
|
|
|
|
* ones, as it could give a nice performance boost to your application. |
|
|
|
|
|
|
|
* Bucket.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 Opaque) through the tranparant parts of the newly drawn |
|
|
|
|
|
|
|
* object. Bucket.Gui - This is a special mode, for drawing 2D object |
|
|
|
|
|
|
|
* without prespective (such as GUI or HUD parts) Lastly, there is a special |
|
|
|
|
|
|
|
* mode, Bucket.Inherit, that will ensure that this spatial uses the same |
|
|
|
|
|
|
|
* mode as the parent Node does. |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* @param queueBucket |
|
|
|
* @param queueBucket |
|
|
|
* The bucket to use for this Spatial. |
|
|
|
* The bucket to use for this Spatial. |
|
|
@ -1312,7 +1320,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
* Sets the shadow mode of the spatial |
|
|
|
* Sets the shadow mode of the spatial |
|
|
|
* The shadow mode determines how the spatial should be shadowed, |
|
|
|
* The shadow mode determines how the spatial should be shadowed, |
|
|
|
* when a shadowing technique is used. See the |
|
|
|
* when a shadowing technique is used. See the |
|
|
|
* documentation for the class ShadowMode for more information. |
|
|
|
* documentation for the class {@link ShadowMode} for more information. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see ShadowMode |
|
|
|
* @see ShadowMode |
|
|
|
* |
|
|
|
* |
|
|
@ -1355,8 +1363,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Overrides the last intersection result. This is useful for operations |
|
|
|
* 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 |
|
|
|
* 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 |
|
|
|
* the parent of that node to influence culling. |
|
|
|
* for example.) |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* @param intersects |
|
|
|
* @param intersects |
|
|
|
* the new value |
|
|
|
* the new value |
|
|
|