com.threerings.opengl.geometry.config
Class GeometryConfig.Stored

java.lang.Object
  extended by com.threerings.util.DeepObject
      extended by com.threerings.opengl.geometry.config.GeometryConfig
          extended by com.threerings.opengl.geometry.config.GeometryConfig.Stored
All Implemented Interfaces:
Exportable, Copyable, Cloneable
Direct Known Subclasses:
GeometryConfig.ArrayStored, GeometryConfig.IndexedStored
Enclosing class:
GeometryConfig

public abstract static class GeometryConfig.Stored
extends GeometryConfig

Superclass of configurations with stored geometry.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.opengl.geometry.config.GeometryConfig
GeometryConfig.ArrayStored, GeometryConfig.AttributeArrayConfig, GeometryConfig.IndexedStored, GeometryConfig.Mode, GeometryConfig.SkinnedIndexedStored, GeometryConfig.Stored
 
Field Summary
protected  SoftCache<PassSummary,BufferObject> _arrayBuffers
          Cached array buffers.
protected  SoftCache<IdentityKey,float[]> _floatArrays
          Cached float arrays.
protected  SoftCache<IdentityKey,int[]> _intArrays
          Cached int arrays.
protected  SoftCache<PassDescriptor,SimpleBatch.DrawCommand> _listCommands
          Cached display list commands.
 Box bounds
          The bounds of the geometry.
 ClientArrayConfig colorArray
          The color array.
 GeometryConfig.Mode mode
          The type of primitives to render.
 ClientArrayConfig normalArray
          The normal array.
 ClientArrayConfig[] texCoordArrays
          The texture coordinate arrays.
 ClientArrayConfig vertexArray
          The vertex array.
 GeometryConfig.AttributeArrayConfig[] vertexAttribArrays
          The vertex attribute arrays.
 
Fields inherited from class com.threerings.opengl.geometry.config.GeometryConfig
_generated
 
Constructor Summary
GeometryConfig.Stored()
           
GeometryConfig.Stored(Box bounds, GeometryConfig.Mode mode, GeometryConfig.AttributeArrayConfig[] vertexAttribArrays, ClientArrayConfig[] texCoordArrays, ClientArrayConfig colorArray, ClientArrayConfig normalArray, ClientArrayConfig vertexArray)
           
 
Method Summary
protected  boolean canMerge(ClientArrayConfig[] a1, ClientArrayConfig[] a2)
          Checks whether the specified arrays of arrays (either or both of which may be null) can be merged.
protected  boolean canMerge(ClientArrayConfig a1, ClientArrayConfig a2)
          Checks whether the specified arrays (either or both of which may be null) can be merged.
protected  boolean canMerge(GeometryConfig.Stored ostored)
          Checks whether, all other things being equal, this geometry can be merged with the specified other.
protected  ArrayState createArrayState(PassDescriptor pass)
          Creates an uncompiled array state for the supplied pass.
 ArrayState[] createArrayStates(GlContext ctx, PassDescriptor[] passes, boolean staticVBO, boolean staticIBO)
          Creates a set of array states for this geometry.
 ArrayState[] createArrayStates(GlContext ctx, PassDescriptor[] passes, PassSummary summary, boolean staticVBO, boolean staticIBO, BufferObject arrayBuffer, FloatBuffer floatArray)
          Creates a set of array states for this geometry.
abstract  SimpleBatch.DrawCommand createDrawCommand(boolean ibo)
          Creates the non-list draw command for this geometry.
 Geometry createGeometry(GlContext ctx, Scope scope, DeformerConfig deformer, PassDescriptor[] passes)
          Creates an instance of the geometry described by this config.
protected  SimpleBatch.DrawCommand createListCommand(GlContext ctx, PassDescriptor pass)
          Creates a display list draw command for this geometry.
protected abstract  GeometryConfig.Stored createMerged(List<TransformedGeometry> glist)
          Creates the merged geometry (without initializing the arrays, etc.)
 Geometry createStaticGeometry(GlContext ctx, Scope scope, PassDescriptor[] passes)
          Creates static geometry for the described passes.
 Matrix4f[] getBoneMatrices(Scope scope)
          Returns the matrices of the bones influencing this geometry, if any.
 Box getBounds()
          Returns the bounds of the geometry.
protected  CoordSpace[] getCoordSpaces(PassDescriptor[] passes)
          Extracts the coord spaces from the supplied passes.
protected abstract  int getCount()
          Returns the number of vertices included in the geometry.
protected  BufferObject getElementArrayBuffer(GlContext ctx)
          Retrieves a reference to the element array buffer, if one should be used.
protected abstract  int getFirst()
          Returns the index of the first vertex included in the geometry.
 float[] getFloatArray(boolean align, ClientArrayConfig... arrays)
          Returns a float array containing the interleaved contents of the specified arrays.
 int[] getIntArray(boolean align, ClientArrayConfig... arrays)
          Returns an int array containing the interleaved contents of the specified arrays.
protected  SimpleBatch.DrawCommand[] getListCommands(GlContext ctx, PassDescriptor[] passes)
          Retrieves a set of display list draw commands for this geometry.
 ClientArrayConfig getTexCoordArray(int idx)
          Returns the texture coordinate array config at the specified index.
 GeometryConfig.AttributeArrayConfig getVertexAttribArray(String name)
          Returns the vertex attribute array config with the specified name.
 int getVertexCount()
          Returns the number of vertices in the arrays.
 GeometryConfig merge(List<TransformedGeometry> glist)
          Attempts to merge several transformed geometries.
protected  FloatBuffer populateClientArrays(HashMap<String,ClientArray> vertexAttribArrays, HashIntMap<ClientArray> texCoordArrays, ClientArray colorArray, ClientArray normalArray, ClientArray vertexArray)
          Creates a new buffer and populates the specified client arrays with this geometry's array data.
 
Methods inherited from class com.threerings.opengl.geometry.config.GeometryConfig
createQuad, getQuad
 
Methods inherited from class com.threerings.util.DeepObject
clone, copy, copy, equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

bounds

public Box bounds
The bounds of the geometry.


mode

public GeometryConfig.Mode mode
The type of primitives to render.


vertexAttribArrays

public GeometryConfig.AttributeArrayConfig[] vertexAttribArrays
The vertex attribute arrays.


texCoordArrays

public ClientArrayConfig[] texCoordArrays
The texture coordinate arrays.


colorArray

public ClientArrayConfig colorArray
The color array.


normalArray

public ClientArrayConfig normalArray
The normal array.


vertexArray

public ClientArrayConfig vertexArray
The vertex array.


_arrayBuffers

protected transient SoftCache<PassSummary,BufferObject> _arrayBuffers
Cached array buffers.


_listCommands

protected transient SoftCache<PassDescriptor,SimpleBatch.DrawCommand> _listCommands
Cached display list commands.


_floatArrays

protected transient SoftCache<IdentityKey,float[]> _floatArrays
Cached float arrays.


_intArrays

protected transient SoftCache<IdentityKey,int[]> _intArrays
Cached int arrays.

Constructor Detail

GeometryConfig.Stored

public GeometryConfig.Stored(Box bounds,
                             GeometryConfig.Mode mode,
                             GeometryConfig.AttributeArrayConfig[] vertexAttribArrays,
                             ClientArrayConfig[] texCoordArrays,
                             ClientArrayConfig colorArray,
                             ClientArrayConfig normalArray,
                             ClientArrayConfig vertexArray)

GeometryConfig.Stored

public GeometryConfig.Stored()
Method Detail

getVertexCount

public int getVertexCount()
Returns the number of vertices in the arrays.


getVertexAttribArray

public GeometryConfig.AttributeArrayConfig getVertexAttribArray(String name)
Returns the vertex attribute array config with the specified name.


getTexCoordArray

public ClientArrayConfig getTexCoordArray(int idx)
Returns the texture coordinate array config at the specified index.


getFloatArray

public float[] getFloatArray(boolean align,
                             ClientArrayConfig... arrays)
Returns a float array containing the interleaved contents of the specified arrays.

Parameters:
align - if true, use power-of-two alignment.

getIntArray

public int[] getIntArray(boolean align,
                         ClientArrayConfig... arrays)
Returns an int array containing the interleaved contents of the specified arrays.

Parameters:
align - if true, use power-of-two alignment.

createStaticGeometry

public Geometry createStaticGeometry(GlContext ctx,
                                     Scope scope,
                                     PassDescriptor[] passes)
