| GL Studio C++ Runtime API

Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GlsGeometry_Generic Class Reference

`#include <gls_geometry_resource.h>`

Inheritance diagram for GlsGeometry_Generic:

## Classes
struct | VertexSortData
struct | VertexStructureDefinition

## Public Member Functions
virtual unsigned int | StatsIndexBufferVertexCount (unsigned int bufferNumber) DISTI_METHOD_OVERRIDE
virtual unsigned int | StatsIndexBufferPolygonCount (unsigned int bufferNumber) DISTI_METHOD_OVERRIDE
virtual unsigned int | GetDataChangedCounter () const DISTI_METHOD_OVERRIDE
virtual void | GetExtents (Vector &min, Vector &max, const GlsMatrixType *matrix=NULL) DISTI_METHOD_OVERRIDE
virtual void | UpdateBoundingVolume () DISTI_METHOD_OVERRIDE
virtual bool | BoundingVolumeHit (const Vector &point, const Vector &direction) DISTI_METHOD_OVERRIDE
virtual bool | HitTest (unsigned char pickType, const Vector &pickLinePoint, const Vector &pickLineDirection, Vector &collisionPoint) DISTI_METHOD_OVERRIDE
virtual void | DrawSetup (VertexAttribIndexLookup *shaderProgram) DISTI_METHOD_OVERRIDE
virtual void | DrawIndexBuffer (unsigned int bufferNumber) DISTI_METHOD_OVERRIDE
virtual void | DrawCleanup (VertexAttribIndexLookup *shaderProgram) DISTI_METHOD_OVERRIDE
virtual void | FreeOpenGLBuffers () DISTI_METHOD_OVERRIDE
void | CopyVertexAndIndexBuffers (GlsGeometry_Generic *rhs)
void | ChangeType (const TypeDesc &type)
bool | LockBuffers ()
void | UnlockBuffers ()
unsigned int | VertexCount () const
void | VertexCount (unsigned int count)
void | SetVertex (GLuint vertIndex, const float *value)
void | SetVertex (GLuint vertIndex, const Vector *value)
void | SetVertices (const float *floatArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=VERTEX_ATTRIBUTE_SIZE)
void | SetVertex (GLuint vertIndex, float x, float y, float z)
const float * | GetVertex (GLuint vertIndex)
void | SetNormal (GLuint vertIndex, float x, float y, float z)
void | SetNormals (const float *floatArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=NORMAL_ATTRIBUTE_SIZE)
const float * | GetNormal (GLuint vertIndex)
void | SetColor (GLuint vertIndex, unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
void | SetColors (const unsigned int *rgbaArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=COLOR_ATTRIBUTE_SIZE)
void | SetColors (const unsigned int *array)
unsigned char * | GetColor (GLuint vertIndex)
void | SetSecondaryColor (GLuint vertIndex, unsigned char red, unsigned char green, unsigned char blue)
void | SetSecondaryColors (const unsigned int *rgbArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=SECONDARY_COLOR_ATTRIBUTE_SIZE)
unsigned char * | GetSecondaryColor (GLuint vertIndex)
void | SetTextureCoord (GLuint vertIndex, unsigned int whichTexture, const float *textureCoord)
void | SetTextureCoord (GLuint vertIndex, unsigned int whichTexture, float textureCoordU, float textureCoordV)
void | SetTextureCoords (unsigned int whichTexture, const float *textureCoordArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=TEXTURE_COORDINATE_ATTRIBUTE_SIZE)
const float * | GetTextureCoord (GLuint vertIndex, unsigned int whichTexture)
void | StoreVertexAttrib (GLuint vertIndex, GLuint attribIndex, void *value, GLuint sizeBytes)
void | SetVertexAttrib1fv (GLuint vertIndex, GLuint attribIndex, const GLfloat *v)
void | SetVertexAttrib2fv (GLuint vertIndex, GLuint attribIndex, const GLfloat *v)
void | SetVertexAttrib3fv (GLuint vertIndex, GLuint attribIndex, const GLfloat *v)
void | SetVertexAttrib4fv (GLuint vertIndex, GLuint attribIndex, const GLfloat *v)
void | SetVertexAttribs (const float *attribArray, GLuint attribIndex, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=TANGENT_ATTRIBUTE_SIZE)
void * | GetVertexAttrib (GLuint vertIndex, GLuint attribIndex)
void | NumIndexBuffers (unsigned int count)
unsigned int | GetIndexBufferSize (unsigned int bufferNum) const
void | SetIndexBufferSize (unsigned int bufferNum, unsigned int newSize)
void | SetIndex (unsigned int bufferNum, unsigned int index, unsigned int indexValue)
void | SetIndices (unsigned int bufferNum, const unsigned int *indexArray, unsigned int numIndices, unsigned int startIndex=0, unsigned int stride=sizeof(unsigned int))
unsigned short | GetIndex (unsigned int bufferNum, unsigned short index)
void | VertexSort (VertexSortData *sortData)
void | DumpVertices ()
void | DumpNormals ()
void | DumpIndices ()
unsigned int | NumIndexBuffers () const
Public Member Functions inherited from GlsGeometryResource
void | AddObserver (Observer *observer)
void | RemoveObserver (Observer *observer)
virtual void | DrawSetup (VertexAttribIndexLookup *shaderProgram)=0
virtual void | DrawIndexBuffer (unsigned int bufferNumber)=0
virtual void | DrawCleanup (VertexAttribIndexLookup *shaderProgram)=0
virtual void | FreeOpenGLBuffers ()=0
virtual unsigned int | GetDataChangedCounter () const =0
virtual void | GetExtents (Vector &min, Vector &max, const GlsMatrixType *matrix=NULL)=0
virtual void | UpdateBoundingVolume ()=0
virtual bool | BoundingVolumeHit (const Vector &point, const Vector &direction)=0
virtual bool | HitTest (unsigned char pickType, const Vector &pickLinePoint, const Vector &pickLineDirection, Vector &collisionPoint)=0
virtual unsigned int | StatsIndexBufferVertexCount (unsigned int bufferNumber)=0
virtual unsigned int | StatsIndexBufferPolygonCount (unsigned int bufferNumber)=0
const TypeDesc & | Type ()
void | IncrementReference ()
void | DecrementReference ()
unsigned int | NumIndexBuffers () const
const Vector & | BoundingVolumeCenter () const
float | BoundingVolumeRadius () const
void | SetResourceId (unsigned int id)
unsigned int | GetResourceId ()

## Static Public Member Functions
static GlsGeometry_Generic * | CreateInstance (const TypeDesc &type)
static GlsGeometry_Generic * | CreateInstance (GlsResourceFileMgr::ResourceRef *resource)
static GlsGeometry_Generic * | CreateFromBinaryResource (GlsResourceFileMgr::BinaryResource *data)
static GlsGeometry_Generic * | CreateEmptyInstance ()
static unsigned int | CopyVertexData (GlsGeometry_Generic *dstGeom, unsigned int dstOffset, GlsGeometry_Generic *srcGeom, unsigned int srcOffset, unsigned int vertexCount)
static unsigned int | TransformVertexData (GlsGeometry_Generic *dstGeom, GlsMatrixType *transform, unsigned int vertexOffset=0, unsigned int vertexCount=UINT_MAX)
static bool | GenerateTangentsAndBinormals (GlsGeometry_Generic *geom)
static void | SetVertexStructureFromTypeDesc (VertexStructureDefinition &vertStruct, const TypeDesc &type)
Static Public Member Functions inherited from GlsGeometryResource
static void | SetCreateInstanceMakesHalfFloat (bool value)
static GlsGeometryResource * | CreateInstance (const TypeDesc &type=GlsGeometryResource::TypeDesc())
static GlsGeometryResource * | CreateInstance (GlsResourceFileMgr::ResourceRef *resource)

## Protected Member Functions
void | CopyVertexBufferOnly (GlsGeometry_Generic *rhs)
bool | BestHit (const Vector &point, const Vector &directionVector, Vector &collisionPoint)
bool | FirstHit (const Vector &point, const Vector &directionVector, Vector &collisionPoint)
void | InitializeMembers ()
| Shared initialization code used by all constructors.
void | InitFromBinaryResource (GlsResourceFileMgr::BinaryResource *resource)
unsigned int | GetTexcoordByteOffset (unsigned int whichTexture)
void | Destroy () DISTI_METHOD_OVERRIDE
Protected Member Functions inherited from GlsGeometryResource
void | OnGeometryResourceChanged ()
| Called to call all observer callbacks when the attribute changes.
virtual void | Destroy ()=0

## Protected Attributes
bool | _bufferLock
| Flag indicating that the vertex buffer is being written to.
char * | _vertexBuffer
| Underlying storage for vertices.
unsigned int | _vertexBufferCount
| The number of vertices in the buffer.
GLuint | _vertexBufferID
| The OpenGL index for this vertex buffer object.
bool | _vertexBufferUpdated
| Is the video card vertex buffer up to date?
GlsGeometry_Generic_IndexBufferData * | _indexBuffers
VertexStructureDefinition | _structure
| Describes the internal storage pattern for vertices, i.e. does it have colors? textures? normals?
Protected Attributes inherited from GlsGeometryResource
DynamicArray< Observer * > | _observers
| The held list of observers w/ callbacks.
unsigned int | _resourceID
unsigned int | _referenceCount
TypeDesc | _type
unsigned int | _numIndexBuffers
Vector | _boundingVolumeCenter
| Center location of the bounding volume.
float | _boundingVolumeRadius
| Radius of the bounding volume.

## Additional Inherited Members
Public Types inherited from GlsGeometryResource
enum | BadId { BAD_ID = 0xffffffff }
Static Public Attributes inherited from GlsGeometryResource
static const unsigned int | MAX_TEXTURE_COORDS = 2
| GL_MAX_TEXTURE_COORDS. GlsGeometryResource currently only supports two sets of texture coordinates.
static const unsigned int | MAX_VERTEX_ATTRIBS = 16
| GL_MAX_VERTEX_ATTRIBS.
static const unsigned int | VERTEX_ATTRIBUTE_SIZE = 3 * sizeof( float )
| Size of vertex storage, in bytes.
static const unsigned int | NORMAL_ATTRIBUTE_SIZE = 3 * sizeof( float )
| Size of normal storage, in bytes.
static const unsigned int | COLOR_ATTRIBUTE_SIZE = 4 * sizeof( unsigned char )
| Size of color storage, in bytes.
static const unsigned int | SECONDARY_COLOR_ATTRIBUTE_SIZE = 3 * sizeof( unsigned char )
| Size of secondary color storage, in bytes.
static const unsigned int | TEXTURE_COORDINATE_ATTRIBUTE_SIZE = 2 * sizeof( float )
| Size of texture coordinate storage, in bytes.
static const unsigned int | TANGENT_ATTRIBUTE_SIZE = 3 * sizeof( float )
| Size of tangent storage, in bytes.
static const unsigned int | BINORMAL_ATTRIBUTE_SIZE = 3 * sizeof( float )
| Size of binormal storage, in bytes.
static const unsigned int | s_invalidDataChangedCounter = 0
Static Protected Attributes inherited from GlsGeometryResource
static bool | _enableVBO
| If true, OpenGL supports vertex buffer objects (1.5 or greater).

## Detailed Description

Flexible implementation of GlsGeometryResource that can store any type of geometry This resource is used in the editor and may be used at runtime if there is not a more efficient implementation for the desired TypeDesc.

## Member Function Documentation

## ◆ BestHit()

bool BestHit | ( | const Vector & | point,
|  | const Vector & | directionVector,
|  | Vector & | collisionPoint
| ) |  |
| protected

Utility routine used by Hit. Performs a "BestHit" test, which performs a hit test on the object and guarantees that the collision point returned by Hit is the closest collision point to the observer.

Parameters

  point | The geometry coordinate of the click, relative to the object
  directionVector | The direction of the pick vector
  collisionPoint | Set to the point on the object hit by directionVector

Returns
  booleanean indicating if the object was hit by the mouse

## ◆ BoundingVolumeHit()

virtual bool BoundingVolumeHit | ( | const Vector & | point,
|  | const Vector & | direction
| ) |  |
| virtual

Determines if the given ray hits the geometry bounding volume. Note: All parameters should be in this object's coordinates.

Parameters

  point | The starting point of the ray.
  direction | The direction vector of the ray.

Returns
  True if this bounding volume is hit by the ray.

Implements GlsGeometryResource.

## ◆ ChangeType()

void ChangeType | ( | const TypeDesc & | type | ) |

Changes the Type of this geometry resource. This is a slow operation; it creates new storage according to the typeDesc and copys the existing vertex data. If a vertex attribute does not map to the new type it will be lost. Any new attributes will be uninitialized. Requires that the OpenGL context is current if this GlsGeometryResource has been previously drawn.

Parameters

  type | The TypeDesc to use for the new structure

## ◆ CopyVertexAndIndexBuffers()

void CopyVertexAndIndexBuffers | ( | GlsGeometry_Generic * | rhs | ) |

Copy the geometry from another resource into this one. Does not change the Type of this resource: only vertex attributes that both resources have in common will be copied.

Parameters

  rhs | the resource to copy from

## ◆ CopyVertexBufferOnly()

void CopyVertexBufferOnly | ( | GlsGeometry_Generic * | rhs | ) |
| protected

Copies vertex data from this buffer into the incoming geometry object.

Parameters

  rhs | The object to copy vertex data into.

## ◆ CopyVertexData()

static unsigned int CopyVertexData | ( | GlsGeometry_Generic * | dstGeom,
|  | unsigned int | dstOffset,
|  | GlsGeometry_Generic * | srcGeom,
|  | unsigned int | srcOffset,
|  | unsigned int | vertexCount
| ) |  |
| static

Copy vertex attributes from srcGeom to dstGeom Does not change the Type of the resource: only vertex attributes that both resources have in common will be copied.

Parameters

  dstGeom | the resource to copy to
  dstOffset | vertex offset to start copying at
  srcGeom | the resource to copy from
  srcOffset | vertex offset to start copying from
  vertexCount | number of vertices to copy

Returns
  the number of vertices that were copied

## ◆ CreateEmptyInstance()

static GlsGeometry_Generic * CreateEmptyInstance | ( |  | ) |
| static

Create an empty GlsGeometry_Generic with default TypeDesc.

Returns
  The new geometry object.

## ◆ CreateFromBinaryResource()

static GlsGeometry_Generic * CreateFromBinaryResource | ( | GlsResourceFileMgr::BinaryResource * | data | ) |
| static

Create GlsGeometry_Generic from binary resource.

Parameters

  data | The data to create object from.

Returns
  The new geometry object.

## ◆ CreateInstance() [1/2]

static GlsGeometry_Generic * CreateInstance | ( | const TypeDesc & | type | ) |
| static

Create GlsGeometry_Generic from TypeDesc.

Parameters

  type | The storage format type to use.

Returns
  The new geometry object.

## ◆ CreateInstance() [2/2]

static GlsGeometry_Generic * CreateInstance | ( | GlsResourceFileMgr::ResourceRef * | resource | ) |
| static

Construct a GlsGeometryResource from a binary resource The initial reference count is 1. Call DecrementReference to free the GlsGeometryResource when you are done with it.

Parameters

  resource | pointer to a ResourceRef containing geometry data

Returns
  The new geometry object.

## ◆ Destroy()

void Destroy | ( |  | ) |
| protected virtual

Deletes this object from the heap that it was allocated on

Implements GlsGeometryResource.

## ◆ DrawCleanup()

virtual void DrawCleanup | ( | VertexAttribIndexLookup * | shaderProgram | ) |
| virtual

Restore the OpenGL state after rendering.

Parameters

  shaderProgram | Must be the same value that was passed to DrawSetup

Precondition
  DrawSetup was called

Postcondition
  The OpenGL state will be restored

Implements GlsGeometryResource.

## ◆ DrawIndexBuffer()

virtual void DrawIndexBuffer | ( | unsigned int | bufferNumber | ) |
| virtual

Draw the geometry specified by the given index buffer This method should only be called between calls to DrawSetup and DrawCleanup.

Precondition
  DrawSetup has been called.

Parameters

  bufferNumber | Which index buffer to draw

Implements GlsGeometryResource.

## ◆ DrawSetup()

virtual void DrawSetup | ( | VertexAttribIndexLookup * | shaderProgram | ) |
| virtual

Setup the OpenGL state for rendering this geometry. To draw, call DrawIndexBuffer for each index buffer in the resource. After drawing, call DrawCleanup to restore the OpenGL state.

Parameters

  shaderProgram | interface to the shader program, used to lookup correct VertexAttrib index values (may be NULL)

Postcondition
  The OpenGL state is configured for rendering from the index buffers.

Implements GlsGeometryResource.

## ◆ DumpIndices()

void DumpIndices | ( |  | ) |

Dump all the Indices to the terminal

## ◆ DumpNormals()

void DumpNormals | ( |  | ) |

Dump all the Normals to the terminal

## ◆ DumpVertices()

void DumpVertices | ( |  | ) |

Dump all the vertices to the terminal

## ◆ FirstHit()

bool FirstHit | ( | const Vector & | point,
|  | const Vector & | directionVector,
|  | Vector & | collisionPoint
| ) |  |
| protected

Utility routine used by Hit. Performs a "FirstHit" test, which performs a hit test on the object but does not guarantee that the collision point returned by Hit is the closest collision point to the observer

Parameters

  point | The logical coordinate of the click, relative to the object
  directionVector | The direction of the pick vector
  collisionPoint | Set to the point on the object hit by directionVector

Returns
  boolean indicating if the object was hit

## ◆ FreeOpenGLBuffers()

virtual void FreeOpenGLBuffers | ( |  | ) |
| virtual

Force the GlsGeometryResource to free any buffers it has allocated in the current OpenGL context.

Implements GlsGeometryResource.

## ◆ GenerateTangentsAndBinormals()

static bool GenerateTangentsAndBinormals | ( | GlsGeometry_Generic * | geom | ) |
| static

Generate tangents/binormals for all vertices in the given GlsGeometryResource and adds them as vertex attributes.

Parameters

  geom | The vertices to generate from.

Returns
  Whether or not the generation was successful.

## ◆ GetColor()

unsigned char * GetColor | ( | GLuint | vertIndex | ) |

Gets the color value of the given vertex index

Parameters

  vertIndex | The index of the color value to get, 0 to VertexCount() - 1

Returns
  a pointer to a color array in rgba order

Precondition
  vertIndex must be less than VertexCount(),

## ◆ GetDataChangedCounter()

virtual unsigned int GetDataChangedCounter | ( |  | ) | const
| virtual

Since calculating metrics like the extents can be an expensive operation, the user can call this function to see if the geometry resource has changed. Caching the expensive-to-calculate values is the responsibility of the caller.

Returns
  The current extents ID. Never equal to s_invalidDataChangedCounter.

See also
  s_invalidDataChangedCounter

Implements GlsGeometryResource.

## ◆ GetExtents()

virtual void GetExtents | ( | Vector & | min,
|  | Vector & | max,
|  | const GlsMatrixType * | matrix = `NULL`
| ) |  |
| virtual

Calculate and return the geometry extents

Parameters

  min | Returns the minimum x,y,z values
  max | Returns the maximum x,y,z values
  matrix | (Optional) matrix to transform the vertices into the desired coordinate system

Note
  This can be an expensive operation. GetDataChangedCounter() can be used to minimize this expense.

See also
  GetDataChangedCounter()

Implements GlsGeometryResource.

## ◆ GetIndex()

unsigned short GetIndex | ( | unsigned int | bufferNum,
|  | unsigned short | index
| ) |  |

Get an index from an index buffer

Parameters

  bufferNum | Which index buffer to read from
  index | The index of the Index to get, 0 to GetIndexBufferSize(bufferNum) - 1

Returns
  an Index value

Precondition
  index must be less than GetIndexBufferSize(bufferNum)

## ◆ GetIndexBufferSize()

unsigned int GetIndexBufferSize | ( | unsigned int | bufferNum | ) | const

Gets the size of an index buffer

Parameters

  bufferNum | Which index buffer to return the size of

Returns
  The number of items that the given index buffer can hold

## ◆ GetNormal()

const float * GetNormal | ( | GLuint | vertIndex | ) |

Get a pointer to the Normal for a given Vertex index. Do not change the Normal, change it through the Set function!

Parameters

  vertIndex | The index of the Normal to get, 0 to VertexCount() - 1

Returns
  a pointer to an array of 3 floats.

Precondition
  vertIndex must be less than VertexCount() NORMAL must be part of the Type

## ◆ GetSecondaryColor()

unsigned char * GetSecondaryColor | ( | GLuint | vertIndex | ) |

Get the secondary color of the vertex at the given index.

Parameters

  vertIndex | The index of the secondary color value to get, 0 to VertexCount() - 1

Returns
  a pointer to a secondary color value in RGB order

Precondition
  vertIndex must be less than VertexCount()

## ◆ GetTexcoordByteOffset()

unsigned int GetTexcoordByteOffset | ( | unsigned int | whichTexture | ) |
| protected

Returns
  The offset in bytes for the given texture index.

Parameters

  whichTexture | The texture index to locate.

## ◆ GetTextureCoord()

const float * GetTextureCoord | ( | GLuint | vertIndex,
|  | unsigned int | whichTexture
| ) |  |

Get a TextureCoord

Parameters

  vertIndex | The index of the TextureCoord value to change, 0 to VertexCount() - 1
  whichTexture | Which set of texture coordinates to change, 0 to NumTextureCoordinateArrays() - 1.

Returns
  Return a pointer to the Texture Coordinates ask for

Precondition
  vertIndex must be less than VertexCount() TEXCOORD must be part of the Type textureCount must be 1 to 8

## ◆ GetVertex()

const float * GetVertex | ( | GLuint | vertIndex | ) |

Return a pointer to an array of 3 or 4 floats which is the vertex for the given index.

Parameters

  vertIndex | The index of the vertex to get, 0 to VertexCount() - 1

Returns
  a pointer to a 3 or 4 float vertex

Precondition
  vertIndex must be less than VertexCount()

## ◆ GetVertexAttrib()

void * GetVertexAttrib | ( | GLuint | vertIndex,
|  | GLuint | attribIndex
| ) |  |

Get pointer to the raw vertex attribute data, be careful with this!

Note
  This method may be removed in the future.

Parameters

  vertIndex | The index of the vertex.
  attribIndex | The index of the generic vertex attribute.

Returns
  A pointer to raw data.

## ◆ HitTest()

virtual bool HitTest | ( | unsigned char | pickType,
|  | const Vector & | pickLinePoint,
|  | const Vector & | pickLineDirection,
|  | Vector & | collisionPoint
| ) |  |
| virtual

Hit test the geometry against a picking line. All values are in geometry space.

Parameters

  pickType | The type of picking (see PickableType_e), must be PICK_FIRST or PICK_BEST
  pickLinePoint | A point on the pick line.
  pickLineDirection | The direction of the pick line.
  collisionPoint | If the method returns true, this contains the point that was hit.

Returns
  true if the object was hit by the pick.

Implements GlsGeometryResource.

## ◆ InitFromBinaryResource()

void InitFromBinaryResource | ( | GlsResourceFileMgr::BinaryResource * | resource | ) |
| protected

Initialize this object from the incoming binary resource.

Parameters

  resource | The binary resource to initialize with.

## ◆ LockBuffers()

bool LockBuffers | ( |  | ) |

Attempt to Lock the Buffers, Non-Blocking

Returns
  True if a lock is posible

## ◆ NumIndexBuffers() [1/2]

unsigned int NumIndexBuffers | ( |  | ) | const
| inline

Returns
  The number of index buffers in this geometry resource.

## ◆ NumIndexBuffers() [2/2]

void NumIndexBuffers | ( | unsigned int | count | ) |

Get the number of available index buffers

Parameters

  count | Set the number of index buffers in this geometry resource.

## ◆ SetColor()

void SetColor | ( | GLuint | vertIndex,
|  | unsigned char | red,
|  | unsigned char | green,
|  | unsigned char | blue,
|  | unsigned char | alpha
| ) |  |

Set a color value

Parameters

  vertIndex | The index of the color value to change, 0 to VertexCount() - 1
  red | Red
  green | Green
  blue | Blue
  alpha | Alpha

## ◆ SetColors() [1/2]

void SetColors | ( | const unsigned int * | array | ) |

Initialize Color from an array

Parameters

  array | an array of color values in RGBA order of size VertexCount()

Precondition
  The array must be of size VertexCount()

## ◆ SetColors() [2/2]

void SetColors | ( | const unsigned int * | rgbaArray,
|  | unsigned int | numVertices,
|  | unsigned int | startVertIndex = `0`,
|  | unsigned int | stride = `COLOR_ATTRIBUTE_SIZE`
| ) |  |

Initialize the vertex colors from an array of unsigned int containing rgba color data.

Steps through the array reading the color data for each vertex. The method will read 1 integer for each color.

Parameters

  rgbaArray | pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
  numVertices | Number of vertices to read from of the array
  startVertIndex | (optional) The vertex buffer index to start copying into
  stride | (optional) The distance between each color in the rgbaArray (in bytes)

## ◆ SetIndex()

void SetIndex | ( | unsigned int | bufferNum,
|  | unsigned int | index,
|  | unsigned int | indexValue
| ) |  |

Change the Vertex index

Parameters

  bufferNum | Which index buffer to modify
  index | The index of the Index to change, 0 to GetIndexBufferSize(bufferNum)) - 1
  indexValue | Index must be less than GetIndexBufferSize(bufferNum)

