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;
147 void NormalType(
unsigned int value )
152 unsigned int NormalType()
const {
return normalType; }
154 void TexCoordType(
unsigned int value ) { texCoordType = value; }
155 unsigned int TexCoordType()
const {
return texCoordType; }
178 numTextureCoords = value;
190 if( which < GlsGeometryResource::MAX_TEXTURE_COORDS && value > 0 && value < 5 )
192 texCoordDimension[ which ] = value;
210 numVertexAttribs = value;
222 if( which < GlsGeometryResource::MAX_VERTEX_ATTRIBS && value > 0 && value < 5 )
223 vertexAttribNumComponents[ which ] = value;
238 vertexAttribType[ which ] = value;
254 vertexAttribNormalize[ which ] = value;
269 vertexAttribSemantic[ which ] = semanticEnum;
323 for(
unsigned int i = 0; i <
_observers.Count(); ++i )
439 virtual bool HitTest(
unsigned char pickType,
const Vector& pickLinePoint,
const Vector& pickLineDirection,
Vector& collisionPoint ) = 0;
488 assert( BAD_ID !=
id );
502class GlsGeometry_Generic_IndexBufferData;
592 GLSGEN_GlsGeometryResource_EXPORT
unsigned int VertexCount() const;
598 GLSGEN_GlsGeometryResource_EXPORT
void VertexCount(
unsigned int count );
605 GLSGEN_GlsGeometryResource_EXPORT
void SetVertex( GLuint vertIndex, const
float* value );
622 GLSGEN_GlsGeometryResource_EXPORT
void SetVertices(
const float* floatArray,
623 unsigned int numVertices,
624 unsigned int startVertIndex = 0,
634 GLSGEN_GlsGeometryResource_EXPORT
void SetVertex( GLuint vertIndex,
646 GLSGEN_GlsGeometryResource_EXPORT
const float*
GetVertex( GLuint vertIndex );
656 GLSGEN_GlsGeometryResource_EXPORT
void SetNormal( GLuint vertIndex,
float x,
float y,
float z );
667 GLSGEN_GlsGeometryResource_EXPORT
void SetNormals(
const float* floatArray,
668 unsigned int numVertices,
669 unsigned int startVertIndex = 0,
679 GLSGEN_GlsGeometryResource_EXPORT
const float*
GetNormal( GLuint vertIndex );
688 GLSGEN_GlsGeometryResource_EXPORT
void SetColor( GLuint vertIndex,
692 unsigned char alpha );
703 GLSGEN_GlsGeometryResource_EXPORT
void SetColors(
const unsigned int* rgbaArray,
704 unsigned int numVertices,
705 unsigned int startVertIndex = 0,
712 GLSGEN_GlsGeometryResource_EXPORT
void SetColors(
const unsigned int* array );
719 GLSGEN_GlsGeometryResource_EXPORT
unsigned char*
GetColor( GLuint vertIndex );
731 unsigned char blue );
743 unsigned int numVertices,
744 unsigned int startVertIndex = 0,
762 GLSGEN_GlsGeometryResource_EXPORT
void SetTextureCoord( GLuint vertIndex,
unsigned int whichTexture,
const float* textureCoord );
769 GLSGEN_GlsGeometryResource_EXPORT
void SetTextureCoord( GLuint vertIndex,
unsigned int whichTexture,
float textureCoordU,
float textureCoordV );
780 GLSGEN_GlsGeometryResource_EXPORT
void SetTextureCoords(
unsigned int whichTexture,
781 const float* textureCoordArray,
782 unsigned int numVertices,
783 unsigned int startVertIndex = 0,
795 GLSGEN_GlsGeometryResource_EXPORT
const float*
GetTextureCoord( GLuint vertIndex,
unsigned int whichTexture );
803 GLSGEN_GlsGeometryResource_EXPORT
void StoreVertexAttrib( GLuint vertIndex, GLuint attribIndex,
void* value, GLuint sizeBytes );
830 GLSGEN_GlsGeometryResource_EXPORT
void SetVertexAttribs(
const float* attribArray,
833 unsigned int numVertices,
834 unsigned int startVertIndex = 0,
843 GLSGEN_GlsGeometryResource_EXPORT
void*
GetVertexAttrib( GLuint vertIndex, GLuint attribIndex );
863 GLSGEN_GlsGeometryResource_EXPORT
void SetIndexBufferSize(
unsigned int bufferNum,
unsigned int newSize );
870 GLSGEN_GlsGeometryResource_EXPORT
void SetIndex(
unsigned int bufferNum,
unsigned int index,
unsigned int indexValue );
884 GLSGEN_GlsGeometryResource_EXPORT
void SetIndices(
unsigned int bufferNum,
885 const unsigned int* indexArray,
886 unsigned int numIndices,
887 unsigned int startIndex = 0,
888 unsigned int stride =
sizeof(
unsigned int ) );
896 GLSGEN_GlsGeometryResource_EXPORT
unsigned int GetIndex(
unsigned int bufferNum,
unsigned int index );
902 GLSGEN_GlsGeometryResource_EXPORT
void MergeIndexBuffers(
unsigned int dstBufferNum,
unsigned int srcBufferNum );
916 GLSGEN_GlsGeometryResource_EXPORT
void SetIndices(
unsigned int bufferNum,
917 const unsigned int* indexArray,
918 unsigned int numIndices,
919 unsigned int startIndex = 0,
920 unsigned int stride =
sizeof(
unsigned int ) );
928 GLSGEN_GlsGeometryResource_EXPORT
unsigned short GetIndex(
unsigned int bufferNum,
unsigned short index );
981 unsigned int vertexCount );
993 unsigned int vertexOffset = 0,
994 unsigned int vertexCount = UINT_MAX );
1073 unsigned int _dataChangedCounter;
1076 void IncDataChangedCounter()
1081 ++_dataChangedCounter;
Definition: dynamic_array.h:79
Definition: gls_geometry_resource.h:288
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:220
bool HasColor() const
Definition: gls_geometry_resource.h:163
int GetVertexAttribSemantic(unsigned char which) const
Definition: gls_geometry_resource.h:274
bool HasNormal() const
Definition: gls_geometry_resource.h:144
void SetVertexAttribType(unsigned char which, GLenum value)
Definition: gls_geometry_resource.h:234
unsigned char GetTexCoordDimension(unsigned char which) const
Definition: gls_geometry_resource.h:198
void SetNumVertexAttribs(unsigned char value)
Definition: gls_geometry_resource.h:207
void HasSecondaryColor(bool value)
Definition: gls_geometry_resource.h:167
void SetVertexAttribNormalize(unsigned char which, GLboolean value)
Definition: gls_geometry_resource.h:250
GLenum GetVertexAttribType(unsigned char which) const
Definition: gls_geometry_resource.h:244
void SetVertexAttribSemantic(unsigned char which, int semanticEnum)
Definition: gls_geometry_resource.h:266
GLboolean GetVertexAttribNormalize(unsigned char which) const
Definition: gls_geometry_resource.h:260
void HasColor(bool value)
Definition: gls_geometry_resource.h:160
GLint GetVertexAttribComponents(unsigned char which) const
Definition: gls_geometry_resource.h:228
void HasNormal(bool value)
Definition: gls_geometry_resource.h:141
unsigned char GetNumTextureCoords() const
Definition: gls_geometry_resource.h:183
unsigned char GetNumVertexAttribs() const
Definition: gls_geometry_resource.h:214
void SetTexCoordDimension(unsigned char which, unsigned char value)
Definition: gls_geometry_resource.h:188
bool HasSecondaryColor() const
Definition: gls_geometry_resource.h:170
void SetNumTextureCoords(unsigned char value)
Definition: gls_geometry_resource.h:174
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:321
DynamicArray< Observer * > _observers
The held list of observers w/ callbacks.
Definition: gls_geometry_resource.h:318
unsigned int GetResourceId()
Definition: gls_geometry_resource.h:494
virtual void GetExtents(Vector &min, Vector &max, const GlsMatrixType *matrix=NULL)=0
unsigned int _numIndexBuffers
Definition: gls_geometry_resource.h:339
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:450
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:342
void DecrementReference()
Definition: gls_geometry_resource.h:458
virtual unsigned int StatsIndexBufferVertexCount(unsigned int bufferNumber)=0
virtual unsigned int GetDataChangedCounter() const =0
void RemoveObserver(Observer *observer)
Definition: gls_geometry_resource.h:312
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:486
virtual bool BoundingVolumeHit(const Vector &point, const Vector &direction)=0
void AddObserver(Observer *observer)
Definition: gls_geometry_resource.h:305
virtual bool HitTest(unsigned char pickType, const Vector &pickLinePoint, const Vector &pickLineDirection, Vector &collisionPoint)=0
void IncrementReference()
Definition: gls_geometry_resource.h:453
Vector _boundingVolumeCenter
Center location of the bounding volume.
Definition: gls_geometry_resource.h:341
static const unsigned int s_invalidDataChangedCounter
Definition: gls_geometry_resource.h:405
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:471
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:345
virtual void UpdateBoundingVolume()=0
TypeDesc _type
Definition: gls_geometry_resource.h:336
BadId
Definition: gls_geometry_resource.h:280
virtual void DrawIndexBuffer(unsigned int bufferNumber)=0
unsigned int _resourceID
Definition: gls_geometry_resource.h:330
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:477
unsigned int _referenceCount
Definition: gls_geometry_resource.h:333
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:480
Definition: gls_geometry_resource.h:507
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:520
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:1027
VertexStructureDefinition _structure
Describes the internal storage pattern for vertices, i.e. does it have colors? textures?...
Definition: gls_geometry_resource.h:1033
void SetVertexAttrib4fv(GLuint vertIndex, GLuint attribIndex, const GLfloat *v)
Definition: gls_geometry_resource.h:827
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
void MergeIndexBuffers(unsigned int dstBufferNum, unsigned int srcBufferNum)
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:809
void CopyVertexBufferOnly(GlsGeometry_Generic *rhs)
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:610
char * _vertexBuffer
Underlying storage for vertices.
Definition: gls_geometry_resource.h:1025
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:1026
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:471
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:821
virtual unsigned int StatsIndexBufferVertexCount(unsigned int bufferNumber) DISTI_METHOD_OVERRIDE
Definition: gls_geometry_resource.h:515
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:1028
void SetVertexAttrib2fv(GLuint vertIndex, GLuint attribIndex, const GLfloat *v)
Definition: gls_geometry_resource.h:815
void SetSecondaryColor(GLuint vertIndex, unsigned char red, unsigned char green, unsigned char blue)
GlsGeometry_Generic_IndexBufferData * _indexBuffers
Definition: gls_geometry_resource.h:1031
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
unsigned int GetIndex(unsigned int bufferNum, unsigned int index)
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:1023
void StoreVertexAttrib(GLuint vertIndex, GLuint attribIndex, void *value, GLuint sizeBytes)
unsigned int GetTexcoordByteOffset(unsigned int whichTexture)
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:235
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:214
The GlsMatrixAffine class.
The disti::GlsRenderEffect class.
Force inclusion of the DirectShow library.
Definition: bmpimage.h:47
Definition: gls_geometry_resource.h:934
unsigned int _order
The order the vertex should be in.
Definition: gls_geometry_resource.h:935
unsigned int _vertexTupleIndex
The index of the primitive.
Definition: gls_geometry_resource.h:936
Definition: gls_geometry_resource.h:1004
unsigned int _texcoordStride
Offset between each texture coordinate in bytes.
Definition: gls_geometry_resource.h:1008
unsigned int _texcoord2Stride
Offset between each secondary texture coordinate in bytes.
Definition: gls_geometry_resource.h:1009
unsigned int _numVertexAttribs
The count of vertex attributes.
Definition: gls_geometry_resource.h:1012
unsigned int _size
Total size of each vertex in bytes (depends on which data is included).
Definition: gls_geometry_resource.h:1005
unsigned int _colorStride
Offset between each color in bytes.
Definition: gls_geometry_resource.h:1010
unsigned int _normalStride
Offset between each normal in bytes.
Definition: gls_geometry_resource.h:1007
unsigned int _secondaryColorStride
Offset between each secondary color in bytes.
Definition: gls_geometry_resource.h:1011
The disti::Vertex class. A class for manipulating 3D vertices.