Aviatrix3D
2.1.0

org.j3d.aviatrix3d
Class IndexedVertexGeometry

java.lang.Object
  extended by org.j3d.aviatrix3d.SceneGraphObject
      extended by org.j3d.aviatrix3d.NodeComponent
          extended by org.j3d.aviatrix3d.Geometry
              extended by org.j3d.aviatrix3d.VertexGeometry
                  extended by org.j3d.aviatrix3d.IndexedVertexGeometry
All Implemented Interfaces:
java.lang.Comparable, LeafPickTarget, PickableObject, PickTarget, DeletableRenderable, GeometryRenderable, Renderable
Direct Known Subclasses:
IndexedLineArray, IndexedLineStripArray, IndexedQuadArray, IndexedQuadStripArray, IndexedTriangleArray, IndexedTriangleFanArray, IndexedTriangleStripArray

public abstract class IndexedVertexGeometry
extends VertexGeometry

Base class that defines indexed geometry types.

The implementation assumes a single index is used to describe all the information needed for rendering. An index will grab the same index from vertex, normal, colour and texture arrays.

Setting geometry

Part of the optimisation we make is to only copy into the underlying structures the exact number of coordinates, normals etc that are needed. To know this number, we need to know how many coordinates exist before attempting to set anything else. When constructing, or updating, geometry, you should always make sure that you first set the vertex list, then the sizing information for the strip or fan counts, and then set normals as needed.

Internationalisation Resource Names

Version:
$Revision: 1.25 $
Author:
Justin Couch

Field Summary
protected  java.nio.IntBuffer indexBuffer
          Buffer holding the current index list
protected  int[] indices
          The indices defining the geometry types.
protected  int numIndices
          The number of valid values in the indices array
protected  int numIndicesUsed
          The number of values in the indices array that are used for a geometry
protected  java.util.HashMap<javax.media.opengl.GL,java.lang.Integer> vboElementIdMap
          Map of VBO IDs
 
Fields inherited from class org.j3d.aviatrix3d.VertexGeometry
ATTRIB_CLEAR, ATTRIB_MASK, attribIds, ATTRIBS, attributes, COLOR_3, COLOR_4, COLOR_CLEAR, COLOR_MASK, COLOR_SINGLE, COLOR2, COLOR2_CLEAR, COLOR2_MASK, color2Buffer, color2s, colorBuffer, colors, COORDINATE_2, COORDINATE_3, COORDINATE_4, COORDINATE_CLEAR, COORDINATE_MASK, coordinates, dataChanged, EDGE_CLEAR, EDGE_MASK, EDGES, FOG, FOG_CLEAR, FOG_MASK, fogBuffer, fogCoords, hasMultiTextureAPI, INTERSECT_ALL, INTERSECT_COLOR, INTERSECT_COORDS, INTERSECT_NORMAL, INTERSECT_TEXCOORDS_MULTI, INTERSECT_TEXCOORDS_SINGLE, maxTextureUnits, NORMAL_CLEAR, normalBuffer, normals, NORMALS, numCoords, numRenderedTextureSets, numRequiredCoords, numTextureArrays, numTextureSets, TEXTURE_CLEAR, TEXTURE_COORDINATE_1, TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3, TEXTURE_COORDINATE_4, TEXTURE_COORDINATE_MULTI, TEXTURE_COORDINATE_SINGLE, TEXTURE_MASK, TEXTURE_SET_AVAILABLE, TEXTURE_SET_CLEAR, textureBuffer, textures, textureSets, textureTypes, useVbo, VBO_HINT_DYNAMIC, VBO_HINT_STATIC, VBO_HINT_STREAM, vboAvailable, vboHint, vboIdMap, vboQueryComplete, vertexBuffer, vertexFormat, wkPolygon
 
Fields inherited from class org.j3d.aviatrix3d.Geometry
bounds, implicitBounds, internalUpdater, INVALID_BOUNDS, lastParentList, parentList, pickFlags, validAlpha
 
Fields inherited from class org.j3d.aviatrix3d.NodeComponent
lastParent, liveCount
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, LISTENER_SET_TIMING_ERR_PROP, updateHandler
 
Fields inherited from interface org.j3d.aviatrix3d.picking.PickableObject
COLLIDABLE_OBJECT, GENERAL_OBJECT, PROXIMITY_OBJECT, VISIBLE_OBJECT
 
Fields inherited from interface org.j3d.aviatrix3d.picking.PickTarget
CUSTOM_PICK_TYPE, GROUP_PICK_TYPE, LEAF_PICK_TYPE, SINGLE_PICK_TYPE
 
Constructor Summary
protected IndexedVertexGeometry()
          Constructs an instance.
protected IndexedVertexGeometry(boolean useVbo, int vboHint)
          Constructs an instance.
 
Method Summary
 void cleanup(javax.media.opengl.GL gl)
          Cleanup the object now for the given GL context.
protected  java.nio.IntBuffer createBuffer(int size)
          Convenience method to allocate a NIO buffer for the vertex handling that handles floats.
protected  int fillBufferData(javax.media.opengl.GL gl)
          Fill VBOs with vertex buffer data.
 void getIndices(int[] values)
          Get the sizes of the valid indexs.
 int getValidIndexCount()
          Get the number of valid indexs that are defined for this geometry.
protected  boolean isVisible()
          Check to see if this geometry is making the geometry visible or not.
protected  void recomputeBounds()
          Internal method to recalculate the implicit bounds of this Node.
 void setIndices(int[] indexList, int num)
          Set the number of valid indexs to use.
 void setVBOEnabled(boolean enabled)
          Set whether Vertex Buffer Objects are used.
