com.jmex.physics
Class Joint

java.lang.Object
  extended by com.jmex.physics.Joint
All Implemented Interfaces:
com.jme.util.export.Savable

public abstract class Joint
extends java.lang.Object
implements com.jme.util.export.Savable

A Joint constraints the relative location and rotation of two PhysicsNodes. By default a Joint does not allow to move any relative position or rotation change between the nodes. Axes can be added to allow movement in a specific direction or rotation around specific axes. Commonly a Joint can have only 6 axes. Some implementations may choose to allow 3 axes for positions plus 3 different axes for rotation but commonly translation and rotation axes will be equal. Commonly the axes should be perpendicular.

Author:
Irrisor
See Also:
PhysicsSpace.createJoint()

Field Summary
static java.lang.String ACTIVE_PROPERTY
           
static java.lang.String ANCHOR_PROPERTY
           
static java.lang.String AXES_PROPERTY
           
static java.lang.String COLLISION_ENABLED_PROPERTY
           
static java.lang.String DAMPING_COEFFICIENT_PROPERTY
           
static java.lang.String NAME_PROPERTY
           
static java.lang.String NODES_PROPERTY
           
static java.lang.String SPRING_CONSTANT_PROPERTY
           
 
Constructor Summary
protected Joint()
           
 
Method Summary
protected  void added(JointAxis axis)
           
abstract  void attach(DynamicPhysicsNode node)
          Attach this Joint to a single dynamic physics node.
abstract  void attach(DynamicPhysicsNode leftNode, DynamicPhysicsNode rightNode)
          Attach this Joint to two dynamic physics nodes.
 RotationalJointAxis createRotationalAxis()
           
protected abstract  RotationalJointAxis createRotationalAxisImplementation()
           
 TranslationalJointAxis createTranslationalAxis()
           
protected abstract  TranslationalJointAxis createTranslationalAxisImplementation()
           
abstract  void detach()
          Detach this joint from all nodes.
abstract  com.jme.math.Vector3f getAnchor(com.jme.math.Vector3f store)
          Query the anchor of this node.
 java.util.List<JointAxis> getAxes()
          Get the list of axes to add/remove or query axes of this Joint.
abstract  float getBreakingLinearForce()
           
abstract  float getBreakingTorque()
           
 java.lang.Class getClassTag()
          Returns the class tag.
abstract  float getDampingCoefficient()
          Returns the value of the damping coefficient.
 java.lang.String getName()
          getter for field name
abstract  java.util.List<? extends DynamicPhysicsNode> getNodes()
          Query a list of nodes connected via this joint.
abstract  PhysicsSpace getSpace()
           
abstract  float getSpringConstant()
          Returns the value of the spring constant.
 boolean isActive()
           
abstract  boolean isCollisionEnabled()
           
 void read(com.jme.util.export.JMEImporter im)
           
 void removed(JointAxis axis)
           
abstract  void reset()
          Reset the joint as if it has just been created.
 boolean setActive(boolean value)
          Activate the node when added to a space.
abstract  void setAnchor(com.jme.math.Vector3f anchor)
          Sets the anchor of this joint.
abstract  void setBreakingLinearForce(float breakingLinearForce)
          Change the maximum allowed force that is applied by this joint in a single time step.
abstract  void setBreakingTorque(float breakingTorque)
          Change the maximum allowed torque that is applied by this joint in a single time step.
abstract  void setCollisionEnabled(boolean enabled)
           
 void setName(java.lang.String value)
          setter for field name
