BrainTrain
 All Classes Namespaces Files Functions Variables Macros Pages
brtr::BaseInteractionCallback Class Referenceabstract

This is the TemplateClass for InteractionCallbacks. More...

#include <BaseInteractionCallback.h>

Inheritance diagram for brtr::BaseInteractionCallback:
brtr::AddPortalGunInteractionCallback brtr::DrunkenInteractionCallback brtr::ProgramSwitcherCallback brtr::ToonTexSwitcherCallback

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
 

Detailed Description

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).

Author
Gleb Ostrowski
Version
1.0
Date
2014

Definition at line 24 of file BaseInteractionCallback.h.

Constructor & Destructor Documentation

brtr::BaseInteractionCallback::BaseInteractionCallback ( osg::Node *  attachTo,
osg::Camera *  hudCam,
int  width,
int  height 
)

Constructor.

Parameters
attachTothe node the Callback will be attached to upon interaction
hudCamthe HUDCam, where the text will appear
widthscreenWidth
heightscreenHeight

Definition at line 6 of file BaseInteractionCallback.cpp.

Member Function Documentation

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.

virtual void brtr::BaseInteractionCallback::interact ( osg::Node *  ,
osg::NodeVisitor *   
)
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.

void brtr::BaseInteractionCallback::operator() ( osg::Node *  node,
osg::NodeVisitor *  nv 
)
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.

virtual void brtr::BaseInteractionCallback::setText ( )
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.

Member Data Documentation

osg::ref_ptr<osg::Node> brtr::BaseInteractionCallback::_attachTo
protected

Definition at line 51 of file BaseInteractionCallback.h.

bool brtr::BaseInteractionCallback::_done
protected

Definition at line 53 of file BaseInteractionCallback.h.

osg::ref_ptr<osg::Camera> brtr::BaseInteractionCallback::_hudCam
protected

Definition at line 52 of file BaseInteractionCallback.h.

osg::ref_ptr<osgText::Text> brtr::BaseInteractionCallback::_text
protected

Definition at line 54 of file BaseInteractionCallback.h.


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