## ◆ SetIndexBufferSize()

void SetIndexBufferSize | ( | unsigned int | bufferNum,
|  | unsigned int | newSize
| ) |  |

Set the size of the specified index buffer

Parameters

  bufferNum | Which index buffer to set the size of
  newSize | How many items the Index Buffer can hold.

Precondition
  newSize must be greater than zero

## ◆ SetIndices()

void SetIndices | ( | unsigned int | bufferNum,
|  | const unsigned int * | indexArray,
|  | unsigned int | numIndices,
|  | unsigned int | startIndex = `0`,
|  | unsigned int | stride = `sizeof(unsigned int)`
| ) |  |

Initialize the Index buffer from an array of index values

Steps through the array reading the color data for each vertex. The method will read 3 bytes for each color.

Parameters

  bufferNum | Which index buffer to modify
  indexArray | pointer to the array to read from. The array must be at least (numIndices * stride) bytes.
  numIndices | Number of indices to read from of the array
  startIndex | (optional) The index buffer element to start copying into
  stride | (optional) The distance between each index in the array (in bytes)

## ◆ SetNormal()

void SetNormal | ( | GLuint | vertIndex,
|  | float | x,
|  | float | y,
|  | float | z
| ) |  |

Set a Normal

Parameters

  vertIndex | The index of the vertex to change, 0 to VertexCount() - 1
  x | X Normal value to assign
  y | Y Normal value to assign
  z | Z Normal value to assign

