com.jmex.physics
Class DynamicPhysicsNode

java.lang.Object
  extended by com.jme.scene.Spatial
      extended by com.jme.scene.Node
          extended by com.jmex.physics.PhysicsNode
              extended by com.jmex.physics.DynamicPhysicsNode
All Implemented Interfaces:
com.jme.util.export.Savable, PhysicsSpatial, java.io.Serializable

public abstract class DynamicPhysicsNode
extends PhysicsNode

This PhysicsNode represents a physical entity that can be subject to forces to move and/or rotate it.

PhysicsNodes are created solely by the PhysicsSpace (methods PhysicsSpace.createDynamicNode() and PhysicsSpace.createStaticNode()).

Author:
Irrisor
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.jme.scene.Spatial
com.jme.scene.Spatial.CullHint, com.jme.scene.Spatial.LightCombineMode, com.jme.scene.Spatial.NormalsMode, com.jme.scene.Spatial.TextureCombineMode
 
Field Summary
static java.lang.String AFFECTED_BY_GRAVITY_PROPERTY
           
static java.lang.String ANGULAR_VELOCITY_PROPERTY
           
static java.lang.String CENTER_OF_MASS_PROPERTY
           
static java.lang.String JOINTS_PROPERTY
           
static java.lang.String LINEAR_VELOCITY_PROPERTY
           
static java.lang.String MASS_PROPERTY
           
 
Fields inherited from class com.jmex.physics.PhysicsNode
MATERIAL_PROPERTY
 
Fields inherited from class com.jme.scene.Node
children
 
Fields inherited from class com.jme.scene.Spatial
cullHint, frustrumIntersects, geometricalControllers, isCollidable, lightCombineMode, localRotation, localScale, localTranslation, LOCKED_BOUNDS, LOCKED_BRANCH, LOCKED_MESH_DATA, LOCKED_NONE, LOCKED_SHADOWS, LOCKED_TRANSFORMS, lockedMode, name, normalsMode, parent, queueDistance, renderQueueMode, renderStateList, textureCombineMode, worldBound, worldRotation, worldScale, worldTranslation, zOrder
 
Constructor Summary
protected DynamicPhysicsNode()
           
protected DynamicPhysicsNode(java.lang.String name)
           
 
Method Summary
 void addForce(com.jme.math.Vector3f force)
          Add a force to be applied to this node (at the center of mass).
abstract  void addForce(com.jme.math.Vector3f force, com.jme.math.Vector3f at)
          Add a force to be applied to this node at a given relative location.
abstract  void addTorque(com.jme.math.Vector3f torque)
          Add a torque to be applied to this node.
 void clearDynamics()
          Resets all force, torque and velocities.
abstract  void clearForce()
          Reset force on this node to 0.
abstract  void clearTorque()
          Reset torque on this node to 0.
abstract  void computeMass()
          Computes the mass for this node that would result from the attached geometries and their densities (materials).
protected  void drawDebugInfo(com.jme.renderer.Renderer renderer)
          Draw information about the physical properties of the Node.
abstract  com.jme.math.Vector3f getAngularVelocity(com.jme.math.Vector3f store)
          Query the angular velocity of this node.
abstract  com.jme.math.Vector3f getCenterOfMass(com.jme.math.Vector3f store)
          Obtain the center of mass.
 java.lang.Class getClassTag()
           
abstract  com.jme.math.Vector3f getForce(com.jme.math.Vector3f store)
          Obtain the current force on this node.
abstract  com.jme.math.Vector3f getLinearVelocity(com.jme.math.Vector3f store)
          Query the linear velocity of this node.
abstract  float getMass()
          Query mass of this physical entity.
abstract  com.jme.math.Vector3f getTorque(com.jme.math.Vector3f store)
          Obtain the current torque on this node.
abstract  boolean isAffectedByGravity()
           
 boolean isStatic()
           
 void read(com.jme.util.export.JMEImporter im)
           
abstract  void rest()
          This method may be called to tell the physics implementation that this node does not move by forces like gravity and other internal constantly applied forces currently.
abstract  void setAffectedByGravity(boolean value)
          Switch gravity on/off for this single node.
abstract  void setAngularVelocity(com.jme.math.Vector3f velocity)
          Sets the angular velocity of this node.
abstract  void setCenterOfMass(com.jme.math.Vector3f value)
          Change the center of mass for this node.
abstract  void setLinearVelocity(com.jme.math.Vector3f velocity)
          Sets the linear velocity of this node.
abstract  void setMass(float value)
          Change mass of this object.
