40 #ifndef GLS_GEOMETRY_RESOURCE_H_INCLUDED
41 #define GLS_GEOMETRY_RESOURCE_H_INCLUDED
63 #include "gls_resource_file_mgr.h"
67 #if( defined( GLSGEN_EXPORT_GLSGEOMETRYRESOURCE ) || defined( GLSGEN_IMPORT_GLSGEOMETRYRESOURCE ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
68 && defined( _MSC_VER )
69 # if defined( GLSGEN_EXPORT_GLSGEOMETRYRESOURCE ) || defined( GLS_EXPORT_GENERATED )
70 # define GLSGEN_GlsGeometryResource_EXPORT __declspec( dllexport )
72 # define GLSGEN_GlsGeometryResource_EXPORT __declspec( dllimport )
75 # define GLSGEN_GlsGeometryResource_EXPORT
85 static const unsigned int MAX_TEXTURE_COORDS = 2;
86 static const unsigned int MAX_VERTEX_ATTRIBS = 16;
90 static const unsigned int NORMAL_ATTRIBUTE_SIZE = 3 *
sizeof( float );
92 static const unsigned int COLOR_ATTRIBUTE_SIZE = 4 *
sizeof(
unsigned char );
94 static const unsigned int COLOR_ATTRIBUTE_SIZE =
sizeof(
unsigned int );
96 static const unsigned int SECONDARY_COLOR_ATTRIBUTE_SIZE = 3 *
sizeof(
unsigned char );
97 static const unsigned int TEXTURE_COORDINATE_ATTRIBUTE_SIZE = 2 *
sizeof( float );
98 static const unsigned int TANGENT_ATTRIBUTE_SIZE = 3 *
sizeof( float );
99 static const unsigned int BINORMAL_ATTRIBUTE_SIZE = 3 *
sizeof( float );
105 bool hasSecondaryColor;
107 unsigned int normalType;
108 unsigned int texCoordType;
111 unsigned char numTextureCoords;
112 unsigned char texCoordDimension[ GlsGeometryResource::MAX_TEXTURE_COORDS ];
113 unsigned char numVertexAttribs;
114 GLint vertexAttribNumComponents[ GlsGeometryResource::MAX_VERTEX_ATTRIBS ];
115 GLenum vertexAttribType[ GlsGeometryResource::MAX_VERTEX_ATTRIBS ];
116 GLboolean vertexAttribNormalize[ GlsGeometryResource::MAX_VERTEX_ATTRIBS ];
117 unsigned int vertexAttribSemantic[ GlsGeometryResource::MAX_VERTEX_ATTRIBS ];
122 memset(
this, 0,
sizeof(
TypeDesc ) );
124 for( i = 0; i < GlsGeometryResource::MAX_TEXTURE_COORDS; i++ )
126 texCoordDimension[ i ] = 2;
128 for( i = 0; i < GlsGeometryResource::MAX_VERTEX_ATTRIBS; i++ )
130 vertexAttribNumComponents[ i ] = 4;
133 normalType = GL_FLOAT;
134 texCoordType = GL_FLOAT;
138 void HasNormal(
bool value ) { hasNormal = value; }
139 bool HasNormal(
void )
const {
return hasNormal; }
142 void NormalType(
unsigned int value )
147 unsigned int NormalType(
void )
const {
return normalType; }
149 void TexCoordType(
unsigned int value ) { texCoordType = value; }
150 unsigned int TexCoordType(
void )
const {
return texCoordType; }
153 void HasColor(
bool value )
157 bool HasColor(
void )
const {
return hasColor; }
159 void HasSecondaryColor(
bool value ) { hasSecondaryColor = value; }
160 bool HasSecondaryColor(
void )
const {
return hasSecondaryColor; }
162 void SetNumTextureCoords(
unsigned char value )
164 if( value <= GlsGeometryResource::MAX_TEXTURE_COORDS )
165 numTextureCoords = value;
167 unsigned char GetNumTextureCoords(
void )
const {
return numTextureCoords; }
169 void SetTexCoordDimension(
unsigned char which,
unsigned char value )
171 if( which < GlsGeometryResource::MAX_TEXTURE_COORDS && value > 0 && value < 5 )
172 texCoordDimension[ which ] = value;
174 unsigned char GetTexCoordDimension(
unsigned char which )
const {
return texCoordDimension[ which ]; }
185 if( value <= GlsGeometryResource::MAX_VERTEX_ATTRIBS )
186 numVertexAttribs = value;
188 unsigned char GetNumVertexAttribs(
void )
const {
return numVertexAttribs; }
194 if( which < GlsGeometryResource::MAX_VERTEX_ATTRIBS && value > 0 && value < 5 )
195 vertexAttribNumComponents[ which ] = value;
197 GLint GetVertexAttribComponents(
unsigned char which )
const {
return vertexAttribNumComponents[ which ]; }
203 if( which < GlsGeometryResource::MAX_VERTEX_ATTRIBS )
204 vertexAttribType[ which ] = value;
206 GLenum GetVertexAttribType(
unsigned char which )
const {
return vertexAttribType[ which ]; }
213 if( which < GlsGeometryResource::MAX_VERTEX_ATTRIBS )
214 vertexAttribNormalize[ which ] = value;
216 GLboolean GetVertexAttribNormalize(
unsigned char which )
const {
return vertexAttribNormalize[ which ]; }
224 if( which < GlsGeometryResource::MAX_VERTEX_ATTRIBS )
225 vertexAttribSemantic[ which ] = semanticEnum;
227 int GetVertexAttribSemantic(
unsigned char which )
const {
return vertexAttribSemantic[ which ]; }
238 virtual ~GlsGeometryResource() {}
254 Vector _boundingVolumeCenter;
255 float _boundingVolumeRadius;
258 static bool _enableVBO;
351 virtual bool HitTest(
unsigned char pickType,
const Vector& pickLinePoint,
const Vector& pickLineDirection,
Vector& collisionPoint ) = 0;
370 DistiAssert( _referenceCount > 0 );
374 if( _referenceCount == 0 )
398 assert( BAD_ID !=
id );
407 assert( BAD_ID != _resourceID );
413 class GlsGeometry_Generic_IndexBufferData;
451 virtual GLSGEN_GlsGeometryResource_EXPORT
bool HitTest(
unsigned char pickType,
const Vector& pickLinePoint,
const Vector& pickLineDirection,
Vector& collisionPoint );
457 virtual GLSGEN_GlsGeometryResource_EXPORT
void DrawIndexBuffer(
unsigned int bufferNumber );
500 GLSGEN_GlsGeometryResource_EXPORT
void ChangeType(
const TypeDesc& type );
505 GLSGEN_GlsGeometryResource_EXPORT
bool LockBuffers();
517 GLSGEN_GlsGeometryResource_EXPORT
unsigned int VertexCount()
const;
523 GLSGEN_GlsGeometryResource_EXPORT
void VertexCount(
unsigned int count );
530 GLSGEN_GlsGeometryResource_EXPORT
void SetVertex( GLuint vertIndex,
const float* value );
544 GLSGEN_GlsGeometryResource_EXPORT
void SetVertices(
const float* floatArray,
545 unsigned int numVertices,
546 unsigned int startVertIndex = 0,
547 unsigned int stride = VERTEX_ATTRIBUTE_SIZE );
556 GLSGEN_GlsGeometryResource_EXPORT
void SetVertex( GLuint vertIndex,
568 GLSGEN_GlsGeometryResource_EXPORT
const float*
GetVertex( GLuint vertIndex );
578 GLSGEN_GlsGeometryResource_EXPORT
void SetNormal( GLuint vertIndex,
float x,
float y,
float z );
589 GLSGEN_GlsGeometryResource_EXPORT
void SetNormals(
const float* floatArray,
590 unsigned int numVertices,
591 unsigned int startVertIndex = 0,
592 unsigned int stride = NORMAL_ATTRIBUTE_SIZE );
601 GLSGEN_GlsGeometryResource_EXPORT
const float*
GetNormal( GLuint vertIndex );
610 GLSGEN_GlsGeometryResource_EXPORT
void SetColor( GLuint vertIndex,
614 unsigned char alpha );
625 GLSGEN_GlsGeometryResource_EXPORT
void SetColors(
const unsigned int* rgbaArray,
626 unsigned int numVertices,
627 unsigned int startVertIndex = 0,
628 unsigned int stride = COLOR_ATTRIBUTE_SIZE );
634 GLSGEN_GlsGeometryResource_EXPORT
void SetColors(
const unsigned int* array );
641 GLSGEN_GlsGeometryResource_EXPORT
unsigned char*
GetColor( GLuint vertIndex );
653 unsigned char blue );
664 GLSGEN_GlsGeometryResource_EXPORT
void SetSecondaryColors(
const unsigned int* rgbArray,
665 unsigned int numVertices,
666 unsigned int startVertIndex = 0,
667 unsigned int stride = SECONDARY_COLOR_ATTRIBUTE_SIZE );
674 GLSGEN_GlsGeometryResource_EXPORT
unsigned char*
GetSecondaryColor( GLuint vertIndex );
684 GLSGEN_GlsGeometryResource_EXPORT
void SetTextureCoord( GLuint vertIndex,
unsigned int whichTexture,
685 const float* textureCoord );
687 GLSGEN_GlsGeometryResource_EXPORT
void SetTextureCoord( GLuint vertIndex,
unsigned int whichTexture,
689 float textureCoordV );
700 GLSGEN_GlsGeometryResource_EXPORT
void SetTextureCoords(
unsigned int whichTexture,
701 const float* textureCoordArray,
702 unsigned int numVertices,
703 unsigned int startVertIndex = 0,
704 unsigned int stride = TEXTURE_COORDINATE_ATTRIBUTE_SIZE );
715 GLSGEN_GlsGeometryResource_EXPORT
const float*
GetTextureCoord( GLuint vertIndex,
unsigned int whichTexture );
723 GLSGEN_GlsGeometryResource_EXPORT
void StoreVertexAttrib( GLuint vertIndex, GLuint attribIndex,
void* value, GLuint sizeBytes );
725 void SetVertexAttrib1fv( GLuint vertIndex, GLuint attribIndex,
const GLfloat* v ) {
StoreVertexAttrib( vertIndex, attribIndex, (
void*)v, 1 *
sizeof(
float ) ); }
726 void SetVertexAttrib2fv( GLuint vertIndex, GLuint attribIndex,
const GLfloat* v ) {
StoreVertexAttrib( vertIndex, attribIndex, (
void*)v, 2 *
sizeof(
float ) ); }
727 void SetVertexAttrib3fv( GLuint vertIndex, GLuint attribIndex,
const GLfloat* v ) {
StoreVertexAttrib( vertIndex, attribIndex, (
void*)v, 3 *
sizeof(
float ) ); }
728 void SetVertexAttrib4fv( GLuint vertIndex, GLuint attribIndex,
const GLfloat* v ) {
StoreVertexAttrib( vertIndex, attribIndex, (
void*)v, 4 *
sizeof(
float ) ); }
731 GLSGEN_GlsGeometryResource_EXPORT
void SetVertexAttribs(
const float* attribArray,
734 unsigned int numVertices,
735 unsigned int startVertIndex = 0,
736 unsigned int stride = TANGENT_ATTRIBUTE_SIZE );
745 GLSGEN_GlsGeometryResource_EXPORT
void*
GetVertexAttrib( GLuint vertIndex, GLuint attribIndex );
752 GLSGEN_GlsGeometryResource_EXPORT
void NumIndexBuffers(
unsigned int count );
758 GLSGEN_GlsGeometryResource_EXPORT
unsigned int GetIndexBufferSize(
unsigned int bufferNum )
const;
765 GLSGEN_GlsGeometryResource_EXPORT
void SetIndexBufferSize(
unsigned int bufferNum,
unsigned int newSize );
772 GLSGEN_GlsGeometryResource_EXPORT
void SetIndex(
unsigned int bufferNum,
unsigned int index,
unsigned int indexValue );
786 GLSGEN_GlsGeometryResource_EXPORT
void SetIndices(
unsigned int bufferNum,
787 const unsigned int* indexArray,
788 unsigned int numIndices,
789 unsigned int startIndex = 0,
790 unsigned int stride =
sizeof(
unsigned int ) );
798 GLSGEN_GlsGeometryResource_EXPORT
unsigned int GetIndex(
unsigned int bufferNum,
unsigned int index );
806 GLSGEN_GlsGeometryResource_EXPORT
void MergeIndexBuffers(
unsigned int dstBufferNum,
unsigned int srcBufferNum );
820 GLSGEN_GlsGeometryResource_EXPORT
void SetIndices(
unsigned int bufferNum,
821 const unsigned int* indexArray,
822 unsigned int numIndices,
823 unsigned int startIndex = 0,
824 unsigned int stride =
sizeof(
unsigned int ) );
832 GLSGEN_GlsGeometryResource_EXPORT
unsigned short GetIndex(
unsigned int bufferNum,
unsigned short index );
840 unsigned int _vertexTupleIndex;
867 GLSGEN_GlsGeometryResource_EXPORT
void DumpNormals();
871 GLSGEN_GlsGeometryResource_EXPORT
void DumpIndices();
882 static GLSGEN_GlsGeometryResource_EXPORT
unsigned int CopyVertexData(
885 unsigned int vertexCount );
894 static GLSGEN_GlsGeometryResource_EXPORT
unsigned int TransformVertexData(
897 unsigned int vertexOffset = 0,
898 unsigned int vertexCount = UINT_MAX );
902 static GLSGEN_GlsGeometryResource_EXPORT
bool GenerateTangentsAndBinormals(
GlsGeometry_Generic* geom );
911 unsigned int _texcoordStride;
912 unsigned int _texcoord2Stride;
913 unsigned int _colorStride;
914 unsigned int _secondaryColorStride;
915 unsigned int _numVertexAttribs;
916 unsigned int _vertexAttribStride[ MAX_VERTEX_ATTRIBS ];
917 unsigned int _vertexAttribSize[ MAX_VERTEX_ATTRIBS ];
926 unsigned int _vertexBufferCount;
927 GLuint _vertexBufferID;
928 bool _vertexBufferUpdated;
945 GLSGEN_GlsGeometryResource_EXPORT
bool BestHit(
const Vector& point,
const Vector& directionVector,
Vector& collisionPoint );
955 GLSGEN_GlsGeometryResource_EXPORT
bool FirstHit(
const Vector& point,
const Vector& directionVector,
Vector& collisionPoint );
957 void InitializeMembers();
961 unsigned int GetTexcoordByteOffset(
unsigned int whichTexture );
963 GLSGEN_GlsGeometryResource_EXPORT
void Destroy();
967 unsigned int _dataChangedCounter;
970 void IncDataChangedCounter()
975 ++_dataChangedCounter;
980 GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic();
983 GLSGEN_GlsGeometryResource_EXPORT ~GlsGeometry_Generic();
986 GlsGeometry_Generic(
const GlsGeometry_Generic& src );
987 GlsGeometry_Generic& operator=(
const GlsGeometry_Generic& rhs );
void SetIndexBufferSize(unsigned int bufferNum, unsigned int newSize)
void SetColors(const unsigned int *rgbaArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=COLOR_ATTRIBUTE_SIZE)
virtual void DrawCleanup(VertexAttribIndexLookup *shaderProgram)
unsigned int VertexCount() const
void SetColor(GLuint vertIndex, unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
float BoundingVolumeRadius() const
Definition: gls_geometry_resource.h:390
TypeDesc _type
Definition: gls_geometry_resource.h:248
unsigned int GetIndexBufferSize(unsigned int bufferNum) const
Definition: gls_geometry_resource.h:101
virtual void DrawIndexBuffer(unsigned int bufferNumber)=0
static const unsigned int s_invalidDataChangedCounter
Definition: gls_geometry_resource.h:317
void SetTextureCoord(GLuint vertIndex, unsigned int whichTexture, const float *textureCoord)
void SetResourceId(unsigned int id)
Definition: gls_geometry_resource.h:396
void DecrementReference()
Definition: gls_geometry_resource.h:368
unsigned int _referenceCount
Definition: gls_geometry_resource.h:245
Definition: gls_geometry_resource.h:837
void SetNumVertexAttribs(unsigned char value)
Definition: gls_geometry_resource.h:183
virtual bool BoundingVolumeHit(const Vector &point, const Vector &direction)=0
The GlsMatrixAffine class.
void MergeIndexBuffers(unsigned int dstBufferNum, unsigned int srcBufferNum)
const Vector & BoundingVolumeCenter() const
Definition: gls_geometry_resource.h:387
void SetVertexAttribSemantic(unsigned char which, int semanticEnum)
Definition: gls_geometry_resource.h:222
unsigned char * GetColor(GLuint vertIndex)
bool BestHit(const Vector &point, const Vector &directionVector, Vector &collisionPoint)
const float * GetTextureCoord(GLuint vertIndex, unsigned int whichTexture)
void SetVertexAttribNormalize(unsigned char which, GLboolean value)
Definition: gls_geometry_resource.h:211
void SetNormals(const float *floatArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=NORMAL_ATTRIBUTE_SIZE)
virtual bool BoundingVolumeHit(const Vector &point, const Vector &direction)
virtual unsigned int StatsIndexBufferPolygonCount(unsigned int bufferNumber)=0
Definition: gls_render_effect.h:81
void SetIndices(unsigned int bufferNum, const unsigned int *indexArray, unsigned int numIndices, unsigned int startIndex=0, unsigned int stride=sizeof(unsigned int))
virtual unsigned int StatsIndexBufferVertexCount(unsigned int bufferNumber)=0
virtual unsigned int GetDataChangedCounter() const
void SetVertexAttribType(unsigned char which, GLenum value)
Definition: gls_geometry_resource.h:201
void StoreVertexAttrib(GLuint vertIndex, GLuint attribIndex, void *value, GLuint sizeBytes)
static const unsigned int VERTEX_ATTRIBUTE_SIZE
Definition: gls_geometry_resource.h:89
void SetSecondaryColor(GLuint vertIndex, unsigned char red, unsigned char green, unsigned char blue)
void SetVertices(const float *floatArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=VERTEX_ATTRIBUTE_SIZE)
bool FirstHit(const Vector &point, const Vector &directionVector, Vector &collisionPoint)
unsigned char * GetSecondaryColor(GLuint vertIndex)
Definition: gls_geometry_resource.h:82
void IncrementReference()
Definition: gls_geometry_resource.h:363
void SetSecondaryColors(const unsigned int *rgbArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=SECONDARY_COLOR_ATTRIBUTE_SIZE)
static void SetCreateInstanceMakesHalfFloat(bool value)
static GlsGeometryResource * CreateInstance(const TypeDesc &type=GlsGeometryResource::TypeDesc())
unsigned int _numIndexBuffers
Definition: gls_geometry_resource.h:251
void * GetVertexAttrib(GLuint vertIndex, GLuint attribIndex)
The disti::Vertex class. A class for manipulating 3D vertices.
virtual void DrawIndexBuffer(unsigned int bufferNumber)
virtual void UpdateBoundingVolume(void)
void SetIndex(unsigned int bufferNum, unsigned int index, unsigned int indexValue)
virtual void GetExtents(Vector &min, Vector &max, const GlsMatrixType *matrix=NULL)
virtual unsigned int StatsIndexBufferVertexCount(unsigned int bufferNumber)
Definition: gls_geometry_resource.h:427
const TypeDesc & Type()
Definition: gls_geometry_resource.h:360
static unsigned int CopyVertexData(GlsGeometry_Generic *dstGeom, unsigned int dstOffset, GlsGeometry_Generic *srcGeom, unsigned int srcOffset, unsigned int vertexCount)
virtual unsigned int GetDataChangedCounter() const =0
virtual void DrawSetup(VertexAttribIndexLookup *shaderProgram)
virtual bool HitTest(unsigned char pickType, const Vector &pickLinePoint, const Vector &pickLineDirection, Vector &collisionPoint)=0
static GlsGeometry_Generic * CreateEmptyInstance()
void VertexSort(VertexSortData *sortData)
unsigned int GetResourceId(void)
Definition: gls_geometry_resource.h:405
unsigned int GetIndex(unsigned int bufferNum, unsigned int index)
unsigned int _resourceID
Definition: gls_geometry_resource.h:242
virtual void FreeOpenGLBuffers()=0
void SetVertex(GLuint vertIndex, const float *value)
const float * GetVertex(GLuint vertIndex)
virtual void GetExtents(Vector &min, Vector &max, const GlsMatrixType *matrix=NULL)=0
void CopyVertexAndIndexBuffers(GlsGeometry_Generic *rhs)
void ChangeType(const TypeDesc &type)
void SetNormal(GLuint vertIndex, float x, float y, float z)
static GlsGeometry_Generic * CreateInstance(const TypeDesc &type)
static GlsGeometry_Generic * CreateFromBinaryResource(GlsResourceFileMgr::BinaryResource *data)
Definition: gls_geometry_resource.h:904
Contains the DistiAssert macro.
void SetVertexAttribComponents(unsigned char which, GLint value)
Definition: gls_geometry_resource.h:192
virtual void UpdateBoundingVolume()=0
Definition: gls_resource_file_mgr.h:38
Definition: gls_resource_file_mgr.h:60
unsigned int _normalStride
Definition: gls_geometry_resource.h:910
const float * GetNormal(GLuint vertIndex)
unsigned int NumIndexBuffers() const
Definition: gls_geometry_resource.h:381
Definition: bmpimage.h:46
virtual void FreeOpenGLBuffers()
GlsGeometry_Generic_IndexBufferData * _indexBuffers
Definition: gls_geometry_resource.h:931
virtual void DrawSetup(VertexAttribIndexLookup *shaderProgram)=0
virtual unsigned int StatsIndexBufferPolygonCount(unsigned int bufferNumber)
Definition: gls_geometry_resource.h:433
virtual void DrawCleanup(VertexAttribIndexLookup *shaderProgram)=0
virtual bool HitTest(unsigned char pickType, const Vector &pickLinePoint, const Vector &pickLineDirection, Vector &collisionPoint)
Definition: gls_geometry_resource.h:417
The disti::GlsRenderEffect class.