Package WildMagic.LibGraphics.SceneGraph
Class Spatial
- java.lang.Object
-
- WildMagic.LibGraphics.ObjectSystem.GraphicsObject
-
- WildMagic.LibGraphics.SceneGraph.Spatial
-
- All Implemented Interfaces:
java.io.Serializable
,NameIdInterface
,StreamInterface
public abstract class Spatial extends GraphicsObject implements NameIdInterface, StreamInterface, java.io.Serializable
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Spatial.CullingMode
Culling parameters.
-
Field Summary
Fields Modifier and Type Field Description Spatial.CullingMode
Culling
Type of culling.Transformation
Local
Local transforms.protected int
m_iStartEffect
Normally, all effects are applied to an object.protected java.util.Vector<Effect>
m_kEffects
Effect state.protected java.util.Vector<GlobalState>
m_kGlobalStates
global render stateprotected java.util.Vector<GraphicsObject>
m_kLights
light stateprotected Spatial
m_pkParent
support for hierarchical scene graphprivate static java.util.HashMap<java.lang.Integer,Spatial.CullingMode>
ms_pkCullingModeMap
Map culling mode to type integer value.private static long
serialVersionUID
Transformation
World
World transforms.BoundingVolume
WorldBound
World bound access.boolean
WorldBoundIsCurrent
If WorldBound is set directly, the WorldBoundIsCurrent flag should be set to true.boolean
WorldIsCurrent
Set when World transform is set directly.
-
Constructor Summary
Constructors Constructor Description Spatial()
Default constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
AttachEffect(Effect pkEffect)
Attach a new effect.void
AttachGlobalState(GlobalState pkState)
Attach the input global state to this object.void
AttachLight(Light pkLight)
Attach the input light.void
DetachAllEffects()
Detach all effects.void
DetachAllGlobalStates()
Detach all global states.void
DetachAllLights()
Detach all lights.void
DetachEffect(Effect pkEffect)
Detach the specified effect.void
DetachGlobalState(GlobalState.StateType eType)
Detach the global state specified by the input type.void
DetachLight(Light pkLight)
Detach the input light.void
dispose()
Delete memory.void
GetAllObjectsByName(java.lang.String rkName, java.util.Vector<GraphicsObject> rkObjects)
Writes all GraphicsObjects with the name that matches the input parameter, rkName into the Vector parameter rkObjects.int
GetDiskUsed(StreamVersion rkVersion)
Returns the size of this object and it's children on disk for the current StreamVersion parameter.Effect
GetEffect(int i)
Get the effect at index.int
GetEffectQuantity()
Get the number of attached effects.GlobalState
GetGlobalState(int i)
Get global state at position i.GlobalState
GetGlobalState(GlobalState.StateType eType)
Get global state by type.int
GetGlobalStateQuantity()
global state sizeLight
GetLight(int i)
Return the light specified by the input index.int
GetLightQuantity()
light state.GraphicsObject
GetObjectByID(int uiID)
Returns the GraphicsObject with the ID that matches the input parameter, uiID.GraphicsObject
GetObjectByName(java.lang.String rkName)
Returns the GraphicsObject with the name that matches the input parameter, rkName.Spatial
GetParent()
Return parent node.int
GetStartEffect()
Get the start effect index.protected abstract void
GetVisibleSet(Culler rkCuller, boolean bNoCull)
Get visible set.void
Link(Stream rkStream, Stream.Link pkLink)
Copies this objects children objects from the input Stream's HashTable, based on the LinkID of the child stored in the pkLink parameter.void
Load(Stream rkStream, Stream.Link pkLink)
Loads this object from the input parameter rkStream, using the input Stream.Link to store the IDs of children objects of this object for linking after all objects are loaded from the Stream.void
OnGetVisibleSet(Culler rkCuller, boolean bNoCull)
Culling callback.protected void
PopState(java.util.Vector<java.util.Vector<GlobalState>> akGStack, java.util.Vector<Light> pkLStack)
Pop state from current render state stack.protected void
PropagateBoundToRoot()
Propagate bound to root.protected void
PropagateStateFromRoot(java.util.Vector<java.util.Vector<GlobalState>> akGStack, java.util.Vector<Light> pkLStack)
render state updatesprotected void
PushState(java.util.Vector<java.util.Vector<GlobalState>> akGStack, java.util.Vector<Light> pkLStack)
Push state onto current render state stack.boolean
Register(Stream rkStream)
Registers this object with the input Stream parameter.void
Save(Stream rkStream)
Write this object and all it's children to the Stream.StringTree
SaveStrings(java.lang.String acTitle)
Write this object into a StringTree for the scene-graph visualization.void
SetParent(Spatial pkParent)
Parent access (Node calls this during attach/detach of children)void
SetStartEffect(int i)
Set the start effect to the specified index.void
UpdateBS()
Update of geometric state and controllers.void
UpdateGS()
Update of geometric state and controllers.void
UpdateGS(double dAppTime, boolean bInitiator)
Update of geometric state and controllers.void
UpdateRS()
Update render state.void
UpdateRS(java.util.Vector<java.util.Vector<GlobalState>> akGStack, java.util.Vector<Light> pkLStack)
update of render stateprotected abstract void
UpdateState(java.util.Vector<java.util.Vector<GlobalState>> akGStack, java.util.Vector<Light> pkLStack)
Update state.protected abstract void
UpdateWorldBound()
Update world bound.protected void
UpdateWorldData(double dAppTime)
geometric updates-
Methods inherited from class WildMagic.LibGraphics.ObjectSystem.GraphicsObject
GetID, GetName, GetNextID, GetObjectByIDBase, GetObjectByNameBase, SetName
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
ms_pkCullingModeMap
private static java.util.HashMap<java.lang.Integer,Spatial.CullingMode> ms_pkCullingModeMap
Map culling mode to type integer value.
-
Local
public Transformation Local
Local transforms.
-
World
public Transformation World
World transforms. In some situations you might need to set the world transform directly and bypass the Spatial::Update() mechanism. If World is set directly, the WorldIsCurrent flag should be set to true. For example, inverse kinematic controllers and skin controllers need this capability.
-
WorldIsCurrent
public boolean WorldIsCurrent
Set when World transform is set directly.
-
WorldBound
public BoundingVolume WorldBound
World bound access. In some situations you might want to set the world bound directly and bypass the Spatial::UpdateGS() mechanism. If WorldBound is set directly, the WorldBoundIsCurrent flag should be set to true.
-
WorldBoundIsCurrent
public boolean WorldBoundIsCurrent
If WorldBound is set directly, the WorldBoundIsCurrent flag should be set to true.
-
Culling
public Spatial.CullingMode Culling
Type of culling.
-
m_pkParent
protected Spatial m_pkParent
support for hierarchical scene graph
-
m_kGlobalStates
protected java.util.Vector<GlobalState> m_kGlobalStates
global render state
-
m_kLights
protected java.util.Vector<GraphicsObject> m_kLights
light state
-
m_kEffects
protected java.util.Vector<Effect> m_kEffects
Effect state. If the effect is attached to a Geometry object, it applies to that object alone. If the effect is attached to a Node object, it applies to all Geometry objects in the subtree rooted at the Node.
-
m_iStartEffect
protected int m_iStartEffect
Normally, all effects are applied to an object. To allow overriding some of the effects, a starting index may be specified by the application. This is useful for complex effects, where the current effects must be ignored and another effect is used instead. Without this mechanism, you would have to detach and save the current effects, attach the desired effect, draw, detach the desired effect, and reattach the old effects. With this mechanism, you attach the desired effect, set the starting index to that of the desired effect, draw, reset the starting index to zero, and detach the desired effect.
-
-
Method Detail
-
AttachEffect
public void AttachEffect(Effect pkEffect)
Attach a new effect.- Parameters:
pkEffect
- the effect to attach.
-
AttachGlobalState
public void AttachGlobalState(GlobalState pkState)
Attach the input global state to this object.- Parameters:
pkState
- state to attach.
-
AttachLight
public void AttachLight(Light pkLight)
Attach the input light.- Parameters:
pkLight
- the light to attach.
-
DetachAllEffects
public void DetachAllEffects()
Detach all effects.
-
DetachAllGlobalStates
public void DetachAllGlobalStates()
Detach all global states.
-
DetachAllLights
public void DetachAllLights()
Detach all lights.
-
DetachEffect
public void DetachEffect(Effect pkEffect)
Detach the specified effect.- Parameters:
pkEffect
- the effect to detach.
-
DetachGlobalState
public void DetachGlobalState(GlobalState.StateType eType)
Detach the global state specified by the input type.- Parameters:
eType
- type of global state to detach.
-
DetachLight
public void DetachLight(Light pkLight)
Detach the input light.- Parameters:
pkLight
- the light to detach.
-
dispose
public void dispose()
Delete memory.- Overrides:
dispose
in classGraphicsObject
-
GetAllObjectsByName
public void GetAllObjectsByName(java.lang.String rkName, java.util.Vector<GraphicsObject> rkObjects)
Writes all GraphicsObjects with the name that matches the input parameter, rkName into the Vector parameter rkObjects.- Specified by:
GetAllObjectsByName
in interfaceNameIdInterface
- Overrides:
GetAllObjectsByName
in classGraphicsObject
- Parameters:
rkName
- the name of the objects to return.rkObjects
- a Vector of all objects with the matching name.
-
GetDiskUsed
public int GetDiskUsed(StreamVersion rkVersion)
Returns the size of this object and it's children on disk for the current StreamVersion parameter.- Specified by:
GetDiskUsed
in interfaceStreamInterface
- Overrides:
GetDiskUsed
in classGraphicsObject
- Parameters:
rkVersion
- the current version of the Stream file being created.- Returns:
- the size of this object on disk.
-
GetEffect
public Effect GetEffect(int i)
Get the effect at index.- Parameters:
i
- index of the effect to return.- Returns:
- the effect at index i.
-
GetEffectQuantity
public int GetEffectQuantity()
Get the number of attached effects.- Returns:
- the number of attached effects.
-
GetGlobalState
public GlobalState GetGlobalState(GlobalState.StateType eType)
Get global state by type.- Parameters:
eType
- type of GlobalState to get.- Returns:
- global state for the input type.
-
GetGlobalState
public GlobalState GetGlobalState(int i)
Get global state at position i.- Parameters:
i
- position of GlobalState to get.- Returns:
- global state at position i.
-
GetGlobalStateQuantity
public int GetGlobalStateQuantity()
global state size- Returns:
- global state size
-
GetLight
public Light GetLight(int i)
Return the light specified by the input index.- Parameters:
i
- the index of the light to return.- Returns:
- the light at index i.
-
GetLightQuantity
public int GetLightQuantity()
light state. Return the number of attached lights.- Returns:
- the number of attached lights.
-
GetObjectByID
public GraphicsObject GetObjectByID(int uiID)
Returns the GraphicsObject with the ID that matches the input parameter, uiID.- Specified by:
GetObjectByID
in interfaceNameIdInterface
- Overrides:
GetObjectByID
in classGraphicsObject
- Parameters:
uiID
- the ID of the object to return.- Returns:
- the GraphicsObject that matches the input name.
-
GetObjectByName
public GraphicsObject GetObjectByName(java.lang.String rkName)
Returns the GraphicsObject with the name that matches the input parameter, rkName.- Specified by:
GetObjectByName
in interfaceNameIdInterface
- Overrides:
GetObjectByName
in classGraphicsObject
- Parameters:
rkName
- the name of the object to return.- Returns:
- the GraphicsObject that matches the input name.
-
GetParent
public Spatial GetParent()
Return parent node.- Returns:
- parent.
-
GetStartEffect
public int GetStartEffect()
Get the start effect index.- Returns:
- the start effect index.
-
Link
public void Link(Stream rkStream, Stream.Link pkLink)
Copies this objects children objects from the input Stream's HashTable, based on the LinkID of the child stored in the pkLink parameter.- Specified by:
Link
in interfaceStreamInterface
- Overrides:
Link
in classGraphicsObject
- Parameters:
rkStream
- the Stream where the child objects are stored.pkLink
- the Link class from which the child object IDs are read.
-
Load
public void Load(Stream rkStream, Stream.Link pkLink)
Loads this object from the input parameter rkStream, using the input Stream.Link to store the IDs of children objects of this object for linking after all objects are loaded from the Stream.- Specified by:
Load
in interfaceStreamInterface
- Overrides:
Load
in classGraphicsObject
- Parameters:
rkStream
- the Stream from which this object is being read.pkLink
- the Link class for storing the IDs of this object's children objects.
-
OnGetVisibleSet
public void OnGetVisibleSet(Culler rkCuller, boolean bNoCull)
Culling callback.- Parameters:
rkCuller
- Culler object.bNoCull
- when true set to no-cull.
-
Register
public boolean Register(Stream rkStream)
Registers this object with the input Stream parameter. All objects streamed to disk are registered with the Stream so that a unique list of objects is maintained.- Specified by:
Register
in interfaceStreamInterface
- Overrides:
Register
in classGraphicsObject
- Parameters:
rkStream
- the Stream where the child objects are stored.- Returns:
- true if this object is registered, false if the object has already been registered.
-
Save
public void Save(Stream rkStream)
Write this object and all it's children to the Stream.- Specified by:
Save
in interfaceStreamInterface
- Overrides:
Save
in classGraphicsObject
- Parameters:
rkStream
- the Stream where the child objects are stored.
-
SaveStrings
public StringTree SaveStrings(java.lang.String acTitle)
Write this object into a StringTree for the scene-graph visualization.- Specified by:
SaveStrings
in interfaceStreamInterface
- Overrides:
SaveStrings
in classGraphicsObject
- Parameters:
acTitle
- the header for this object in the StringTree.- Returns:
- StringTree containing a String-based representation of this object and it's children.
-
SetParent
public void SetParent(Spatial pkParent)
Parent access (Node calls this during attach/detach of children)- Parameters:
pkParent
- set parent.
-
SetStartEffect
public void SetStartEffect(int i)
Set the start effect to the specified index.- Parameters:
i
- the index of the start effect.
-
UpdateBS
public void UpdateBS()
Update of geometric state and controllers. The UpdateBS function just computes the world bounding volumes on an upward pass. This is useful if model data changes, causing the model and world bounds to change, but no transformations need recomputing.
-
UpdateGS
public void UpdateGS()
Update of geometric state and controllers. The UpdateGS function computes world transformations on the downward pass and world bounding volumes on the upward pass.
-
UpdateGS
public void UpdateGS(double dAppTime, boolean bInitiator)
Update of geometric state and controllers. The UpdateGS function computes world transformations on the downward pass and world bounding volumes on the upward pass.- Parameters:
dAppTime
- animation time step from application.bInitiator
- when true propagate bound to root.
-
UpdateRS
public void UpdateRS()
Update render state.
-
UpdateRS
public void UpdateRS(java.util.Vector<java.util.Vector<GlobalState>> akGStack, java.util.Vector<Light> pkLStack)
update of render state- Parameters:
akGStack
- global states.akLStack
- lights.
-
GetVisibleSet
protected abstract void GetVisibleSet(Culler rkCuller, boolean bNoCull)
Get visible set.- Parameters:
rkCuller
- CullerbNoCull
- when true set to no-cull.
-
PopState
protected void PopState(java.util.Vector<java.util.Vector<GlobalState>> akGStack, java.util.Vector<Light> pkLStack)
Pop state from current render state stack.- Parameters:
akGStack
- global states.akLStack
- lights.
-
PropagateBoundToRoot
protected void PropagateBoundToRoot()
Propagate bound to root.
-
PropagateStateFromRoot
protected void PropagateStateFromRoot(java.util.Vector<java.util.Vector<GlobalState>> akGStack, java.util.Vector<Light> pkLStack)
render state updates- Parameters:
akGStack
- global states.akLStack
- lights.
-
PushState
protected void PushState(java.util.Vector<java.util.Vector<GlobalState>> akGStack, java.util.Vector<Light> pkLStack)
Push state onto current render state stack.- Parameters:
akGStack
- global states.akLStack
- lights.
-
UpdateState
protected abstract void UpdateState(java.util.Vector<java.util.Vector<GlobalState>> akGStack, java.util.Vector<Light> pkLStack)
Update state.- Parameters:
akGStack
- global states.akLStack
- lights.
-
UpdateWorldBound
protected abstract void UpdateWorldBound()
Update world bound.
-
UpdateWorldData
protected void UpdateWorldData(double dAppTime)
geometric updates- Parameters:
dAppTime
- animation time step from application.
-
-