GL Studio C++ Runtime API
GlsRSOInterfaceImpl Class Reference

#include <gls_rso_interface_impl.h>

Inheritance diagram for GlsRSOInterfaceImpl:
GlsPainter

Public Member Functions

int LiveComponentEventHandlerCb (ComponentBase *, disti::DisplayEvent *ev)
 
void Calculate (double time) override
 The RSO Interface methods. More...
 
RsoImplBaseInterfaceCloneObject () override
 
void DeleteInstance () override
 Safely delete the object. More...
 
void Draw () override
 
bool SetEmittedEventHandler (RsoImplBaseInterface::EmittedEventHandler *handler) override
 
bool GetBoundingSphere (RsoImplBaseInterface::Vector *center, float *radius) override
 
bool GetBoundingBox (RsoImplBaseInterface::Vector *min, RsoImplBaseInterface::Vector *max, const RSOMatrixT *transform=NULL) override
 
bool HandleInput (RsoImplBaseInterface::Event *ev) override
 
bool HandleMultiTouchInput (RsoImplMultiTouchInterface::MouseMultiTouchEvent *ev) override
 
bool Pick3D (const RsoImplBaseInterface::Vector &winLoc, const RsoImplBaseInterface::Vector &logicalCoords, float scale, const RsoImplBaseInterface::Vector &directionVector, RsoImplBaseInterface::Vector &collisionWinLoc, const RsoImplBaseInterface::OpenGLMatrices &drawnMatrices) override
 
void PreDraw (const RsoImplBaseInterface::OpenGLMatrices &current, RsoImplBaseInterface::Culler &culler) override
 
void SetResource (const char *resourceName, const char *resourceVal) override
 
const char * GetResource (const char *resourceName) override
 
const char * GetResources (RsoImplBaseInterface::ResourceFilter *filter=NULL) override
 
ResourceHandle CreateResourceHandle (const char *resourceName) override
 
void ReleaseResourceHandle (ResourceHandle resourceHandle) override
 
bool IsResourceHandleValid (ResourceHandle resourceHandle) override
 
void SetResource (ResourceHandle resourceHandle, const char *resourceVal) override
 
const char * GetResource (ResourceHandle resourceHandle) override
 
void SetIntResource (const char *resourceName, long resourceVal) override
 
long GetIntResource (const char *resourceName) override
 
void SetIntResource (ResourceHandle handle, long resourceVal) override
 
long GetIntResource (ResourceHandle resourceHandle) override
 
void SetFloatResource (const char *resourceName, double resourceVal) override
 
double GetFloatResource (const char *resourceName) override
 
void SetFloatResource (ResourceHandle handle, double resourceVal) override
 
double GetFloatResource (ResourceHandle resourceHandle) override
 
CallbackID RegisterResourceObserver (ResourceHandle resourceHandle, ResourceObserver *observer) override
 
void UnregisterResourceObserver (ResourceHandle resourceHandle, CallbackID id) override
 
unsigned int GetMaxNumLights ()
 
void SetLightData (unsigned int numLights, LightData *lightData)
 
unsigned int GetMaxClipPlanes ()
 
void SetClipPlaneData (unsigned int numClipPlanes, float **equations)
 
void SetMatrix (int type, const float *matrix)
 
void SetDefaultOpenGLState ()
 Restores the state manager back to its default state.
 
void Invalidate () override
 
bool IsInvalidated () const override
 
void SetPainter (RSOPainterT *painter) override
 
virtual void Invalidate ()=0
 Notify the painter that the scene needs to be redrawn. More...
 
virtual bool IsInvalidated () const =0
 

Static Public Member Functions

static GlsRSOInterfaceImplCreateInstance (ComponentBase *component)
 

Protected Types

typedef std::map< ResourceHandle, DistiAttributeBase * > ResourceHandleMap
 Typedef to associate external ids (ResourceHandle) with runtime attributes.
 

Protected Member Functions

DistiAttributeBaseGetAttribute (ResourceHandle handle)
 
 GlsRSOInterfaceImpl (ComponentBase *component)
 

Protected Attributes

ComponentBase_component
 
RsoImplBaseInterface::EmittedEventHandler * _emittedEventHandler
 The container's event handler.
 
