|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jme.math.spring.SpringSystem
public class SpringSystem
SpringSystem
is a set of springs and nodes that
act and update as a cohesive unit.
Field Summary | |
---|---|
protected java.util.ArrayList<SpringPoint> |
nodes
Array of SpringNodes in this system. |
protected java.util.ArrayList<Spring> |
springs
Array of Springs in this system. |
Constructor Summary | |
---|---|
SpringSystem()
Public constructor useful for creating custom SpringSystems. |
Method Summary | |
---|---|
void |
addForce(SpringPointForce force)
Add an external force to this system. |
void |
addNode(SpringPoint node)
Add a SpringNode to this system. |
void |
addSpring(Spring spring)
Add a Spring to this system. |
void |
addSpring(SpringPoint node1,
SpringPoint node2)
Create and add a Spring to this system given two nodes. |
void |
calcForces(float dt)
Calculate all external forces to be applied on the system nodes. |
static SpringSystem |
createRectField(int width,
int height,
java.nio.FloatBuffer verts,
float particleMass)
Convienence method for creating a rectangular system of springs and nodes. |
java.lang.Class |
getClassTag()
|
SpringPoint |
getNode(int index)
Grab a specific node from this system. |
int |
getNodeCount()
Return the number of nodes in this system. |
int |
getRelaxLoops()
Return how many times each spring is updated per SpringSystem update. |
Spring |
getSpring(int index)
Grab a specific spring from this system. |
int |
getSpringCount()
Return the number of springs in this system. |
void |
read(JMEImporter e)
|
boolean |
removeForce(SpringPointForce force)
Remove a force from this system. |
boolean |
removeNode(SpringPoint node)
Remove a given SpringNode from this system. |
boolean |
removeSpring(Spring spring)
Remove a given Spring from this system. |
void |
setRelaxLoops(int relaxLoops)
Set how many times the springs are updated per SpringSystem update. |
void |
update(float dt)
Update the SpringNodes and Springs in this System. |
void |
write(JMEExporter e)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.ArrayList<SpringPoint> nodes
protected java.util.ArrayList<Spring> springs
Constructor Detail |
---|
public SpringSystem()
Method Detail |
---|
public SpringPoint getNode(int index)
index
- int
public int getNodeCount()
public void addNode(SpringPoint node)
node
- SpringNodepublic boolean removeNode(SpringPoint node)
node
- SpringNode
public Spring getSpring(int index)
index
- int
public int getSpringCount()
public void addSpring(SpringPoint node1, SpringPoint node2)
node1
- SpringNodenode2
- SpringNodepublic void addSpring(Spring spring)
spring
- Springpublic boolean removeSpring(Spring spring)
spring
- Spring
public void setRelaxLoops(int relaxLoops)
relaxLoops
- int should be at least 2 for stability.public int getRelaxLoops()
public void addForce(SpringPointForce force)
force
- SpringPointForcepublic boolean removeForce(SpringPointForce force)
force
- SpringPointForce
public static SpringSystem createRectField(int width, int height, java.nio.FloatBuffer verts, float particleMass)
width
- number of nodes wideheight
- number of nodes highverts
- a precreated array of vertices. These should be setup
from left to right, top to bottom.normals
- a precreated array to use as normals. Should be ordered
the same as the verts array.particleMass
- a mass applied to each individual node. Total system
mass would equals particleMass x width x height. (i.e. particale mass x
getNodeCount())
public void calcForces(float dt)
dt
- change in time since last call to this function in ms.public void update(float dt)
dt
- floatpublic void write(JMEExporter e) throws java.io.IOException
write
in interface Savable
java.io.IOException
public void read(JMEImporter e) throws java.io.IOException
read
in interface Savable
java.io.IOException
public java.lang.Class getClassTag()
getClassTag
in interface Savable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |