GL Studio C++ Runtime API
GlsGeometryResource Class Referenceabstract

#include <gls_geometry_resource.h>

Inheritance diagram for GlsGeometryResource:
GlsGeometry_Generic

Classes

class  Observer
 
class  TypeDesc
 

Public Types

enum  BadId { BAD_ID = 0xffffffff }
 

Public Member Functions

void AddObserver (Observer *observer)
 
void RemoveObserver (Observer *observer)
 
virtual void DrawSetup (VertexAttribIndexLookup *shaderProgram)=0
 
virtual void DrawIndexBuffer (unsigned int bufferNumber)=0
 
virtual void DrawCleanup (VertexAttribIndexLookup *shaderProgram)=0
 
virtual void FreeOpenGLBuffers ()=0
 
virtual unsigned int GetDataChangedCounter () const =0
 
virtual void GetExtents (Vector &min, Vector &max, const GlsMatrixType *matrix=NULL)=0
 
virtual void UpdateBoundingVolume ()=0
 
virtual bool BoundingVolumeHit (const Vector &point, const Vector &direction)=0
 
virtual bool HitTest (unsigned char pickType, const Vector &pickLinePoint, const Vector &pickLineDirection, Vector &collisionPoint)=0
 
virtual unsigned int StatsIndexBufferVertexCount (unsigned int bufferNumber)=0
 
virtual unsigned int StatsIndexBufferPolygonCount (unsigned int bufferNumber)=0
 
const TypeDescType ()
 
void IncrementReference ()
 
void DecrementReference ()
 
unsigned int NumIndexBuffers () const
 
const VectorBoundingVolumeCenter () const
 
float BoundingVolumeRadius () const
 
void SetResourceId (unsigned int id)
 
unsigned int GetResourceId ()
 

Static Public Member Functions

static void SetCreateInstanceMakesHalfFloat (bool value)
 
static GlsGeometryResourceCreateInstance (const TypeDesc &type=GlsGeometryResource::TypeDesc())
 
static GlsGeometryResourceCreateInstance (GlsResourceFileMgr::ResourceRef *resource)
 

Static Public Attributes

static const unsigned int MAX_TEXTURE_COORDS = 2
 GL_MAX_TEXTURE_COORDS. GlsGeometryResource currently only supports two sets of texture coordinates.
 
static const unsigned int MAX_VERTEX_ATTRIBS = 16
 GL_MAX_VERTEX_ATTRIBS.
 
static const unsigned int VERTEX_ATTRIBUTE_SIZE = 3 * sizeof( float )
 Size of vertex storage, in bytes.
 
static const unsigned int NORMAL_ATTRIBUTE_SIZE = 3 * sizeof( float )
 Size of normal storage, in bytes.
 
static const unsigned int COLOR_ATTRIBUTE_SIZE = 4 * sizeof( unsigned char )
 Size of color storage, in bytes.
 
static const unsigned int SECONDARY_COLOR_ATTRIBUTE_SIZE = 3 * sizeof( unsigned char )
 Size of secondary color storage, in bytes.
 
static const unsigned int TEXTURE_COORDINATE_ATTRIBUTE_SIZE = 2 * sizeof( float )
 Size of texture coordinate storage, in bytes.
 
static const unsigned int TANGENT_ATTRIBUTE_SIZE = 3 * sizeof( float )
 Size of tangent storage, in bytes.
 
static const unsigned int BINORMAL_ATTRIBUTE_SIZE = 3 * sizeof( float )
 Size of binormal storage, in bytes.
 
static const unsigned int s_invalidDataChangedCounter = 0
 

Protected Member Functions

void OnGeometryResourceChanged ()
 Called to call all observer callbacks when the attribute changes.
 
virtual void Destroy ()=0
 

Protected Attributes

DynamicArray< Observer * > _observers
 The held list of observers w/ callbacks.
 
unsigned int _resourceID
 
unsigned int _referenceCount
 
TypeDesc _type
 
unsigned int _numIndexBuffers
 
Vector _boundingVolumeCenter
 Center location of the bounding volume.
 
float _boundingVolumeRadius
 Radius of the bounding volume.
 

Static Protected Attributes

static bool _enableVBO
 If true, OpenGL supports vertex buffer objects (1.5 or greater).
 

Detailed Description

The geometry resource abstract base class

Member Enumeration Documentation

◆ BadId

enum BadId

Something that we can initialize the Resource ID to and then check for to see if we have initialized the resource.

Member Function Documentation

◆ AddObserver()

void AddObserver ( Observer observer)
inline

Adds a new observer to the list.

Parameters
observerThe new observer to add.

◆ BoundingVolumeCenter()

const Vector & BoundingVolumeCenter ( ) const
inline
Returns
The bounding sphere center.

◆ BoundingVolumeHit()

virtual bool BoundingVolumeHit ( const Vector point,
const Vector direction 
)
pure virtual

Determines if the given ray hits the geometry bounding volume. Note: All parameters should be in this object's coordinates.

Parameters
pointThe starting point of the ray.
directionThe direction vector of the ray.
Returns
True if this bounding volume is hit by the ray.

Implemented in GlsGeometry_Generic.

◆ BoundingVolumeRadius()

float BoundingVolumeRadius ( ) const
inline
Returns
The bounding sphere radius.

◆ CreateInstance() [1/2]

static GlsGeometryResource * CreateInstance ( const TypeDesc type = GlsGeometryResource::TypeDesc())
static

Construct an empty GlsGeometryResource with the given type. The initial reference count is 1. Call DecrementReference to free the resource when you are done with it.

Parameters
typeA description of the initial Structure.
Returns
A pointer to a new GlsGeometryResource.

◆ CreateInstance() [2/2]

static GlsGeometryResource * CreateInstance ( GlsResourceFileMgr::ResourceRef resource)
static

Construct a GlsGeometryResource from a binary resource. The initial reference count is 1. Call DecrementReference to free the GlsGeometryResource when you are done with it.

Parameters
resourceA pointer to a ResourceRef containing geometry data.
Returns
A pointer to a new GlsGeometryResource.

◆ DecrementReference()

void DecrementReference ( )
inline

Decrement the Reference count to this instance.

Note
The OpenGL context should be available to free resources.

◆ Destroy()

virtual void Destroy ( )
protectedpure virtual

Deletes this object from the heap that it was allocated on

Implemented in GlsGeometry_Generic.

◆ DrawCleanup()

virtual void DrawCleanup ( VertexAttribIndexLookup shaderProgram)
pure virtual

Restore the OpenGL state after rendering.

Parameters
shaderProgramMust be the same value that was passed to DrawSetup
Precondition
DrawSetup was called
Postcondition
The OpenGL state will be restored

Implemented in GlsGeometry_Generic.

◆ DrawIndexBuffer()

virtual void DrawIndexBuffer ( unsigned int  bufferNumber)
pure virtual

Draw the geometry specified by the given index buffer This method should only be called between calls to DrawSetup and DrawCleanup.

Precondition
DrawSetup has been called.
Parameters
bufferNumberWhich index buffer to draw

Implemented in GlsGeometry_Generic.

◆ DrawSetup()

virtual void DrawSetup ( VertexAttribIndexLookup shaderProgram)
pure virtual

Setup the OpenGL state for rendering this geometry. To draw, call DrawIndexBuffer for each index buffer in the resource. After drawing, call DrawCleanup to restore the OpenGL state.

Parameters
shaderPrograminterface to the shader program, used to lookup correct VertexAttrib index values (may be NULL)
Postcondition
The OpenGL state is configured for rendering from the index buffers.

Implemented in GlsGeometry_Generic.

◆ FreeOpenGLBuffers()

virtual void FreeOpenGLBuffers ( )
pure virtual

Force the GlsGeometryResource to free any buffers it has allocated in the current OpenGL context.

Implemented in GlsGeometry_Generic.

◆ GetDataChangedCounter()

virtual unsigned int GetDataChangedCounter ( ) const
pure virtual

Since calculating metrics like the extents can be an expensive operation, the user can call this function to see if the geometry resource has changed. Caching the expensive-to-calculate values is the responsibility of the caller.

