40#ifndef GLS_GEOMETRY_RESOURCE_H_INCLUDED
41#define GLS_GEOMETRY_RESOURCE_H_INCLUDED
58# include <OpenGL/gl.h>
67#include "gls_resource_file_mgr.h"
71#if( defined( GLSGEN_EXPORT_GLSGEOMETRYRESOURCE ) || defined( GLSGEN_IMPORT_GLSGEOMETRYRESOURCE ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
72 && defined( _MSC_VER )
73# if defined( GLSGEN_EXPORT_GLSGEOMETRYRESOURCE ) || defined( GLS_EXPORT_GENERATED )
74# define GLSGEN_GlsGeometryResource_EXPORT __declspec( dllexport )
76# define GLSGEN_GlsGeometryResource_EXPORT __declspec( dllimport )
79# define GLSGEN_GlsGeometryResource_EXPORT
106 bool hasSecondaryColor;
108 unsigned int normalType;
109 unsigned int texCoordType;
112 unsigned char numTextureCoords;
114 unsigned char numVertexAttribs;
123 memset(
this, 0,
sizeof(
TypeDesc ) );
127 texCoordDimension[ i ] = 2;
131 vertexAttribNumComponents[ i ] = 4;
134 normalType = GL_FLOAT;
135 texCoordType = GL_FLOAT;
185 numTextureCoords = value;
197 if( which < GlsGeometryResource::MAX_TEXTURE_COORDS && value > 0 && value < 5 )
199 texCoordDimension[ which ] = value;
217 numVertexAttribs = value;
229 if( which < GlsGeometryResource::MAX_VERTEX_ATTRIBS && value > 0 && value < 5 )
230 vertexAttribNumComponents[ which ] = value;
245 vertexAttribType[ which ] = value;
261 vertexAttribNormalize[ which ] = value;
276 vertexAttribSemantic[ which ] = semanticEnum;
330 for(
unsigned int i = 0; i <
_observers.Count(); ++i )
446 virtual bool HitTest(
unsigned char pickType,
const Vector& pickLinePoint,
const Vector& pickLineDirection,
Vector& collisionPoint ) = 0;
495 assert( BAD_ID !=
id );
509class GlsGeometry_Generic_IndexBufferData;
599 GLSGEN_GlsGeometryResource_EXPORT
unsigned int VertexCount() const;
605 GLSGEN_GlsGeometryResource_EXPORT
void VertexCount(
unsigned int count );
612 GLSGEN_GlsGeometryResource_EXPORT
void SetVertex( GLuint vertIndex, const
float* value );
629 GLSGEN_GlsGeometryResource_EXPORT
void SetVertices(
const float* floatArray,
630 unsigned int numVertices,
631 unsigned int startVertIndex = 0,
641 GLSGEN_GlsGeometryResource_EXPORT
void SetVertex( GLuint vertIndex,
653 GLSGEN_GlsGeometryResource_EXPORT
const float*
GetVertex( GLuint vertIndex );
663 GLSGEN_GlsGeometryResource_EXPORT
void SetNormal( GLuint vertIndex,
float x,
float y,
float z );
674 GLSGEN_GlsGeometryResource_EXPORT
void SetNormals(
const float* floatArray,
675 unsigned int numVertices,
676 unsigned int startVertIndex = 0,
686 GLSGEN_GlsGeometryResource_EXPORT
const float*
GetNormal( GLuint vertIndex );
695 GLSGEN_GlsGeometryResource_EXPORT
void SetColor( GLuint vertIndex,
699 unsigned char alpha );
710 GLSGEN_GlsGeometryResource_EXPORT
void SetColors(
const unsigned int* rgbaArray,
711 unsigned int numVertices,
712 unsigned int startVertIndex = 0,
719 GLSGEN_GlsGeometryResource_EXPORT
void SetColors(
const unsigned int* array );
726 GLSGEN_GlsGeometryResource_EXPORT
unsigned char*
GetColor( GLuint vertIndex );
738 unsigned char blue );
750 unsigned int numVertices,
751 unsigned int startVertIndex = 0,
769 GLSGEN_GlsGeometryResource_EXPORT
void SetTextureCoord( GLuint vertIndex,
unsigned int whichTexture,
const float* textureCoord );
776 GLSGEN_GlsGeometryResource_EXPORT
void SetTextureCoord( GLuint vertIndex,
unsigned int whichTexture,
float textureCoordU,
float textureCoordV );
788 const float* textureCoordArray,
789 unsigned int numVertices,
790 unsigned int startVertIndex = 0,
802 GLSGEN_GlsGeometryResource_EXPORT
const float*
GetTextureCoord( GLuint vertIndex,
unsigned int whichTexture );
810 GLSGEN_GlsGeometryResource_EXPORT
void StoreVertexAttrib( GLuint vertIndex, GLuint attribIndex,
void* value, GLuint sizeBytes );
845 unsigned int numVertices,
846 unsigned int startVertIndex = 0,
855 GLSGEN_GlsGeometryResource_EXPORT
void*
GetVertexAttrib( GLuint vertIndex, GLuint attribIndex );
875 GLSGEN_GlsGeometryResource_EXPORT
void SetIndexBufferSize(
unsigned int bufferNum,
unsigned int newSize );
882 GLSGEN_GlsGeometryResource_EXPORT
void SetIndex(
unsigned int bufferNum,
unsigned int index,
unsigned int indexValue );
896 GLSGEN_GlsGeometryResource_EXPORT
void SetIndices(
unsigned int bufferNum,
897 const unsigned int* indexArray,
898 unsigned int numIndices,
899 unsigned int startIndex = 0,
900 unsigned int stride =
sizeof(
unsigned int ) );
908 GLSGEN_GlsGeometryResource_EXPORT
unsigned int GetIndex(
unsigned int bufferNum,
unsigned int index );
914 GLSGEN_GlsGeometryResource_EXPORT
void MergeIndexBuffers(
unsigned int dstBufferNum,
unsigned int srcBufferNum );
928 GLSGEN_GlsGeometryResource_EXPORT
void SetIndices(
unsigned int bufferNum,
929 const unsigned int* indexArray,
930 unsigned int numIndices,
931 unsigned int startIndex = 0,
932 unsigned int stride =
sizeof(
unsigned int ) );
940 GLSGEN_GlsGeometryResource_EXPORT
unsigned short GetIndex(
unsigned int bufferNum,
unsigned short index );
993 unsigned int vertexCount );
1005 unsigned int vertexOffset = 0,
1006 unsigned int vertexCount = UINT_MAX );
1085 unsigned int _dataChangedCounter;
1088 void IncDataChangedCounter()
1093 ++_dataChangedCounter;
Definition: dynamic_array.h:79
Definition: gls_geometry_resource.h:295
virtual void OnGeometryResourceChanged()=0
Callback method to be called by this observer.
Definition: gls_geometry_resource.h:103
void SetVertexAttribComponents(unsigned char which, GLint value)
Definition: gls_geometry_resource.h:227
bool HasColor() const
Definition: gls_geometry_resource.h:170
int GetVertexAttribSemantic(unsigned char which) const
Definition: gls_geometry_resource.h:281
bool HasNormal() const
Definition: gls_geometry_resource.h:144
void SetVertexAttribType(unsigned char which, GLenum value)
Definition: gls_geometry_resource.h:241
unsigned char GetTexCoordDimension(unsigned char which) const
Definition: gls_geometry_resource.h:205
void SetNumVertexAttribs(unsigned char value)
Definition: gls_geometry_resource.h:214
void HasSecondaryColor(bool value)
Definition: gls_geometry_resource.h:174
void SetVertexAttribNormalize(unsigned char which, GLboolean value)
Definition: gls_geometry_resource.h:257
unsigned int TexCoordType() const
Definition: gls_geometry_resource.h:162
GLenum GetVertexAttribType(unsigned char which) const
Definition: gls_geometry_resource.h:251
void SetVertexAttribSemantic(unsigned char which, int semanticEnum)
Definition: gls_geometry_resource.h:273
GLboolean GetVertexAttribNormalize(unsigned char which) const
Definition: gls_geometry_resource.h:267
unsigned int NormalType() const
Definition: gls_geometry_resource.h:155
void HasColor(bool value)
Definition: gls_geometry_resource.h:167
GLint GetVertexAttribComponents(unsigned char which) const
Definition: gls_geometry_resource.h:235
void NormalType(unsigned int value)
Definition: gls_geometry_resource.h:149
void HasNormal(bool value)
Definition: gls_geometry_resource.h:141
unsigned char GetNumTextureCoords() const
Definition: gls_geometry_resource.h:190
unsigned char GetNumVertexAttribs() const
Definition: gls_geometry_resource.h:221
void TexCoordType(unsigned int value)
Definition: gls_geometry_resource.h:159
void SetTexCoordDimension(unsigned char which, unsigned char value)
Definition: gls_geometry_resource.h:195
bool HasSecondaryColor() const
Definition: gls_geometry_resource.h:177
void SetNumTextureCoords(unsigned char value)
Definition: gls_geometry_resource.h:181
Definition: gls_geometry_resource.h:87
static const unsigned int VERTEX_ATTRIBUTE_SIZE
Size of vertex storage, in bytes.
Definition: gls_geometry_resource.h:92
void OnGeometryResourceChanged()
Called to call all observer callbacks when the attribute changes.
Definition: gls_geometry_resource.h:328
DynamicArray< Observer * > _observers
The held list of observers w/ callbacks.
Definition: gls_geometry_resource.h:325
unsigned int GetResourceId()
Definition: gls_geometry_resource.h:501
virtual void GetExtents(Vector &min, Vector &max, const GlsMatrixType *matrix=NULL)=0
unsigned int _numIndexBuffers
Definition: gls_geometry_resource.h:346
virtual unsigned int StatsIndexBufferPolygonCount(unsigned int bufferNumber)=0
static const unsigned int TANGENT_ATTRIBUTE_SIZE
Size of tangent storage, in bytes.
Definition: gls_geometry_resource.h:98
const TypeDesc & Type()
Definition: gls_geometry_resource.h:457
static const unsigned int NORMAL_ATTRIBUTE_SIZE
Size of normal storage, in bytes.
Definition: gls_geometry_resource.h:93
float _boundingVolumeRadius
Radius of the bounding volume.
Definition: gls_geometry_resource.h:349
void DecrementReference()
Definition: gls_geometry_resource.h:465
virtual unsigned int StatsIndexBufferVertexCount(unsigned int bufferNumber)=0
virtual unsigned int GetDataChangedCounter() const =0
void RemoveObserver(Observer *observer)
Definition: gls_geometry_resource.h:319
static const unsigned int TEXTURE_COORDINATE_ATTRIBUTE_SIZE
Size of texture coordinate storage, in bytes.
Definition: gls_geometry_resource.h:97
void SetResourceId(unsigned int id)
Definition: gls_geometry_resource.h:493
virtual bool BoundingVolumeHit(const Vector &point, const Vector &direction)=0
void AddObserver(Observer *observer)
Definition: gls_geometry_resource.h:312
virtual bool HitTest(unsigned char pickType, const Vector &pickLinePoint, const Vector &pickLineDirection, Vector &collisionPoint)=0
void IncrementReference()
Definition: gls_geometry_resource.h:460
Vector _boundingVolumeCenter
Center location of the bounding volume.
Definition: gls_geometry_resource.h:348
static const unsigned int s_invalidDataChangedCounter
Definition: gls_geometry_resource.h:412
static const unsigned int MAX_TEXTURE_COORDS
GL_MAX_TEXTURE_COORDS. GlsGeometryResource currently only supports two sets of texture coordinates.
Definition: gls_geometry_resource.h:89
static GlsGeometryResource * CreateInstance(const TypeDesc &type=GlsGeometryResource::TypeDesc())
virtual void DrawSetup(VertexAttribIndexLookup *shaderProgram)=0
unsigned int NumIndexBuffers() const
Definition: gls_geometry_resource.h:478
virtual void DrawCleanup(VertexAttribIndexLookup *shaderProgram)=0
virtual void FreeOpenGLBuffers()=0
static bool _enableVBO
If true, OpenGL supports vertex buffer objects (1.5 or greater).
Definition: gls_geometry_resource.h:352
virtual void UpdateBoundingVolume()=0
TypeDesc _type
Definition: gls_geometry_resource.h:343
BadId
Definition: gls_geometry_resource.h:287
virtual void DrawIndexBuffer(unsigned int bufferNumber)=0
unsigned int _resourceID
Definition: gls_geometry_resource.h:337
static const unsigned int MAX_VERTEX_ATTRIBS
GL_MAX_VERTEX_ATTRIBS.
Definition: gls_geometry_resource.h:90
static const unsigned int SECONDARY_COLOR_ATTRIBUTE_SIZE
Size of secondary color storage, in bytes.
Definition: gls_geometry_resource.h:96
static const unsigned int COLOR_ATTRIBUTE_SIZE
Size of color storage, in bytes.
Definition: gls_geometry_resource.h:94
const Vector & BoundingVolumeCenter() const
Definition: gls_geometry_resource.h:484
unsigned int _referenceCount
Definition: gls_geometry_resource.h:340
static void SetCreateInstanceMakesHalfFloat(bool value)
static const unsigned int BINORMAL_ATTRIBUTE_SIZE
Size of binormal storage, in bytes.
Definition: gls_geometry_resource.h:99
float BoundingVolumeRadius() const
Definition: gls_geometry_resource.h:487
Definition: gls_geometry_resource.h:514
void SetColor(GLuint vertIndex, unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
unsigned int GetIndexBufferSize(unsigned int bufferNum) const
void InitializeMembers()
Shared initialization code used by all constructors.
virtual unsigned int StatsIndexBufferPolygonCount(unsigned int bufferNumber) DISTI_METHOD_OVERRIDE
Definition: gls_geometry_resource.h:527
virtual void DrawCleanup(VertexAttribIndexLookup *shaderProgram) DISTI_METHOD_OVERRIDE
void SetIndices(unsigned int bufferNum, const unsigned int *indexArray, unsigned int numIndices, unsigned int startIndex=0, unsigned int stride=sizeof(unsigned int))
void SetIndex(unsigned int bufferNum, unsigned int index, unsigned int indexValue)
GLuint _vertexBufferID
The OpenGL index for this vertex buffer object.
Definition: gls_geometry_resource.h:1039
VertexStructureDefinition _structure
Describes the internal storage pattern for vertices, i.e. does it have colors? textures?...
Definition: gls_geometry_resource.h:1045
void SetVertexAttrib4fv(GLuint vertIndex, GLuint attribIndex, const GLfloat *v)
Definition: gls_geometry_resource.h:834
static unsigned int TransformVertexData(GlsGeometry_Generic *dstGeom, GlsMatrixType *transform, unsigned int vertexOffset=0, unsigned int vertexCount=UINT_MAX)
bool BestHit(const Vector &point, const Vector &directionVector, Vector &collisionPoint)
virtual void DrawIndexBuffer(unsigned int bufferNumber) DISTI_METHOD_OVERRIDE
static bool GenerateTangentsAndBinormals(GlsGeometry_Generic *geom)
void SetNormal(GLuint vertIndex, float x, float y, float z)
unsigned char * GetColor(GLuint vertIndex)
void ChangeType(const TypeDesc &type)
unsigned char * GetSecondaryColor(GLuint vertIndex)
virtual bool HitTest(unsigned char pickType, const Vector &pickLinePoint, const Vector &pickLineDirection, Vector &collisionPoint) DISTI_METHOD_OVERRIDE
void SetVertexAttrib1fv(GLuint vertIndex, GLuint attribIndex, const GLfloat *v)
Definition: gls_geometry_resource.h:816
void CopyVertexBufferOnly(GlsGeometry_Generic *rhs)
unsigned short GetIndex(unsigned int bufferNum, unsigned short index)
void SetVertexAttribs(const float *attribArray, GLuint attribIndex, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=TANGENT_ATTRIBUTE_SIZE)
virtual unsigned int GetDataChangedCounter() const DISTI_METHOD_OVERRIDE
const float * GetNormal(GLuint vertIndex)
const float * GetVertex(GLuint vertIndex)
void SetVertices(const float *floatArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=VERTEX_ATTRIBUTE_SIZE)
void VertexSort(VertexSortData *sortData)
void SetVertex(GLuint vertIndex, const Vector *value)
Definition: gls_geometry_resource.h:617
char * _vertexBuffer
Underlying storage for vertices.
Definition: gls_geometry_resource.h:1037
bool FirstHit(const Vector &point, const Vector &directionVector, Vector &collisionPoint)
void SetVertex(GLuint vertIndex, const float *value)
void * GetVertexAttrib(GLuint vertIndex, GLuint attribIndex)
void SetColors(const unsigned int *rgbaArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=COLOR_ATTRIBUTE_SIZE)
void SetSecondaryColors(const unsigned int *rgbArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=SECONDARY_COLOR_ATTRIBUTE_SIZE)
virtual void GetExtents(Vector &min, Vector &max, const GlsMatrixType *matrix=NULL) DISTI_METHOD_OVERRIDE
static GlsGeometry_Generic * CreateInstance(const TypeDesc &type)
static unsigned int CopyVertexData(GlsGeometry_Generic *dstGeom, unsigned int dstOffset, GlsGeometry_Generic *srcGeom, unsigned int srcOffset, unsigned int vertexCount)
unsigned int _vertexBufferCount
The number of vertices in the buffer.
Definition: gls_geometry_resource.h:1038
const float * GetTextureCoord(GLuint vertIndex, unsigned int whichTexture)
static void SetVertexStructureFromTypeDesc(VertexStructureDefinition &vertStruct, const TypeDesc &type)
unsigned int NumIndexBuffers() const
Definition: gls_geometry_resource.h:478
virtual bool BoundingVolumeHit(const Vector &point, const Vector &direction) DISTI_METHOD_OVERRIDE
void SetTextureCoord(GLuint vertIndex, unsigned int whichTexture, const float *textureCoord)
void InitFromBinaryResource(GlsResourceFileMgr::BinaryResource *resource)
void SetVertexAttrib3fv(GLuint vertIndex, GLuint attribIndex, const GLfloat *v)
Definition: gls_geometry_resource.h:828
virtual unsigned int StatsIndexBufferVertexCount(unsigned int bufferNumber) DISTI_METHOD_OVERRIDE
Definition: gls_geometry_resource.h:522
static GlsGeometry_Generic * CreateEmptyInstance()
void SetIndexBufferSize(unsigned int bufferNum, unsigned int newSize)
bool _vertexBufferUpdated
Is the video card vertex buffer up to date?
Definition: gls_geometry_resource.h:1040
void SetVertexAttrib2fv(GLuint vertIndex, GLuint attribIndex, const GLfloat *v)
Definition: gls_geometry_resource.h:822
void SetSecondaryColor(GLuint vertIndex, unsigned char red, unsigned char green, unsigned char blue)
GlsGeometry_Generic_IndexBufferData * _indexBuffers
Definition: gls_geometry_resource.h:1043
void SetNormals(const float *floatArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=NORMAL_ATTRIBUTE_SIZE)
virtual void FreeOpenGLBuffers() DISTI_METHOD_OVERRIDE
void Destroy() DISTI_METHOD_OVERRIDE
virtual void UpdateBoundingVolume() DISTI_METHOD_OVERRIDE
virtual void DrawSetup(VertexAttribIndexLookup *shaderProgram) DISTI_METHOD_OVERRIDE
void CopyVertexAndIndexBuffers(GlsGeometry_Generic *rhs)
bool _bufferLock
Flag indicating that the vertex buffer is being written to.
Definition: gls_geometry_resource.h:1035
void StoreVertexAttrib(GLuint vertIndex, GLuint attribIndex, void *value, GLuint sizeBytes)
unsigned int GetTexcoordByteOffset(unsigned int whichTexture)
void SetTextureCoords(unsigned int whichTexture, const float *textureCoordArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=TEXTURE_COORDINATE_ATTRIBUTE_SIZE)
static GlsGeometry_Generic * CreateFromBinaryResource(GlsResourceFileMgr::BinaryResource *data)
unsigned int VertexCount() const
Definition: gls_resource_file_mgr.h:35
Definition: gls_resource_file_mgr.h:57
Definition: gls_resource_file_mgr.h:26
Definition: gls_render_effect.h:79
Contains the DistiAssert macro.
#define GLS_ASSERT(exp)
Definition: disti_assert.h:150
#define DISTI_SPECIAL_MEM_FUN_DELETE
Macro to wrap function deletion, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:246
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:222
The GlsMatrixAffine class.
The disti::GlsRenderEffect class.
Definition: bmpimage.h:47
Definition: gls_geometry_resource.h:946
unsigned int _order
The order the vertex should be in.
Definition: gls_geometry_resource.h:947
unsigned int _vertexTupleIndex
The index of the primitive.
Definition: gls_geometry_resource.h:948
Definition: gls_geometry_resource.h:1016
unsigned int _texcoordStride
Offset between each texture coordinate in bytes.
Definition: gls_geometry_resource.h:1020
unsigned int _texcoord2Stride
Offset between each secondary texture coordinate in bytes.
Definition: gls_geometry_resource.h:1021
unsigned int _numVertexAttribs
The count of vertex attributes.
Definition: gls_geometry_resource.h:1024
unsigned int _size
Total size of each vertex in bytes (depends on which data is included).
Definition: gls_geometry_resource.h:1017
unsigned int _colorStride
Offset between each color in bytes.
Definition: gls_geometry_resource.h:1022
unsigned int _normalStride
Offset between each normal in bytes.
Definition: gls_geometry_resource.h:1019
unsigned int _secondaryColorStride
Offset between each secondary color in bytes.
Definition: gls_geometry_resource.h:1023
The disti::Vertex class. A class for manipulating 3D vertices.