Precondition
  normal must be a valid Vector, vertIndex must be less than VertexCount() NORMAL must be part of the Type

## ◆ SetNormals()

void SetNormals | ( | const float * | floatArray,
|  | unsigned int | numVertices,
|  | unsigned int | startVertIndex = `0`,
|  | unsigned int | stride = `NORMAL_ATTRIBUTE_SIZE`
| ) |  |

Initialize the vertex normals from an array of floats.

Steps through the array reading the normal data for each vertex. The method will read 3 floats for each normal.

Parameters

  floatArray | Pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
  numVertices | Number of vertices to read from of the array
  startVertIndex | (optional) The vertex buffer index to start copying into
  stride | (optional) The distance between each normal in the floatArray (in bytes)

## ◆ SetSecondaryColor()

void SetSecondaryColor | ( | GLuint | vertIndex,
|  | unsigned char | red,
|  | unsigned char | green,
|  | unsigned char | blue
| ) |  |

Set a secondary color value (specular)

Parameters

  red | Red
  green | Green
  blue | Blue
  vertIndex | The index of the secondary color value to change, 0 to VertexCount() - 1

Precondition
  vertIndex must be less than VertexCount()

## ◆ SetSecondaryColors()

void SetSecondaryColors | ( | const unsigned int * | rgbArray,
|  | unsigned int | numVertices,
|  | unsigned int | startVertIndex = `0`,
|  | unsigned int | stride = `SECONDARY_COLOR_ATTRIBUTE_SIZE`
| ) |  |

Initialize the vertex secondary colors from an array of unsigned int containing rgb color data. (Secondary colors do not include alpha)

Steps through the array reading the color data for each vertex. The method will read 3 bytes for each color.

Parameters

  rgbArray | pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
  numVertices | Number of vertices to read from of the array
  startVertIndex | (optional) The vertex buffer index to start copying into
  stride | (optional) The distance between each color in the array (in bytes)

## ◆ SetTextureCoord() [1/2]

void SetTextureCoord | ( | GLuint | vertIndex,
|  | unsigned int | whichTexture,
|  | const float * | textureCoord
| ) |  |

Set a TextureCoord

Parameters

  textureCoord | TextureCoord value to assign. Must point to a float array containing TextureCoordinateDepth() elements
  vertIndex | The index of the TextureCoord value to change, 0 to VertexCount() - 1
  whichTexture | Which set of texture coordinates to change, 0 to NumTextureCoordinateArrays() - 1.

Precondition
  vertIndex must be less than VertexCount() TEXCOORD must be part of the Type whichTexture must be 0 to 7

## ◆ SetTextureCoord() [2/2]

void SetTextureCoord | ( | GLuint | vertIndex,
|  | unsigned int | whichTexture,
|  | float | textureCoordU,
|  | float | textureCoordV
| ) |  |

