com.jme.scene
Class Line

java.lang.Object
  extended by com.jme.scene.Spatial
      extended by com.jme.scene.Geometry
          extended by com.jme.scene.Line
All Implemented Interfaces:
Savable, java.io.Serializable
Direct Known Subclasses:
Circle

public class Line
extends Geometry

Line subclasses geometry and defines a collection of lines. For every two points, a line is created. If mode is set to CONNECTED, these lines as connected as one big line. If it is set to LOOP, it is also rendered connected but the last point is connected to the first point.

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

Nested Class Summary
static class Line.Mode
           
 
Nested classes/interfaces inherited from class com.jme.scene.Spatial
Spatial.CullHint, Spatial.LightCombineMode, Spatial.NormalsMode, Spatial.TextureCombineMode
 
Field Summary
protected  java.nio.IntBuffer indexBuffer
           
 
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
Line()
           
Line(java.lang.String name)
          Constructs a new line with the given name.
Line(java.lang.String name, java.nio.FloatBuffer vertex, java.nio.FloatBuffer normal, java.nio.FloatBuffer color, TexCoords coords)
          Constructor instantiates a new Line object with a given set of data.
Line(java.lang.String name, Vector3f[] vertex, Vector3f[] normal, ColorRGBA[] color, Vector2f[] texture)
          Constructor instantiates a new Line object with a given set of data.
 
Method Summary
 void appendCircle(float radius, float x, float y, int segments, boolean insideOut)
          Puts a circle into vertex and normal buffer at the current buffer position.
 void draw(Renderer r)
          draw prepares the geometry for rendering to the display.
 void findCollisions(Spatial scene, CollisionResults results)
          checks this spatial against a second spatial, any collisions are stored in the results object.
 void generateIndices()
           
 java.nio.IntBuffer getIndexBuffer()
          getIndexBuffer retrieves the indices array as an IntBuffer.
 float getLineWidth()
           
 Line.Mode getMode()
           
 int getStippleFactor()
           
 short getStipplePattern()
           
 boolean hasCollision(Spatial scene, boolean checkTriangles)
          Always return false for lines.
 boolean isAntialiased()
           
 void read(JMEImporter e)
           
 void reconstruct(java.nio.FloatBuffer vertices, java.nio.FloatBuffer normals, java.nio.FloatBuffer colors, TexCoords coords)
          reconstruct reinitializes the geometry with new data.
 void setAntialiased(boolean antialiased)
          Sets whether the point should be antialiased.
 void setIndexBuffer(java.nio.IntBuffer indices)
          setIndexBuffer sets the index array for this Line.
 void setLineWidth(float lineWidth)
          Sets the width of the line when drawn.
 void setMode(Line.Mode mode)
           
 void setStippleFactor(int stippleFactor)
           
 void setStipplePattern(short stipplePattern)
          The stipple or pattern to use when drawing this line.
 void write(JMEExporter e)
           
 
Methods inherited from class com.jme.scene.Geometry
addTextureCoordinates, addTextureCoordinates, applyRenderState, 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, 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, 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, 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

indexBuffer

protected transient java.nio.IntBuffer indexBuffer
Constructor Detail

Line

public Line()

Line

public Line(java.lang.String name)
Constructs a new line with the given name. By default, the line has no information.

Parameters:
name - The name of the line.

Line

public Line(java.lang.String name,
            java.nio.FloatBuffer vertex,
            java.nio.FloatBuffer normal,
            java.nio.FloatBuffer color,
            TexCoords coords)
Constructor instantiates a new Line object with a given set of data. Any data can be null except for the vertex list. If vertices are null an exception will be thrown.

Parameters:
name - the name of the scene element. This is required for identification and comparision purposes.
vertex - the vertices that make up the lines.
normal - the normals of the lines.
color - the color of each point of the lines.
coords - the texture coordinates of the lines.

Line

public Line(java.lang.String name,
            Vector3f[] vertex,
            Vector3f[] normal,
            ColorRGBA[] color,
            Vector2f[] texture)
Constructor instantiates a new Line object with a given set of data. Any data can be null except for the vertex list. If vertices are null an exception will be thrown.

