j3d.org Code

org.j3d.renderer.java3d.geom
Class Spring

java.lang.Object
  extended byjavax.media.j3d.SceneGraphObject
      extended byjavax.media.j3d.Node
          extended byjavax.media.j3d.Leaf
              extended byjavax.media.j3d.Shape3D
                  extended byorg.j3d.renderer.java3d.geom.Spring

public class Spring
extends javax.media.j3d.Shape3D

A simple spring that uses triangle strips.

The created spring does not have any capabilities set except for the ability to write the geometry - needed so that we can modify the geometry when you change the height or radius. If you know that you are not going to be changing the geometry you can turn this off.

As we assume you may want to use this as a collidable object, we store the GeometryData instance that is used to create the object in the userData of the underlying TriangleStripArray. The geometry does not have texture coordinates set.

Version:
$Revision: 1.1 $
Author:
Justin Couch

Field Summary
 
Fields inherited from class javax.media.j3d.Shape3D
ALLOW_APPEARANCE_OVERRIDE_READ, ALLOW_APPEARANCE_OVERRIDE_WRITE, ALLOW_APPEARANCE_READ, ALLOW_APPEARANCE_WRITE, ALLOW_COLLISION_BOUNDS_READ, ALLOW_COLLISION_BOUNDS_WRITE, ALLOW_GEOMETRY_READ, ALLOW_GEOMETRY_WRITE
 
Fields inherited from class javax.media.j3d.Node
ALLOW_AUTO_COMPUTE_BOUNDS_READ, ALLOW_AUTO_COMPUTE_BOUNDS_WRITE, ALLOW_BOUNDS_READ, ALLOW_BOUNDS_WRITE, ALLOW_COLLIDABLE_READ, ALLOW_COLLIDABLE_WRITE, ALLOW_LOCAL_TO_VWORLD_READ, ALLOW_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING
 
Constructor Summary
Spring()
          Construct a default spring that has:
inner radius: 0.25
outer radius: 1.0
inner facet count: 16
outer facet count: 16
loop count: 4
loop spacing: 1.0
Spring(javax.media.j3d.Appearance app)
          Construct a default spring with a given appearance that has:
inner radius: 0.25
outer radius: 1.0
inner facet count: 16
outer facet count: 16
loop count: 4
loop spacing: 1.0
Spring(float spacing)
          Construct a spring with the given loop spacing and all other values fixed at the defaults.
Spring(float spacing, javax.media.j3d.Appearance app)
          Construct a spring with the given loop spacing and all other values fixed at the defaults.
Spring(float ir, float or)
          Construct a spring that has the given radius values with all other values fixed at the defaults
Spring(float ir, float or, javax.media.j3d.Appearance app)
          Construct a spring that has the given radius values with all other values fixed at the defaults but a customisable appearance.
Spring(float ir, float or, float spacing, int lc)
          Construct a spring with the given radius, spacing and loop count information.
Spring(float ir, float or, float spacing, int lc, int ifc, int ofc, javax.media.j3d.Appearance app)
          Construct a spring with the given radius, spacing and loop count information, and facet count.
Spring(int lc)
          Construct a spring that has the given number of loops with all other values fixed at the defaults.
Spring(int lc, javax.media.j3d.Appearance app)
          Construct a spring that has the given number of loops with all other values fixed at the defaults.
Spring(int ifc, int ofc)
          Construct a spring that has the selected number of facets but with all other values fixed at the defaults.
Spring(int ifc, int ofc, javax.media.j3d.Appearance app)
          Construct a spring that has the selected number of facets but with all other values fixed at the defaults.
 
Method Summary
 void setDimensions(float innerRadius, float outerRadius)
          Change the radius values of the spring to the new values.
 void setFacetCount(int inner, int outer)
          Set the facet count of the spring to the new value.
 void setLoopDimensions(float spacing, int lc)
          Change the loop values of the spring to the new values.
 
Methods inherited from class javax.media.j3d.Shape3D
addGeometry, cloneNode, duplicateNode, getAllGeometries, getAppearance, getAppearanceOverrideEnable, getBounds, getCollisionBounds, getGeometry, getGeometry, indexOfGeometry, insertGeometry, intersect, intersect, intersect, numGeometries, removeAllGeometries, removeGeometry, removeGeometry, setAppearance, setAppearanceOverrideEnable, setCollisionBounds, setGeometry, setGeometry
 
Methods inherited from class javax.media.j3d.Node
cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, getBoundsAutoCompute, getCollidable, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable
 
