GL Studio C++ Runtime 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) 2017 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 "disti_assert.h"
61 #include "gls_matrix_affine.h"
62 #include "gls_render_effect.h"
63 #include "gls_resource_file_mgr.h"
64 #include "vertex.h"
65 
66 //////////////////// Provides support for creating DLLs ////////////////////////
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 )
71 # else
72 # define GLSGEN_GlsGeometryResource_EXPORT __declspec( dllimport )
73 # endif
74 #else
75 # define GLSGEN_GlsGeometryResource_EXPORT
76 #endif
77 ///////////////////////////////////////////////////////////////////////////////
78 
79 namespace disti
80 {
81 /** The geometry resource abstract base class */
83 {
84 public:
85  static const unsigned int MAX_TEXTURE_COORDS = 2; // GL_MAX_TEXTURE_COORDS. GlsGeometryResource currently only supports two sets of texture coordinates
86  static const unsigned int MAX_VERTEX_ATTRIBS = 16; // GL_MAX_VERTEX_ATTRIBS
87 
88  /** The sizes of various vertex attributes, in bytes. */
89  static const unsigned int VERTEX_ATTRIBUTE_SIZE = 3 * sizeof( float );
90  static const unsigned int NORMAL_ATTRIBUTE_SIZE = 3 * sizeof( float );
91 #ifdef GLES
92  static const unsigned int COLOR_ATTRIBUTE_SIZE = 4 * sizeof( unsigned char );
93 #else
94  static const unsigned int COLOR_ATTRIBUTE_SIZE = sizeof( unsigned int );
95 #endif
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 );
100 
101  class TypeDesc
102  {
103  bool hasNormal; // True if vertices have normals (float[3])
104  bool hasColor; // True if vertices have color (UINT32)
105  bool hasSecondaryColor; // True if vertices have secondary color (UINT32)
106 #ifdef GLES
107  unsigned int normalType; // GL_FLOAT or GL_UNSIGNED_BYTE
108  unsigned int texCoordType; // GL_FLOAT or GL_SHORT
109 #endif
110 
111  unsigned char numTextureCoords; // Number of texture coordinates per vertex [0-MAX_TEXTURE_COORDS]
112  unsigned char texCoordDimension[ GlsGeometryResource::MAX_TEXTURE_COORDS ]; // Number of components for each texture coordinate
113  unsigned char numVertexAttribs; // Number of generic vertex attributes per vertex [0-MAX_VERTEX_ATTRIBS]
114  GLint vertexAttribNumComponents[ GlsGeometryResource::MAX_VERTEX_ATTRIBS ]; // Number of components in the generic vertex attribute
115  GLenum vertexAttribType[ GlsGeometryResource::MAX_VERTEX_ATTRIBS ]; // Specifies the type of each vertex attribute
116  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.
117  unsigned int vertexAttribSemantic[ GlsGeometryResource::MAX_VERTEX_ATTRIBS ]; // Semantic for each vertex attribute
118  public:
119  // Default constructor
120  TypeDesc()
121  {
122  memset( this, 0, sizeof( TypeDesc ) );
123  unsigned int i;
124  for( i = 0; i < GlsGeometryResource::MAX_TEXTURE_COORDS; i++ )
125  {
126  texCoordDimension[ i ] = 2;
127  }
128  for( i = 0; i < GlsGeometryResource::MAX_VERTEX_ATTRIBS; i++ )
129  {
130  vertexAttribNumComponents[ i ] = 4;
131  }
132 #ifdef GLES
133  normalType = GL_FLOAT;
134  texCoordType = GL_FLOAT;
135 #endif
136  }
137 
138  void HasNormal( bool value ) { hasNormal = value; }
139  bool HasNormal( void ) const { return hasNormal; }
140 
141 #ifdef GLES
142  void NormalType( unsigned int value )
143  {
144  normalType = value;
145  }
146 
147  unsigned int NormalType( void ) const { return normalType; }
148 
149  void TexCoordType( unsigned int value ) { texCoordType = value; }
150  unsigned int TexCoordType( void ) const { return texCoordType; }
151 #endif
152 
153  void HasColor( bool value )
154  {
155  hasColor = value;
156  }
157  bool HasColor( void ) const { return hasColor; }
158 
159  void HasSecondaryColor( bool value ) { hasSecondaryColor = value; }
160  bool HasSecondaryColor( void ) const { return hasSecondaryColor; }
161 
162  void SetNumTextureCoords( unsigned char value )
163  {
164  if( value <= GlsGeometryResource::MAX_TEXTURE_COORDS )
165  numTextureCoords = value;
166  }
167  unsigned char GetNumTextureCoords( void ) const { return numTextureCoords; }
168 
169  void SetTexCoordDimension( unsigned char which, unsigned char value )
170  {
171  if( which < GlsGeometryResource::MAX_TEXTURE_COORDS && value > 0 && value < 5 )
172  texCoordDimension[ which ] = value;
173  }
174  unsigned char GetTexCoordDimension( unsigned char which ) const { return texCoordDimension[ which ]; }
175 
176  /** Set the number of generic vertex attributes stored in the resource.
177  Generic vertex attributes are passed to OpenGL using glVertexAttribPointer.
178  These are special attributes to be used by the vertex shader.
179 
180  \param value The new number of generic vertex attributes
181  \sa SetVertexAttribSizeBytes
182  */
183  void SetNumVertexAttribs( unsigned char value )
184  {
185  if( value <= GlsGeometryResource::MAX_VERTEX_ATTRIBS )
186  numVertexAttribs = value;
187  }
188  unsigned char GetNumVertexAttribs( void ) const { return numVertexAttribs; }
189 
190  /// Set the size (number of components) in the generic vertex attribute
191  /// See documentation on glVertexAttribPointer for details
192  void SetVertexAttribComponents( unsigned char which, GLint value )
193  {
194  if( which < GlsGeometryResource::MAX_VERTEX_ATTRIBS && value > 0 && value < 5 )
195  vertexAttribNumComponents[ which ] = value;
196  }
197  GLint GetVertexAttribComponents( unsigned char which ) const { return vertexAttribNumComponents[ which ]; }
198 
199  /// Set the type of a given generic vertex attribute
200  /// See documentation on glVertexAttribPointer for details
201  void SetVertexAttribType( unsigned char which, GLenum value )
202  {
203  if( which < GlsGeometryResource::MAX_VERTEX_ATTRIBS )
204  vertexAttribType[ which ] = value;
205  }
206  GLenum GetVertexAttribType( unsigned char which ) const { return vertexAttribType[ which ]; }
207 
208  /// Set whether fixed-point data values should be normalized
209  /// (Default is false)
210  /// See documentation on glVertexAttribPointer for details
211  void SetVertexAttribNormalize( unsigned char which, GLboolean value )
212  {
213  if( which < GlsGeometryResource::MAX_VERTEX_ATTRIBS )
214  vertexAttribNormalize[ which ] = value;
215  }
216  GLboolean GetVertexAttribNormalize( unsigned char which ) const { return vertexAttribNormalize[ which ]; }
217 
218  /// Set semantic of a given generic vertex attribute
219  /// The semantic value can be used to determine the "meaning" of the vertex attribute
220  /// \param which Which vertex attrib to set
221  /// \param semanticEnum The new sematic value (see AttributeSemanticEnum)
222  void SetVertexAttribSemantic( unsigned char which, int semanticEnum )
223  {
224  if( which < GlsGeometryResource::MAX_VERTEX_ATTRIBS )
225  vertexAttribSemantic[ which ] = semanticEnum;
226  }
227  int GetVertexAttribSemantic( unsigned char which ) const { return vertexAttribSemantic[ which ]; }
228  };
229 
230  typedef enum
231  {
232  // Something that we can initialize the Resource ID to
233  // and then check for to see if we have initialized
234  // the resource.
235  BAD_ID = 0xffffffff
236  } BadId;
237 
238  virtual ~GlsGeometryResource() {}
239 
240 protected:
241  /** Give this Resource a unique id so we can get it. */
242  unsigned int _resourceID;
243 
244  /** The number of Parent Objects using this object. Once the number reaches zero, the object self deletes. */
245  unsigned int _referenceCount;
246 
247  /** The TypeDesc that describes what is in this Resource */
249 
250  /** The number of index buffers in this mesh */
251  unsigned int _numIndexBuffers;
252 
253  // Bounding volume information
254  Vector _boundingVolumeCenter;
255  float _boundingVolumeRadius;
256 
257  // Shared between all instances
258  static bool _enableVBO; // If the OpenGL Context is version 1.5 or greater
259 
260  /** Deletes this object from the heap that it was allocated on */
261  virtual void Destroy() = 0;
262 
263 public:
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  /** Returns vertex count for use in editor statistics */
354  virtual unsigned int StatsIndexBufferVertexCount( unsigned int bufferNumber ) = 0;
355 
356  /** Returns polygon count for use in editor statistics */
357  virtual unsigned int StatsIndexBufferPolygonCount( unsigned int bufferNumber ) = 0;
358 
359  /** Returns the TypeDesc for this resource */
360  GLSGEN_GlsGeometryResource_EXPORT const TypeDesc& Type() { return _type; }
361 
362  /** Increment the Reference count to this instance. */
363  GLSGEN_GlsGeometryResource_EXPORT void IncrementReference() { _referenceCount++; }
364 
365  /** Decrement the Reference count to this instance.
366  * \note The OpenGL context should be available to free resources.
367  */
368  GLSGEN_GlsGeometryResource_EXPORT void DecrementReference()
369  {
370  DistiAssert( _referenceCount > 0 );
371 
372  _referenceCount--;
373 
374  if( _referenceCount == 0 )
375  {
376  Destroy();
377  }
378  }
379 
380  /** Returns The number of index buffers in this geometry resource. */
381  unsigned int NumIndexBuffers() const
382  {
383  return _numIndexBuffers;
384  }
385 
386  /** Get the bounding sphere center */
387  const Vector& BoundingVolumeCenter() const { return _boundingVolumeCenter; }
388 
389  /** Get the bounding sphere radius */
390  float BoundingVolumeRadius() const { return _boundingVolumeRadius; }
391 
392  /** Sets a new resource ID
393  * \param id The new ID
394  * \pre id != BAD_ID
395  */
396  GLSGEN_GlsGeometryResource_EXPORT void SetResourceId( unsigned int id )
397  {
398  assert( BAD_ID != id );
399  _resourceID = id;
400  }
401 
402  /** Gets the current resource ID
403  * \pre _resourceID != BAD_ID
404  */
405  GLSGEN_GlsGeometryResource_EXPORT unsigned int GetResourceId( void )
406  {
407  assert( BAD_ID != _resourceID );
408  return _resourceID;
409  }
410 };
411 
412 /** Forward declaration */
413 class GlsGeometry_Generic_IndexBufferData;
414 /** Flexible implementation of GlsGeometryResource that can store any type of geometry
415  * 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.
416  */
418 {
419 public:
420  ////////////////////////////////
421  //
422  // GlsGeometryResource methods
423  //
424  ////////////////////////////////
425 
426  // See base class
427  virtual GLSGEN_GlsGeometryResource_EXPORT unsigned int StatsIndexBufferVertexCount( unsigned int bufferNumber )
428  {
429  return GetIndexBufferSize( bufferNumber ) / 3;
430  }
431 
432  // See base class
433  virtual GLSGEN_GlsGeometryResource_EXPORT unsigned int StatsIndexBufferPolygonCount( unsigned int bufferNumber )
434  {
435  return GetIndexBufferSize( bufferNumber );
436  }
437 
438  // See base class
439  virtual GLSGEN_GlsGeometryResource_EXPORT unsigned int GetDataChangedCounter() const;
440 
441  // See base class
442  virtual GLSGEN_GlsGeometryResource_EXPORT void GetExtents( Vector& min, Vector& max, const GlsMatrixType* matrix = NULL );
443 
444  // See base class
445  virtual GLSGEN_GlsGeometryResource_EXPORT void UpdateBoundingVolume( void );
446 
447  // See base class
448  virtual GLSGEN_GlsGeometryResource_EXPORT bool BoundingVolumeHit( const Vector& point, const Vector& direction );
449 
450  // See base class
451  virtual GLSGEN_GlsGeometryResource_EXPORT bool HitTest( unsigned char pickType, const Vector& pickLinePoint, const Vector& pickLineDirection, Vector& collisionPoint );
452 
453  // See base class
454  virtual GLSGEN_GlsGeometryResource_EXPORT void DrawSetup( VertexAttribIndexLookup* shaderProgram );
455 
456  // See base class
457  virtual GLSGEN_GlsGeometryResource_EXPORT void DrawIndexBuffer( unsigned int bufferNumber );
458 
459  // See base class
460  virtual GLSGEN_GlsGeometryResource_EXPORT void DrawCleanup( VertexAttribIndexLookup* shaderProgram );
461 
462  // See base class
463  virtual GLSGEN_GlsGeometryResource_EXPORT void FreeOpenGLBuffers();
464 
465  ////////////////////////////////
466  //
467  // GlsGeometry_Generic methods
468  //
469  ////////////////////////////////
470 
471  /** Create GlsGeometry_Generic from TypeDesc */
472  static GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic* CreateInstance( const TypeDesc& type );
473 
474  /** Construct a GlsGeometryResource from a binary resource
475  The initial reference count is 1.
476  Call DecrementReference to free the GlsGeometryResource when you are done with it.
477  \param resource pointer to a ResourceRef containing geometry data
478  */
479  static GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic* CreateInstance( GlsResourceFileMgr::ResourceRef* resource );
480 
481  /** Create GlsGeometry_Generic from binary resource */
482  static GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic* CreateFromBinaryResource( GlsResourceFileMgr::BinaryResource* data );
483 
484  /** Create an empty GlsGeometry_Generic with default TypeDesc */
485  static GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic* CreateEmptyInstance();
486 
487  /** Copy the geometry from another resource into this one.
488  Does not change the Type of this resource: only vertex attributes that both resources have in common will be copied.
489  \param rhs the resource to copy from
490  */
491  GLSGEN_GlsGeometryResource_EXPORT void CopyVertexAndIndexBuffers( GlsGeometry_Generic* rhs );
492 
493  /** Changes the Type of this geometry resource.
494  This is a slow operation; it creates new storage according to the typeDesc and copys the existing vertex data.
495  If a vertex attribute does not map to the new type it will be lost. Any new attributes will be uninitialized.
496  Requires that the OpenGL context is current if this GlsGeometryResource has been previously drawn.
497 
498  \param type The TypeDesc to use for the new structure
499  */
500  GLSGEN_GlsGeometryResource_EXPORT void ChangeType( const TypeDesc& type );
501 
502  /** Attempt to Lock the Buffers, Non-Blocking
503  \return True if a lock is posible
504  */
505  GLSGEN_GlsGeometryResource_EXPORT bool LockBuffers();
506 
507  /** Release the lock on the buffers.
508  Note: If the Vertex data was changed, you should typically call UpdateBoundingVolume() before unlocking.
509  \see UpdateBoundingVolume
510  \post If the buffer is not locked a debug message is sent to the terminal
511  */
512  GLSGEN_GlsGeometryResource_EXPORT void UnlockBuffers();
513 
514  /** Get the size of the vertex buffer
515  \return The number of items in the vertex buffer
516  */
517  GLSGEN_GlsGeometryResource_EXPORT unsigned int VertexCount() const;
518 
519  /** Set the size of the vertex buffer
520  \param count How many items the Vertex Buffer contains.
521  \pre size must be greater than zero
522  */
523  GLSGEN_GlsGeometryResource_EXPORT void VertexCount( unsigned int count );
524 
525  /** Set a vertex
526  \param vertIndex The index of the vertex to change, 0 to VertexCount() - 1
527  \param *value Vertex can either be 3 or 4 floats depending on the type
528  \pre vertex must be a pointer to 3 or 4 floats, vertIndex must be less than VertexCount()
529  */
530  GLSGEN_GlsGeometryResource_EXPORT void SetVertex( GLuint vertIndex, const float* value );
531 
532  void SetVertex( GLuint vertIndex, const Vector* value ) { SetVertex( vertIndex, (float*)value ); }
533 
534  /** Initialize the vertex data from an array of floats.
535 
536  Steps through the array reading the data for each vertex. If Type() is POSITION_XYZ, the method will read 3 floats per vertex.
537  If Type() is POSITION_XYZW, the method will read 4 floats per vertex.
538 
539  \param floatArray Pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
540  \param numVertices Number of vertices to read from of the array
541  \param startVertIndex (optional) The vertex buffer index to start copying into
542  \param stride (optional) The distance between each vertex in the floatArray (in bytes)
543  */
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 );
548 
549  /** Set the vertex at a given index to a coordinate
550  \param vertIndex The index of the vertex to change, 0 to VertexCount() - 1
551  \param x The x-coord
552  \param y The y-coord
553  \param z The z-coord
554  \pre vertex must be a pointer to 3 or 4 floats, vertIndex must be less than VertexCount()
555  */
556  GLSGEN_GlsGeometryResource_EXPORT void SetVertex( GLuint vertIndex,
557  float x,
558  float y,
559  float z );
560 
561  /** Return a pointer to an array of 3 or 4 floats which is the vertex
562  for the given index.
563 
564  \param vertIndex The index of the vertex to get, 0 to VertexCount() - 1
565  \return a pointer to a 3 or 4 float vertex
566  \pre vertIndex must be less than VertexCount()
567  */
568  GLSGEN_GlsGeometryResource_EXPORT const float* GetVertex( GLuint vertIndex );
569 
570  /** Set a Normal
571  \param vertIndex The index of the vertex to change, 0 to VertexCount() - 1
572  \param x X Normal value to assign
573  \param y Y Normal value to assign
574  \param z Z Normal value to assign
575  \pre normal must be a valid Vector, vertIndex must be less than VertexCount()
576  NORMAL must be part of the Type
577  */
578  GLSGEN_GlsGeometryResource_EXPORT void SetNormal( GLuint vertIndex, float x, float y, float z );
579 
580  /** Initialize the vertex normals from an array of floats.
581 
582  Steps through the array reading the normal data for each vertex. The method will read 3 floats for each normal.
583 
584  \param floatArray Pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
585  \param numVertices Number of vertices to read from of the array
586  \param startVertIndex (optional) The vertex buffer index to start copying into
587  \param stride (optional) The distance between each normal in the floatArray (in bytes)
588  */
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 );
593 
594  /** Get a pointer to the Normal for a given Vertex index. Do
595  not change the Normal, change it through the Set function!
596  \param vertIndex The index of the Normal to get, 0 to VertexCount() - 1
597  \return a pointer to an array of 3 floats.
598  \pre vertIndex must be less than VertexCount()
599  NORMAL must be part of the Type
600  */
601  GLSGEN_GlsGeometryResource_EXPORT const float* GetNormal( GLuint vertIndex );
602 
603  /** Set a color value
604  \param vertIndex The index of the color value to change, 0 to VertexCount() - 1
605  \param red Red
606  \param green Green
607  \param blue Blue
608  \param alpha Alpha
609  */
610  GLSGEN_GlsGeometryResource_EXPORT void SetColor( GLuint vertIndex,
611  unsigned char red,
612  unsigned char green,
613  unsigned char blue,
614  unsigned char alpha );
615 
616  /** Initialize the vertex colors from an array of unsigned int containing rgba color data.
617 
618  Steps through the array reading the color data for each vertex. The method will read 1 integer for each color.
619 
620  \param rgbaArray pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
621  \param numVertices Number of vertices to read from of the array
622  \param startVertIndex (optional) The vertex buffer index to start copying into
623  \param stride (optional) The distance between each color in the rgbaArray (in bytes)
624  */
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 );
629 
630  /** Initialize Color from an array
631  \param array an array of color values in RGBA order of size VertexCount()
632  \pre The array must be of size VertexCount()
633  */
634  GLSGEN_GlsGeometryResource_EXPORT void SetColors( const unsigned int* array );
635 
636  /** Gets the color value of the given vertex index
637  \param vertIndex The index of the color value to get, 0 to VertexCount() - 1
638  \return a pointer to a color array in rgba order
639  \pre vertIndex must be less than VertexCount(),
640  */
641  GLSGEN_GlsGeometryResource_EXPORT unsigned char* GetColor( GLuint vertIndex );
642 
643  /** Set a secondary color value (specular)
644  \param red Red
645  \param green Green
646  \param blue Blue
647  \param vertIndex The index of the secondary color value to change, 0 to VertexCount() - 1
648  \pre vertIndex must be less than VertexCount()
649  */
650  GLSGEN_GlsGeometryResource_EXPORT void SetSecondaryColor( GLuint vertIndex,
651  unsigned char red,
652  unsigned char green,
653  unsigned char blue );
654 
655  /** Initialize the vertex secondary colors from an array of unsigned int containing rgb color data. (Secondary colors do not include alpha)
656 
657  Steps through the array reading the color data for each vertex. The method will read 3 bytes for each color.
658 
659  \param rgbArray pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
660  \param numVertices Number of vertices to read from of the array
661  \param startVertIndex (optional) The vertex buffer index to start copying into
662  \param stride (optional) The distance between each color in the array (in bytes)
663  */
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 );
668 
669  /** Get the secondary color of the vertex at the given index.
670  \param vertIndex The index of the secondary color value to get, 0 to VertexCount() - 1
671  \return a pointer to a secondary color value in RGB order
672  \pre vertIndex must be less than VertexCount()
673  */
674  GLSGEN_GlsGeometryResource_EXPORT unsigned char* GetSecondaryColor( GLuint vertIndex );
675 
676  /** Set a TextureCoord
677  \param textureCoord TextureCoord value to assign. Must point to a float array containing TextureCoordinateDepth() elements
678  \param vertIndex The index of the TextureCoord value to change, 0 to VertexCount() - 1
679  \param whichTexture Which set of texture coordinates to change, 0 to NumTextureCoordinateArrays() - 1.
680  \pre vertIndex must be less than VertexCount()
681  TEXCOORD must be part of the Type
682  whichTexture must be 0 to 7
683  */
684  GLSGEN_GlsGeometryResource_EXPORT void SetTextureCoord( GLuint vertIndex, unsigned int whichTexture,
685  const float* textureCoord );
686 
687  GLSGEN_GlsGeometryResource_EXPORT void SetTextureCoord( GLuint vertIndex, unsigned int whichTexture,
688  float textureCoordU,
689  float textureCoordV );
690 
691 #ifdef GLES
692  /** Sets all texture coordinates from a pointer of texture coordinate data
693 
694  \param whichTexture Which set of texture coordinates to change, 0 to NumTextureCoordinateArrays() - 1.
695  \param textureCoordArray Pointer to texture coordinate data to assign. Must point to a float array containing TextureCoordinateDepth() elements
696  \param numVertices The number of vertices worth of texture coordinate data in the array
697  \param startIndex (optional) The texture coord vertex element to start copying into
698  \param stride (optional) The distance between each texture coordinate in the array (in bytes)
699  */
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 );
705 #endif
706 
707  /** Get a TextureCoord
708  \param vertIndex The index of the TextureCoord value to change, 0 to VertexCount() - 1
709  \param whichTexture Which set of texture coordinates to change, 0 to NumTextureCoordinateArrays() - 1.
710  \return Return a pointer to the Texture Coordinates ask for
711  \pre vertIndex must be less than VertexCount()
712  TEXCOORD must be part of the Type
713  textureCount must be 1 to 8
714  */
715  GLSGEN_GlsGeometryResource_EXPORT const float* GetTextureCoord( GLuint vertIndex, unsigned int whichTexture );
716 
717  /** Store a generic vertex attribute value
718  \param vertIndex The index of the vertex
719  \param attribIndex The index of the generic vertex attribute to be modified
720  \param value void pointer to the value
721  \param sizeBytes size of the value in bytes
722  */
723  GLSGEN_GlsGeometryResource_EXPORT void StoreVertexAttrib( GLuint vertIndex, GLuint attribIndex, void* value, GLuint sizeBytes );
724 
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 ) ); }
729 
730 #ifdef GLES
731  GLSGEN_GlsGeometryResource_EXPORT void SetVertexAttribs( const float* attribArray,
732 
733  GLuint attribIndex,
734  unsigned int numVertices,
735  unsigned int startVertIndex = 0,
736  unsigned int stride = TANGENT_ATTRIBUTE_SIZE );
737 #endif
738 
739  /** Get pointer to the raw vertex attribute data
740  Be careful with this!
741  \note This method may be removed in the future
742  \param vertIndex The index of the vertex
743  \param attribIndex The index of the generic vertex attribute
744  */
745  GLSGEN_GlsGeometryResource_EXPORT void* GetVertexAttrib( GLuint vertIndex, GLuint attribIndex );
746 
748 
749  /** Get the number of available index buffers
750  * \param count Set the number of index buffers in this geometry resource.
751  */
752  GLSGEN_GlsGeometryResource_EXPORT void NumIndexBuffers( unsigned int count );
753 
754  /** Gets the size of an index buffer
755  \param bufferNum Which index buffer to return the size of
756  \return The number of items that the given index buffer can hold
757  */
758  GLSGEN_GlsGeometryResource_EXPORT unsigned int GetIndexBufferSize( unsigned int bufferNum ) const;
759 
760  /** Set the size of the specified index buffer
761  \param bufferNum Which index buffer to set the size of
762  \param newSize How many items the Index Buffer can hold.
763  \pre newSize must be greater than zero
764  */
765  GLSGEN_GlsGeometryResource_EXPORT void SetIndexBufferSize( unsigned int bufferNum, unsigned int newSize );
766 
767  /** Change the Vertex index
768  \param bufferNum Which index buffer to modify
769  \param index The index of the Index to change, 0 to GetIndexBufferSize(bufferNum)) - 1
770  \param indexValue Index must be less than GetIndexBufferSize(bufferNum)
771  */
772  GLSGEN_GlsGeometryResource_EXPORT void SetIndex( unsigned int bufferNum, unsigned int index, unsigned int indexValue );
773 
774 #ifndef GLES
775 
776  /** Initialize the Index buffer from an array of index values
777  *
778  * Steps through the array reading the color data for each vertex. The method will read 3 bytes for each color.
779  *
780  * \param bufferNum Which index buffer to modify
781  * \param indexArray pointer to the array to read from. The array must be at least (numIndices * stride) bytes.
782  * \param numIndices Number of indices to read from of the array
783  * \param startIndex (optional) The index buffer element to start copying into
784  * \param stride (optional) The distance between each index in the array (in bytes)
785  */
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 ) );
791 
792  /** Gets an index from an index buffer
793  \param bufferNum Which index buffer to read from
794  \param index The index of the Index to get, 0 to GetIndexBufferSize(bufferNum) - 1
795  \return an Index value
796  \pre index must be less than GetIndexBufferSize(bufferNum)
797  */
798  GLSGEN_GlsGeometryResource_EXPORT unsigned int GetIndex( unsigned int bufferNum, unsigned int index );
799 
800  /** Merge two index buffers by adding the indexes from the source buffer to the dest buffer,
801  then deleting the source buffer.
802  \param dstBufferNum Which index buffer to add to
803  \param srcBufferNum Which index buffer to delete
804  \returns true on success, false if there was an error
805  */
806  GLSGEN_GlsGeometryResource_EXPORT void MergeIndexBuffers( unsigned int dstBufferNum, unsigned int srcBufferNum );
807 
808 #else // GLES
809 
810  /** Initialize the Index buffer from an array of index values
811 
812  Steps through the array reading the color data for each vertex. The method will read 3 bytes for each color.
813 
814  \param bufferNum Which index buffer to modify
815  \param indexArray pointer to the array to read from. The array must be at least (numIndices * stride) bytes.
816  \param numIndices Number of indices to read from of the array
817  \param startIndex (optional) The index buffer element to start copying into
818  \param stride (optional) The distance between each index in the array (in bytes)
819  */
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 ) );
825 
826  /** Get an index from an index buffer
827  \param bufferNum Which index buffer to read from
828  \param index The index of the Index to get, 0 to GetIndexBufferSize(bufferNum) - 1
829  \return an Index value
830  \pre index must be less than GetIndexBufferSize(bufferNum)
831  */
832  GLSGEN_GlsGeometryResource_EXPORT unsigned short GetIndex( unsigned int bufferNum, unsigned short index );
833 
834 #endif // !GLES
835 
836  /** See GlsGeometryResource::VertexSort() */
837  typedef struct
838  {
839  unsigned int _order; // The order the vertex should be in
840  unsigned int _vertexTupleIndex; // The index of the primitive
841  } VertexSortData;
842 
843  /** Sort the vertices, based on the input data
844 
845  \param *sortData An array of VertexSortData structures, one for each primitive (set of three vertices).
846  The data in this is array is used to reorder the primitives. e.g.:
847  Input:
848  order 0,1,0,5,2
849  index 0,1,2,3,4
850  Sorted:
851  order 0,0,1,2,5
852  index 0,2,1,4,3
853 
854  \pre sortData must be an array of VertexSortData VertexCount()/3 in size
855 
856  \post The sortData array will be sorted based on _order.
857  The vertex buffer will be sorted based on the new order from the sortData.
858  */
859  GLSGEN_GlsGeometryResource_EXPORT void VertexSort( VertexSortData* sortData );
860 
861  /** Dump all the vertices to the terminal
862  */
863  GLSGEN_GlsGeometryResource_EXPORT void DumpVertices();
864 
865  /** Dump all the Normals to the terminal
866  */
867  GLSGEN_GlsGeometryResource_EXPORT void DumpNormals();
868 
869  /** Dump all the Indices to the terminal
870  */
871  GLSGEN_GlsGeometryResource_EXPORT void DumpIndices();
872 
873  /** Copy vertex attributes from srcGeom to dstGeom
874  Does not change the Type of the resource: only vertex attributes that both resources have in common will be copied.
875  \param dstGeom the resource to copy to
876  \param dstOffset vertex offset to start copying at
877  \param srcGeom the resource to copy from
878  \param srcOffset vertex offset to start copying from
879  \param vertexCount number of vertices to copy
880  \returns the number of vertices that were copied
881  */
882  static GLSGEN_GlsGeometryResource_EXPORT unsigned int CopyVertexData(
883  GlsGeometry_Generic* dstGeom, unsigned int dstOffset,
884  GlsGeometry_Generic* srcGeom, unsigned int srcOffset,
885  unsigned int vertexCount );
886 
887  /* Apply a transform to the vertex attributes of the given mesh
888  * The transform affects vertex position, normals, ATTRIB_TANGENT, and ATTRIB_BINORMAL
889  * \param dstGeom The resource to modify
890  * \param transform matrix used to convert vertex attributes
891  * \param vertexOffset start of the range of verts to transform
892  * \param vertexCount number of verts to transform
893  */
894  static GLSGEN_GlsGeometryResource_EXPORT unsigned int TransformVertexData(
895  GlsGeometry_Generic* dstGeom,
896  GlsMatrixType* transform,
897  unsigned int vertexOffset = 0,
898  unsigned int vertexCount = UINT_MAX );
899 
900  // Generate tangents/binormals for all vertices in the given
901  // GlsGeometryResource and adds them as vertex attributes.
902  static GLSGEN_GlsGeometryResource_EXPORT bool GenerateTangentsAndBinormals( GlsGeometry_Generic* geom );
903 
904  typedef struct
905  {
906  unsigned int _size; // Total size of each vertex (depends on which data are included)
907 
908  /** Offsets into the structure for the various data
909  */
910  unsigned int _normalStride;
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 ];
919 
920  static GLSGEN_GlsGeometryResource_EXPORT void SetVertexStructureFromTypeDesc( VertexStructureDefinition& vertStruct, const TypeDesc& type );
921 
922 protected:
923  bool _bufferLock;
924 
925  char* _vertexBuffer;
926  unsigned int _vertexBufferCount;
927  GLuint _vertexBufferID;
928  bool _vertexBufferUpdated; // Is the video card vertex buffer up to date?
929 
930  /** Index buffers array */
931  GlsGeometry_Generic_IndexBufferData* _indexBuffers;
932  //unsigned int _numIndexBuffers; // in base class for inlining
933 
934  VertexStructureDefinition _structure;
935 
936  GLSGEN_GlsGeometryResource_EXPORT void CopyVertexBufferOnly( GlsGeometry_Generic* rhs );
937 
938  /** Utility routine used by Hit. Performs a "BestHit" test, which performs a hit test on the object
939  * and guarantees that the collision point returned by Hit is the closest collision point to the observer.
940  * @param point The geometry coordinate of the click, relative to the object
941  * @param directionVector The direction of the pick vector
942  * @param collisionPoint Set to the point on the object hit by directionVector
943  * @return booleanean indicating if the object was hit by the mouse
944  */
945  GLSGEN_GlsGeometryResource_EXPORT bool BestHit( const Vector& point, const Vector& directionVector, Vector& collisionPoint );
946 
947  /** Utility routine used by Hit. Performs a "FirstHit" test, which performs a hit test on the object
948  * but does not guarantee that the collision point returned by Hit is the closest collision point
949  * to the observer
950  * @param point The logical coordinate of the click, relative to the object
951  * @param directionVector The direction of the pick vector
952  * @param collisionPoint Set to the point on the object hit by directionVector
953  * @return boolean indicating if the object was hit
954  */
955  GLSGEN_GlsGeometryResource_EXPORT bool FirstHit( const Vector& point, const Vector& directionVector, Vector& collisionPoint );
956 
957  void InitializeMembers();
958 
959  void InitFromBinaryResource( GlsResourceFileMgr::BinaryResource* resource );
960 
961  unsigned int GetTexcoordByteOffset( unsigned int whichTexture );
962 
963  GLSGEN_GlsGeometryResource_EXPORT void Destroy();
964 
965 private:
966  // Member data
967  unsigned int _dataChangedCounter;
968 
969  /** Should be called when any data changes. Used to optimize calls like GetExtents(). */
970  void IncDataChangedCounter()
971  {
972  // If we hit the invalid ID, skip past it.
973  if( ++_dataChangedCounter == s_invalidDataChangedCounter )
974  {
975  ++_dataChangedCounter;
976  }
977  }
978 
979  /** Private Constructor: Use CreateInstance methods */
980  GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic();
981 
982  /** Private Destructor: Use DecrementReference to delete the object*/
983  GLSGEN_GlsGeometryResource_EXPORT ~GlsGeometry_Generic();
984 
985  // Disable implicit generated Members
986  GlsGeometry_Generic( const GlsGeometry_Generic& src );
987  GlsGeometry_Generic& operator=( const GlsGeometry_Generic& rhs );
988 };
989 
990 } // namespace disti
991 
992 #endif
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
Definition: vertex.h:83
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 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:417
The disti::GlsRenderEffect class.
The gls_gl.