GL Studio C++ Runtime API
GlsGeometry_Generic Class Reference

#include <gls_geometry_resource.h>

Inheritance diagram for GlsGeometry_Generic:
GlsGeometryResource

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)
 
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 * 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 int GetIndex (unsigned int bufferNum, unsigned int index)
 
void MergeIndexBuffers (unsigned int dstBufferNum, unsigned int srcBufferNum)
 
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 TypeDescType ()
 
void IncrementReference ()
 
void DecrementReference ()
 
unsigned int NumIndexBuffers () const
 
const VectorBoundingVolumeCenter () const
 
float BoundingVolumeRadius () const
 
void SetResourceId (unsigned int id)
 
unsigned int GetResourceId ()
 

Static Public Member Functions

static GlsGeometry_GenericCreateInstance (const TypeDesc &type)
 
static GlsGeometry_GenericCreateInstance (GlsResourceFileMgr::ResourceRef *resource)
 
static GlsGeometry_GenericCreateFromBinaryResource (GlsResourceFileMgr::BinaryResource *data)
 
static GlsGeometry_GenericCreateEmptyInstance ()
 
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 GlsGeometryResourceCreateInstance (const TypeDesc &type=GlsGeometryResource::TypeDesc())
 
static GlsGeometryResourceCreateInstance (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
pointThe geometry coordinate of the click, relative to the object
directionVectorThe direction of the pick vector
collisionPointSet 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
pointThe starting point of the ray.
directionThe 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
typeThe 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
rhsthe resource to copy from

◆ CopyVertexBufferOnly()

void CopyVertexBufferOnly ( GlsGeometry_Generic rhs)
protected

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

Parameters
rhsThe 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
dstGeomthe resource to copy to
dstOffsetvertex offset to start copying at
srcGeomthe resource to copy from
srcOffsetvertex offset to start copying from
vertexCountnumber 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
dataThe 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
typeThe 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
resourcepointer to a ResourceRef containing geometry data
Returns
The new geometry object.

◆ Destroy()

void Destroy ( )
protectedvirtual

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
shaderProgramMust 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
bufferNumberWhich 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
shaderPrograminterface 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
pointThe logical coordinate of the click, relative to the object
directionVectorThe direction of the pick vector
collisionPointSet 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
geomThe 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
vertIndexThe 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
minReturns the minimum x,y,z values
maxReturns 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 int GetIndex ( unsigned int  bufferNum,
unsigned int  index 
)

Gets an index from an index buffer

Parameters
bufferNumWhich index buffer to read from
indexThe 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
bufferNumWhich 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
vertIndexThe 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
vertIndexThe 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
whichTextureThe texture index to locate.

◆ GetTextureCoord()

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

Get a TextureCoord

Parameters
vertIndexThe index of the TextureCoord value to change, 0 to VertexCount() - 1
whichTextureWhich 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
vertIndexThe 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
vertIndexThe index of the vertex.
attribIndexThe 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
pickTypeThe type of picking (see PickableType_e), must be PICK_FIRST or PICK_BEST
pickLinePointA point on the pick line.
pickLineDirectionThe direction of the pick line.
collisionPointIf 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
resourceThe binary resource to initialize with.

◆ LockBuffers()

bool LockBuffers ( )

Attempt to Lock the Buffers, Non-Blocking

Returns
True if a lock is posible

◆ MergeIndexBuffers()

void MergeIndexBuffers ( unsigned int  dstBufferNum,
unsigned int  srcBufferNum 
)

Merge two index buffers by adding the indexes from the source buffer to the dest buffer, then deleting the source buffer.

Parameters
dstBufferNumWhich index buffer to add to.
srcBufferNumWhich index buffer to delete.

◆ 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
countSet 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
vertIndexThe index of the color value to change, 0 to VertexCount() - 1
redRed
greenGreen
blueBlue
alphaAlpha

◆ SetColors() [1/2]

void SetColors ( const unsigned int *  array)

Initialize Color from an array

Parameters
arrayan 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
rgbaArraypointer to the array to read from. The array must be at least (numVertices * stride) bytes.
numVerticesNumber 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
bufferNumWhich index buffer to modify
indexThe index of the Index to change, 0 to GetIndexBufferSize(bufferNum)) - 1
indexValueIndex must be less than GetIndexBufferSize(bufferNum)