Returns
The current extents ID. Never equal to s_invalidDataChangedCounter.
See also
s_invalidDataChangedCounter

Implemented in GlsGeometry_Generic.

◆ GetExtents()

virtual void GetExtents ( Vector min,
Vector max,
const GlsMatrixType matrix = NULL 
)
pure virtual

Calculate and return the geometry extents

Parameters
minReturns the minimum x,y,z values
maxReturns the maximum x,y,z values
matrix(Optional) matrix to transform the vertices into the desired coordinate system
Note
This can be an expensive operation. GetDataChangedCounter() can be used to minimize this expense.
See also
GetDataChangedCounter()

Implemented in GlsGeometry_Generic.

◆ GetResourceId()

unsigned int GetResourceId ( )
inline
Returns
The current resource ID.
Precondition
_resourceID != BAD_ID

◆ HitTest()

virtual bool HitTest ( unsigned char  pickType,
const Vector pickLinePoint,
const Vector pickLineDirection,
Vector collisionPoint 
)
pure virtual

Hit test the geometry against a picking line. All values are in geometry space.

Parameters
pickTypeThe type of picking (see PickableType_e), must be PICK_FIRST or PICK_BEST
pickLinePointA point on the pick line.
pickLineDirectionThe direction of the pick line.
collisionPointIf the method returns true, this contains the point that was hit.
Returns
true if the object was hit by the pick.

Implemented in GlsGeometry_Generic.

◆ IncrementReference()

void IncrementReference ( )
inline

Increment the Reference count to this instance.

◆ NumIndexBuffers()

unsigned int NumIndexBuffers ( ) const
inline
Returns
The number of index buffers in this geometry resource.

◆ RemoveObserver()

void RemoveObserver ( Observer observer)
inline

Removes the specified observer from the list.

Parameters
observerThe observer to remove.

◆ SetCreateInstanceMakesHalfFloat()

static void SetCreateInstanceMakesHalfFloat ( bool  value)
static

When enabled, GlsGeometryResource::CreateInstance will instantiate GlsGeometry_HalfFloat objects when possible.

Parameters
valueWhether or not to use half floats.

◆ SetResourceId()

void SetResourceId ( unsigned int  id)
inline

Sets a new resource ID

Parameters
idThe new ID
Precondition
id != BAD_ID

◆ StatsIndexBufferPolygonCount()

virtual unsigned int StatsIndexBufferPolygonCount ( unsigned int  bufferNumber)
pure virtual
Returns
The polygon count for use in editor statistics.
Parameters
bufferNumberThe index of the buffer to count up.

Implemented in GlsGeometry_Generic.

◆ StatsIndexBufferVertexCount()

virtual unsigned int StatsIndexBufferVertexCount ( unsigned int  bufferNumber)
pure virtual
Returns
The vertex count for use in editor statistics.
Parameters
bufferNumberThe index of the buffer to count up.

Implemented in GlsGeometry_Generic.

◆ Type()

const TypeDesc & Type ( )
inline
Returns
The TypeDesc for this resource.

◆ UpdateBoundingVolume()

virtual void UpdateBoundingVolume ( )
pure virtual

Updates the bounding volume of this object This method should be called if the vertices change for picking and culling to work correctly.

Note
This can be an expensive operation. GetDataChangedCounter() can be used to minimize this expense.
See also
GetDataChangedCounter()

Implemented in GlsGeometry_Generic.

Member Data Documentation

◆ _numIndexBuffers

unsigned int _numIndexBuffers
protected

The number of index buffers in this mesh

◆ _referenceCount

unsigned int _referenceCount
protected

The number of Parent Objects using this object. Once the number reaches zero, the object self deletes.

◆ _resourceID

unsigned int _resourceID
protected

Give this Resource a unique id so we can get it.

◆ _type

TypeDesc _type
protected

The TypeDesc that describes what is in this Resource

◆ s_invalidDataChangedCounter

const unsigned int s_invalidDataChangedCounter = 0
static

A sentinel value for clients to initialize their counts with. GetDataChangedCounter() will never return this value.


The documentation for this class was generated from the following file: