#include <Renderable.h>
Inheritance diagram for Renderable:
This is the base class, and a new effect/renderer should sub-class from it.
Please note: this object contains a gutz::Manip smart pointer, when it is constructed (by default) it creates a new manipulator (_manip). USE IT! It is generally assumed that you might want to interact with your object this is why we create one for you. If you just want to interact with your object with the least amout of effort, call setManipEventsDefault() and follow the notes on GL picking (below). If you don't override the mouse() and move() functions then events are automatically forwarded to your Manip. Apply your manip (using OpenGL) like this:
glPushMatrix(); { glMultMatrixf(_manip->getWorldTransform().m); /* ... draw stuff ...*/ } glPopMatrix();
NOTE on GL picking (gl interaction):
There are 2 strict rules for GL style picking of renderables.
1) push the RENDERABLE_NAME on the gl name stack first
2) push your (Renderable*) pointer onto the stack as an unsigned int
Like this:
glPushName(RENDERABLE_NAME); glPushName((unsigned int)(Renderable *)this);
There is a third rule, but it is obvious:
3) Pop all names that you pushed onto the stack back off when you are done rendering.
Like this:
Here is what your draw function might look like if you are using OpenGL, you want interaction, and you are using the _manip for the transformation:
void draw(const gutz::RenderEvent &re) { glPushName(RENDERABLE_NAME); glPushName((unsigned int)(Renderable *)this); glPushMatrix(); { glMultMatrixf(_manip->getWorldTransform().m); /* ... draw your geometry ...*/ } glPopMatrix(); glPopName(); ///DONT FORGET THESE!!! glPopName(); }
Why is this object "Counted", see gutz::Counted and gutz::SmartPtr for details on what this means.
This object really needs to be counted, since it is usualy the primary interface to renderable objects for any framework that uses them. This may be problematic in situations with polymorphisim in the hierarchy's derivation. Oh well, need to deal with this somehow, I think that this kind of baddness will be rare if you can sepparate the appearance from the behavior/data associated with a renderable object.
NOTE: Please be carefull, you need to make very sure that if a renderable pushes its name on the glName stack for GL style picking, it better have a smartptr to it somewhere, or the object that created it needs to do the reference counting, since the user interface is probably going to keep a smartptr to it too. This can lead to trouble if the user interface's smart pointer calls delete on the object because it has no references, or the objects owner deletes it. This is the classic smart pointer problem; bad things occur when we create objects on the stack, or we create objects that have automatic deletion, like non-smart pointer member variables. See gutz::SmartPtr & gutz::Counted
See also: gutz::RenderEvent, gutz::MouseEvent, gutz::MouseMoveEvent
Definition at line 125 of file Renderable.h.
DRAW! | |
This is the draw function.
Calling it renders the object. Pure virtual, you must override this function in a subclass. | |
virtual void | draw (const gutz::RenderEvent &rs)=0 |
Draw on/off. | |
bool | isOn () const |
void | setOn (bool yes) |
Delete. | |
Does this object need to be removed from a render list? This means that the object is finished and anyone with a smart pointer to it needs to delete the smart pointer and stop using the renderable. | |
bool | needsDelete () const |
void | setDelete (bool yes) |
Interaction Functions | |
Return true if the event was for you.
By default interaction is forwarded to your protected manipulator (_manip). To use it just apply it in your draw function. However, if you don't add any events or call setManipEventsDefault(), you won't have any interaction. Override these functions in your base class to implement custom behaviors. | |
virtual bool | key (unsigned char k, int x, int y) |
virtual bool | mouse (const gutz::MouseEvent &me) |
virtual bool | move (const gutz::MouseMoveEvent &mme) |
Selected | |
Is this object currently selected? | |
virtual void | setSelected (bool yes) |
bool | isSelected () const |
Manipulator Interface | |
gutz::Manip * | getManip () const |
void | setManip (gutz::Manip *const m) |
void | setManipEventsDefault () |
you have to call this to enable default interaction, OR customize the manipulators events yourself. | |
copy/assign | |
Renderable (const Renderable &r) | |
Renderable & | operator= (const Renderable &r) |
Public Member Functions | |
~Renderable () | |
Protected Member Functions | |
Renderable () | |
since this is a base class/interface it cannot be publicly created. | |
virtual void | _incCount () |
gutz::Counted interface, increment reference count by one. | |
virtual void | _decCount () |
gutz::Counted interface, decrement reference count by one. | |
virtual int | _getCount () const |
gutz::Counted interface, get the current reference count. | |
Protected Attributes | |
bool | _on |
is this renderable currently "render-able"? | |
bool | _selected |
is this renderable selected? | |
bool | _deleteMe |
does this object need to be deleted? | |
gutz::ManipSP | _manip |
You get a manipulator free, no charge. | |
Friends | |
class | SmartPtr |
class | SmartPtrRef |
|
Definition at line 127 of file Renderable.h. |
|
since this is a base class/interface it cannot be publicly created. Only derived classes can construct this guy. Definition at line 206 of file Renderable.h. |
|
Definition at line 217 of file Renderable.h. |
|
gutz::Counted interface, decrement reference count by one. Not generaly used by subclasses, mostly for collaboration with gutz::SmartPtr. Sometimes you need to call this though, see the documentation for gutz::SmartPtr Definition at line 54 of file smartptr.h. Referenced by TFImage::clear(), NrroImage::fBlendOverRGBA(), and Nrro::updateMinMax(). |
|
gutz::Counted interface, get the current reference count. Not generaly used by subclasses, mostly for collaboration with gutz::SmartPtr. Definition at line 58 of file smartptr.h. |
|
gutz::Counted interface, increment reference count by one. Not generaly used by subclasses, mostly for collaboration with gutz::SmartPtr. Sometimes you need to call this though, see the documentation for gutz::SmartPtr Definition at line 48 of file smartptr.h. Referenced by TFImage::clear(), NrroImage::fBlendOverRGBA(), and Nrro::updateMinMax(). |
|
Implemented in VolRenBase, and WidgetItem. |
|
Definition at line 184 of file Renderable.h. References _manip. |
|
Definition at line 141 of file Renderable.h. References _on. |
|
Definition at line 177 of file Renderable.h. References _selected. |
|
Definition at line 166 of file Renderable.h. |
|
Reimplemented in WidgetItem. Definition at line 167 of file Renderable.h. References _manip. |
|
Reimplemented in WidgetItem. Definition at line 168 of file Renderable.h. References _manip. |
|
Definition at line 152 of file Renderable.h. References _deleteMe. |
|
Definition at line 225 of file Renderable.h. References _manip, _on, and r. Referenced by NodeWidget::operator=(), and EdgeWidget::operator=(). |
|
Definition at line 153 of file Renderable.h. |
|
Definition at line 185 of file Renderable.h. References _manip. |
|
you have to call this to enable default interaction, OR customize the manipulators events yourself.
Definition at line 188 of file Renderable.h. References _manip. |
|
Definition at line 142 of file Renderable.h. References _on. Referenced by setDelete(). |
|
Definition at line 176 of file Renderable.h. References _selected. |
|
Definition at line 40 of file smartptr.h. Referenced by Nrro::NrroIter< T >::NrroIter(). |
|
Definition at line 41 of file smartptr.h. |
|
does this object need to be deleted?
Definition at line 237 of file Renderable.h. Referenced by needsDelete(), Renderable(), and setDelete(). |
|
|
is this renderable currently "render-able"?
Definition at line 235 of file Renderable.h. Referenced by isOn(), operator=(), Renderable(), and setOn(). |
|
is this renderable selected?
Definition at line 236 of file Renderable.h. Referenced by isSelected(), Renderable(), and setSelected(). |