j3d.org Code

org.j3d.geom.spring
Class SpringNode

java.lang.Object
  extended by org.j3d.geom.spring.SpringNode

public class SpringNode
extends java.lang.Object

Representation of a node in a collection that many springs are connected to.

For memory efficiency purposes, each node has a position and normal direction that are sourced from a global array. An offset provides the direct reference into the array for it's specific information.

Version:
$Revision: 1.3 $
Author:
Justin Couch

Field Summary
 SpringNode[] connections
          Connections to other nodes
 float[] dir
          Direction the node is currently moving.
 boolean locked
          Is this node currently locked in position?
 float[] naturalLengths
          Natural length of each connection
 int nNormal
          number of valid normals from the contributing connections
 float[] normal
          A reference to the global array containing normal information
 int numConnections
          The number of valid items in the connections array
 int offset
          The offset into the array to work with the normal and positions.
 float[] position
          A reference to the global array containing position information
 
Constructor Summary
SpringNode()
          Create an empty version of this node.
SpringNode(float[] pos, float[] norm, int offset)
          Create a new node at the given position and normal.
 
Method Summary
 void addSpring(SpringNode node)
          Add a spring between the given node and this node.
 void resetNaturalLengths()
          Regenerate the natural lengths based on the current separation between this node and it's connections.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

position

public float[] position
A reference to the global array containing position information


normal

public float[] normal
A reference to the global array containing normal information


dir

public float[] dir
Direction the node is currently moving. Shouldn't be touched by anything other than our local internal evaluator.


offset

public int offset
The offset into the array to work with the normal and positions. This is the actual index (ie multply by 3 for the coord index).


connections

public SpringNode[] connections
Connections to other nodes


naturalLengths

public float[] naturalLengths
Natural length of each connection


numConnections

public int numConnections
The number of valid items in the connections array


nNormal

public int nNormal
number of valid normals from the contributing connections


locked

public boolean locked
Is this node currently locked in position?

Constructor Detail

SpringNode

public SpringNode()
Create an empty version of this node. No internal references for normals or coordiantes will be made in this version and all other arrays must be initialized buy the end user. If they are not set up, the system will crash hard at a later date.


SpringNode

public SpringNode(float[] pos,
                  float[] norm,
                  int offset)
Create a new node at the given position and normal. The array values are kept as references, not copied. This is an internal version used by the SpringSystem.addRectField(int, int, float[], float[]) method of SpringSystem.

Parameters:
pos - The position array that contains the location
norm - The normal array that contains our normal
offset - The offset into the arrays that this node is located at
Method Detail

addSpring

public void addSpring(SpringNode node)
Add a spring between the given node and this node.

Parameters:
node - The new node instance to connect to this one

resetNaturalLengths

public void resetNaturalLengths()
Regenerate the natural lengths based on the current separation between this node and it's connections. This will also reset the current direction vector back to zero again.


j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org