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 Member Functions

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 (void)
 

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 VERTEX_ATTRIBUTE_SIZE = 3 * sizeof( float )
 
static const unsigned int s_invalidDataChangedCounter = 0
 

Protected Member Functions

virtual void Destroy ()=0
 

Protected Attributes

unsigned int _resourceID
 
unsigned int _referenceCount
 
TypeDesc _type
 
unsigned int _numIndexBuffers
 

Detailed Description

The geometry resource abstract base class

Member Function Documentation

const Vector& BoundingVolumeCenter ( ) const
inline

Get the bounding sphere center

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.

float BoundingVolumeRadius ( ) const
inline

Get the bounding sphere radius

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
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
resourcepointer to a ResourceRef containing geometry data
void DecrementReference ( )
inline

Decrement the Reference count to this instance.

Note
The OpenGL context should be available to free resources.
virtual void Destroy ( )
protectedpure virtual

Deletes this object from the heap that it was allocated on

Implemented in GlsGeometry_Generic.

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.

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.

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.

virtual void FreeOpenGLBuffers ( )
pure virtual

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

Implemented in GlsGeometry_Generic.

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.

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.

unsigned int GetResourceId ( void  )
inline

Gets the current resource ID

Precondition
_resourceID != BAD_ID
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.

void IncrementReference ( )
inline

Increment the Reference count to this instance.

unsigned int NumIndexBuffers ( ) const
inline

Returns The number of index buffers in this geometry resource.

static void SetCreateInstanceMakesHalfFloat ( bool  value)
static

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

void SetResourceId ( unsigned int  id)
inline

Sets a new resource ID

Parameters
idThe new ID
Precondition
id != BAD_ID
virtual unsigned int StatsIndexBufferPolygonCount ( unsigned int  bufferNumber)
pure virtual

Returns polygon count for use in editor statistics

Implemented in GlsGeometry_Generic.

virtual unsigned int StatsIndexBufferVertexCount ( unsigned int  bufferNumber)
pure virtual

Returns vertex count for use in editor statistics

Implemented in GlsGeometry_Generic.

const TypeDesc& Type ( )
inline

Returns the TypeDesc for this resource

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

unsigned int _numIndexBuffers
protected

The number of index buffers in this mesh

unsigned int _referenceCount
protected

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

unsigned int _resourceID
protected

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

TypeDesc _type
protected

The TypeDesc that describes what is in this Resource

const unsigned int s_invalidDataChangedCounter = 0
static

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

const unsigned int VERTEX_ATTRIBUTE_SIZE = 3 * sizeof( float )
static

The sizes of various vertex attributes, in bytes.


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