Two float version of SetTextureCoord().

Parameters

  vertIndex | The index of the TextureCoord value to change, 0 to VertexCount() - 1.
  whichTexture | Which set of texture coordinates to change, 0 to NumTextureCoordinateArrays() - 1.
  textureCoordU | The new U coordinate to set.
  textureCoordV | The new V coordinate to set.

## ◆ SetTextureCoords()

void SetTextureCoords | ( | unsigned int | whichTexture,
|  | const float * | textureCoordArray,
|  | unsigned int | numVertices,
|  | unsigned int | startVertIndex = `0`,
|  | unsigned int | stride = `TEXTURE_COORDINATE_ATTRIBUTE_SIZE`
| ) |  |

Sets all texture coordinates from a pointer of texture coordinate data

Parameters

  whichTexture | Which set of texture coordinates to change, 0 to NumTextureCoordinateArrays() - 1.
  textureCoordArray | Pointer to texture coordinate data to assign. Must point to a float array containing TextureCoordinateDepth() elements
  numVertices | The number of vertices worth of texture coordinate data in the array
  startVertIndex | (optional) The texture coord vertex element to start copying into
  stride | (optional) The distance between each texture coordinate in the array (in bytes)

## ◆ SetVertex() [1/3]

void SetVertex | ( | GLuint | vertIndex,
|  | const float * | value
| ) |  |

Set a vertex

Parameters

  vertIndex | The index of the vertex to change, 0 to VertexCount() - 1
  *value | Vertex can either be 3 or 4 floats depending on the type

Precondition
  vertex must be a pointer to 3 or 4 floats, vertIndex must be less than VertexCount()

## ◆ SetVertex() [2/3]

void SetVertex | ( | GLuint | vertIndex,
|  | const Vector * | value
| ) |  |
| inline

Vector version of SetVertex().

Parameters

  vertIndex | The index of the vertex to change, 0 to VertexCount() - 1.
  value | The Vector to set, uses its internal float array.

## ◆ SetVertex() [3/3]

void SetVertex | ( | GLuint | vertIndex,
|  | float | x,
|  | float | y,
|  | float | z
| ) |  |

Set the vertex at a given index to a coordinate

Parameters

  vertIndex | The index of the vertex to change, 0 to VertexCount() - 1
  x | The x-coord
  y | The y-coord
  z | The z-coord

Precondition
  vertex must be a pointer to 3 or 4 floats, vertIndex must be less than VertexCount()

## ◆ SetVertexAttrib1fv()

void SetVertexAttrib1fv | ( | GLuint | vertIndex,
|  | GLuint | attribIndex,
|  | const GLfloat * | v
| ) |  |
| inline

