Class DefaultRigidBodyPhysicsManager
- All Implemented Interfaces:
Runnable
,NodeManager
Keeps track of both the collections of bodies and the individual joints. The collection nodes are evaluated at the end of the frame so as to modify the final object locations for this frame. The joints are managed so that those that need to produce output will be evaluated at the start of the next frame. This requires the manager to register as both pre and post event model node manager, as it manages both sets of nodes, though independently.
The physics model is run at a somewhat fixed frame rate. Physics models don't like to have variable frame rate as input, so we smooth these out over a fixed number of frames. Every set of frame resets the calculation interval based on recent history.
- Version:
- $Revision: 1.7 $
- Author:
- Justin Couch
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new, empty instance of the physics manager. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addManagedNode
(VRMLNodeType node) Add a node of the require type to be managed.void
clear()
Force clearing all currently managed nodes from this manager now.boolean
Ask whether this manager needs to be run after the event model has been evaluated for this frame.boolean
Ask whether this manager needs to be run before the event model has been evaluated for this frame.void
executePostEventModel
(long time) Run the post-event modeling for this frame now.void
executePreEventModel
(long time) Run the pre-event modeling for this frame now.int[]
Get the list of node type IDs that this manager wants to handle.Get the list of component names that this manager would normally manage.boolean
Initialise the node manager now with any per-manager setup that is needed.void
Remove a node of the require type to be managed.void
Reset the local time zero for the manager.void
run()
void
setErrorReporter
(org.j3d.util.ErrorReporter reporter) Register an error reporter with the engine so that any errors generated by the loading of script code can be reported in a nice, pretty fashion.void
setVRMLClock
(VRMLClock clk) Set the VRMLClock instance in use by this manager.void
shutdown()
Shutdown the node manager now.
-
Constructor Details
-
DefaultRigidBodyPhysicsManager
public DefaultRigidBodyPhysicsManager()Create a new, empty instance of the physics manager.
-
-
Method Details
-
run
-
initialize
public boolean initialize()Description copied from interface:NodeManager
Initialise the node manager now with any per-manager setup that is needed. If this returns false, then the node manager is assumed to have failed some part of the setup and will be removed from the system- Specified by:
initialize
in interfaceNodeManager
- Returns:
- true if initialization was successful
-
shutdown
public void shutdown()Description copied from interface:NodeManager
Shutdown the node manager now. If this is using any external resources it should remove those now as the entire application is about to die- Specified by:
shutdown
in interfaceNodeManager
-
setErrorReporter
public void setErrorReporter(org.j3d.util.ErrorReporter reporter) Description copied from interface:NodeManager
Register an error reporter with the engine so that any errors generated by the loading of script code can be reported in a nice, pretty fashion. Setting a value of null will clear the currently set reporter. If one is already set, the new value replaces the old.- Specified by:
setErrorReporter
in interfaceNodeManager
- Parameters:
reporter
- The instance to use or null
-
getSupportedComponents
Description copied from interface:NodeManager
Get the list of component names that this manager would normally manage. The component definition is assumed to be the same across all versions of the specifications that the browser supports. The level of the component is assumed to be the lowest level supported (ie if the given level fails, then levels above this cannot be supported, but those below can still be).Mostly this is used for when initialization fails and we wish to disable support for loading of nodes in that component.
- Specified by:
getSupportedComponents
in interfaceNodeManager
- Returns:
- The collection of components that this manager supports
-
setVRMLClock
Description copied from interface:NodeManager
Set the VRMLClock instance in use by this manager.- Specified by:
setVRMLClock
in interfaceNodeManager
- Parameters:
clk
- A reference to the clock to use
-
resetTimeZero
public void resetTimeZero()Description copied from interface:NodeManager
Reset the local time zero for the manager. This is called when a new root world has been loaded and any manager that needs to rely on delta time from the start of the world loading can reset it's local reference from the passed inVRMLClock
instance.- Specified by:
resetTimeZero
in interfaceNodeManager
-
getManagedNodeTypes
public int[] getManagedNodeTypes()Description copied from interface:NodeManager
Get the list of node type IDs that this manager wants to handle. These should be the constants fromTypeConstants
.- Specified by:
getManagedNodeTypes
in interfaceNodeManager
- Returns:
- A list of managed node identifiers
-
evaluatePreEventModel
public boolean evaluatePreEventModel()Description copied from interface:NodeManager
Ask whether this manager needs to be run before the event model has been evaluated for this frame.- Specified by:
evaluatePreEventModel
in interfaceNodeManager
- Returns:
- true if this is to be run pre-event model, false otherwise
-
evaluatePostEventModel
public boolean evaluatePostEventModel()Description copied from interface:NodeManager
Ask whether this manager needs to be run after the event model has been evaluated for this frame.- Specified by:
evaluatePostEventModel
in interfaceNodeManager
- Returns:
- true if this is to be run post event model, false otherwise
-
addManagedNode
Description copied from interface:NodeManager
Add a node of the require type to be managed.- Specified by:
addManagedNode
in interfaceNodeManager
- Parameters:
node
- The node instance to add for management
-
removeManagedNode
Description copied from interface:NodeManager
Remove a node of the require type to be managed.- Specified by:
removeManagedNode
in interfaceNodeManager
- Parameters:
node
- The node instance to add for management
-
executePreEventModel
public void executePreEventModel(long time) Description copied from interface:NodeManager
Run the pre-event modeling for this frame now. This is a blocking call and does not return until the event model is complete for this frame. The time should be system clock time, not VRML time.- Specified by:
executePreEventModel
in interfaceNodeManager
- Parameters:
time
- The timestamp of this frame to evaluate
-
executePostEventModel
public void executePostEventModel(long time) Description copied from interface:NodeManager
Run the post-event modeling for this frame now. This is a blocking call and does not return until the event model is complete for this frame. The time should be system clock time, not VRML time.- Specified by:
executePostEventModel
in interfaceNodeManager
- Parameters:
time
- The timestamp of this frame to evaluate
-
clear
public void clear()Description copied from interface:NodeManager
Force clearing all currently managed nodes from this manager now. This is used to indicate that a new world is about to be loaded and everything should be cleaned out now.- Specified by:
clear
in interfaceNodeManager
-