abstract  void setSpring(float springConstant, float dampingCoefficient)
          Makes the joint 'softer' like a spring.
 void write(com.jme.util.export.JMEExporter ex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTIVE_PROPERTY

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

ANCHOR_PROPERTY

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

AXES_PROPERTY

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

NAME_PROPERTY

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

NODES_PROPERTY

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

SPRING_CONSTANT_PROPERTY

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

DAMPING_COEFFICIENT_PROPERTY

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

COLLISION_ENABLED_PROPERTY

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

Joint

protected Joint()
Method Detail

added

protected void added(JointAxis axis)

removed

public void removed(JointAxis axis)

getAxes

public java.util.List<JointAxis> getAxes()
Get the list of axes to add/remove or query axes of this Joint.

Returns:
list of axes

createTranslationalAxis

public TranslationalJointAxis createTranslationalAxis()

createRotationalAxis

public RotationalJointAxis createRotationalAxis()

createTranslationalAxisImplementation

protected abstract TranslationalJointAxis createTranslationalAxisImplementation()

createRotationalAxisImplementation

protected abstract RotationalJointAxis createRotationalAxisImplementation()

getSpace

public abstract PhysicsSpace getSpace()
Returns:
space this joint belongs to, must not be null

isActive

public final boolean isActive()
Returns:
true if joint is currently active

setActive

public boolean setActive(boolean value)
Activate the node when added to a space. Deactivate when removed.

Parameters:
value - true when activated
Returns:
true if node was (de)activated, false if state was already set to value

getName

public java.lang.String getName()
getter for field name

Returns:
current value of field name

setName

public void setName(java.lang.String value)
setter for field name

Parameters:
value - new value

attach

public abstract void attach(DynamicPhysicsNode leftNode,
                            DynamicPhysicsNode rightNode)
Attach this Joint to two dynamic physics nodes. All formerly attached nodes are detached.

Parameters:
leftNode - first node this joint is attached to, not null
rightNode - second node this joint is attached to, not null
See Also:
attach(com.jmex.physics.DynamicPhysicsNode), detach()

attach

public abstract void attach(DynamicPhysicsNode node)
Attach this Joint to a single dynamic physics node. This Joint then constraints the abolute translation and/or rotation of the node (relative the the space). All formerly attached nodes are detached.

Parameters:
node - the only node this joint is attached to, not null
See Also:
attach(DynamicPhysicsNode, DynamicPhysicsNode), detach()

detach

public abstract void detach()
Detach this joint from all nodes. Effectively disables the joint.

See Also:
attach(DynamicPhysicsNode, DynamicPhysicsNode), attach(DynamicPhysicsNode)

getNodes

public abstract java.util.List<? extends DynamicPhysicsNode> getNodes()
Query a list of nodes connected via this joint. This may contain 0 to 2 nodes. The list cannot be altered. To alter is use the attach(com.jmex.physics.DynamicPhysicsNode, com.jmex.physics.DynamicPhysicsNode) and detach() methods.

Returns:
a list of dynamic nodes connected via this joint.

reset

public abstract void reset()
Reset the joint as if it has just been created.


setAnchor

public abstract void setAnchor(com.jme.math.Vector3f anchor)
Sets the anchor of this joint. The point is specified in world coordinate space if the joint attaches a single node to the world. If two nodes are attached the anchor is specified relative to the center of mass of the first node.

Parameters:
anchor - new anchor point

getAnchor

public abstract com.jme.math.Vector3f getAnchor(com.jme.math.Vector3f store)
Query the anchor of this node. The passed in Vector3f will be populated with the values, and then returned. The point in specified in world coordinate space if the joint attaches a single node to the world. If two nodes are attached the anchor is specified relative to the center of mass of the first node.

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

setSpring

public abstract void setSpring(float springConstant,
                               float dampingCoefficient)
Makes the joint 'softer' like a spring. Invoke with NaN to apply default stiffness.

Parameters:
springConstant - spring constant
dampingCoefficient - damping coefficient
Throws:
java.lang.UnsupportedOperationException - if not supported for the current axis configuration

getSpringConstant

public abstract float getSpringConstant()
Returns the value of the spring constant.

Returns:
spring constant

getDampingCoefficient

public abstract float getDampingCoefficient()
Returns the value of the damping coefficient.

Returns:
damping coefficient

getClassTag

public java.lang.Class getClassTag()
Returns the class tag.

Specified by:
getClassTag in interface com.jme.util.export.Savable
Returns:
class tag

read

public void read(com.jme.util.export.JMEImporter im)
          throws java.io.IOException
Specified by:
read in interface com.jme.util.export.Savable
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
Throws:
java.io.IOException

getBreakingLinearForce

public abstract float getBreakingLinearForce()
Returns:
current maximum force before joint breaks
See Also:
setBreakingLinearForce(float)

setBreakingLinearForce

public abstract void setBreakingLinearForce(float breakingLinearForce)
Change the maximum allowed force that is applied by this joint in a single time step. If this threshold is exceeded the joint breaks (gets detached).

Parameters:
breakingLinearForce - new maximum force

getBreakingTorque

public abstract float getBreakingTorque()
Returns:
current maximum torque before joint breaks
See Also:
setBreakingTorque(float)

setBreakingTorque

public abstract void setBreakingTorque(float breakingTorque)
Change the maximum allowed torque that is applied by this joint in a single time step. If this threshold is exceeded the joint breaks (gets detached).

Parameters:
breakingTorque - new maximum torque

setCollisionEnabled

public abstract void setCollisionEnabled(boolean enabled)
Parameters:
enabled - true to allow collision detection between joint bodies (default is false)

isCollisionEnabled

public abstract boolean isCollisionEnabled()
Returns:
true if nodes attached to this joint can collide with each other