std::string _resourcesRetVal
 String to return from Resources methods.
 
ResourceHandleMap _resourceHandleMap
 Mapping of external RSO interface resource ids with runtime attributes.
 
ResourceHandle _nextResourceHandle
 Used to track the highest id, to assign as the next resource handle.
 
bool _firstDraw
 If true, this RSO has not been drawn yet.
 
RSOPainterT_painter
 Painter object that tracks the conditional rendering state.
 
bool _redraw
 If true, this RSO should redraw itself on the next frame.
 

Detailed Description

Implementation of RSOInterface.

Constructor & Destructor Documentation

◆ GlsRSOInterfaceImpl()

GlsRSOInterfaceImpl ( ComponentBase component)
protected

Protected constructor - Call CreateInstance instead

Parameters
componentThe component object to wrap.

Member Function Documentation

◆ Calculate()

void Calculate ( double  time)
override

The RSO Interface methods.

Perform component simulation. Any non-drawing activities can be performed here. Call this before PreDraw()

Parameters
timeThe current application time in seconds.

◆ CloneObject()

RsoImplBaseInterface * CloneObject ( )
override

Returns
A new instance of the RSO that is a clone of this object or NULL if not possible.

◆ CreateInstance()

static GlsRSOInterfaceImpl * CreateInstance ( ComponentBase component)
static
Returns
An RSO interface wrapper for the incoming component object.
Parameters
componentThe component object to wrap.

◆ CreateResourceHandle()

ResourceHandle CreateResourceHandle ( const char *  resourceName)
override

Obtains a resource handle to a given named resource This handle must be disposed of with the ReleaseResourceHandle method once it is no longer needed. If this method fails, the return value will not be a valid handle; this can be determined by calling IsResourceHandleValid.

Parameters
resourceNameThe resource name to create a handle for.
Returns
A handle to the desired resource.

◆ DeleteInstance()

void DeleteInstance ( )
override

Safely delete the object.

◆ Draw()

void Draw ( )
override

Draw the object via OpenGL Call this after PreDraw()

◆ GetAttribute()

DistiAttributeBase & GetAttribute ( ResourceHandle  handle)
protected
Returns
The runtime attribute associated with the external handle.
Parameters
handleThe external id for the desired runtime attribute.

◆ GetBoundingBox()

bool GetBoundingBox ( RsoImplBaseInterface::Vector *  min,
RsoImplBaseInterface::Vector *  max,
const RSOMatrixT transform = NULL 
)
override

Get the extents of the component when drawn with the given transformation matrix, as a coordinate system-aligned box

Parameters
minIf the method returns true, contains the point corresponding with the 1st corner of the box. If the method returns false, value is undefined.
maxIf the method returns true, contains the point corresponding with the 2nd corner of the box. If the method returns false, value is undefined.
transformTransformation matrix from A to B where A is the component's coordinate system and B is the coordinate system to compute the bounding box in. (If NULL then identity matrix is assumed)
Returns
true if the extents were calculated, false if the extents could not be calculated.

◆ GetBoundingSphere()

bool GetBoundingSphere ( RsoImplBaseInterface::Vector *  center,
float *  radius 
)
override

Get the bounding sphere for the component in the components coordinate system

Parameters
centerIf the method returns true, contains the center point of the sphere. If the method returns false, value is undefined.
radiusIf the method returns true, contains the radius of the sphere. If the method returns false, value is undefined.
Returns
true if the bounding sphere was returned, false if the bounding sphere is not available.

◆ GetFloatResource() [1/2]

double GetFloatResource ( const char *  resourceName)
override

Returns
The value as a float for a given named resource.
Parameters
resourceNameThe name to return the float value for.

◆ GetFloatResource() [2/2]

double GetFloatResource ( ResourceHandle  resourceHandle)
override

Returns
The value as a float for a resource specified by handle.
Parameters
resourceHandleThe handle to return the integer value for.

◆ GetIntResource() [1/2]

long GetIntResource ( const char *  resourceName)
override

Returns
The value as an integer for a given named resource.
Parameters
resourceNameThe name to return the integer value for.

◆ GetIntResource() [2/2]

long GetIntResource ( ResourceHandle  resourceHandle)
override

Returns
The value as an integer for a resource specified by handle.
Parameters
resourceHandleThe handle to return the integer value for.

◆ GetMaxClipPlanes()

unsigned int GetMaxClipPlanes ( )
Returns
The maximum number of clip planes supported by the current driver.

◆ GetMaxNumLights()

unsigned int GetMaxNumLights ( )
Returns
The maximum number of possible lights this platform supports.

◆ GetResource() [1/2]

const char * GetResource ( const char *  resourceName)
override

Get the string value for the given resource

Parameters
resourceNameThe name of the resource whose value is to be returned.
Returns
The string value for the given resource, or empty string if not found.

◆ GetResource() [2/2]

const char * GetResource ( ResourceHandle  resourceHandle)
override

Returns
The string value for a resource specified by handle.
Parameters
resourceHandleThe handle to return the string value for.

◆ GetResources()

const char * GetResources ( RsoImplBaseInterface::ResourceFilter *  filter = NULL)
override

Get a list of the resources for the component. Each resource is separated by a newline ('
') with the output controlled by filter. filter may be NULL in which case the default values are used.

Parameters
filterThe filter parameters to use.
Returns
A string containing the list of resource data that passes the filter.

◆ HandleInput()

bool HandleInput ( RsoImplBaseInterface::Event *  ev)
override

Allow the object to handle an event

Parameters
evThe event to handle.
Returns
True if the event was handled by the component.

◆ HandleMultiTouchInput()

bool HandleMultiTouchInput ( RsoImplMultiTouchInterface::MouseMultiTouchEvent *  ev)
override

Allow the object to handle a multitouch event.

Parameters
evThe event to handle.
Returns
True if the event was handled by the component.

◆ Invalidate()

void Invalidate ( )
overridevirtual

Notify the painter that the scene needs to be redrawn

Implements GlsPainter.

◆ IsInvalidated()

bool IsInvalidated ( ) const
overridevirtual

Returns
Whether or not the painter has already been invalidated.

Implements GlsPainter.

◆ IsResourceHandleValid()

bool IsResourceHandleValid ( ResourceHandle  resourceHandle)
override

Checks if a given resource handle is valid.

Parameters
resourceHandleThe resource handle to check.
Returns
Whether or not the handle is valid.

◆ LiveComponentEventHandlerCb()

int LiveComponentEventHandlerCb ( ComponentBase ,
disti::DisplayEvent ev 
)

Pass an event that was emitted from the component to the container.

Parameters
evThe event to pass into the container.
Returns
Zero if the event was not handled, otherwise not zero.

◆ Pick3D()

bool Pick3D ( const RsoImplBaseInterface::Vector &  winLoc,
const RsoImplBaseInterface::Vector &  logicalCoords,
float  scale,
const RsoImplBaseInterface::Vector &  directionVector,
RsoImplBaseInterface::Vector &  collisionWinLoc,
const RsoImplBaseInterface::OpenGLMatrices &  drawnMatrices 
)
override

Pick3D returns true if the RSO was picked.

Parameters
winLocDevice coordinates for the mouse click. Z value should be set to 0 to ensure pick ray starts at near clip plane.
logicalCoordsThe start of the pick ray in logical coordinates. Should be calculated from the winLoc using this->WindowToLogical(winLoc, logicalCoords, &directionVector).
scaleCurrent window scale. Affects picking radius of outlines. Initial value should typically be 1.0.
directionVectorThe direction of the pick ray in logical coordinates. Should be calculated from the winLoc using this->WindowToLogical(winLoc, logicalCoords, &directionVector).
collisionWinLocReturns where the pick vector intersects the object that is hit in device coordinates.
drawnMatricesThe matrices used to draw the object, including matrices set by parents that may have dynamically rotated, translated or scaled this object. Initial value should typically be a default OpenGLMatrices() object.
Returns
True if the object was picked.

◆ PreDraw()

void PreDraw ( const RsoImplBaseInterface::OpenGLMatrices &  current,
RsoImplBaseInterface::Culler &  culler 
)
override

Calculate transformations and perform culling Call this before Draw()

Parameters
currentThe current state of the OpenGL matrices.
cullerThe current culler state.

◆ RegisterResourceObserver()

CallbackID RegisterResourceObserver ( ResourceHandle  resourceHandle,
ResourceObserver *  observer 
)
override

Register a resource observer to be notified when a resource changes *

Parameters
resourceHandlethe resource handle
observerthe observer to be notified. The RSO takes ownership of the observer and will call Destroy to delete it when needed.
Returns
the id used to unregister the observer in combination with the original resourceHandle

◆ ReleaseResourceHandle()

void ReleaseResourceHandle ( ResourceHandle  resourceHandle)
override

Disposes of a resource handle.

Parameters
resourceHandleThe resource handle to release.

◆ SetClipPlaneData()

void SetClipPlaneData ( unsigned int  numClipPlanes,
float **  equations 
)

Activates and updates the clip planes in the state manager.

Parameters
[in]numClipPlanesDetermines how many planes are defined in the equations array.
[in]equationsAn array of floats that define each plane where each equation is defined by four floats. equations[numClipPlanes][4].

◆ SetEmittedEventHandler()

bool SetEmittedEventHandler ( RsoImplBaseInterface::EmittedEventHandler *  handler)
override

Allow for handling events from inside the object. The emitted event handler will be passed events that are from inside the component

Parameters
handlerpointer to the EmittedEventHandler object to use or NULL to remove the current event handler.
Returns
true if this component may emit events, false if this component will never emit events.

◆ SetFloatResource() [1/2]

void SetFloatResource ( const char *  resourceName,
double  resourceVal 
)
override

Set the value as a float for a given named resource.

Parameters
resourceNameThe name of the resource to set.
resourceValThe new float value to set.

◆ SetFloatResource() [2/2]

void SetFloatResource ( ResourceHandle  handle,
double  resourceVal 
)
override

Set the value as a float for a resource specified by handle.

Parameters
handleThe handle of the resource to set.
resourceValThe new float value to set.

◆ SetIntResource() [1/2]

void SetIntResource ( const char *  resourceName,
long  resourceVal 
)
override

Set the value as an integer for a given named resource.

Parameters
resourceNameThe name of the resource to set.
resourceValThe new integer value to set.

◆ SetIntResource() [2/2]

void SetIntResource ( ResourceHandle  handle,
long  resourceVal 
)
override

Set the value as an integer for a resource specified by handle.

Parameters
handleThe handle of the resource to set.
resourceValThe new integer value to set.

◆ SetLightData()

void SetLightData ( unsigned int  numLights,
LightData *  lightData 
)

Updates the state manager to set various light parameters.

Parameters
numLightsThe number of lights within the lightData.
lightDataAn array of data where each element contains a collection of light properties.

◆ SetMatrix()

void SetMatrix ( int  type,
const float *  matrix 
)

Updates the state manager's top matrix based on the type.

Parameters
[in]typeIf it's equal to RSO_MODELVIEW_MATRIX, it'll load the model view matrix. If it's RSO_PROJECTION_MATRIX, then it'll retrieve the ProjectionMatrix instead.
[in]matrixThe matrix to push to the top of the stack.

◆ SetPainter()

void SetPainter ( RSOPainterT painter)
override

Set the painter for this object, it will manage when this object should be redrawn.

Parameters
painterThe new painter to set, or NULL for no painter.

◆ SetResource() [1/2]

void SetResource ( const char *  resourceName,
const char *  resourceVal 
)
override

Set the string value for a given named resource.

Parameters
resourceNameThe name of the resource to set.
resourceValThe new string value to set for the resource.

◆ SetResource() [2/2]

void SetResource ( ResourceHandle  resourceHandle,
const char *  resourceVal 
)
override

Set the string value for a resource specified by handle

Parameters
resourceHandleThe handle of the resource to set.
resourceValThe new string value to set.

◆ UnregisterResourceObserver()

void UnregisterResourceObserver ( ResourceHandle  resourceHandle,
CallbackID  id 
)
override

Unregister a resource observer

Parameters
resourceHandlethe resource handle used to register the observer
idthe id used to register the resource observer

Member Data Documentation

◆ _component

ComponentBase* _component
protected

Reference to the component being wrapped. GlsRSOInterface1Impl will delete this object.


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