Parameters:
name - the name of the scene element. This is required for identification and comparision purposes.
vertex - the vertices that make up the lines.
normal - the normals of the lines.
color - the color of each point of the lines.
texture - the texture coordinates of the lines.
Method Detail

reconstruct

public void reconstruct(java.nio.FloatBuffer vertices,
                        java.nio.FloatBuffer normals,
                        java.nio.FloatBuffer colors,
                        TexCoords coords)
Description copied from class: Geometry
reconstruct reinitializes the geometry with new data. This will reuse the geometry object.

Overrides:
reconstruct in class Geometry
Parameters:
vertices - the new vertices to use.
normals - the new normals to use.
colors - the new colors to use.
coords - the new texture coordinates to use (position 0).

generateIndices

public void generateIndices()

getIndexBuffer

public java.nio.IntBuffer getIndexBuffer()
getIndexBuffer retrieves the indices array as an IntBuffer.

Returns:
the indices array as an IntBuffer.

setIndexBuffer

public void setIndexBuffer(java.nio.IntBuffer indices)
setIndexBuffer sets the index array for this Line.

Parameters:
indices - the index array as an IntBuffer.

findCollisions

public void findCollisions(Spatial scene,
                           CollisionResults results)
Description copied from class: Spatial
checks this spatial against a second spatial, any collisions are stored in the results object.

Specified by:
findCollisions in class Spatial
Parameters:
scene - the scene to test against.
results - the results of the collisions.

hasCollision

public boolean hasCollision(Spatial scene,
                            boolean checkTriangles)
Always return false for lines.

Specified by:
hasCollision in class Spatial
Parameters:
scene - the scene to test against.
checkTriangles - check for collisions on triangle accuracy level
Returns:
always false for lines

appendCircle

public void appendCircle(float radius,
                         float x,
                         float y,
                         int segments,
                         boolean insideOut)
Puts a circle into vertex and normal buffer at the current buffer position. The buffers are enlarged and copied if they are too small.

Parameters:
radius - radius of the circle
x - x coordinate of circle center
y - y coordinate of circle center
segments - number of line segments the circle is built from
insideOut - false for normal winding (ccw), true for clockwise winding

isAntialiased

public boolean isAntialiased()
Returns:
true if points are to be drawn antialiased

setAntialiased

public void setAntialiased(boolean antialiased)
Sets whether the point should be antialiased. May decrease performance. If you want to enabled antialiasing, you should also use an alphastate with a source of SourceFunction.SourceAlpha and a destination of DB_ONE_MINUS_SRC_ALPHA or DB_ONE.

Parameters:
antialiased - true if the line should be antialiased.

getMode

public Line.Mode getMode()
Returns:
either SEGMENTS, CONNECTED or LOOP. See class description.

setMode

public void setMode(Line.Mode mode)
Parameters:
mode - either SEGMENTS, CONNECTED or LOOP. See class description.

getLineWidth

public float getLineWidth()
Returns:
the width of this line.

setLineWidth

public void setLineWidth(float lineWidth)
Sets the width of the line when drawn. Non anti-aliased line widths are rounded to the nearest whole number by opengl.

Parameters:
lineWidth - The lineWidth to set.

getStipplePattern

public short getStipplePattern()
Returns:
the set stipplePattern. 0xFFFF means no stipple.

setStipplePattern

public void setStipplePattern(short stipplePattern)
The stipple or pattern to use when drawing this line. 0xFFFF is a solid line.

Parameters:
stipplePattern - a 16bit short whose bits describe the pattern to use when drawing this line

getStippleFactor

public int getStippleFactor()
Returns:
the set stippleFactor.

setStippleFactor

public void setStippleFactor(int stippleFactor)
Parameters:
stippleFactor - magnification factor to apply to the stipple pattern.

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

draw

public void draw(Renderer r)
Description copied from class: Geometry
draw prepares the geometry for rendering to the display. The renderstate is set and the subclass is responsible for rendering the actual data.

Overrides:
draw in class Geometry
Parameters:
r - the renderer that displays to the context.
See Also:
Spatial.draw(com.jme.renderer.Renderer)