GL Studio API
gls_geometry_resource.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::GlsGeometryResource class.
3 
4  \par Copyright Information
5 
6  Copyright (c) 2015 by The DiSTI Corporation.<br>
7  11301 Corporate Blvd; Suite 100<br>
8  Orlando, Florida 32817<br>
9  USA<br>
10  <br>
11  All rights reserved.<br>
12 
13  This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19 
20  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26 
27  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35 
36  The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38 
39 */
40 #ifndef GLS_GEOMETRY_RESOURCE_H_INCLUDED
41 #define GLS_GEOMETRY_RESOURCE_H_INCLUDED
42 
43 #include "assert.h"
44 
45 #ifdef _WIN32
46  #include <windows.h>
47 #endif
48 
49 #ifdef LINUX
50  #include <limits.h>
51 #endif
52 
53 #ifdef GLES
54  #include "gls_gl.h"
55  #include "limits.h"
56 #else
57  #include <GL/gl.h>
58 #endif
59 
60 #include "vertex.h"
61 #include "gls_matrix_affine.h"
62 #include "disti_assert.h"
63 #include "gls_resource_file_mgr.h"
64 #include "gls_render_effect.h"
65 
66 //////////////////// Provides support for creating DLLs ////////////////////////
67 #if (defined(GLSGEN_EXPORT_GLSGEOMETRYRESOURCE) || \
68  defined(GLSGEN_IMPORT_GLSGEOMETRYRESOURCE) || \
69  defined(GLS_EXPORT_GENERATED) || \
70  defined(GLS_IMPORT_GENERATED)) \
71  && defined(_MSC_VER)
72 # if defined(GLSGEN_EXPORT_GLSGEOMETRYRESOURCE) || defined(GLS_EXPORT_GENERATED)
73 # define GLSGEN_GlsGeometryResource_EXPORT __declspec(dllexport)
74 # else
75 # define GLSGEN_GlsGeometryResource_EXPORT __declspec(dllimport)
76 # endif
77 #else
78 # define GLSGEN_GlsGeometryResource_EXPORT
79 #endif
80 ///////////////////////////////////////////////////////////////////////////////
81 
82 namespace disti
83 {
84 
85 /** The geometry resource abstract base class */
87 {
88 public:
89 
90  static const unsigned int MAX_TEXTURE_COORDS = 2; // GL_MAX_TEXTURE_COORDS. GlsGeometryResource currently only supports two sets of texture coordinates
91  static const unsigned int MAX_VERTEX_ATTRIBS = 16; // GL_MAX_VERTEX_ATTRIBS
92 
93  /** The sizes of various vertex attributes, in bytes. */
94  static const unsigned int VERTEX_ATTRIBUTE_SIZE = 3 * sizeof(float);
95  static const unsigned int NORMAL_ATTRIBUTE_SIZE = 3 * sizeof(float);
96 #ifdef GLES
97  static const unsigned int COLOR_ATTRIBUTE_SIZE = 4 * sizeof(unsigned char);
98 #else
99  static const unsigned int COLOR_ATTRIBUTE_SIZE = sizeof(unsigned int);
100 #endif
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);
105 
106  class TypeDesc
107  {
108  bool hasNormal; // True if vertices have normals (float[3])
109  bool hasColor; // True if vertices have color (UINT32)
110  bool hasSecondaryColor; // True if vertices have secondary color (UINT32)
111 #ifdef GLES
112  unsigned int normalType; // GL_FLOAT or GL_UNSIGNED_BYTE
113  unsigned int texCoordType; // GL_FLOAT or GL_SHORT
114 #endif
115 
116  unsigned char numTextureCoords; // Number of texture coordinates per vertex [0-MAX_TEXTURE_COORDS]
117  unsigned char texCoordDimension[GlsGeometryResource::MAX_TEXTURE_COORDS]; // Number of components for each texture coordinate
118  unsigned char numVertexAttribs; // Number of generic vertex attributes per vertex [0-MAX_VERTEX_ATTRIBS]
119  GLint vertexAttribNumComponents[GlsGeometryResource::MAX_VERTEX_ATTRIBS]; // Number of components in the generic vertex attribute
120  GLenum vertexAttribType[GlsGeometryResource::MAX_VERTEX_ATTRIBS]; // Specifies the type of each vertex attribute
121  GLboolean vertexAttribNormalize[GlsGeometryResource::MAX_VERTEX_ATTRIBS]; // Specifies whether fixed-point data values should be normalized (GL_TRUE) or converted directly as fixed-point values (GL_FALSE) when they are accessed.
122  unsigned int vertexAttribSemantic[GlsGeometryResource::MAX_VERTEX_ATTRIBS]; // Semantic for each vertex attribute
123  public:
124 
125  // Default constructor
126  TypeDesc()
127  {
128  memset(this, 0, sizeof(TypeDesc));
129  unsigned int i;
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; }
134 #ifdef GLES
135  normalType = GL_FLOAT;
136  texCoordType = GL_FLOAT;
137 #endif
138  }
139 
140  void HasNormal(bool value) { hasNormal = value; }
141  bool HasNormal(void) const { return hasNormal; }
142 
143 #ifdef GLES
144  void NormalType(unsigned int value) { normalType = value; }
145 
146  unsigned int NormalType(void) const { return normalType; }
147 
148  void TexCoordType(unsigned int value) { texCoordType = value; }
149  unsigned int TexCoordType(void) const { return texCoordType; }
150 #endif
151 
152  void HasColor(bool value) { hasColor = value; }
153  bool HasColor(void) const { return hasColor; }
154 
155  void HasSecondaryColor(bool value) { hasSecondaryColor = value; }
156  bool HasSecondaryColor(void) const { return hasSecondaryColor; }
157 
158  void SetNumTextureCoords(unsigned char value)
159  {
160  if (value <= GlsGeometryResource::MAX_TEXTURE_COORDS)
161  numTextureCoords = value;
162  }
163  unsigned char GetNumTextureCoords(void) const { return numTextureCoords; }
164 
165  void SetTexCoordDimension(unsigned char which, unsigned char value)
166  {
167  if (which < GlsGeometryResource::MAX_TEXTURE_COORDS &&
168  value > 0 && value < 5)
169  texCoordDimension[which] = value;
170  }
171  unsigned char GetTexCoordDimension(unsigned char which) const { return texCoordDimension[which]; }
172 
173  /** Set the number of generic vertex attributes stored in the resource.
174  Generic vertex attributes are passed to OpenGL using glVertexAttribPointer.
175  These are special attributes to be used by the vertex shader.
176 
177  \param value The new number of generic vertex attributes
178  \sa SetVertexAttribSizeBytes
179  */
180  void SetNumVertexAttribs(unsigned char value)
181  {
182  if (value <= GlsGeometryResource::MAX_VERTEX_ATTRIBS)
183  numVertexAttribs = value;
184  }
185  unsigned char GetNumVertexAttribs(void) const { return numVertexAttribs; }
186 
187  /// Set the size (number of components) in the generic vertex attribute
188  /// See documentation on glVertexAttribPointer for details
189  void SetVertexAttribComponents(unsigned char which, GLint value)
190  {
191  if (which < GlsGeometryResource::MAX_VERTEX_ATTRIBS &&
192  value > 0 && value < 5)
193  vertexAttribNumComponents[which] = value;
194  }
195  GLint GetVertexAttribComponents(unsigned char which) const { return vertexAttribNumComponents[which]; }
196 
197  /// Set the type of a given generic vertex attribute
198  /// See documentation on glVertexAttribPointer for details
199  void SetVertexAttribType(unsigned char which, GLenum value)
200  {
201  if (which < GlsGeometryResource::MAX_VERTEX_ATTRIBS)
202  vertexAttribType[which] = value;
203  }
204  GLenum GetVertexAttribType(unsigned char which) const { return vertexAttribType[which]; }
205 
206  /// Set whether fixed-point data values should be normalized
207  /// (Default is false)
208  /// See documentation on glVertexAttribPointer for details
209  void SetVertexAttribNormalize(unsigned char which, GLboolean value)
210  {
211  if (which < GlsGeometryResource::MAX_VERTEX_ATTRIBS)
212  vertexAttribNormalize[which] = value;
213  }
214  GLboolean GetVertexAttribNormalize(unsigned char which) const { return vertexAttribNormalize[which]; }
215 
216  /// Set semantic of a given generic vertex attribute
217  /// The semantic value can be used to determine the "meaning" of the vertex attribute
218  /// \param which Which vertex attrib to set
219  /// \param semanticEnum The new sematic value (see AttributeSemanticEnum)
220  void SetVertexAttribSemantic(unsigned char which, int semanticEnum)
221  {
222  if (which < GlsGeometryResource::MAX_VERTEX_ATTRIBS)
223  vertexAttribSemantic[which] = semanticEnum;
224  }
225  int GetVertexAttribSemantic(unsigned char which) const { return vertexAttribSemantic[which]; }
226 
227  };
228 
229  typedef enum
230  {
231  // Something that we can initialize the Resource ID to
232  // and then check for to see if we have initialized
233  // the resource.
234  BAD_ID = 0xffffffff
235  } BadId;
236 
237  virtual ~GlsGeometryResource() {}
238 
239 protected:
240  /** Give this Resource a unique id so we can get it. */
241  unsigned int _resourceID;
242 
243  /** The number of Parent Objects using this object. Once the number reaches zero, the object self deletes. */
244  unsigned int _referenceCount;
245 
246  /** The TypeDesc that describes what is in this Resource */
248 
249  /** The number of index buffers in this mesh */
250  unsigned int _numIndexBuffers;
251 
252  // Bounding volume information
253  Vector _boundingVolumeCenter;
254  float _boundingVolumeRadius;
255 
256  // Shared between all instances
257  static bool _enableVBO; // If the OpenGL Context is version 1.5 or greater
258 
259  /** Deletes this object from the heap that it was allocated on */
260  virtual void Destroy() = 0;
261 
262 public:
263 
264  /** When enabled, GlsGeometryResource::CreateInstance will instantiate GlsGeometry_HalfFloat objects when possible. */
265  static GLSGEN_GlsGeometryResource_EXPORT void SetCreateInstanceMakesHalfFloat(bool value);
266 
267  /** Construct an empty GlsGeometryResource with the given type
268  The initial reference count is 1.
269  Call DecrementReference to free the resource when you are done with it.
270  \param type A description of the initial Structure
271  */
272  static GLSGEN_GlsGeometryResource_EXPORT GlsGeometryResource* CreateInstance(const TypeDesc& type = GlsGeometryResource::TypeDesc());
273 
274  /** Construct a GlsGeometryResource from a binary resource
275  The initial reference count is 1.
276  Call DecrementReference to free the GlsGeometryResource when you are done with it.
277  \param resource pointer to a ResourceRef containing geometry data
278  */
279  static GLSGEN_GlsGeometryResource_EXPORT GlsGeometryResource* CreateInstance(GlsResourceFileMgr::ResourceRef* resource);
280 
281  /** Setup the OpenGL state for rendering this geometry.
282  To draw, call DrawIndexBuffer for each index buffer in the resource.
283  After drawing, call DrawCleanup to restore the OpenGL state.
284  \param shaderProgram interface to the shader program, used to lookup correct VertexAttrib index values (may be NULL)
285  \post The OpenGL state is configured for rendering from the index buffers.
286  */
287  virtual void DrawSetup(VertexAttribIndexLookup* shaderProgram) = 0;
288 
289  /** Draw the geometry specified by the given index buffer
290  This method should only be called between calls to DrawSetup
291  and DrawCleanup.
292  \pre DrawSetup has been called.
293  \param bufferNumber Which index buffer to draw
294  */
295  virtual void DrawIndexBuffer(unsigned int bufferNumber) = 0;
296 
297  /** Restore the OpenGL state after rendering.
298  \param shaderProgram Must be the same value that was passed to DrawSetup
299  \pre DrawSetup was called
300  \post The OpenGL state will be restored
301  */
302  virtual void DrawCleanup(VertexAttribIndexLookup* shaderProgram) = 0;
303 
304  /** Force the GlsGeometryResource to free any buffers it has allocated in the current OpenGL context.
305  */
306  virtual void FreeOpenGLBuffers() = 0;
307 
308  /** Since calculating metrics like the extents can be an expensive operation, the user can call this
309  * function to see if the geometry resource has changed. Caching the expensive-to-calculate values
310  * is the responsibility of the caller.
311  * \return The current extents ID. Never equal to s_invalidDataChangedCounter.
312  * \sa s_invalidDataChangedCounter
313  */
314  virtual unsigned int GetDataChangedCounter() const = 0;
315 
316  /** A sentinel value for clients to initialize their counts with. GetDataChangedCounter() will never return this value. */
317  static const unsigned int s_invalidDataChangedCounter = 0;
318 
319  /** Calculate and return the geometry extents
320  * \param min Returns the minimum x,y,z values
321  * \param max Returns the maximum x,y,z values
322  * \param matrix (Optional) matrix to transform the vertices into the desired coordinate system
323  * \note This can be an expensive operation. GetDataChangedCounter() can be used to minimize this expense.
324  * \sa GetDataChangedCounter()
325  */
326  virtual void GetExtents(Vector& min, Vector& max, const GlsMatrixType* matrix = NULL ) = 0;
327 
328  /** Updates the bounding volume of this object
329  * This method should be called if the vertices change for picking and
330  * culling to work correctly.
331  * \note This can be an expensive operation. GetDataChangedCounter() can be used to minimize this expense.
332  * \sa GetDataChangedCounter()
333  */
334  virtual void UpdateBoundingVolume() = 0;
335 
336  /** Determines if the given ray hits the geometry bounding volume.
337  * Note: All parameters should be in this object's coordinates.
338  * @param point The starting point of the ray.
339  * @param direction The direction vector of the ray.
340  * @return True if this bounding volume is hit by the ray.
341  */
342  virtual bool BoundingVolumeHit(const Vector& point, const Vector& direction) = 0;
343 
344  /** Hit test the geometry against a picking line. All values are in geometry space.
345  * \param pickType The type of picking (see PickableType_e), must be PICK_FIRST or PICK_BEST
346  * \param pickLinePoint A point on the pick line.
347  * \param pickLineDirection The direction of the pick line.
348  * \param collisionPoint If the method returns true, this contains the point that was hit.
349  * \return true if the object was hit by the pick.
350  */
351  virtual bool HitTest(unsigned char pickType, const Vector& pickLinePoint, const Vector& pickLineDirection, Vector& collisionPoint) = 0;
352 
353 
354  /** Returns vertex count for use in editor statistics */
355  virtual unsigned int StatsIndexBufferVertexCount(unsigned int bufferNumber) = 0;
356 
357  /** Returns polygon count for use in editor statistics */
358  virtual unsigned int StatsIndexBufferPolygonCount(unsigned int bufferNumber) = 0;
359 
360 
361 
362  /** Returns the TypeDesc for this resource */
363  GLSGEN_GlsGeometryResource_EXPORT const TypeDesc& Type() { return _type; }
364 
365  /** Increment the Reference count to this instance. */
366  GLSGEN_GlsGeometryResource_EXPORT void IncrementReference() { _referenceCount++; }
367 
368  /** Decrement the Reference count to this instance.
369  * \note The OpenGL context should be available to free resources.
370  */
371  GLSGEN_GlsGeometryResource_EXPORT void DecrementReference()
372  {
373  DistiAssert(_referenceCount > 0);
374 
375  _referenceCount--;
376 
377  if (_referenceCount == 0)
378  {
379  Destroy();
380  }
381  }
382 
383  /** Returns The number of index buffers in this geometry resource. */
384  unsigned int NumIndexBuffers() const
385  {
386  return _numIndexBuffers;
387  }
388 
389  /** Get the bounding sphere center */
390  const Vector& BoundingVolumeCenter() const { return _boundingVolumeCenter; }
391 
392  /** Get the bounding sphere radius */
393  float BoundingVolumeRadius() const { return _boundingVolumeRadius; }
394 
395  /** Sets a new resource ID
396  * \param id The new ID
397  * \pre id != BAD_ID
398  */
399  GLSGEN_GlsGeometryResource_EXPORT void SetResourceId(unsigned int id)
400  {
401  assert(BAD_ID != id);
402  _resourceID = id;
403  }
404 
405  /** Gets the current resource ID
406  * \pre _resourceID != BAD_ID
407  */
408  GLSGEN_GlsGeometryResource_EXPORT unsigned int GetResourceId(void)
409  {
410  assert(BAD_ID != _resourceID);
411  return _resourceID;
412  }
413 };
414 
415 
416 /** Forward declaration */
417 class GlsGeometry_Generic_IndexBufferData;
418 /** Flexible implementation of GlsGeometryResource that can store any type of geometry
419  * 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.
420  */
422 {
423 public:
424 
425  ////////////////////////////////
426  //
427  // GlsGeometryResource methods
428  //
429  ////////////////////////////////
430 
431  // See base class
432  virtual GLSGEN_GlsGeometryResource_EXPORT unsigned int StatsIndexBufferVertexCount(unsigned int bufferNumber)
433  {
434  return GetIndexBufferSize(bufferNumber) / 3;
435  }
436 
437  // See base class
438  virtual GLSGEN_GlsGeometryResource_EXPORT unsigned int StatsIndexBufferPolygonCount(unsigned int bufferNumber)
439  {
440  return GetIndexBufferSize(bufferNumber);
441  }
442 
443  // See base class
444  virtual GLSGEN_GlsGeometryResource_EXPORT unsigned int GetDataChangedCounter() const;
445 
446  // See base class
447  virtual GLSGEN_GlsGeometryResource_EXPORT void GetExtents(Vector& min, Vector& max, const GlsMatrixType* matrix = NULL);
448 
449  // See base class
450  virtual GLSGEN_GlsGeometryResource_EXPORT void UpdateBoundingVolume(void);
451 
452  // See base class
453  virtual GLSGEN_GlsGeometryResource_EXPORT bool BoundingVolumeHit(const Vector& point, const Vector& direction);
454 
455  // See base class
456  virtual GLSGEN_GlsGeometryResource_EXPORT bool HitTest(unsigned char pickType, const Vector& pickLinePoint, const Vector& pickLineDirection, Vector& collisionPoint);
457 
458  // See base class
459  virtual GLSGEN_GlsGeometryResource_EXPORT void DrawSetup(VertexAttribIndexLookup* shaderProgram);
460 
461  // See base class
462  virtual GLSGEN_GlsGeometryResource_EXPORT void DrawIndexBuffer(unsigned int bufferNumber);
463 
464  // See base class
465  virtual GLSGEN_GlsGeometryResource_EXPORT void DrawCleanup(VertexAttribIndexLookup* shaderProgram);
466 
467 
468  // See base class
469  virtual GLSGEN_GlsGeometryResource_EXPORT void FreeOpenGLBuffers();
470 
471 
472 
473  ////////////////////////////////
474  //
475  // GlsGeometry_Generic methods
476  //
477  ////////////////////////////////
478 
479  /** Create GlsGeometry_Generic from TypeDesc */
480  static GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic* CreateInstance(const TypeDesc& type);
481 
482  /** Construct a GlsGeometryResource from a binary resource
483  The initial reference count is 1.
484  Call DecrementReference to free the GlsGeometryResource when you are done with it.
485  \param resource pointer to a ResourceRef containing geometry data
486  */
487  static GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic* CreateInstance(GlsResourceFileMgr::ResourceRef* resource);
488 
489  /** Create GlsGeometry_Generic from binary resource */
490  static GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic* CreateFromBinaryResource( GlsResourceFileMgr::BinaryResource* data );
491 
492  /** Create an empty GlsGeometry_Generic with default TypeDesc */
493  static GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic* CreateEmptyInstance();
494 
495  /** Copy the geometry from another resource into this one.
496  Does not change the Type of this resource: only vertex attributes that both resources have in common will be copied.
497  \param rhs the resource to copy from
498  */
499  GLSGEN_GlsGeometryResource_EXPORT void CopyVertexAndIndexBuffers(GlsGeometry_Generic* rhs);
500 
501  /** Changes the Type of this geometry resource.
502  This is a slow operation; it creates new storage according to the typeDesc and copys the existing vertex data.
503  If a vertex attribute does not map to the new type it will be lost. Any new attributes will be uninitialized.
504  Requires that the OpenGL context is current if this GlsGeometryResource has been previously drawn.
505 
506  \param type The TypeDesc to use for the new structure
507  */
508  GLSGEN_GlsGeometryResource_EXPORT void ChangeType(const TypeDesc& type);
509 
510  /** Attempt to Lock the Buffers, Non-Blocking
511  \return True if a lock is posible
512  */
513  GLSGEN_GlsGeometryResource_EXPORT bool LockBuffers();
514 
515  /** Release the lock on the buffers.
516  Note: If the Vertex data was changed, you should typically call UpdateBoundingVolume() before unlocking.
517  \see UpdateBoundingVolume
518  \post If the buffer is not locked a debug message is sent to the terminal
519  */
520  GLSGEN_GlsGeometryResource_EXPORT void UnlockBuffers();
521 
522  /** Get the size of the vertex buffer
523  \return The number of items in the vertex buffer
524  */
525  GLSGEN_GlsGeometryResource_EXPORT unsigned int VertexCount() const;
526 
527  /** Set the size of the vertex buffer
528  \param count How many items the Vertex Buffer contains.
529  \pre size must be greater than zero
530  */
531  GLSGEN_GlsGeometryResource_EXPORT void VertexCount(unsigned int count);
532 
533  /** Set a vertex
534  \param vertIndex The index of the vertex to change, 0 to VertexCount() - 1
535  \param *value Vertex can either be 3 or 4 floats depending on the type
536  \pre vertex must be a pointer to 3 or 4 floats, vertIndex must be less than VertexCount()
537  */
538  GLSGEN_GlsGeometryResource_EXPORT void SetVertex(GLuint vertIndex, const float *value);
539 
540  void SetVertex(GLuint vertIndex, const Vector *value) { SetVertex(vertIndex, (float*)value); }
541 
542  /** Initialize the vertex data from an array of floats.
543 
544  Steps through the array reading the data for each vertex. If Type() is POSITION_XYZ, the method will read 3 floats per vertex.
545  If Type() is POSITION_XYZW, the method will read 4 floats per vertex.
546 
547  \param floatArray Pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
548  \param numVertices Number of vertices to read from of the array
549  \param startVertIndex (optional) The vertex buffer index to start copying into
550  \param stride (optional) The distance between each vertex in the floatArray (in bytes)
551  */
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);
556 
557  /** Set the vertex at a given index to a coordinate
558  \param vertIndex The index of the vertex to change, 0 to VertexCount() - 1
559  \param x The x-coord
560  \param y The y-coord
561  \param z The z-coord
562  \pre vertex must be a pointer to 3 or 4 floats, vertIndex must be less than VertexCount()
563  */
564  GLSGEN_GlsGeometryResource_EXPORT void SetVertex(GLuint vertIndex,
565  float x,
566  float y,
567  float z);
568 
569  /** Return a pointer to an array of 3 or 4 floats which is the vertex
570  for the given index.
571 
572  \param vertIndex The index of the vertex to get, 0 to VertexCount() - 1
573  \return a pointer to a 3 or 4 float vertex
574  \pre vertIndex must be less than VertexCount()
575  */
576  GLSGEN_GlsGeometryResource_EXPORT const float* GetVertex(GLuint vertIndex);
577 
578  /** Set a Normal
579  \param vertIndex The index of the vertex to change, 0 to VertexCount() - 1
580  \param x X Normal value to assign
581  \param y Y Normal value to assign
582  \param z Z Normal value to assign
583  \pre normal must be a valid Vector, vertIndex must be less than VertexCount()
584  NORMAL must be part of the Type
585  */
586  GLSGEN_GlsGeometryResource_EXPORT void SetNormal(GLuint vertIndex, float x, float y, float z);
587 
588  /** Initialize the vertex normals from an array of floats.
589 
590  Steps through the array reading the normal data for each vertex. The method will read 3 floats for each normal.
591 
592  \param floatArray Pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
593  \param numVertices Number of vertices to read from of the array
594  \param startVertIndex (optional) The vertex buffer index to start copying into
595  \param stride (optional) The distance between each normal in the floatArray (in bytes)
596  */
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);
601 
602  /** Get a pointer to the Normal for a given Vertex index. Do
603  not change the Normal, change it through the Set function!
604  \param vertIndex The index of the Normal to get, 0 to VertexCount() - 1
605  \return a pointer to an array of 3 floats.
606  \pre vertIndex must be less than VertexCount()
607  NORMAL must be part of the Type
608  */
609  GLSGEN_GlsGeometryResource_EXPORT const float * GetNormal(GLuint vertIndex);
610 
611  /** Set a color value
612  \param vertIndex The index of the color value to change, 0 to VertexCount() - 1
613  \param red Red
614  \param green Green
615  \param blue Blue
616  \param alpha Alpha
617  */
618  GLSGEN_GlsGeometryResource_EXPORT void SetColor(GLuint vertIndex,
619  unsigned char red,
620  unsigned char green,
621  unsigned char blue,
622  unsigned char alpha);
623 
624  /** Initialize the vertex colors from an array of unsigned int containing rgba color data.
625 
626  Steps through the array reading the color data for each vertex. The method will read 1 integer for each color.
627 
628  \param rgbaArray pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
629  \param numVertices Number of vertices to read from of the array
630  \param startVertIndex (optional) The vertex buffer index to start copying into
631  \param stride (optional) The distance between each color in the rgbaArray (in bytes)
632  */
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);
637 
638  /** Initialize Color from an array
639  \param array an array of color values in RGBA order of size VertexCount()
640  \pre The array must be of size VertexCount()
641  */
642  GLSGEN_GlsGeometryResource_EXPORT void SetColors(const unsigned int *array);
643 
644  /** Gets the color value of the given vertex index
645  \param vertIndex The index of the color value to get, 0 to VertexCount() - 1
646  \return a pointer to a color array in rgba order
647  \pre vertIndex must be less than VertexCount(),
648  */
649  GLSGEN_GlsGeometryResource_EXPORT unsigned char * GetColor(GLuint vertIndex);
650 
651  /** Set a secondary color value (specular)
652  \param red Red
653  \param green Green
654  \param blue Blue
655  \param vertIndex The index of the secondary color value to change, 0 to VertexCount() - 1
656  \pre vertIndex must be less than VertexCount()
657  */
658  GLSGEN_GlsGeometryResource_EXPORT void SetSecondaryColor(GLuint vertIndex,
659  unsigned char red,
660  unsigned char green,
661  unsigned char blue);
662 
663  /** Initialize the vertex secondary colors from an array of unsigned int containing rgb color data. (Secondary colors do not include alpha)
664 
665  Steps through the array reading the color data for each vertex. The method will read 3 bytes for each color.
666 
667  \param rgbArray pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
668  \param numVertices Number of vertices to read from of the array
669  \param startVertIndex (optional) The vertex buffer index to start copying into
670  \param stride (optional) The distance between each color in the array (in bytes)
671  */
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);
676 
677  /** Get the secondary color of the vertex at the given index.
678  \param vertIndex The index of the secondary color value to get, 0 to VertexCount() - 1
679  \return a pointer to a secondary color value in RGB order
680  \pre vertIndex must be less than VertexCount()
681  */
682  GLSGEN_GlsGeometryResource_EXPORT unsigned char * GetSecondaryColor(GLuint vertIndex);
683 
684 
685  /** Set a TextureCoord
686  \param textureCoord TextureCoord value to assign. Must point to a float array containing TextureCoordinateDepth() elements
687  \param vertIndex The index of the TextureCoord value to change, 0 to VertexCount() - 1
688  \param whichTexture Which set of texture coordinates to change, 0 to NumTextureCoordinateArrays() - 1.
689  \pre vertIndex must be less than VertexCount()
690  TEXCOORD must be part of the Type
691  whichTexture must be 0 to 7
692  */
693  GLSGEN_GlsGeometryResource_EXPORT void SetTextureCoord(GLuint vertIndex, unsigned int whichTexture,
694  const float *textureCoord);
695 
696  GLSGEN_GlsGeometryResource_EXPORT void SetTextureCoord(GLuint vertIndex, unsigned int whichTexture,
697  float textureCoordU,
698  float textureCoordV);
699 
700 #ifdef GLES
701  /** Sets all texture coordinates from a pointer of texture coordinate data
702 
703  \param whichTexture Which set of texture coordinates to change, 0 to NumTextureCoordinateArrays() - 1.
704  \param textureCoordArray Pointer to texture coordinate data to assign. Must point to a float array containing TextureCoordinateDepth() elements
705  \param numVertices The number of vertices worth of texture coordinate data in the array
706  \param startIndex (optional) The texture coord vertex element to start copying into
707  \param stride (optional) The distance between each texture coordinate in the array (in bytes)
708  */
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);
714 #endif
715 
716  /** Get a TextureCoord
717  \param vertIndex The index of the TextureCoord value to change, 0 to VertexCount() - 1
718  \param whichTexture Which set of texture coordinates to change, 0 to NumTextureCoordinateArrays() - 1.
719  \return Return a pointer to the Texture Coordinates ask for
720  \pre vertIndex must be less than VertexCount()
721  TEXCOORD must be part of the Type
722  textureCount must be 1 to 8
723  */
724  GLSGEN_GlsGeometryResource_EXPORT const float * GetTextureCoord(GLuint vertIndex, unsigned int whichTexture);
725 
726 
727  /** Store a generic vertex attribute value
728  \param vertIndex The index of the vertex
729  \param attribIndex The index of the generic vertex attribute to be modified
730  \param value void pointer to the value
731  \param sizeBytes size of the value in bytes
732  */
733  GLSGEN_GlsGeometryResource_EXPORT void StoreVertexAttrib(GLuint vertIndex, GLuint attribIndex, void* value, GLuint sizeBytes);
734 
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)); }
739 
740 #ifdef GLES
741  GLSGEN_GlsGeometryResource_EXPORT void SetVertexAttribs(const float* attribArray,
742 
743  GLuint attribIndex,
744  unsigned int numVertices,
745  unsigned int startVertIndex = 0,
746  unsigned int stride = TANGENT_ATTRIBUTE_SIZE);
747 #endif
748 
749  /** Get pointer to the raw vertex attribute data
750  Be careful with this!
751  \note This method may be removed in the future
752  \param vertIndex The index of the vertex
753  \param attribIndex The index of the generic vertex attribute
754  */
755  GLSGEN_GlsGeometryResource_EXPORT void* GetVertexAttrib(GLuint vertIndex, GLuint attribIndex);
756 
758 
759  /** Get the number of available index buffers
760  * \param count Set the number of index buffers in this geometry resource.
761  */
762  GLSGEN_GlsGeometryResource_EXPORT void NumIndexBuffers(unsigned int count);
763 
764  /** Gets the size of an index buffer
765  \param bufferNum Which index buffer to return the size of
766  \return The number of items that the given index buffer can hold
767  */
768  GLSGEN_GlsGeometryResource_EXPORT unsigned int GetIndexBufferSize(unsigned int bufferNum) const;
769 
770  /** Set the size of the specified index buffer
771  \param bufferNum Which index buffer to set the size of
772  \param newSize How many items the Index Buffer can hold.
773  \pre newSize must be greater than zero
774  */
775  GLSGEN_GlsGeometryResource_EXPORT void SetIndexBufferSize(unsigned int bufferNum, unsigned int newSize);
776 
777  /** Change the Vertex index
778  \param bufferNum Which index buffer to modify
779  \param index The index of the Index to change, 0 to GetIndexBufferSize(bufferNum)) - 1
780  \param indexValue Index must be less than GetIndexBufferSize(bufferNum)
781  */
782  GLSGEN_GlsGeometryResource_EXPORT void SetIndex(unsigned int bufferNum, unsigned int index, unsigned int indexValue);
783 
784 #ifndef GLES
785 
786  /** Initialize the Index buffer from an array of index values
787  *
788  * Steps through the array reading the color data for each vertex. The method will read 3 bytes for each color.
789  *
790  * \param bufferNum Which index buffer to modify
791  * \param indexArray pointer to the array to read from. The array must be at least (numIndices * stride) bytes.
792  * \param numIndices Number of indices to read from of the array
793  * \param startIndex (optional) The index buffer element to start copying into
794  * \param stride (optional) The distance between each index in the array (in bytes)
795  */
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));
801 
802  /** Gets an index from an index buffer
803  \param bufferNum Which index buffer to read from
804  \param index The index of the Index to get, 0 to GetIndexBufferSize(bufferNum) - 1
805  \return an Index value
806  \pre index must be less than GetIndexBufferSize(bufferNum)
807  */
808  GLSGEN_GlsGeometryResource_EXPORT unsigned int GetIndex(unsigned int bufferNum, unsigned int index);
809 
810  /** Merge two index buffers by adding the indexes from the source buffer to the dest buffer,
811  then deleting the source buffer.
812  \param dstBufferNum Which index buffer to add to
813  \param srcBufferNum Which index buffer to delete
814  \returns true on success, false if there was an error
815  */
816  GLSGEN_GlsGeometryResource_EXPORT void MergeIndexBuffers(unsigned int dstBufferNum, unsigned int srcBufferNum);
817 
818 #else // GLES
819 
820  /** Initialize the Index buffer from an array of index values
821 
822  Steps through the array reading the color data for each vertex. The method will read 3 bytes for each color.
823 
824  \param bufferNum Which index buffer to modify
825  \param indexArray pointer to the array to read from. The array must be at least (numIndices * stride) bytes.
826  \param numIndices Number of indices to read from of the array
827  \param startIndex (optional) The index buffer element to start copying into
828  \param stride (optional) The distance between each index in the array (in bytes)
829  */
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));
835 
836  /** Get an index from an index buffer
837  \param bufferNum Which index buffer to read from
838  \param index The index of the Index to get, 0 to GetIndexBufferSize(bufferNum) - 1
839  \return an Index value
840  \pre index must be less than GetIndexBufferSize(bufferNum)
841  */
842  GLSGEN_GlsGeometryResource_EXPORT unsigned short GetIndex(unsigned int bufferNum, unsigned short index);
843 
844 #endif // !GLES
845 
846  /** See GlsGeometryResource::VertexSort() */
847  typedef struct
848  {
849  unsigned int _order; // The order the vertex should be in
850  unsigned int _vertexTupleIndex;// The index of the primitive
851  } VertexSortData;
852 
853  /** Sort the vertices, based on the input data
854 
855  \param *sortData An array of VertexSortData structures, one for each primitive (set of three vertices).
856  The data in this is array is used to reorder the primitives. e.g.:
857  Input:
858  order 0,1,0,5,2
859  index 0,1,2,3,4
860  Sorted:
861  order 0,0,1,2,5
862  index 0,2,1,4,3
863 
864  \pre sortData must be an array of VertexSortData VertexCount()/3 in size
865 
866  \post The sortData array will be sorted based on _order.
867  The vertex buffer will be sorted based on the new order from the sortData.
868  */
869  GLSGEN_GlsGeometryResource_EXPORT void VertexSort(VertexSortData* sortData);
870 
871  /** Dump all the vertices to the terminal
872  */
873  GLSGEN_GlsGeometryResource_EXPORT void DumpVertices();
874 
875  /** Dump all the Normals to the terminal
876  */
877  GLSGEN_GlsGeometryResource_EXPORT void DumpNormals();
878 
879  /** Dump all the Indices to the terminal
880  */
881  GLSGEN_GlsGeometryResource_EXPORT void DumpIndices();
882 
883  /** Copy vertex attributes from srcGeom to dstGeom
884  Does not change the Type of the resource: only vertex attributes that both resources have in common will be copied.
885  \param dstGeom the resource to copy to
886  \param dstOffset vertex offset to start copying at
887  \param srcGeom the resource to copy from
888  \param srcOffset vertex offset to start copying from
889  \param vertexCount number of vertices to copy
890  \returns the number of vertices that were copied
891  */
892  static GLSGEN_GlsGeometryResource_EXPORT unsigned int CopyVertexData(
893  GlsGeometry_Generic* dstGeom, unsigned int dstOffset,
894  GlsGeometry_Generic* srcGeom, unsigned int srcOffset,
895  unsigned int vertexCount);
896 
897  /* Apply a transform to the vertex attributes of the given mesh
898  * The transform affects vertex position, normals, ATTRIB_TANGENT, and ATTRIB_BINORMAL
899  * \param dstGeom The resource to modify
900  * \param transform matrix used to convert vertex attributes
901  * \param vertexOffset start of the range of verts to transform
902  * \param vertexCount number of verts to transform
903  */
904  static GLSGEN_GlsGeometryResource_EXPORT unsigned int TransformVertexData(
905  GlsGeometry_Generic* dstGeom,
906  GlsMatrixType* transform,
907  unsigned int vertexOffset = 0,
908  unsigned int vertexCount = UINT_MAX);
909 
910  // Generate tangents/binormals for all vertices in the given
911  // GlsGeometryResource and adds them as vertex attributes.
912  static GLSGEN_GlsGeometryResource_EXPORT bool GenerateTangentsAndBinormals(GlsGeometry_Generic* geom);
913 
914  typedef struct
915  {
916  unsigned int _size; // Total size of each vertex (depends on which data are included)
917 
918  /** Offsets into the structure for the various data
919  */
920  unsigned int _normalStride;
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];
929 
930  static GLSGEN_GlsGeometryResource_EXPORT void SetVertexStructureFromTypeDesc( VertexStructureDefinition& vertStruct, const TypeDesc& type );
931 
932 
933 protected:
934 
935  bool _bufferLock;
936 
937  char *_vertexBuffer;
938  unsigned int _vertexBufferCount;
939  GLuint _vertexBufferID;
940  bool _vertexBufferUpdated; // Is the video card vertex buffer up to date?
941 
942  /** Index buffers array */
943  GlsGeometry_Generic_IndexBufferData *_indexBuffers;
944  //unsigned int _numIndexBuffers; // in base class for inlining
945 
946  VertexStructureDefinition _structure;
947 
948  GLSGEN_GlsGeometryResource_EXPORT void CopyVertexBufferOnly(GlsGeometry_Generic* rhs);
949 
950  /** Utility routine used by Hit. Performs a "BestHit" test, which performs a hit test on the object
951  * and guarantees that the collision point returned by Hit is the closest collision point to the observer.
952  * @param point The geometry coordinate of the click, relative to the object
953  * @param directionVector The direction of the pick vector
954  * @param collisionPoint Set to the point on the object hit by directionVector
955  * @return booleanean indicating if the object was hit by the mouse
956  */
957  GLSGEN_GlsGeometryResource_EXPORT bool BestHit(const Vector &point,const Vector& directionVector,Vector& collisionPoint);
958 
959  /** Utility routine used by Hit. Performs a "FirstHit" test, which performs a hit test on the object
960  * but does not guarantee that the collision point returned by Hit is the closest collision point
961  * to the observer
962  * @param point The logical coordinate of the click, relative to the object
963  * @param directionVector The direction of the pick vector
964  * @param collisionPoint Set to the point on the object hit by directionVector
965  * @return boolean indicating if the object was hit
966  */
967  GLSGEN_GlsGeometryResource_EXPORT bool FirstHit(const Vector &point,const Vector& directionVector,Vector& collisionPoint);
968 
969  void InitializeMembers();
970 
971  void InitFromBinaryResource( GlsResourceFileMgr::BinaryResource* resource );
972 
973  unsigned int GetTexcoordByteOffset( unsigned int whichTexture );
974 
975  GLSGEN_GlsGeometryResource_EXPORT void Destroy();
976 
977 private:
978 
979  // Member data
980  unsigned int _dataChangedCounter;
981 
982  /** Should be called when any data changes. Used to optimize calls like GetExtents(). */
983  void IncDataChangedCounter()
984  {
985  // If we hit the invalid ID, skip past it.
986  if( ++_dataChangedCounter == s_invalidDataChangedCounter )
987  {
988  ++_dataChangedCounter;
989  }
990  }
991 
992  /** Private Constructor: Use CreateInstance methods */
993  GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic();
994 
995  /** Private Destructor: Use DecrementReference to delete the object*/
996  GLSGEN_GlsGeometryResource_EXPORT ~GlsGeometry_Generic();
997 
998  // Disable implicit generated Members
999  GlsGeometry_Generic( const GlsGeometry_Generic &src );
1000  GlsGeometry_Generic& operator=( const GlsGeometry_Generic &rhs );
1001 };
1002 
1003 }
1004 
1005 #endif
1006 
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
Definition: vertex.h:84
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 Destroy()=0
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.
The gls_gl.