One float version of StoreVertexAttrib().

Parameters

  vertIndex | The index of the vertex.
  attribIndex | The index of the generic vertex attribute to be modified.
  v | A pointer to an array of floats.

## ◆ SetVertexAttrib2fv()

void SetVertexAttrib2fv | ( | GLuint | vertIndex,
|  | GLuint | attribIndex,
|  | const GLfloat * | v
| ) |  |
| inline

Two float version of StoreVertexAttrib().

Parameters

  vertIndex | The index of the vertex.
  attribIndex | The index of the generic vertex attribute to be modified.
  v | A pointer to an array of floats.

## ◆ SetVertexAttrib3fv()

void SetVertexAttrib3fv | ( | GLuint | vertIndex,
|  | GLuint | attribIndex,
|  | const GLfloat * | v
| ) |  |
| inline

Three float version of StoreVertexAttrib().

Parameters

  vertIndex | The index of the vertex.
  attribIndex | The index of the generic vertex attribute to be modified.
  v | A pointer to an array of floats.

## ◆ SetVertexAttrib4fv()

void SetVertexAttrib4fv | ( | GLuint | vertIndex,
|  | GLuint | attribIndex,
|  | const GLfloat * | v
| ) |  |
| inline

Four float version of StoreVertexAttrib().

Parameters

  vertIndex | The index of the vertex.
  attribIndex | The index of the generic vertex attribute to be modified.
  v | A pointer to an array of floats.

## ◆ SetVertexAttribs()

void SetVertexAttribs | ( | const float * | attribArray,
|  | GLuint | attribIndex,
|  | unsigned int | numVertices,
|  | unsigned int | startVertIndex = `0`,
|  | unsigned int | stride = `TANGENT_ATTRIBUTE_SIZE`
| ) |  |

Updates the VertexStructureDefinition to contain new vertex data.

Parameters

  attribArray | An array of floats that contains the raw vertex data.
  attribIndex | Index of the vertex attribute. This determines which attribute to access in each vertex.
  numVertices | Determines the number of vertices to access starting from startVertIndex.
  startVertIndex | Index to the first vertex to access.
  stride | Determines the amount to 'jump' for each vertex.