abstract  void unrest()
          This method tells the physics implementation to check the node for movement after it has been rested (manually or automatically).
 void write(com.jme.util.export.JMEExporter ex)
           
 
Methods inherited from class com.jmex.physics.PhysicsNode
createBox, createCapsule, createCylinder, createMesh, createRay, createSphere, delete, generatePhysicsGeometry, generatePhysicsGeometry, generatePhysicsGeometry, generatePhysicsGeometry, getCollisionEventHandler, getCollisionGroup, getMaterial, getPhysicsNode, getSpace, isActive, isResting, setActive, setCollisionGroup, setMaterial, setParent
 
Methods inherited from class com.jme.scene.Node
applyRenderState, attachChild, attachChildAt, childChange, detachAllChildren, detachChild, detachChildAt, detachChildNamed, draw, findCollisions, findPick, getChild, getChild, getChildIndex, getChildren, getQuantity, getTriangleCount, getVertexCount, hasChild, hasCollision, lockBounds, lockMeshes, lockShadows, lockTransforms, setModelBound, sortLights, swapChildren, unlockBounds, unlockMeshes, unlockShadows, unlockTransforms, updateModelBound, updateWorldBound, updateWorldData, updateWorldVectors
 
Methods inherited from class com.jme.scene.Spatial
addController, calculateCollisions, calculatePick, clearControllers, clearRenderState, clearRenderState, getController, getControllerCount, getControllers, getCullHint, getLastFrustumIntersection, getLightCombineMode, getLocalCullHint, getLocalLightCombineMode, getLocalNormalsMode, getLocalRenderQueueMode, getLocalRotation, getLocalScale, getLocalTextureCombineMode, getLocalToWorldMatrix, getLocalTranslation, getLocks, getName, getNormalsMode, getParent, getRenderQueueMode, getRenderState, getRenderState, getTextureCombineMode, getUserData, getWorldBound, getWorldRotation, getWorldScale, getWorldTranslation, getZOrder, hasAncestor, isCollidable, localToWorld, lock, lock, lockBranch, lockMeshes, lookAt, onDraw, propagateBoundToRoot, propagateStatesFromRoot, removeController, removeController, removeFromParent, removeUserData, rotateUpTo, setCullHint, setIsCollidable, setLastFrustumIntersection, setLightCombineMode, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalTranslation, setLocalTranslation, setLocks, setLocks, setName, setNormalsMode, setRenderQueueMode, setRenderState, setTextureCombineMode, setUserData, setZOrder, setZOrder, toString, unlock, unlock, unlockBranch, unlockMeshes, updateGeometricState, updateRenderState, updateRenderState, updateWorldRotation, updateWorldScale, updateWorldTranslation, updateWorldVectors, worldToLocal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MASS_PROPERTY

public static final java.lang.String MASS_PROPERTY
See Also:
Constant Field Values

CENTER_OF_MASS_PROPERTY

public static final java.lang.String CENTER_OF_MASS_PROPERTY
See Also:
Constant Field Values

LINEAR_VELOCITY_PROPERTY

public static final java.lang.String LINEAR_VELOCITY_PROPERTY
See Also:
Constant Field Values

ANGULAR_VELOCITY_PROPERTY

public static final java.lang.String ANGULAR_VELOCITY_PROPERTY
See Also:
Constant Field Values

AFFECTED_BY_GRAVITY_PROPERTY

public static final java.lang.String AFFECTED_BY_GRAVITY_PROPERTY
See Also:
Constant Field Values

JOINTS_PROPERTY

public static final java.lang.String JOINTS_PROPERTY
See Also:
Constant Field Values
Constructor Detail

DynamicPhysicsNode

protected DynamicPhysicsNode(java.lang.String name)

DynamicPhysicsNode

protected DynamicPhysicsNode()
Method Detail

isStatic

public final boolean isStatic()
Specified by:
isStatic in class PhysicsNode
Returns:
true if this is a static (passive, immovable) node.

getMass

public abstract float getMass()
Query mass of this physical entity. Defaults to 1.

Returns:
mass

setMass

public abstract void setMass(float value)
Change mass of this object.

Parameters:
value - new mass

getCenterOfMass

public abstract com.jme.math.Vector3f getCenterOfMass(com.jme.math.Vector3f store)
Obtain the center of mass.

Parameters:
store - where to put the position (null to create a new vector)
Returns:
center as vector in object coordinate space

setCenterOfMass

