com.jme.curve
Class Curve

java.lang.Object
  extended by com.jme.scene.Spatial
      extended by com.jme.scene.Geometry
          extended by com.jme.curve.Curve
All Implemented Interfaces:
Savable, java.io.Serializable
Direct Known Subclasses:
BezierCurve, CatmullRomCurve, PolylineCurve

public abstract class Curve
extends Geometry

Curve defines a collection of points that make up a curve. How this curve is constructed is undefined, and the job of a subclass. The control points are defined as the super class Geometry vertex array. They can be set and accessed as such. Curve is abstract only maintaining the point collection. It defines getPoint and getOrientation. Extending classes are responsible for implementing these methods in the appropriate way.

Version:
$Id: Curve.java 4131 2009-03-19 20:15:28Z blaine.dev $
Author:
Mark Powell
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.jme.scene.Spatial
Spatial.CullHint, Spatial.LightCombineMode, Spatial.NormalsMode, Spatial.TextureCombineMode
 
Field Summary
protected  int steps
           
 
Fields inherited from class com.jme.scene.Geometry
binormalBuf, bound, castsShadows, colorBuf, compVect, defaultColor, displayListID, enabled, fogBuf, hasDirtyVertices, normBuf, states, tangentBuf, texBuf, vboInfo, vertBuf, vertQuantity
 
Fields inherited from class com.jme.scene.Spatial
cullHint, frustrumIntersects, geometricalControllers, isCollidable, lightCombineMode, localRotation, localScale, localTranslation, LOCKED_BOUNDS, LOCKED_BRANCH, LOCKED_MESH_DATA, LOCKED_NONE, LOCKED_SHADOWS, LOCKED_TRANSFORMS, lockedMode, name, normalsMode, parent, queueDistance, renderQueueMode, renderStateList, textureCombineMode, worldBound, worldRotation, worldScale, worldTranslation, zOrder
 
Constructor Summary
Curve(java.lang.String name)
          Constructor creates a default Curve object with a no points.
Curve(java.lang.String name, Vector3f[] controlPoints)
          Constructor creates a Curve object.
 
Method Summary
protected  void applyRenderState(java.util.Stack<? extends RenderState>[] states)
          applyRenderState determines if a particular render state is set for this Geometry.
 void draw(Renderer r)
          draw calls super to set the render state then calls the renderer to display the curve.
abstract  Matrix3f getOrientation(float time, float precision)
          getOrientation calculates a rotation matrix that defines the orientation along a curve.
abstract  Matrix3f getOrientation(float time, float precision, Vector3f up)
          getOrientation calculates a rotation matrix that defines the orientation along a curve.
abstract  Vector3f getPoint(float time)
          getPoint calculates a point on the curve based on the time, where time is [0, 1].
abstract  Vector3f getPoint(float time, Vector3f store)
          Equivalent to getPoint(float) but instead of creating a new Vector3f object on the heap, the result is stored in store and store is returned.
 int getSteps()
          getSteps retrieves the number of steps that make up the curve.
 void read(JMEImporter e)
           
 void setSteps(int steps)
          setSteps sets the number of steps that make up the curve.
 void write(JMEExporter e)
           
 
Methods inherited from class com.jme.scene.Geometry
addTextureCoordinates, addTextureCoordinates, checkTextureCoordinates, clearBuffers, clearTextureBuffers, copyTextureCoordinates, copyTextureCoordinates, findPick, getBinormalBuffer, getColorBuffer, getDefaultColor, getDisplayListID, getFogBuffer, getLightState, getModelBound, getNormalBuffer, getNumberOfUnits, getTangentBuffer, getTextureCoords, getTextureCoords, getTriangleCount, getVBOInfo, getVertexBuffer, getVertexCount, getWorldCoords, getWorldNormals, hasDirtyVertices, isCastsShadows, lockMeshes, postdraw, predraw, randomVertex, reconstruct, resizeTextureIds, rotateNormals, rotatePoints, scaleTextureCoordinates, scaleTextureCoordinates, setBinormalBuffer, setCastsShadows, setColorBuffer, setDefaultColor, setDisplayListID, setFogCoordBuffer, setHasDirtyVertices, setLightState, setModelBound, setNormalBuffer, setRandomColors, setSolidColor, setTangentBuffer, setTextureCoords, setTextureCoords, setTextureCoords, setVBOInfo, setVertexBuffer, setVertexCount, sortLights, translatePoints, translatePoints, unlockMeshes, updateModelBound, updateWorldBound
 