## ◆ SetVertexStructureFromTypeDesc()

static void SetVertexStructureFromTypeDesc | ( | VertexStructureDefinition & | vertStruct,
|  | const TypeDesc & | type
| ) |  |
| static

Return the appropriate VertexStructureDefinition type derived from the incoming TypeDesc.

Parameters

  vertStruct | The returned vertex structure.
  type | The type to generate a vertex structure definiton for.

## ◆ SetVertices()

void SetVertices | ( | const float * | floatArray,
|  | unsigned int | numVertices,
|  | unsigned int | startVertIndex = `0`,
|  | unsigned int | stride = `VERTEX_ATTRIBUTE_SIZE`
| ) |  |

Initialize the vertex data from an array of floats.

Steps through the array reading the data for each vertex. If Type() is POSITION_XYZ, the method will read 3 floats per vertex. If Type() is POSITION_XYZW, the method will read 4 floats per vertex.

Parameters

  floatArray | Pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
  numVertices | Number of vertices to read from of the array
  startVertIndex | (optional) The vertex buffer index to start copying into
  stride | (optional) The distance between each vertex in the floatArray (in bytes)

## ◆ StatsIndexBufferPolygonCount()

virtual unsigned int StatsIndexBufferPolygonCount | ( | unsigned int | bufferNumber | ) |
| inline virtual

Returns
  The polygon count for use in editor statistics.

Parameters

  bufferNumber | The index of the buffer to count up.

Implements GlsGeometryResource.

## ◆ StatsIndexBufferVertexCount()

virtual unsigned int StatsIndexBufferVertexCount | ( | unsigned int | bufferNumber | ) |
| inline virtual

Returns
  The vertex count for use in editor statistics.

Parameters

  bufferNumber | The index of the buffer to count up.

Implements GlsGeometryResource.

## ◆ StoreVertexAttrib()

void StoreVertexAttrib | ( | GLuint | vertIndex,
|  | GLuint | attribIndex,
|  | void * | value,
|  | GLuint | sizeBytes
| ) |  |

Store a generic vertex attribute value

Parameters

  vertIndex | The index of the vertex
  attribIndex | The index of the generic vertex attribute to be modified
  value | void pointer to the value
  sizeBytes | size of the value in bytes

## ◆ TransformVertexData()

static unsigned int TransformVertexData | ( | GlsGeometry_Generic * | dstGeom,
|  | GlsMatrixType * | transform,
|  | unsigned int | vertexOffset = `0`,
|  | unsigned int | vertexCount = `UINT_MAX`
| ) |  |
| static

Apply a transform to the vertex attributes of the given mesh The transform affects vertex position, normals, ATTRIB_TANGENT, and ATTRIB_BINORMAL

Parameters

  dstGeom | The resource to modify.
  transform | The matrix used to convert vertex attributes.
  vertexOffset | Start of the range of verts to transform.
  vertexCount | Number of verts to transform.

Returns
  The number of verts that were transformed.

## ◆ UnlockBuffers()

void UnlockBuffers | ( |  | ) |

Release the lock on the buffers. Note: If the Vertex data was changed, you should typically call UpdateBoundingVolume() before unlocking.

See also
  UpdateBoundingVolume

Postcondition
  If the buffer is not locked a debug message is sent to the terminal

## ◆ UpdateBoundingVolume()

virtual void UpdateBoundingVolume | ( |  | ) |
| virtual

Updates the bounding volume of this object This method should be called if the vertices change for picking and culling to work correctly.

Note
  This can be an expensive operation. GetDataChangedCounter() can be used to minimize this expense.

See also
  GetDataChangedCounter()

Implements GlsGeometryResource.

## ◆ VertexCount() [1/2]

unsigned int VertexCount | ( |  | ) | const

Get the size of the vertex buffer

Returns
  The number of items in the vertex buffer

## ◆ VertexCount() [2/2]

void VertexCount | ( | unsigned int | count | ) |

Set the size of the vertex buffer

Parameters

  count | How many items the Vertex Buffer contains.

Precondition
  size must be greater than zero

## ◆ VertexSort()

void VertexSort | ( | VertexSortData * | sortData | ) |

Sort the vertices, based on the input data

Parameters

  *sortData | An array of VertexSortData structures, one for each primitive (set of three vertices). The data in this is array is used to reorder the primitives. e.g.: Input: order 0,1,0,5,2 index 0,1,2,3,4 Sorted: order 0,0,1,2,5 index 0,2,1,4,3

Precondition
  sortData must be an array of VertexSortData VertexCount()/3 in size

Postcondition
  The sortData array will be sorted based on _order. The vertex buffer will be sorted based on the new order from the sortData.

## Member Data Documentation

## ◆ _indexBuffers

GlsGeometry_Generic_IndexBufferData* _indexBuffers
| protected

Index buffers array

The documentation for this class was generated from the following file:

- gls_geometry_resource.h