com.jme.curve
Class Curve

java.lang.Object
  extended bycom.jme.scene.Spatial
      extended bycom.jme.scene.Geometry
          extended bycom.jme.curve.Curve
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BezierCurve

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,v 1.12 2004/08/21 06:18:30 cep21 Exp $
Author:
Mark Powell
See Also:
Serialized Form

Field Summary
protected  int steps
           
 
Fields inherited from class com.jme.scene.Geometry
bound, color, colorBuf, normal, normBuf, texBuf, texture, vertBuf, vertex, vertQuantity
 
Fields inherited from class com.jme.scene.Spatial
currentStates, defaultStateList, forceCull, forceView, frustrumIntersects, geometricalControllers, lightCombineMode, localRotation, localScale, localTranslation, name, 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 zero size array for the points.
Curve(java.lang.String name, Vector3f[] controlPoints)
          Constructor creates a Curve object.
 
Method Summary
 void draw(Renderer r)
          draw calls super to set the render state then calls the renderer to display the curve.
 void drawBounds(Renderer r)
          drawBounds calls super to set the render state then passes itself to the renderer.
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 setSteps(int steps)
          setSteps sets the number of steps that make up the curve.
 
Methods inherited from class com.jme.scene.Geometry
applyRenderState, applyStates, clearBuffers, copyTextureCoords, findPick, getAllTextures, getCloneID, getColorAsFloatBuffer, getColors, getModelBound, getNormalAsFloatBuffer, getNormals, getNumberOfUnits, getTextureAsFloatBuffer, getTextureAsFloatBuffer, getTextures, getTextures, getVBOColorID, getVBONormalID, getVBOTextureID, getVBOVertexID, getVerticeAsFloatBuffer, getVertices, getVertQuantity, isVBOColorEnabled, isVBONormalEnabled, isVBOTextureEnabled, isVBOVertexEnabled, putClone, randomVertice, reconstruct, setAllTextures, setColor, setColors, setFloatBuffer, setForceView, setModelBound, setNormal, setNormalBuffer, setNormals, setRandomColors, setSolidColor, setTexture, setTexture, setTextureBuffer, setTextureCoord, setTextures, setTextures, setVBOColorEnabled, setVBOColorID, setVBONormalEnabled, setVBONormalID, setVBOTextureEnabled, setVBOTextureID, setVBOVertexEnabled, setVBOVertexID, setVertex, setVertexBuffer, setVertices, updateColorBuffer, updateColorBuffer, updateModelBound, updateNormalBuffer, updateNormalBuffer, updateTextureBuffer, updateTextureBuffer, updateTextureBuffer, updateVertexBuffer, updateVertexBuffer, updateWorldBound
 
Methods inherited from class com.jme.scene.Spatial
addController, applyDefaultStates, calculateCollisions, calculatePick, clearCurrentState, clearCurrentStates, clearRenderState, findCollisions, getController, getControllers, getCurrentState, getLastFrustumIntersection, getLightCombineMode, getLocalRotation, getLocalScale, getLocalTranslation, getName, getParent, getRenderQueueMode, getRenderStateList, getTextureCombineMode, getWorldBound, getWorldRotation, getWorldScale, getWorldTranslation, getZOrder, hasCollision, isForceCulled, isForceView, onDraw, onDrawBounds, propagateBoundToRoot, propagateStatesFromRoot, removeController, removeFromParent, setForceCull, setLightCombineMode, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalTranslation, setName, setParent, setRenderQueueMode, setRenderState, setTextureCombineMode, setWorldBound, setZOrder, toString, updateCollisionTree, updateGeometricState, updateRenderState, updateRenderState, updateWorldData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

steps

protected int steps
Constructor Detail

Curve

public Curve(java.lang.String name)
Constructor creates a default Curve object with a zero size array for the 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.
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)

drawBounds

public void drawBounds(Renderer r)
drawBounds calls super to set the render state then passes itself to the renderer.

Overrides:
drawBounds in class Geometry
Parameters:
r - the renderer to display

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.