Creates static geometry for the described passes.


getBoneMatrices

public Matrix4f[] getBoneMatrices(Scope scope)
Returns the matrices of the bones influencing this geometry, if any.


createArrayStates

public ArrayState[] createArrayStates(GlContext ctx,
                                      PassDescriptor[] passes,
                                      boolean staticVBO,
                                      boolean staticIBO)
Creates a set of array states for this geometry.

Parameters:
staticVBO - if true, use a shared static buffer object for vertex data.
staticIBO - if true, use a shared static buffer object for index data.

createArrayStates

public ArrayState[] createArrayStates(GlContext ctx,
                                      PassDescriptor[] passes,
                                      PassSummary summary,
                                      boolean staticVBO,
                                      boolean staticIBO,
                                      BufferObject arrayBuffer,
                                      FloatBuffer floatArray)
Creates a set of array states for this geometry.

Parameters:
staticVBO - if true, use a shared static buffer object for vertex data.
staticIBO - if true, use a shared static buffer object for index data.
arrayBuffer - the precreated buffer object to use for the arrays, if any.
floatArray - the precreated float buffer to use for the arrays, if any.

createDrawCommand

public abstract SimpleBatch.DrawCommand createDrawCommand(boolean ibo)
Creates the non-list draw command for this geometry.

Parameters:
ibo - if true, indices will be read from a buffer object.

getBounds

public Box getBounds()
Description copied from class: GeometryConfig
Returns the bounds of the geometry.

Specified by:
getBounds in class GeometryConfig

createGeometry

public Geometry createGeometry(GlContext ctx,
                               Scope scope,
                               DeformerConfig deformer,
                               PassDescriptor[] passes)
Description copied from class: GeometryConfig
Creates an instance of the geometry described by this config.

Specified by:
createGeometry in class GeometryConfig

merge

public GeometryConfig merge(List<TransformedGeometry> glist)
Description copied from class: GeometryConfig
Attempts to merge several transformed geometries.

Overrides:
merge in class GeometryConfig
Parameters:
glist - a list of the geometry to merge. Any successfully merged elements will be removed from the list.
Returns:
the combined geometry, or null if we could not merge any.

canMerge

protected boolean canMerge(GeometryConfig.Stored ostored)
Checks whether, all other things being equal, this geometry can be merged with the specified other.


canMerge

protected boolean canMerge(ClientArrayConfig[] a1,
                           ClientArrayConfig[] a2)
Checks whether the specified arrays of arrays (either or both of which may be null) can be merged.


canMerge

protected boolean canMerge(ClientArrayConfig a1,
                           ClientArrayConfig a2)
Checks whether the specified arrays (either or both of which may be null) can be merged.


getFirst

protected abstract int getFirst()
Returns the index of the first vertex included in the geometry.


getCount

protected abstract int getCount()
Returns the number of vertices included in the geometry.


createMerged

protected abstract GeometryConfig.Stored createMerged(List<TransformedGeometry> glist)
Creates the merged geometry (without initializing the arrays, etc.)


getCoordSpaces

protected CoordSpace[] getCoordSpaces(PassDescriptor[] passes)
Extracts the coord spaces from the supplied passes.


populateClientArrays

protected FloatBuffer populateClientArrays(HashMap<String,ClientArray> vertexAttribArrays,
                                           HashIntMap<ClientArray> texCoordArrays,
                                           ClientArray colorArray,
                                           ClientArray normalArray,
                                           ClientArray vertexArray)
Creates a new buffer and populates the specified client arrays with this geometry's array data.

Returns:
a reference to the newly created and populated buffer.

getElementArrayBuffer

protected BufferObject getElementArrayBuffer(GlContext ctx)
Retrieves a reference to the element array buffer, if one should be used.


getListCommands

protected SimpleBatch.DrawCommand[] getListCommands(GlContext ctx,
                                                    PassDescriptor[] passes)
Retrieves a set of display list draw commands for this geometry.


createListCommand

protected SimpleBatch.DrawCommand createListCommand(GlContext ctx,
                                                    PassDescriptor pass)
Creates a display list draw command for this geometry.


createArrayState

protected ArrayState createArrayState(PassDescriptor pass)
Creates an uncompiled array state for the supplied pass.