protected  void setVertexStateVBO(javax.media.opengl.GL gl)
          Handles state setting when VBOs are used.
 
Methods inherited from class org.j3d.aviatrix3d.VertexGeometry
clearVertexState, computeBufferSize, getColor, getColors, getFogCoordinates, getFogCoordinates, getNormal, getNormals, getSecondaryColors, getSecondaryColors, getTextureCoordinate, getTextureCoordinates, getValidVertexCount, getVBOEnabled, getVBOHint, getVertex, getVertexType, getVertices, initPolygonDetails, is2D, isMultiTextureAllowed, numTextureUnits, ray3DQuadChecked, ray3DTriangleChecked, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setColors, setFogCoordinates, setLive, setNormals, setSecondaryColors, setSingleColor, setTextureCoordinates, setTextureCoordinates, setTextureCoordinates, setTextureSetMap, setTextureSetMap, setValidVertexCount, setVBOHint, setVertexState, setVertices, setVertices, updateBounds
 
Methods inherited from class org.j3d.aviatrix3d.Geometry
addParent, boundsChanged, checkPickMask, getBounds, getPickableBounds, getPickMask, getPickTargetType, hasTransparency, markBoundsDirty, pickBatch, pickLineRay, pickLineSegment, pickSingle, removeParent, setBounds, setPickMask
 
Methods inherited from class org.j3d.aviatrix3d.NodeComponent
addParent, getParents, numParents, removeParent
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicChild, checkForCyclicParent, dataChanged, getAppUpdateWriteTimingMessage, getBoundsWriteTimingMessage, getDataWriteTimingMessage, getUserData, isLive, setUpdateHandler, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.j3d.aviatrix3d.rendering.GeometryRenderable
hasTransparency, render
 
Methods inherited from interface org.j3d.aviatrix3d.rendering.Renderable
equals
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

indices

protected int[] indices
The indices defining the geometry types. A reference to the user-provided array. The current values are kept in the accompanying IntBuffer instance.


numIndices

protected int numIndices
The number of valid values in the indices array


numIndicesUsed

protected int numIndicesUsed
The number of values in the indices array that are used for a geometry


indexBuffer

protected java.nio.IntBuffer indexBuffer
Buffer holding the current index list


vboElementIdMap

protected java.util.HashMap<javax.media.opengl.GL,java.lang.Integer> vboElementIdMap
Map of VBO IDs

Constructor Detail

IndexedVertexGeometry

protected IndexedVertexGeometry()
Constructs an instance.


IndexedVertexGeometry

protected IndexedVertexGeometry(boolean useVbo,
                                int vboHint)
Constructs an instance.

Parameters:
useVbo - Should we use vertex buffer objects
vboHint - Hints for how to setup VBO. Valid values are VBO_HINT_*
Method Detail

isVisible

protected boolean isVisible()
Check to see if this geometry is making the geometry visible or not. Returns true if the defined number of coordinates and indices are both non-zero.

Overrides:
isVisible in class VertexGeometry
Returns:
true when the geometry is visible

recomputeBounds

protected void recomputeBounds()
Internal method to recalculate the implicit bounds of this Node. By default the bounds are a point sphere, so derived classes should override this method with something better.

Overrides:
recomputeBounds in class VertexGeometry

setVertexStateVBO

protected void setVertexStateVBO(javax.media.opengl.GL gl)
Description copied from class: VertexGeometry
Handles state setting when VBOs are used. Called from setVertexState(GL gl) only!

Overrides:
setVertexStateVBO in class VertexGeometry

fillBufferData

protected int fillBufferData(javax.media.opengl.GL gl)
Fill VBOs with vertex buffer data. The VBO must be bound and allocated with glBufferData before the method is called. This method is called by setVertexStateVBO, and should not be called other places.

Must be overridden in subclasses that has vertex data in addition to what is in VertexGeometry. See TriangleArray for examples.

Overrides:
fillBufferData in class VertexGeometry

cleanup

public void cleanup(javax.media.opengl.GL gl)
Cleanup the object now for the given GL context.

Specified by:
cleanup in interface DeletableRenderable
Overrides:
cleanup in class VertexGeometry
Parameters:
gl - The gl context to draw with

setIndices

public void setIndices(int[] indexList,
                       int num)
                throws InvalidWriteTimingException,
                       java.lang.IllegalArgumentException
Set the number of valid indexs to use. A check is performed to make sure that the number of vertices high enough to support the total of all the index counts so make sure to call setVertex() with the required array length before calling this method. Each index must be a minumum length of three.

Parameters:
indexList - The array of indices to set
num - The number of valid items to read from the array
Throws:
java.lang.IllegalArgumentException - Invalid total index count or individual index count < 3
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener bounds changed callback method

getValidIndexCount

public int getValidIndexCount()
Get the number of valid indexs that are defined for this geometry.

Returns:
a positive number

getIndices

public void getIndices(int[] values)
Get the sizes of the valid indexs. The passed array must be big enough to contain all the indexs.

Parameters:
values - An array to copy the index values into

setVBOEnabled

public void setVBOEnabled(boolean enabled)
                   throws InvalidWriteTimingException
Set whether Vertex Buffer Objects are used. This will only apply on graphics hardware that supports VBO's.

Overrides:
setVBOEnabled in class VertexGeometry
Parameters:
enabled - Should VBO's be used.
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

createBuffer

protected java.nio.IntBuffer createBuffer(int size)
Convenience method to allocate a NIO buffer for the vertex handling that handles floats.

Parameters:
size - The number of floats to have in the array

Aviatrix3D
2.1.0

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2009 j3d.org