public abstract void setCenterOfMass(com.jme.math.Vector3f value)
Change the center of mass for this node. This moves the attached spatials to a suited position. So this method should be called _after_ configuring the geometries (e.g. after PhysicsNode.generatePhysicsGeometry()).

Parameters:
value - new center as vector in object coordinate space

clearForce

public abstract void clearForce()
Reset force on this node to 0.


getForce

public abstract com.jme.math.Vector3f getForce(com.jme.math.Vector3f store)
Obtain the current force on this node.

Parameters:
store - where to put the force (null to create a new vector)
Returns:
store

addForce

public abstract void addForce(com.jme.math.Vector3f force,
                              com.jme.math.Vector3f at)
Add a force to be applied to this node at a given relative location. The force vector is given in world coordinate space. The force is applied in the next computation step and is cleared afterwards. Thus this method has to be called frequently (before each physics step) if a constant force should be applied.

Parameters:
force - force to be added (world coordinate space)
at - position of the object where the force should be applied (relative to the center of mass)
See Also:
PhysicsUpdateCallback

addForce

public void addForce(com.jme.math.Vector3f force)
Add a force to be applied to this node (at the center of mass). The vector is given in world coordinate space.

Parameters:
force - force to be added
See Also:
addForce(com.jme.math.Vector3f, com.jme.math.Vector3f)

clearTorque

public abstract void clearTorque()
Reset torque on this node to 0.


getTorque

public abstract com.jme.math.Vector3f getTorque(com.jme.math.Vector3f store)
Obtain the current torque on this node.

Parameters:
store - where to put the torque (null to create a new vector)
Returns:
store

addTorque

public abstract void addTorque(com.jme.math.Vector3f torque)
Add a torque to be applied to this node. The vector is given in world coordinate space.

Parameters:
torque - torque to be added

setLinearVelocity

public abstract void setLinearVelocity(com.jme.math.Vector3f velocity)
Sets the linear velocity of this node.

Parameters:
velocity - new velocity in world coordinate space

getLinearVelocity

public abstract com.jme.math.Vector3f getLinearVelocity(com.jme.math.Vector3f store)
Query the linear velocity of this node. The passed in Vector3f will be populated with the values, and then returned.

Parameters:
store - where to store the velocity (null to create a new vector)
Returns:
store

setAngularVelocity

public abstract void setAngularVelocity(com.jme.math.Vector3f velocity)
Sets the angular velocity of this node.

Parameters:
velocity - new velocity in world coordinate space

getAngularVelocity

public abstract com.jme.math.Vector3f getAngularVelocity(com.jme.math.Vector3f store)
Query the angular velocity of this node. The passed in Vector3f will be populated with the values, and then returned.

Parameters:
store - where to store the velocity (null to create a new vector)
Returns:
store

isAffectedByGravity

public abstract boolean isAffectedByGravity()
Returns:
true if node is affected by gravity
See Also:
setAffectedByGravity(boolean)

setAffectedByGravity

public abstract void setAffectedByGravity(boolean value)
Switch gravity on/off for this single node.

Parameters:
value - new value

clearDynamics

public void clearDynamics()
Resets all force, torque and velocities.


drawDebugInfo

protected void drawDebugInfo(com.jme.renderer.Renderer renderer)
Description copied from class: PhysicsNode
Draw information about the physical properties of the Node.

Overrides:
drawDebugInfo in class PhysicsNode
Parameters:
renderer - where to draw to

computeMass

public abstract void computeMass()
Computes the mass for this node that would result from the attached geometries and their densities (materials).


getClassTag

public java.lang.Class getClassTag()
Specified by:
getClassTag in interface com.jme.util.export.Savable
Overrides:
getClassTag in class PhysicsNode

read

public void read(com.jme.util.export.JMEImporter im)
          throws java.io.IOException
Specified by:
read in interface com.jme.util.export.Savable
Overrides:
read in class PhysicsNode
Throws:
java.io.IOException

write

public void write(com.jme.util.export.JMEExporter ex)
           throws java.io.IOException
Specified by:
write in interface com.jme.util.export.Savable
Overrides:
write in class PhysicsNode
Throws:
java.io.IOException

rest

public abstract void rest()
This method may be called to tell the physics implementation that this node does not move by forces like gravity and other internal constantly applied forces currently. This can optimize the physics calculations quite a lot. Note this will cause this node to e.g. hang around in the air if it's not really resting on the ground.

See Also:
unrest()

unrest

public abstract void unrest()
This method tells the physics implementation to check the node for movement after it has been rested (manually or automatically).

See Also:
rest()