com.jme.math.spring
Class Spring

java.lang.Object
  extended by com.jme.math.spring.Spring
All Implemented Interfaces:
Savable

public class Spring
extends java.lang.Object
implements Savable

Spring defines a single spring connecting two SpringNodes in a SpringSystem.

Version:
$Id: Spring.java 4131 2009-03-19 20:15:28Z blaine.dev $
Author:
Joshua Slack

Field Summary
 SpringPoint node1
          First node connected by this Spring.
 SpringPoint node2
          Second node connected by this Spring.
 
Constructor Summary
Spring(SpringPoint node1, SpringPoint node2, float restLength)
          Public constructor.
 
Method Summary
 java.lang.Class getClassTag()
           
 float getRestLength()
          Return the rest length of this Spring.
 void read(JMEImporter e)
           
 void setRestLength(float restLength)
          Set the rest length of this Spring.
 void update()
          Updates the positions of the nodes connected by this spring based on spring force calculations.
 void updateTotalMassFromNodes()
          Computes the spring collective mass from the node using inverted masses for stability
 void write(JMEExporter e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

node1

public SpringPoint node1
First node connected by this Spring.


node2

public SpringPoint node2
Second node connected by this Spring.

Constructor Detail

Spring

public Spring(SpringPoint node1,
              SpringPoint node2,
              float restLength)
Public constructor.

Parameters:
node1 - SpringNode
node2 - SpringNode
restLength - float
Method Detail

setRestLength

public void setRestLength(float restLength)
Set the rest length of this Spring. Also, calculates and sets the squared rest length field.

Parameters:
restLength - float

getRestLength

public float getRestLength()
Return the rest length of this Spring.

Returns:
float

updateTotalMassFromNodes

public void updateTotalMassFromNodes()
Computes the spring collective mass from the node using inverted masses for stability


update

public void update()
Updates the positions of the nodes connected by this spring based on spring force calculations. Relaxation method idea came from paper on physics system of Hitman game.


write

public void write(JMEExporter e)
           throws java.io.IOException
Specified by:
write in interface Savable
Throws:
java.io.IOException

read

public void read(JMEImporter e)
          throws java.io.IOException
Specified by:
read in interface Savable
Throws:
java.io.IOException

getClassTag

public java.lang.Class getClassTag()
Specified by:
getClassTag in interface Savable