Methods inherited from class com.jme.scene.Spatial
addController, calculateCollisions, calculatePick, clearControllers, clearRenderState, clearRenderState, findCollisions, getClassTag, getController, getControllerCount, getControllers, getCullHint, getLastFrustumIntersection, getLightCombineMode, getLocalCullHint, getLocalLightCombineMode, getLocalNormalsMode, getLocalRenderQueueMode, getLocalRotation, getLocalScale, getLocalTextureCombineMode, getLocalToWorldMatrix, getLocalTranslation, getLocks, getName, getNormalsMode, getParent, getRenderQueueMode, getRenderState, getRenderState, getTextureCombineMode, getUserData, getWorldBound, getWorldRotation, getWorldScale, getWorldTranslation, getZOrder, hasAncestor, hasCollision, isCollidable, localToWorld, lock, lock, lockBounds, lockBranch, lockMeshes, lockShadows, lockTransforms, lookAt, onDraw, propagateBoundToRoot, propagateStatesFromRoot, removeController, removeController, removeFromParent, removeUserData, rotateUpTo, setCullHint, setIsCollidable, setLastFrustumIntersection, setLightCombineMode, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalTranslation, setLocalTranslation, setLocks, setLocks, setName, setNormalsMode, setParent, setRenderQueueMode, setRenderState, setTextureCombineMode, setUserData, setZOrder, setZOrder, toString, unlock, unlock, unlockBounds, unlockBranch, unlockMeshes, unlockShadows, unlockTransforms, updateGeometricState, updateRenderState, updateRenderState, updateWorldData, updateWorldRotation, updateWorldScale, updateWorldTranslation, updateWorldVectors, updateWorldVectors, worldToLocal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.jme.util.export.Savable
getClassTag
 

Field Detail

steps

protected int steps
Constructor Detail

Curve

public Curve(java.lang.String name)
Constructor creates a default Curve object with a no points.

Parameters:
name - the name of the scene element. This is required for identification and comparision purposes.

Curve

public Curve(java.lang.String name,
             Vector3f[] controlPoints)
Constructor creates a Curve object. The control point list is set during creation. If the control point list is null or has fewer than 2 points, an exception is thrown.

Parameters:
name - the name of the scene element. This is required for identification and comparision purposes.
controlPoints - the points that define the curve. These are copied into the object, further changes to these Vectors will not affect the Curve.
Method Detail

setSteps

public void setSteps(int steps)
setSteps sets the number of steps that make up the curve.

Parameters:
steps - the number of steps that make up the curve.

getSteps

public int getSteps()
getSteps retrieves the number of steps that make up the curve.

Returns:
the number of steps that makes up the curve.

draw

public void draw(Renderer r)
draw calls super to set the render state then calls the renderer to display the curve.

Overrides:
draw in class Geometry
Parameters:
r - the renderer used to display the curve.
See Also:
Spatial.draw(com.jme.renderer.Renderer)

getPoint

public abstract Vector3f getPoint(float time)
getPoint calculates a point on the curve based on the time, where time is [0, 1]. How the point is calculated is defined by the subclass.

Parameters:
time - the time frame on the curve, [0, 1].
Returns:
the point on the curve at a specified time.

getPoint

public abstract Vector3f getPoint(float time,
                                  Vector3f store)
Equivalent to getPoint(float) but instead of creating a new Vector3f object on the heap, the result is stored in store and store is returned.

Parameters:
time - the time frame on the curve: [0, 1].
store - the vector3f object to store the point in.
Returns:
store, after receiving the result.
See Also:
getPoint(float)

getOrientation

public abstract Matrix3f getOrientation(float time,
                                        float precision)
getOrientation calculates a rotation matrix that defines the orientation along a curve. How the matrix is calculated is defined by the subclass.

Parameters:
time - the time frame on the curve, [0, 1].
precision - the accuracy of the orientation (lower is more precise). Recommended (0.1).
Returns:
the rotational matrix that defines the orientation of along a curve.

getOrientation

public abstract Matrix3f getOrientation(float time,
                                        float precision,
                                        Vector3f up)
getOrientation calculates a rotation matrix that defines the orientation along a curve. The up vector is provided keeping the orientation from "rolling" along the curve. This is useful for camera tracks. How the matrix is calculated is defined by the subclass.

Parameters:
time - the time frame on the curve, [0, 1].
precision - the accuracy of the orientation (lower is more precise). Recommended (0.1).
up - the up vector to lock.
Returns:
the rotational matrix that defines the orientation of along a curve.

applyRenderState

protected void applyRenderState(java.util.Stack<? extends RenderState>[] states)
Description copied from class: Geometry
applyRenderState determines if a particular render state is set for this Geometry. If not, the default state will be used.

Overrides:
applyRenderState in class Geometry
Parameters:
states - An array of stacks for each state.

write

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

read

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