Methods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setUserData, updateNodeReferences
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Spring

public Spring()
Construct a default spring that has:
inner radius: 0.25
outer radius: 1.0
inner facet count: 16
outer facet count: 16
loop count: 4
loop spacing: 1.0


Spring

public Spring(javax.media.j3d.Appearance app)
Construct a default spring with a given appearance that has:
inner radius: 0.25
outer radius: 1.0
inner facet count: 16
outer facet count: 16
loop count: 4
loop spacing: 1.0

Parameters:
app - The Appearance to use

Spring

public Spring(float ir,
              float or)
Construct a spring that has the given radius values with all other values fixed at the defaults

Parameters:
ir - The inner radius to use
or - The outer radius to use

Spring

public Spring(float ir,
              float or,
              javax.media.j3d.Appearance app)
Construct a spring that has the given radius values with all other values fixed at the defaults but a customisable appearance.

Parameters:
ir - The inner radius to use
or - The outer radius to use
app - The Appearance to use

Spring

public Spring(int lc)
Construct a spring that has the given number of loops with all other values fixed at the defaults. The loop count must be one or more.

Parameters:
lc - The loop count
Throws:
java.lang.IllegalArgumentException - The loop count was invalid

Spring

public Spring(int lc,
              javax.media.j3d.Appearance app)
Construct a spring that has the given number of loops with all other values fixed at the defaults. The loop count must be one or more. An Appearance value may be supplied.

Parameters:
lc - The loop count
app - The Appearance to use
Throws:
java.lang.IllegalArgumentException - The loop count was invalid

Spring

public Spring(float spacing)
Construct a spring with the given loop spacing and all other values fixed at the defaults.

Parameters:
spacing - The spacing between loops

Spring

public Spring(float spacing,
              javax.media.j3d.Appearance app)
Construct a spring with the given loop spacing and all other values fixed at the defaults.

Parameters:
spacing - The spacing between loops
app - The Appearance to use

Spring

public Spring(int ifc,
              int ofc)
Construct a spring that has the selected number of facets but with all other values fixed at the defaults. The minimum number of facets is 3.

Parameters:
ifc - The number of facets to use around the inner radius
ofc - The number of facets to use around the outer radius
Throws:
java.lang.IllegalArgumentException - The number of facets is less than 3

Spring

public Spring(int ifc,
              int ofc,
              javax.media.j3d.Appearance app)
Construct a spring that has the selected number of facets but with all other values fixed at the defaults. The minimum number of facets is 3.

Parameters:
ifc - The number of facets to use around the inner radius
ofc - The number of facets to use around the outer radius
app - The Appearance to use
Throws:
java.lang.IllegalArgumentException - The number of facets is less than 3

Spring

public Spring(float ir,
              float or,
              float spacing,
              int lc)
Construct a spring with the given radius, spacing and loop count information. All other values are defaults. The loop count must be greater than or equal to 1.

Parameters:
ir - The inner radius to use
or - The outer radius to use
spacing - The spacing between loops
lc - The loop count
Throws:
java.lang.IllegalArgumentException - The loop count was invalid

Spring

public Spring(float ir,
              float or,
              float spacing,
              int lc,
              int ifc,
              int ofc,
              javax.media.j3d.Appearance app)
Construct a spring with the given radius, spacing and loop count information, and facet count. The loop count must be greater than or equal to 1 and the facet counts must be 3 or more.

Parameters:
ir - The inner radius to use
or - The outer radius to use
spacing - The spacing between loops
lc - The loop count
ifc - The number of facets to use around the inner radius
ofc - The number of facets to use around the outer radius
Throws:
java.lang.IllegalArgumentException - The loop count was invalid or facet counts were less than 4
Method Detail

setDimensions

public void setDimensions(float innerRadius,
                          float outerRadius)
Change the radius values of the spring to the new values. If the geometry write capability has been turned off, this will not do anything.

Parameters:
innerRadius - The inner radius of the spring
outerRadius - The outer radius of the spring

setLoopDimensions

public void setLoopDimensions(float spacing,
                              int lc)
Change the loop values of the spring to the new values. If the geometry write capability has been turned off, this will not do anything.

Parameters:
spacing - The spacing between loops
lc - The loop count

setFacetCount

public void setFacetCount(int inner,
                          int outer)
Set the facet count of the spring to the new value. If the geometry write capability has been turned off, this will not do anything.

Parameters:
inner - The number of faces to use around the inner radius
outer - The number of faces to use around the outer radius

j3d.org Code

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