◆ SetIndexBufferSize()

void SetIndexBufferSize ( unsigned int  bufferNum,
unsigned int  newSize 
)

Set the size of the specified index buffer

Parameters
bufferNumWhich index buffer to set the size of
newSizeHow 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
bufferNumWhich index buffer to modify
indexArraypointer to the array to read from. The array must be at least (numIndices * stride) bytes.
numIndicesNumber 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
vertIndexThe index of the vertex to change, 0 to VertexCount() - 1
xX Normal value to assign
yY Normal value to assign
zZ 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
floatArrayPointer to the array to read from. The array must be at least (numVertices * stride) bytes.
numVerticesNumber 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
redRed
greenGreen
blueBlue
vertIndexThe 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
rgbArraypointer to the array to read from. The array must be at least (numVertices * stride) bytes.
numVerticesNumber 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
textureCoordTextureCoord value to assign. Must point to a float array containing TextureCoordinateDepth() elements
vertIndexThe index of the TextureCoord value to change, 0 to VertexCount() - 1
whichTextureWhich 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
vertIndexThe index of the TextureCoord value to change, 0 to VertexCount() - 1.
whichTextureWhich set of texture coordinates to change, 0 to NumTextureCoordinateArrays() - 1.
textureCoordUThe new U coordinate to set.
textureCoordVThe new V coordinate to set.

◆ SetVertex() [1/3]

void SetVertex ( GLuint  vertIndex,
const float *  value 
)

Set a vertex

Parameters
vertIndexThe index of the vertex to change, 0 to VertexCount() - 1
*valueVertex 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
vertIndexThe index of the vertex to change, 0 to VertexCount() - 1.
valueThe 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
vertIndexThe index of the vertex to change, 0 to VertexCount() - 1
xThe x-coord
yThe y-coord
zThe 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
vertIndexThe index of the vertex.
attribIndexThe index of the generic vertex attribute to be modified.
vA pointer to an array of floats.

◆ SetVertexAttrib2fv()

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

Two float version of StoreVertexAttrib().

Parameters
vertIndexThe index of the vertex.
attribIndexThe index of the generic vertex attribute to be modified.
vA pointer to an array of floats.

◆ SetVertexAttrib3fv()

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

Three float version of StoreVertexAttrib().

Parameters
vertIndexThe index of the vertex.
attribIndexThe index of the generic vertex attribute to be modified.
vA pointer to an array of floats.

◆ SetVertexAttrib4fv()

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

Four float version of StoreVertexAttrib().

Parameters
vertIndexThe index of the vertex.
attribIndexThe index of the generic vertex attribute to be modified.
vA pointer to an array of floats.

◆ SetVertexStructureFromTypeDesc()

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

Return the appropriate VertexStructureDefinition type derived from the incoming TypeDesc.

Parameters
vertStructThe returned vertex structure.
typeThe 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
floatArrayPointer to the array to read from. The array must be at least (numVertices * stride) bytes.
numVerticesNumber 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)
inlinevirtual
Returns
The polygon count for use in editor statistics.
Parameters
bufferNumberThe index of the buffer to count up.

Implements GlsGeometryResource.

◆ StatsIndexBufferVertexCount()

virtual unsigned int StatsIndexBufferVertexCount ( unsigned int  bufferNumber)
inlinevirtual
Returns
The vertex count for use in editor statistics.
Parameters
bufferNumberThe 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
vertIndexThe index of the vertex
attribIndexThe index of the generic vertex attribute to be modified
valuevoid pointer to the value
sizeBytessize 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
dstGeomThe resource to modify.
transformThe matrix used to convert vertex attributes.
vertexOffsetStart of the range of verts to transform.
vertexCountNumber 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
countHow 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
*sortDataAn 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: