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) || \
68 defined(GLSGEN_IMPORT_GLSGEOMETRYRESOURCE) || \
69 defined(GLS_EXPORT_GENERATED) || \
70 defined(GLS_IMPORT_GENERATED)) \
72 # if defined(GLSGEN_EXPORT_GLSGEOMETRYRESOURCE) || defined(GLS_EXPORT_GENERATED)
73 # define GLSGEN_GlsGeometryResource_EXPORT __declspec(dllexport)
75 # define GLSGEN_GlsGeometryResource_EXPORT __declspec(dllimport)
78 # define GLSGEN_GlsGeometryResource_EXPORT
90 static const unsigned int MAX_TEXTURE_COORDS = 2;
91 static const unsigned int MAX_VERTEX_ATTRIBS = 16;
95 static const unsigned int NORMAL_ATTRIBUTE_SIZE = 3 *
sizeof(float);
97 static const unsigned int COLOR_ATTRIBUTE_SIZE = 4 *
sizeof(
unsigned char);
99 static const unsigned int COLOR_ATTRIBUTE_SIZE =
sizeof(
unsigned int);
101 static const unsigned int SECONDARY_COLOR_ATTRIBUTE_SIZE = 3 *
sizeof(
unsigned char);
102 static const unsigned int TEXTURE_COORDINATE_ATTRIBUTE_SIZE = 2 *
sizeof(float);
103 static const unsigned int TANGENT_ATTRIBUTE_SIZE = 3 *
sizeof(float);
104 static const unsigned int BINORMAL_ATTRIBUTE_SIZE = 3 *
sizeof(float);
110 bool hasSecondaryColor;
112 unsigned int normalType;
113 unsigned int texCoordType;
116 unsigned char numTextureCoords;
117 unsigned char texCoordDimension[GlsGeometryResource::MAX_TEXTURE_COORDS];
118 unsigned char numVertexAttribs;
119 GLint vertexAttribNumComponents[GlsGeometryResource::MAX_VERTEX_ATTRIBS];
120 GLenum vertexAttribType[GlsGeometryResource::MAX_VERTEX_ATTRIBS];
121 GLboolean vertexAttribNormalize[GlsGeometryResource::MAX_VERTEX_ATTRIBS];
122 unsigned int vertexAttribSemantic[GlsGeometryResource::MAX_VERTEX_ATTRIBS];
130 for(i = 0; i < GlsGeometryResource::MAX_TEXTURE_COORDS; i++)
131 { texCoordDimension[i] = 2; }
132 for(i = 0; i < GlsGeometryResource::MAX_VERTEX_ATTRIBS; i++)
133 { vertexAttribNumComponents[i] = 4; }
135 normalType = GL_FLOAT;
136 texCoordType = GL_FLOAT;
140 void HasNormal(
bool value) { hasNormal = value; }
141 bool HasNormal(
void)
const {
return hasNormal; }
144 void NormalType(
unsigned int value) { normalType = value; }
146 unsigned int NormalType(
void)
const {
return normalType; }
148 void TexCoordType(
unsigned int value) { texCoordType = value; }
149 unsigned int TexCoordType(
void)
const {
return texCoordType; }
152 void HasColor(
bool value) { hasColor = value; }
153 bool HasColor(
void)
const {
return hasColor; }
155 void HasSecondaryColor(
bool value) { hasSecondaryColor = value; }
156 bool HasSecondaryColor(
void)
const {
return hasSecondaryColor; }
158 void SetNumTextureCoords(
unsigned char value)
160 if (value <= GlsGeometryResource::MAX_TEXTURE_COORDS)
161 numTextureCoords = value;
163 unsigned char GetNumTextureCoords(
void)
const {
return numTextureCoords; }
165 void SetTexCoordDimension(
unsigned char which,
unsigned char value)
167 if (which < GlsGeometryResource::MAX_TEXTURE_COORDS &&
168 value > 0 && value < 5)
169 texCoordDimension[which] = value;
171 unsigned char GetTexCoordDimension(
unsigned char which)
const {
return texCoordDimension[which]; }
182 if (value <= GlsGeometryResource::MAX_VERTEX_ATTRIBS)
183 numVertexAttribs = value;
185 unsigned char GetNumVertexAttribs(
void)
const {
return numVertexAttribs; }
191 if (which < GlsGeometryResource::MAX_VERTEX_ATTRIBS &&
192 value > 0 && value < 5)
193 vertexAttribNumComponents[which] = value;
195 GLint GetVertexAttribComponents(
unsigned char which)
const {
return vertexAttribNumComponents[which]; }
201 if (which < GlsGeometryResource::MAX_VERTEX_ATTRIBS)
202 vertexAttribType[which] = value;
204 GLenum GetVertexAttribType(
unsigned char which)
const {
return vertexAttribType[which]; }
211 if (which < GlsGeometryResource::MAX_VERTEX_ATTRIBS)
212 vertexAttribNormalize[which] = value;
214 GLboolean GetVertexAttribNormalize(
unsigned char which)
const {
return vertexAttribNormalize[which]; }
222 if (which < GlsGeometryResource::MAX_VERTEX_ATTRIBS)
223 vertexAttribSemantic[which] = semanticEnum;
225 int GetVertexAttribSemantic(
unsigned char which)
const {
return vertexAttribSemantic[which]; }
237 virtual ~GlsGeometryResource() {}
253 Vector _boundingVolumeCenter;
254 float _boundingVolumeRadius;
257 static bool _enableVBO;
351 virtual bool HitTest(
unsigned char pickType,
const Vector& pickLinePoint,
const Vector& pickLineDirection,
Vector& collisionPoint) = 0;
373 DistiAssert(_referenceCount > 0);
377 if (_referenceCount == 0)
401 assert(BAD_ID !=
id);
410 assert(BAD_ID != _resourceID);
417 class GlsGeometry_Generic_IndexBufferData;
456 virtual GLSGEN_GlsGeometryResource_EXPORT
bool HitTest(
unsigned char pickType,
const Vector& pickLinePoint,
const Vector& pickLineDirection,
Vector& collisionPoint);
462 virtual GLSGEN_GlsGeometryResource_EXPORT
void DrawIndexBuffer(
unsigned int bufferNumber);
508 GLSGEN_GlsGeometryResource_EXPORT
void ChangeType(
const TypeDesc& type);
513 GLSGEN_GlsGeometryResource_EXPORT
bool LockBuffers();
525 GLSGEN_GlsGeometryResource_EXPORT
unsigned int VertexCount()
const;
531 GLSGEN_GlsGeometryResource_EXPORT
void VertexCount(
unsigned int count);
538 GLSGEN_GlsGeometryResource_EXPORT
void SetVertex(GLuint vertIndex,
const float *value);
552 GLSGEN_GlsGeometryResource_EXPORT
void SetVertices(
const float *floatArray,
553 unsigned int numVertices,
554 unsigned int startVertIndex = 0,
555 unsigned int stride = VERTEX_ATTRIBUTE_SIZE);
564 GLSGEN_GlsGeometryResource_EXPORT
void SetVertex(GLuint vertIndex,
576 GLSGEN_GlsGeometryResource_EXPORT
const float*
GetVertex(GLuint vertIndex);
586 GLSGEN_GlsGeometryResource_EXPORT
void SetNormal(GLuint vertIndex,
float x,
float y,
float z);
597 GLSGEN_GlsGeometryResource_EXPORT
void SetNormals(
const float *floatArray,
598 unsigned int numVertices,
599 unsigned int startVertIndex = 0,
600 unsigned int stride = NORMAL_ATTRIBUTE_SIZE);
609 GLSGEN_GlsGeometryResource_EXPORT
const float *
GetNormal(GLuint vertIndex);
618 GLSGEN_GlsGeometryResource_EXPORT
void SetColor(GLuint vertIndex,
622 unsigned char alpha);
633 GLSGEN_GlsGeometryResource_EXPORT
void SetColors(
const unsigned int *rgbaArray,
634 unsigned int numVertices,
635 unsigned int startVertIndex = 0,
636 unsigned int stride = COLOR_ATTRIBUTE_SIZE);
642 GLSGEN_GlsGeometryResource_EXPORT
void SetColors(
const unsigned int *array);
649 GLSGEN_GlsGeometryResource_EXPORT
unsigned char *
GetColor(GLuint vertIndex);
672 GLSGEN_GlsGeometryResource_EXPORT
void SetSecondaryColors(
const unsigned int *rgbArray,
673 unsigned int numVertices,
674 unsigned int startVertIndex = 0,
675 unsigned int stride = SECONDARY_COLOR_ATTRIBUTE_SIZE);
682 GLSGEN_GlsGeometryResource_EXPORT
unsigned char *
GetSecondaryColor(GLuint vertIndex);
693 GLSGEN_GlsGeometryResource_EXPORT
void SetTextureCoord(GLuint vertIndex,
unsigned int whichTexture,
694 const float *textureCoord);
696 GLSGEN_GlsGeometryResource_EXPORT
void SetTextureCoord(GLuint vertIndex,
unsigned int whichTexture,
698 float textureCoordV);
709 GLSGEN_GlsGeometryResource_EXPORT
void SetTextureCoords(
unsigned int whichTexture,
710 const float *textureCoordArray,
711 unsigned int numVertices,
712 unsigned int startVertIndex = 0,
713 unsigned int stride = TEXTURE_COORDINATE_ATTRIBUTE_SIZE);
724 GLSGEN_GlsGeometryResource_EXPORT
const float *
GetTextureCoord(GLuint vertIndex,
unsigned int whichTexture);
733 GLSGEN_GlsGeometryResource_EXPORT
void StoreVertexAttrib(GLuint vertIndex, GLuint attribIndex,
void* value, GLuint sizeBytes);
735 void SetVertexAttrib1fv(GLuint vertIndex, GLuint attribIndex,
const GLfloat *v) {
StoreVertexAttrib(vertIndex, attribIndex, (
void*)v, 1*
sizeof(
float)); }
736 void SetVertexAttrib2fv(GLuint vertIndex, GLuint attribIndex,
const GLfloat *v) {
StoreVertexAttrib(vertIndex, attribIndex, (
void*)v, 2*
sizeof(
float)); }
737 void SetVertexAttrib3fv(GLuint vertIndex, GLuint attribIndex,
const GLfloat *v) {
StoreVertexAttrib(vertIndex, attribIndex, (
void*)v, 3*
sizeof(
float)); }
738 void SetVertexAttrib4fv(GLuint vertIndex, GLuint attribIndex,
const GLfloat *v) {
StoreVertexAttrib(vertIndex, attribIndex, (
void*)v, 4*
sizeof(
float)); }
741 GLSGEN_GlsGeometryResource_EXPORT
void SetVertexAttribs(
const float* attribArray,
744 unsigned int numVertices,
745 unsigned int startVertIndex = 0,
746 unsigned int stride = TANGENT_ATTRIBUTE_SIZE);
755 GLSGEN_GlsGeometryResource_EXPORT
void*
GetVertexAttrib(GLuint vertIndex, GLuint attribIndex);
762 GLSGEN_GlsGeometryResource_EXPORT
void NumIndexBuffers(
unsigned int count);
768 GLSGEN_GlsGeometryResource_EXPORT
unsigned int GetIndexBufferSize(
unsigned int bufferNum)
const;
775 GLSGEN_GlsGeometryResource_EXPORT
void SetIndexBufferSize(
unsigned int bufferNum,
unsigned int newSize);
782 GLSGEN_GlsGeometryResource_EXPORT
void SetIndex(
unsigned int bufferNum,
unsigned int index,
unsigned int indexValue);
796 GLSGEN_GlsGeometryResource_EXPORT
void SetIndices(
unsigned int bufferNum,
797 const unsigned int *indexArray,
798 unsigned int numIndices,
799 unsigned int startIndex = 0,
800 unsigned int stride =
sizeof(
unsigned int));
808 GLSGEN_GlsGeometryResource_EXPORT
unsigned int GetIndex(
unsigned int bufferNum,
unsigned int index);
816 GLSGEN_GlsGeometryResource_EXPORT
void MergeIndexBuffers(
unsigned int dstBufferNum,
unsigned int srcBufferNum);
830 GLSGEN_GlsGeometryResource_EXPORT
void SetIndices(
unsigned int bufferNum,
831 const unsigned int *indexArray,
832 unsigned int numIndices,
833 unsigned int startIndex = 0,
834 unsigned int stride =
sizeof(
unsigned int));
842 GLSGEN_GlsGeometryResource_EXPORT
unsigned short GetIndex(
unsigned int bufferNum,
unsigned short index);
850 unsigned int _vertexTupleIndex;
877 GLSGEN_GlsGeometryResource_EXPORT
void DumpNormals();
881 GLSGEN_GlsGeometryResource_EXPORT
void DumpIndices();
892 static GLSGEN_GlsGeometryResource_EXPORT
unsigned int CopyVertexData(
895 unsigned int vertexCount);
904 static GLSGEN_GlsGeometryResource_EXPORT
unsigned int TransformVertexData(
907 unsigned int vertexOffset = 0,
908 unsigned int vertexCount = UINT_MAX);
912 static GLSGEN_GlsGeometryResource_EXPORT
bool GenerateTangentsAndBinormals(
GlsGeometry_Generic* geom);
921 unsigned int _texcoordStride;
922 unsigned int _texcoord2Stride;
923 unsigned int _colorStride;
924 unsigned int _secondaryColorStride;
925 unsigned int _numVertexAttribs;
926 unsigned int _vertexAttribStride[MAX_VERTEX_ATTRIBS];
927 unsigned int _vertexAttribSize[MAX_VERTEX_ATTRIBS];
938 unsigned int _vertexBufferCount;
939 GLuint _vertexBufferID;
940 bool _vertexBufferUpdated;
957 GLSGEN_GlsGeometryResource_EXPORT
bool BestHit(
const Vector &point,
const Vector& directionVector,
Vector& collisionPoint);
969 void InitializeMembers();
973 unsigned int GetTexcoordByteOffset(
unsigned int whichTexture );
975 GLSGEN_GlsGeometryResource_EXPORT
void Destroy();
980 unsigned int _dataChangedCounter;
983 void IncDataChangedCounter()
988 ++_dataChangedCounter;
993 GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic();
996 GLSGEN_GlsGeometryResource_EXPORT ~GlsGeometry_Generic();
999 GlsGeometry_Generic(
const GlsGeometry_Generic &src );
1000 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:393
TypeDesc _type
Definition: gls_geometry_resource.h:247
unsigned int GetIndexBufferSize(unsigned int bufferNum) const
Definition: gls_geometry_resource.h:106
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:399
void DecrementReference()
Definition: gls_geometry_resource.h:371
unsigned int _referenceCount
Definition: gls_geometry_resource.h:244
Definition: gls_geometry_resource.h:847
void SetNumVertexAttribs(unsigned char value)
Definition: gls_geometry_resource.h:180
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:390
void SetVertexAttribSemantic(unsigned char which, int semanticEnum)
Definition: gls_geometry_resource.h:220
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:209
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:84
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:199
void StoreVertexAttrib(GLuint vertIndex, GLuint attribIndex, void *value, GLuint sizeBytes)
static const unsigned int VERTEX_ATTRIBUTE_SIZE
Definition: gls_geometry_resource.h:94
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:86
void IncrementReference()
Definition: gls_geometry_resource.h:366
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:250
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:432
const TypeDesc & Type()
Definition: gls_geometry_resource.h:363
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:408
unsigned int GetIndex(unsigned int bufferNum, unsigned int index)
unsigned int _resourceID
Definition: gls_geometry_resource.h:241
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:914
Contains the DistiAssert macro.
void SetVertexAttribComponents(unsigned char which, GLint value)
Definition: gls_geometry_resource.h:189
virtual void UpdateBoundingVolume()=0
Definition: gls_resource_file_mgr.h:41
Definition: gls_resource_file_mgr.h:62
unsigned int _normalStride
Definition: gls_geometry_resource.h:920
const float * GetNormal(GLuint vertIndex)
unsigned int NumIndexBuffers() const
Definition: gls_geometry_resource.h:384
Definition: bmpimage.h:46
virtual void FreeOpenGLBuffers()
GlsGeometry_Generic_IndexBufferData * _indexBuffers
Definition: gls_geometry_resource.h:943
virtual void DrawSetup(VertexAttribIndexLookup *shaderProgram)=0
virtual unsigned int StatsIndexBufferPolygonCount(unsigned int bufferNumber)
Definition: gls_geometry_resource.h:438
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:421
The disti::GlsRenderEffect class.