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  // The observer class is used for notifications when attributes that affect how the object would draw are changed
241  class Observer
242  {
243  public:
244  virtual void OnGeometryResourceChanged() = 0;
245 
246  protected:
247  Observer() {}
248  virtual ~Observer() {}
249 
250  private:
251  // Disable copying
252  Observer( const Observer& ) DISTI_SPECIAL_MEM_FUN_DELETE;
253  void operator=( const Observer& ) DISTI_SPECIAL_MEM_FUN_DELETE;
254  };
255 
256  void AddObserver( Observer* observer )
257  {
258  _observers.PushBack( observer );
259  }
260 
261  void RemoveObserver( Observer* observer )
262  {
263  _observers.Erase( observer );
264  }
265 
266 protected:
267  DynamicArray<Observer*> _observers;
268 
269  void OnGeometryResourceChanged()
270  {
271  for( unsigned int i = 0; i < _observers.Count(); ++i )
272  {
273  _observers[ i ]->OnGeometryResourceChanged();
274  }
275  }
276 
277  /** Give this Resource a unique id so we can get it. */
278  unsigned int _resourceID;
279 
280  /** The number of Parent Objects using this object. Once the number reaches zero, the object self deletes. */
281  unsigned int _referenceCount;
282 
283  /** The TypeDesc that describes what is in this Resource */
285 
286  /** The number of index buffers in this mesh */
287  unsigned int _numIndexBuffers;
288 
289  // Bounding volume information
290  Vector _boundingVolumeCenter;
291  float _boundingVolumeRadius;
292 
293  // Shared between all instances
294  static bool _enableVBO; // If the OpenGL Context is version 1.5 or greater
295 
296  /** Deletes this object from the heap that it was allocated on */
297  virtual void Destroy() = 0;
298 
299 public:
300  /** When enabled, GlsGeometryResource::CreateInstance will instantiate GlsGeometry_HalfFloat objects when possible. */
301  static GLSGEN_GlsGeometryResource_EXPORT void SetCreateInstanceMakesHalfFloat( bool value );
302 
303  /** Construct an empty GlsGeometryResource with the given type
304  The initial reference count is 1.
305  Call DecrementReference to free the resource when you are done with it.
306  \param type A description of the initial Structure
307  */
308  static GLSGEN_GlsGeometryResource_EXPORT GlsGeometryResource* CreateInstance( const TypeDesc& type = GlsGeometryResource::TypeDesc() );
309 
310  /** Construct a GlsGeometryResource from a binary resource
311  The initial reference count is 1.
312  Call DecrementReference to free the GlsGeometryResource when you are done with it.
313  \param resource pointer to a ResourceRef containing geometry data
314  */
315  static GLSGEN_GlsGeometryResource_EXPORT GlsGeometryResource* CreateInstance( GlsResourceFileMgr::ResourceRef* resource );
316 
317  /** Setup the OpenGL state for rendering this geometry.
318  To draw, call DrawIndexBuffer for each index buffer in the resource.
319  After drawing, call DrawCleanup to restore the OpenGL state.
320  \param shaderProgram interface to the shader program, used to lookup correct VertexAttrib index values (may be NULL)
321  \post The OpenGL state is configured for rendering from the index buffers.
322  */
323  virtual void DrawSetup( VertexAttribIndexLookup* shaderProgram ) = 0;
324 
325  /** Draw the geometry specified by the given index buffer
326  This method should only be called between calls to DrawSetup
327  and DrawCleanup.
328  \pre DrawSetup has been called.
329  \param bufferNumber Which index buffer to draw
330  */
331  virtual void DrawIndexBuffer( unsigned int bufferNumber ) = 0;
332 
333  /** Restore the OpenGL state after rendering.
334  \param shaderProgram Must be the same value that was passed to DrawSetup
335  \pre DrawSetup was called
336  \post The OpenGL state will be restored
337  */
338  virtual void DrawCleanup( VertexAttribIndexLookup* shaderProgram ) = 0;
339 
340  /** Force the GlsGeometryResource to free any buffers it has allocated in the current OpenGL context.
341  */
342  virtual void FreeOpenGLBuffers() = 0;
343 
344  /** Since calculating metrics like the extents can be an expensive operation, the user can call this
345  * function to see if the geometry resource has changed. Caching the expensive-to-calculate values
346  * is the responsibility of the caller.
347  * \return The current extents ID. Never equal to s_invalidDataChangedCounter.
348  * \sa s_invalidDataChangedCounter
349  */
350  virtual unsigned int GetDataChangedCounter() const = 0;
351 
352  /** A sentinel value for clients to initialize their counts with. GetDataChangedCounter() will never return this value. */
353  static const unsigned int s_invalidDataChangedCounter = 0;
354 
355  /** Calculate and return the geometry extents
356  * \param min Returns the minimum x,y,z values
357  * \param max Returns the maximum x,y,z values
358  * \param matrix (Optional) matrix to transform the vertices into the desired coordinate system
359  * \note This can be an expensive operation. GetDataChangedCounter() can be used to minimize this expense.
360  * \sa GetDataChangedCounter()
361  */
362  virtual void GetExtents( Vector& min, Vector& max, const GlsMatrixType* matrix = NULL ) = 0;
363 
364  /** Updates the bounding volume of this object
365  * This method should be called if the vertices change for picking and
366  * culling to work correctly.
367  * \note This can be an expensive operation. GetDataChangedCounter() can be used to minimize this expense.
368  * \sa GetDataChangedCounter()
369  */
370  virtual void UpdateBoundingVolume() = 0;
371 
372  /** Determines if the given ray hits the geometry bounding volume.
373  * Note: All parameters should be in this object's coordinates.
374  * @param point The starting point of the ray.
375  * @param direction The direction vector of the ray.
376  * @return True if this bounding volume is hit by the ray.
377  */
378  virtual bool BoundingVolumeHit( const Vector& point, const Vector& direction ) = 0;
379 
380  /** Hit test the geometry against a picking line. All values are in geometry space.
381  * \param pickType The type of picking (see PickableType_e), must be PICK_FIRST or PICK_BEST
382  * \param pickLinePoint A point on the pick line.
383  * \param pickLineDirection The direction of the pick line.
384  * \param collisionPoint If the method returns true, this contains the point that was hit.
385  * \return true if the object was hit by the pick.
386  */
387  virtual bool HitTest( unsigned char pickType, const Vector& pickLinePoint, const Vector& pickLineDirection, Vector& collisionPoint ) = 0;
388 
389  /** Returns vertex count for use in editor statistics */
390  virtual unsigned int StatsIndexBufferVertexCount( unsigned int bufferNumber ) = 0;
391 
392  /** Returns polygon count for use in editor statistics */
393  virtual unsigned int StatsIndexBufferPolygonCount( unsigned int bufferNumber ) = 0;
394 
395  /** Returns the TypeDesc for this resource */
396  GLSGEN_GlsGeometryResource_EXPORT const TypeDesc& Type() { return _type; }
397 
398  /** Increment the Reference count to this instance. */
399  GLSGEN_GlsGeometryResource_EXPORT void IncrementReference() { _referenceCount++; }
400 
401  /** Decrement the Reference count to this instance.
402  * \note The OpenGL context should be available to free resources.
403  */
404  GLSGEN_GlsGeometryResource_EXPORT void DecrementReference()
405  {
406  DistiAssert( _referenceCount > 0 );
407 
408  _referenceCount--;
409 
410  if( _referenceCount == 0 )
411  {
412  Destroy();
413  }
414  }
415 
416  /** Returns The number of index buffers in this geometry resource. */
417  unsigned int NumIndexBuffers() const
418  {
419  return _numIndexBuffers;
420  }
421 
422  /** Get the bounding sphere center */
423  const Vector& BoundingVolumeCenter() const { return _boundingVolumeCenter; }
424 
425  /** Get the bounding sphere radius */
426  float BoundingVolumeRadius() const { return _boundingVolumeRadius; }
427 
428  /** Sets a new resource ID
429  * \param id The new ID
430  * \pre id != BAD_ID
431  */
432  GLSGEN_GlsGeometryResource_EXPORT void SetResourceId( unsigned int id )
433  {
434  assert( BAD_ID != id );
435  _resourceID = id;
436  }
437 
438  /** Gets the current resource ID
439  * \pre _resourceID != BAD_ID
440  */
441  GLSGEN_GlsGeometryResource_EXPORT unsigned int GetResourceId( void )
442  {
443  assert( BAD_ID != _resourceID );
444  return _resourceID;
445  }
446 };
447 
448 /** Forward declaration */
449 class GlsGeometry_Generic_IndexBufferData;
450 /** Flexible implementation of GlsGeometryResource that can store any type of geometry
451  * 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.
452  */
454 {
455 public:
456  ////////////////////////////////
457  //
458  // GlsGeometryResource methods
459  //
460  ////////////////////////////////
461 
462  // See base class
463  virtual GLSGEN_GlsGeometryResource_EXPORT unsigned int StatsIndexBufferVertexCount( unsigned int bufferNumber )
464  {
465  return GetIndexBufferSize( bufferNumber ) / 3;
466  }
467 
468  // See base class
469  virtual GLSGEN_GlsGeometryResource_EXPORT unsigned int StatsIndexBufferPolygonCount( unsigned int bufferNumber )
470  {
471  return GetIndexBufferSize( bufferNumber );
472  }
473 
474  // See base class
475  virtual GLSGEN_GlsGeometryResource_EXPORT unsigned int GetDataChangedCounter() const;
476 
477  // See base class
478  virtual GLSGEN_GlsGeometryResource_EXPORT void GetExtents( Vector& min, Vector& max, const GlsMatrixType* matrix = NULL );
479 
480  // See base class
481  virtual GLSGEN_GlsGeometryResource_EXPORT void UpdateBoundingVolume( void );
482 
483  // See base class
484  virtual GLSGEN_GlsGeometryResource_EXPORT bool BoundingVolumeHit( const Vector& point, const Vector& direction );
485 
486  // See base class
487  virtual GLSGEN_GlsGeometryResource_EXPORT bool HitTest( unsigned char pickType, const Vector& pickLinePoint, const Vector& pickLineDirection, Vector& collisionPoint );
488 
489  // See base class
490  virtual GLSGEN_GlsGeometryResource_EXPORT void DrawSetup( VertexAttribIndexLookup* shaderProgram );
491 
492  // See base class
493  virtual GLSGEN_GlsGeometryResource_EXPORT void DrawIndexBuffer( unsigned int bufferNumber );
494 
495  // See base class
496  virtual GLSGEN_GlsGeometryResource_EXPORT void DrawCleanup( VertexAttribIndexLookup* shaderProgram );
497 
498  // See base class
499  virtual GLSGEN_GlsGeometryResource_EXPORT void FreeOpenGLBuffers();
500 
501  ////////////////////////////////
502  //
503  // GlsGeometry_Generic methods
504  //
505  ////////////////////////////////
506 
507  /** Create GlsGeometry_Generic from TypeDesc */
508  static GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic* CreateInstance( const TypeDesc& type );
509 
510  /** Construct a GlsGeometryResource from a binary resource
511  The initial reference count is 1.
512  Call DecrementReference to free the GlsGeometryResource when you are done with it.
513  \param resource pointer to a ResourceRef containing geometry data
514  */
515  static GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic* CreateInstance( GlsResourceFileMgr::ResourceRef* resource );
516 
517  /** Create GlsGeometry_Generic from binary resource */
518  static GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic* CreateFromBinaryResource( GlsResourceFileMgr::BinaryResource* data );
519 
520  /** Create an empty GlsGeometry_Generic with default TypeDesc */
521  static GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic* CreateEmptyInstance();
522 
523  /** Copy the geometry from another resource into this one.
524  Does not change the Type of this resource: only vertex attributes that both resources have in common will be copied.
525  \param rhs the resource to copy from
526  */
527  GLSGEN_GlsGeometryResource_EXPORT void CopyVertexAndIndexBuffers( GlsGeometry_Generic* rhs );
528 
529  /** Changes the Type of this geometry resource.
530  This is a slow operation; it creates new storage according to the typeDesc and copys the existing vertex data.
531  If a vertex attribute does not map to the new type it will be lost. Any new attributes will be uninitialized.
532  Requires that the OpenGL context is current if this GlsGeometryResource has been previously drawn.
533 
534  \param type The TypeDesc to use for the new structure
535  */
536  GLSGEN_GlsGeometryResource_EXPORT void ChangeType( const TypeDesc& type );
537 
538  /** Attempt to Lock the Buffers, Non-Blocking
539  \return True if a lock is posible
540  */
541  GLSGEN_GlsGeometryResource_EXPORT bool LockBuffers();
542 
543  /** Release the lock on the buffers.
544  Note: If the Vertex data was changed, you should typically call UpdateBoundingVolume() before unlocking.
545  \see UpdateBoundingVolume
546  \post If the buffer is not locked a debug message is sent to the terminal
547  */
548  GLSGEN_GlsGeometryResource_EXPORT void UnlockBuffers();
549 
550  /** Get the size of the vertex buffer
551  \return The number of items in the vertex buffer
552  */
553  GLSGEN_GlsGeometryResource_EXPORT unsigned int VertexCount() const;
554 
555  /** Set the size of the vertex buffer
556  \param count How many items the Vertex Buffer contains.
557  \pre size must be greater than zero
558  */
559  GLSGEN_GlsGeometryResource_EXPORT void VertexCount( unsigned int count );
560 
561  /** Set a vertex
562  \param vertIndex The index of the vertex to change, 0 to VertexCount() - 1
563  \param *value Vertex can either be 3 or 4 floats depending on the type
564  \pre vertex must be a pointer to 3 or 4 floats, vertIndex must be less than VertexCount()
565  */
566  GLSGEN_GlsGeometryResource_EXPORT void SetVertex( GLuint vertIndex, const float* value );
567 
568  void SetVertex( GLuint vertIndex, const Vector* value ) { SetVertex( vertIndex, (float*)value ); }
569 
570  /** Initialize the vertex data from an array of floats.
571 
572  Steps through the array reading the data for each vertex. If Type() is POSITION_XYZ, the method will read 3 floats per vertex.
573  If Type() is POSITION_XYZW, the method will read 4 floats per vertex.
574 
575  \param floatArray Pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
576  \param numVertices Number of vertices to read from of the array
577  \param startVertIndex (optional) The vertex buffer index to start copying into
578  \param stride (optional) The distance between each vertex in the floatArray (in bytes)
579  */
580  GLSGEN_GlsGeometryResource_EXPORT void SetVertices( const float* floatArray,
581  unsigned int numVertices,
582  unsigned int startVertIndex = 0,
583  unsigned int stride = VERTEX_ATTRIBUTE_SIZE );
584 
585  /** Set the vertex at a given index to a coordinate
586  \param vertIndex The index of the vertex to change, 0 to VertexCount() - 1
587  \param x The x-coord
588  \param y The y-coord
589  \param z The z-coord
590  \pre vertex must be a pointer to 3 or 4 floats, vertIndex must be less than VertexCount()
591  */
592  GLSGEN_GlsGeometryResource_EXPORT void SetVertex( GLuint vertIndex,
593  float x,
594  float y,
595  float z );
596 
597  /** Return a pointer to an array of 3 or 4 floats which is the vertex
598  for the given index.
599 
600  \param vertIndex The index of the vertex to get, 0 to VertexCount() - 1
601  \return a pointer to a 3 or 4 float vertex
602  \pre vertIndex must be less than VertexCount()
603  */
604  GLSGEN_GlsGeometryResource_EXPORT const float* GetVertex( GLuint vertIndex );
605 
606  /** Set a Normal
607  \param vertIndex The index of the vertex to change, 0 to VertexCount() - 1
608  \param x X Normal value to assign
609  \param y Y Normal value to assign
610  \param z Z Normal value to assign
611  \pre normal must be a valid Vector, vertIndex must be less than VertexCount()
612  NORMAL must be part of the Type
613  */
614  GLSGEN_GlsGeometryResource_EXPORT void SetNormal( GLuint vertIndex, float x, float y, float z );
615 
616  /** Initialize the vertex normals from an array of floats.
617 
618  Steps through the array reading the normal data for each vertex. The method will read 3 floats for each normal.
619 
620  \param floatArray 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 normal in the floatArray (in bytes)
624  */
625  GLSGEN_GlsGeometryResource_EXPORT void SetNormals( const float* floatArray,
626  unsigned int numVertices,
627  unsigned int startVertIndex = 0,
628  unsigned int stride = NORMAL_ATTRIBUTE_SIZE );
629 
630  /** Get a pointer to the Normal for a given Vertex index. Do
631  not change the Normal, change it through the Set function!
632  \param vertIndex The index of the Normal to get, 0 to VertexCount() - 1
633  \return a pointer to an array of 3 floats.
634  \pre vertIndex must be less than VertexCount()
635  NORMAL must be part of the Type
636  */
637  GLSGEN_GlsGeometryResource_EXPORT const float* GetNormal( GLuint vertIndex );
638 
639  /** Set a color value
640  \param vertIndex The index of the color value to change, 0 to VertexCount() - 1
641  \param red Red
642  \param green Green
643  \param blue Blue
644  \param alpha Alpha
645  */
646  GLSGEN_GlsGeometryResource_EXPORT void SetColor( GLuint vertIndex,
647  unsigned char red,
648  unsigned char green,
649  unsigned char blue,
650  unsigned char alpha );
651 
652  /** Initialize the vertex colors from an array of unsigned int containing rgba color data.
653 
654  Steps through the array reading the color data for each vertex. The method will read 1 integer for each color.
655 
656  \param rgbaArray pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
657  \param numVertices Number of vertices to read from of the array
658  \param startVertIndex (optional) The vertex buffer index to start copying into
659  \param stride (optional) The distance between each color in the rgbaArray (in bytes)
660  */
661  GLSGEN_GlsGeometryResource_EXPORT void SetColors( const unsigned int* rgbaArray,
662  unsigned int numVertices,
663  unsigned int startVertIndex = 0,
664  unsigned int stride = COLOR_ATTRIBUTE_SIZE );
665 
666  /** Initialize Color from an array
667  \param array an array of color values in RGBA order of size VertexCount()
668  \pre The array must be of size VertexCount()
669  */
670  GLSGEN_GlsGeometryResource_EXPORT void SetColors( const unsigned int* array );
671 
672  /** Gets the color value of the given vertex index
673  \param vertIndex The index of the color value to get, 0 to VertexCount() - 1
674  \return a pointer to a color array in rgba order
675  \pre vertIndex must be less than VertexCount(),
676  */
677  GLSGEN_GlsGeometryResource_EXPORT unsigned char* GetColor( GLuint vertIndex );
678 
679  /** Set a secondary color value (specular)
680  \param red Red
681  \param green Green
682  \param blue Blue
683  \param vertIndex The index of the secondary color value to change, 0 to VertexCount() - 1
684  \pre vertIndex must be less than VertexCount()
685  */
686  GLSGEN_GlsGeometryResource_EXPORT void SetSecondaryColor( GLuint vertIndex,
687  unsigned char red,
688  unsigned char green,
689  unsigned char blue );
690 
691  /** Initialize the vertex secondary colors from an array of unsigned int containing rgb color data. (Secondary colors do not include alpha)
692 
693  Steps through the array reading the color data for each vertex. The method will read 3 bytes for each color.
694 
695  \param rgbArray pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
696  \param numVertices Number of vertices to read from of the array
697  \param startVertIndex (optional) The vertex buffer index to start copying into
698  \param stride (optional) The distance between each color in the array (in bytes)
699  */
700  GLSGEN_GlsGeometryResource_EXPORT void SetSecondaryColors( const unsigned int* rgbArray,
701  unsigned int numVertices,
702  unsigned int startVertIndex = 0,
703  unsigned int stride = SECONDARY_COLOR_ATTRIBUTE_SIZE );
704 
705  /** Get the secondary color of the vertex at the given index.
706  \param vertIndex The index of the secondary color value to get, 0 to VertexCount() - 1
707  \return a pointer to a secondary color value in RGB order
708  \pre vertIndex must be less than VertexCount()
709  */
710  GLSGEN_GlsGeometryResource_EXPORT unsigned char* GetSecondaryColor( GLuint vertIndex );
711 
712  /** Set a TextureCoord
713  \param textureCoord TextureCoord value to assign. Must point to a float array containing TextureCoordinateDepth() elements
714  \param vertIndex The index of the TextureCoord value to change, 0 to VertexCount() - 1
715  \param whichTexture Which set of texture coordinates to change, 0 to NumTextureCoordinateArrays() - 1.
716  \pre vertIndex must be less than VertexCount()
717  TEXCOORD must be part of the Type
718  whichTexture must be 0 to 7
719  */
720  GLSGEN_GlsGeometryResource_EXPORT void SetTextureCoord( GLuint vertIndex, unsigned int whichTexture,
721  const float* textureCoord );
722 
723  GLSGEN_GlsGeometryResource_EXPORT void SetTextureCoord( GLuint vertIndex, unsigned int whichTexture,
724  float textureCoordU,
725  float textureCoordV );
726 
727 #ifdef GLES
728  /** Sets all texture coordinates from a pointer of texture coordinate data
729 
730  \param whichTexture Which set of texture coordinates to change, 0 to NumTextureCoordinateArrays() - 1.
731  \param textureCoordArray Pointer to texture coordinate data to assign. Must point to a float array containing TextureCoordinateDepth() elements
732  \param numVertices The number of vertices worth of texture coordinate data in the array
733  \param startIndex (optional) The texture coord vertex element to start copying into
734  \param stride (optional) The distance between each texture coordinate in the array (in bytes)
735  */
736  GLSGEN_GlsGeometryResource_EXPORT void SetTextureCoords( unsigned int whichTexture,
737  const float* textureCoordArray,
738  unsigned int numVertices,
739  unsigned int startVertIndex = 0,
740  unsigned int stride = TEXTURE_COORDINATE_ATTRIBUTE_SIZE );
741 #endif
742 
743  /** Get a TextureCoord
744  \param vertIndex The index of the TextureCoord value to change, 0 to VertexCount() - 1
745  \param whichTexture Which set of texture coordinates to change, 0 to NumTextureCoordinateArrays() - 1.
746  \return Return a pointer to the Texture Coordinates ask for
747  \pre vertIndex must be less than VertexCount()
748  TEXCOORD must be part of the Type
749  textureCount must be 1 to 8
750  */
751  GLSGEN_GlsGeometryResource_EXPORT const float* GetTextureCoord( GLuint vertIndex, unsigned int whichTexture );
752 
753  /** Store a generic vertex attribute value
754  \param vertIndex The index of the vertex
755  \param attribIndex The index of the generic vertex attribute to be modified
756  \param value void pointer to the value
757  \param sizeBytes size of the value in bytes
758  */
759  GLSGEN_GlsGeometryResource_EXPORT void StoreVertexAttrib( GLuint vertIndex, GLuint attribIndex, void* value, GLuint sizeBytes );
760 
761  void SetVertexAttrib1fv( GLuint vertIndex, GLuint attribIndex, const GLfloat* v ) { StoreVertexAttrib( vertIndex, attribIndex, (void*)v, 1 * sizeof( float ) ); }
762  void SetVertexAttrib2fv( GLuint vertIndex, GLuint attribIndex, const GLfloat* v ) { StoreVertexAttrib( vertIndex, attribIndex, (void*)v, 2 * sizeof( float ) ); }
763  void SetVertexAttrib3fv( GLuint vertIndex, GLuint attribIndex, const GLfloat* v ) { StoreVertexAttrib( vertIndex, attribIndex, (void*)v, 3 * sizeof( float ) ); }
764  void SetVertexAttrib4fv( GLuint vertIndex, GLuint attribIndex, const GLfloat* v ) { StoreVertexAttrib( vertIndex, attribIndex, (void*)v, 4 * sizeof( float ) ); }
765 
766 #ifdef GLES
767  GLSGEN_GlsGeometryResource_EXPORT void SetVertexAttribs( const float* attribArray,
768 
769  GLuint attribIndex,
770  unsigned int numVertices,
771  unsigned int startVertIndex = 0,
772  unsigned int stride = TANGENT_ATTRIBUTE_SIZE );
773 #endif
774 
775  /** Get pointer to the raw vertex attribute data
776  Be careful with this!
777  \note This method may be removed in the future
778  \param vertIndex The index of the vertex
779  \param attribIndex The index of the generic vertex attribute
780  */
781  GLSGEN_GlsGeometryResource_EXPORT void* GetVertexAttrib( GLuint vertIndex, GLuint attribIndex );
782 
784 
785  /** Get the number of available index buffers
786  * \param count Set the number of index buffers in this geometry resource.
787  */
788  GLSGEN_GlsGeometryResource_EXPORT void NumIndexBuffers( unsigned int count );
789 
790  /** Gets the size of an index buffer
791  \param bufferNum Which index buffer to return the size of
792  \return The number of items that the given index buffer can hold
793  */
794  GLSGEN_GlsGeometryResource_EXPORT unsigned int GetIndexBufferSize( unsigned int bufferNum ) const;
795 
796  /** Set the size of the specified index buffer
797  \param bufferNum Which index buffer to set the size of
798  \param newSize How many items the Index Buffer can hold.
799  \pre newSize must be greater than zero
800  */
801  GLSGEN_GlsGeometryResource_EXPORT void SetIndexBufferSize( unsigned int bufferNum, unsigned int newSize );
802 
803  /** Change the Vertex index
804  \param bufferNum Which index buffer to modify
805  \param index The index of the Index to change, 0 to GetIndexBufferSize(bufferNum)) - 1
806  \param indexValue Index must be less than GetIndexBufferSize(bufferNum)
807  */
808  GLSGEN_GlsGeometryResource_EXPORT void SetIndex( unsigned int bufferNum, unsigned int index, unsigned int indexValue );
809 
810 #ifndef GLES
811 
812  /** Initialize the Index buffer from an array of index values
813  *
814  * Steps through the array reading the color data for each vertex. The method will read 3 bytes for each color.
815  *
816  * \param bufferNum Which index buffer to modify
817  * \param indexArray pointer to the array to read from. The array must be at least (numIndices * stride) bytes.
818  * \param numIndices Number of indices to read from of the array
819  * \param startIndex (optional) The index buffer element to start copying into
820  * \param stride (optional) The distance between each index in the array (in bytes)
821  */
822  GLSGEN_GlsGeometryResource_EXPORT void SetIndices( unsigned int bufferNum,
823  const unsigned int* indexArray,
824  unsigned int numIndices,
825  unsigned int startIndex = 0,
826  unsigned int stride = sizeof( unsigned int ) );
827 
828  /** Gets an index from an index buffer
829  \param bufferNum Which index buffer to read from
830  \param index The index of the Index to get, 0 to GetIndexBufferSize(bufferNum) - 1
831  \return an Index value
832  \pre index must be less than GetIndexBufferSize(bufferNum)
833  */
834  GLSGEN_GlsGeometryResource_EXPORT unsigned int GetIndex( unsigned int bufferNum, unsigned int index );
835 
836  /** Merge two index buffers by adding the indexes from the source buffer to the dest buffer,
837  then deleting the source buffer.
838  \param dstBufferNum Which index buffer to add to
839  \param srcBufferNum Which index buffer to delete
840  \returns true on success, false if there was an error
841  */
842  GLSGEN_GlsGeometryResource_EXPORT void MergeIndexBuffers( unsigned int dstBufferNum, unsigned int srcBufferNum );
843 
844 #else // GLES
845 
846  /** Initialize the Index buffer from an array of index values
847 
848  Steps through the array reading the color data for each vertex. The method will read 3 bytes for each color.
849 
850  \param bufferNum Which index buffer to modify
851  \param indexArray pointer to the array to read from. The array must be at least (numIndices * stride) bytes.
852  \param numIndices Number of indices to read from of the array
853  \param startIndex (optional) The index buffer element to start copying into
854  \param stride (optional) The distance between each index in the array (in bytes)
855  */
856  GLSGEN_GlsGeometryResource_EXPORT void SetIndices( unsigned int bufferNum,
857  const unsigned int* indexArray,
858  unsigned int numIndices,
859  unsigned int startIndex = 0,
860  unsigned int stride = sizeof( unsigned int ) );
861 
862  /** Get an index from an index buffer
863  \param bufferNum Which index buffer to read from
864  \param index The index of the Index to get, 0 to GetIndexBufferSize(bufferNum) - 1
865  \return an Index value
866  \pre index must be less than GetIndexBufferSize(bufferNum)
867  */
868  GLSGEN_GlsGeometryResource_EXPORT unsigned short GetIndex( unsigned int bufferNum, unsigned short index );
869 
870 #endif // !GLES
871 
872  /** See GlsGeometryResource::VertexSort() */
873  typedef struct
874  {
875  unsigned int _order; // The order the vertex should be in
876  unsigned int _vertexTupleIndex; // The index of the primitive
877  } VertexSortData;
878 
879  /** Sort the vertices, based on the input data
880 
881  \param *sortData An array of VertexSortData structures, one for each primitive (set of three vertices).
882  The data in this is array is used to reorder the primitives. e.g.:
883  Input:
884  order 0,1,0,5,2
885  index 0,1,2,3,4
886  Sorted:
887  order 0,0,1,2,5
888  index 0,2,1,4,3
889 
890  \pre sortData must be an array of VertexSortData VertexCount()/3 in size
891 
892  \post The sortData array will be sorted based on _order.
893  The vertex buffer will be sorted based on the new order from the sortData.
894  */
895  GLSGEN_GlsGeometryResource_EXPORT void VertexSort( VertexSortData* sortData );
896 
897  /** Dump all the vertices to the terminal
898  */
899  GLSGEN_GlsGeometryResource_EXPORT void DumpVertices();
900 
901  /** Dump all the Normals to the terminal
902  */
903  GLSGEN_GlsGeometryResource_EXPORT void DumpNormals();
904 
905  /** Dump all the Indices to the terminal
906  */
907  GLSGEN_GlsGeometryResource_EXPORT void DumpIndices();
908 
909  /** Copy vertex attributes from srcGeom to dstGeom
910  Does not change the Type of the resource: only vertex attributes that both resources have in common will be copied.
911  \param dstGeom the resource to copy to
912  \param dstOffset vertex offset to start copying at
913  \param srcGeom the resource to copy from
914  \param srcOffset vertex offset to start copying from
915  \param vertexCount number of vertices to copy
916  \returns the number of vertices that were copied
917  */
918  static GLSGEN_GlsGeometryResource_EXPORT unsigned int CopyVertexData(
919  GlsGeometry_Generic* dstGeom, unsigned int dstOffset,
920  GlsGeometry_Generic* srcGeom, unsigned int srcOffset,
921  unsigned int vertexCount );
922 
923  /* Apply a transform to the vertex attributes of the given mesh
924  * The transform affects vertex position, normals, ATTRIB_TANGENT, and ATTRIB_BINORMAL
925  * \param dstGeom The resource to modify
926  * \param transform matrix used to convert vertex attributes
927  * \param vertexOffset start of the range of verts to transform
928  * \param vertexCount number of verts to transform
929  */
930  static GLSGEN_GlsGeometryResource_EXPORT unsigned int TransformVertexData(
931  GlsGeometry_Generic* dstGeom,
932  GlsMatrixType* transform,
933  unsigned int vertexOffset = 0,
934  unsigned int vertexCount = UINT_MAX );
935 
936  // Generate tangents/binormals for all vertices in the given
937  // GlsGeometryResource and adds them as vertex attributes.
938  static GLSGEN_GlsGeometryResource_EXPORT bool GenerateTangentsAndBinormals( GlsGeometry_Generic* geom );
939 
940  typedef struct
941  {
942  unsigned int _size; // Total size of each vertex (depends on which data are included)
943 
944  /** Offsets into the structure for the various data
945  */
946  unsigned int _normalStride;
947  unsigned int _texcoordStride;
948  unsigned int _texcoord2Stride;
949  unsigned int _colorStride;
950  unsigned int _secondaryColorStride;
951  unsigned int _numVertexAttribs;
952  unsigned int _vertexAttribStride[ MAX_VERTEX_ATTRIBS ];
953  unsigned int _vertexAttribSize[ MAX_VERTEX_ATTRIBS ];
955 
956  static GLSGEN_GlsGeometryResource_EXPORT void SetVertexStructureFromTypeDesc( VertexStructureDefinition& vertStruct, const TypeDesc& type );
957 
958 protected:
959  bool _bufferLock;
960 
961  char* _vertexBuffer;
962  unsigned int _vertexBufferCount;
963  GLuint _vertexBufferID;
964  bool _vertexBufferUpdated; // Is the video card vertex buffer up to date?
965 
966  /** Index buffers array */
967  GlsGeometry_Generic_IndexBufferData* _indexBuffers;
968  //unsigned int _numIndexBuffers; // in base class for inlining
969 
970  VertexStructureDefinition _structure;
971 
972  GLSGEN_GlsGeometryResource_EXPORT void CopyVertexBufferOnly( GlsGeometry_Generic* rhs );
973 
974  /** Utility routine used by Hit. Performs a "BestHit" test, which performs a hit test on the object
975  * and guarantees that the collision point returned by Hit is the closest collision point to the observer.
976  * @param point The geometry coordinate of the click, relative to the object
977  * @param directionVector The direction of the pick vector
978  * @param collisionPoint Set to the point on the object hit by directionVector
979  * @return booleanean indicating if the object was hit by the mouse
980  */
981  GLSGEN_GlsGeometryResource_EXPORT bool BestHit( const Vector& point, const Vector& directionVector, Vector& collisionPoint );
982 
983  /** Utility routine used by Hit. Performs a "FirstHit" test, which performs a hit test on the object
984  * but does not guarantee that the collision point returned by Hit is the closest collision point
985  * to the observer
986  * @param point The logical coordinate of the click, relative to the object
987  * @param directionVector The direction of the pick vector
988  * @param collisionPoint Set to the point on the object hit by directionVector
989  * @return boolean indicating if the object was hit
990  */
991  GLSGEN_GlsGeometryResource_EXPORT bool FirstHit( const Vector& point, const Vector& directionVector, Vector& collisionPoint );
992 
993  void InitializeMembers();
994 
995  void InitFromBinaryResource( GlsResourceFileMgr::BinaryResource* resource );
996 
997  unsigned int GetTexcoordByteOffset( unsigned int whichTexture );
998 
999  GLSGEN_GlsGeometryResource_EXPORT void Destroy();
1000 
1001 private:
1002  // Member data
1003  unsigned int _dataChangedCounter;
1004 
1005  /** Should be called when any data changes. Used to optimize calls like GetExtents(). */
1006  void IncDataChangedCounter()
1007  {
1008  // If we hit the invalid ID, skip past it.
1009  if( ++_dataChangedCounter == s_invalidDataChangedCounter )
1010  {
1011  ++_dataChangedCounter;
1012  }
1013  }
1014 
1015  /** Private Constructor: Use CreateInstance methods */
1016  GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic();
1017 
1018  /** Private Destructor: Use DecrementReference to delete the object*/
1019  GLSGEN_GlsGeometryResource_EXPORT ~GlsGeometry_Generic();
1020 
1021  // Disable implicit generated Members
1022  GlsGeometry_Generic( const GlsGeometry_Generic& src );
1023  GlsGeometry_Generic& operator=( const GlsGeometry_Generic& rhs );
1024 };
1025 
1026 } // namespace disti
1027 
1028 #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:426
TypeDesc _type
Definition: gls_geometry_resource.h:284
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:353
void SetTextureCoord(GLuint vertIndex, unsigned int whichTexture, const float *textureCoord)
void SetResourceId(unsigned int id)
Definition: gls_geometry_resource.h:432
void DecrementReference()
Definition: gls_geometry_resource.h:404
unsigned int _referenceCount
Definition: gls_geometry_resource.h:281
Definition: gls_geometry_resource.h:873
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:423
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
Definition: gls_geometry_resource.h:241
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:399
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:287
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:463
const TypeDesc & Type()
Definition: gls_geometry_resource.h:396
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:441
unsigned int GetIndex(unsigned int bufferNum, unsigned int index)
unsigned int _resourceID
Definition: gls_geometry_resource.h:278
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:940
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:946
const float * GetNormal(GLuint vertIndex)
unsigned int NumIndexBuffers() const
Definition: gls_geometry_resource.h:417
Definition: bmpimage.h:46
virtual void FreeOpenGLBuffers()
GlsGeometry_Generic_IndexBufferData * _indexBuffers
Definition: gls_geometry_resource.h:967
virtual void DrawSetup(VertexAttribIndexLookup *shaderProgram)=0
virtual unsigned int StatsIndexBufferPolygonCount(unsigned int bufferNumber)
Definition: gls_geometry_resource.h:469
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:453
The disti::GlsRenderEffect class.
The gls_gl.