BrainTrain
|
This is the TemplateClass for InteractionCallbacks. More...
#include <BaseInteractionCallback.h>
Public Member Functions | |
BaseInteractionCallback (osg::Node *attachTo, osg::Camera *hudCam, int width, int height) | |
Constructor. More... | |
virtual void | operator() (osg::Node *node, osg::NodeVisitor *nv) |
virtual void | setText ()=0 |
sets the text on screen. Subclasses must override to set its own (info)text More... | |
void | clearText () |
void | reactivate () |
osg::ref_ptr< osg::Node > | getNode () const |
void | setNode (osg::ref_ptr< osg::Node > val) |
Protected Member Functions | |
virtual void | interact (osg::Node *, osg::NodeVisitor *)=0 |
the interaction logic must be implemented be the children in this method More... | |
Protected Attributes | |
osg::ref_ptr< osg::Node > | _attachTo |
osg::ref_ptr< osg::Camera > | _hudCam |
bool | _done |
osg::ref_ptr< osgText::Text > | _text |
This is the TemplateClass for InteractionCallbacks.
InteractionCallbacks are set as an UserObject in an UserDataContainer of a Geometry.
Furthermore, the right NodeMask (brtr::interactionMask) must be set.
Every subclass must override the setText() and interact() method.
After the child is finished with its work, it must set the done-flag to the value true
The client must check if there is a valid Geometry with a valid InteractionCallback and call
the setText Method to set the text on screen. If the user interacts (e.g by clicking a mouse button)
the client must attach the callback to the node with getNode()->addUpdateCallback(), if its not already attached.
In this case the client must call reactivate() to reactivate the callback. (which basicly sets the done flag back to false)
clearText() should be called, if the clients wants to remove the message from the screen (e.g. if the player no longer looks at the geometry).
Definition at line 24 of file BaseInteractionCallback.h.
brtr::BaseInteractionCallback::BaseInteractionCallback | ( | osg::Node * | attachTo, |
osg::Camera * | hudCam, | ||
int | width, | ||
int | height | ||
) |
Constructor.
attachTo | the node the Callback will be attached to upon interaction |
hudCam | the HUDCam, where the text will appear |
width | screenWidth |
height | screenHeight |
Definition at line 6 of file BaseInteractionCallback.cpp.
void brtr::BaseInteractionCallback::clearText | ( | ) |
Definition at line 31 of file BaseInteractionCallback.cpp.
osg::ref_ptr< osg::Node > brtr::BaseInteractionCallback::getNode | ( | ) | const |
Definition at line 27 of file BaseInteractionCallback.cpp.
|
protectedpure virtual |
the interaction logic must be implemented be the children in this method
Implemented in brtr::ProgramSwitcherCallback, brtr::ToonTexSwitcherCallback, brtr::DrunkenInteractionCallback, and brtr::AddPortalGunInteractionCallback.
|
virtual |
Definition at line 16 of file BaseInteractionCallback.cpp.
void brtr::BaseInteractionCallback::reactivate | ( | ) |
Definition at line 35 of file BaseInteractionCallback.cpp.
void brtr::BaseInteractionCallback::setNode | ( | osg::ref_ptr< osg::Node > | val | ) |
Definition at line 23 of file BaseInteractionCallback.cpp.
|
pure virtual |
sets the text on screen. Subclasses must override to set its own (info)text
Implemented in brtr::ProgramSwitcherCallback, brtr::ToonTexSwitcherCallback, brtr::DrunkenInteractionCallback, and brtr::AddPortalGunInteractionCallback.
|
protected |
Definition at line 51 of file BaseInteractionCallback.h.
|
protected |
Definition at line 53 of file BaseInteractionCallback.h.
|
protected |
Definition at line 52 of file BaseInteractionCallback.h.
|
protected |
Definition at line 54 of file BaseInteractionCallback.h.