Panda3D
|
A special node that can issue arbitrary callbacks to user code, either during the cull or draw traversals. More...
#include "callbackNode.h"
Classes | |
class | CData |
Public Member Functions | |
CallbackNode (const string &name) | |
CallbackNode (const CallbackNode ©) | |
virtual void | add_for_draw (CullTraverser *trav, CullTraverserData &data) |
Adds the node's contents to the CullResult we are building up during the cull traversal, so that it will be drawn at render time. | |
void | clear_cull_callback () |
Removes the callback set by an earlier call to set_cull_callback(). | |
void | clear_draw_callback () |
Removes the callback set by an earlier call to set_draw_callback(). | |
virtual bool | cull_callback (CullTraverser *trav, CullTraverserData &data) |
This function will be called during the cull traversal to perform any additional operations that should be performed at cull time. | |
virtual TypeHandle | force_init_type () |
CallbackObject * | get_cull_callback () const |
Returns the CallbackObject set by set_cull_callback(). | |
CallbackObject * | get_draw_callback () const |
Returns the CallbackObject set by set_draw_callback(). | |
virtual TypeHandle | get_type () const |
virtual bool | is_renderable () const |
Returns true if there is some value to visiting this particular node during the cull traversal for any camera, false otherwise. | |
virtual PandaNode * | make_copy () const |
Returns a newly-allocated Node that is a shallow copy of this one. | |
virtual void | output (ostream &out) const |
Writes a brief description of the node to the indicated output stream. | |
virtual bool | safe_to_combine () const |
Returns true if it is generally safe to combine this particular kind of PandaNode with other kinds of PandaNodes of compatible type, adding children or whatever. | |
void | set_cull_callback (CallbackObject *object) |
Sets the CallbackObject that will be notified when this node is visited during the cull traversal. | |
void | set_draw_callback (CallbackObject *object) |
Sets the CallbackObject that will be notified when this node is visited during the draw traversal. | |
virtual void | write_datagram (BamWriter *manager, Datagram &dg) |
Writes the contents of this object to the datagram for shipping out to a Bam file. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
static void | register_with_read_factory () |
Tells the BamReader how to create objects of type CallbackNode. | |
Protected Member Functions | |
void | fillin (DatagramIterator &scan, BamReader *manager) |
This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new CallbackNode. | |
Static Protected Member Functions | |
static TypedWritable * | make_from_bam (const FactoryParams ¶ms) |
This function is called by the BamReader's factory when a new object of type CallbackNode is encountered in the Bam file. |
A special node that can issue arbitrary callbacks to user code, either during the cull or draw traversals.
Definition at line 28 of file callbackNode.h.
void CallbackNode::add_for_draw | ( | CullTraverser * | trav, |
CullTraverserData & | data | ||
) | [virtual] |
Adds the node's contents to the CullResult we are building up during the cull traversal, so that it will be drawn at render time.
For most nodes other than GeomNodes, this is a do-nothing operation.
Reimplemented from PandaNode.
Definition at line 149 of file callbackNode.cxx.
References CullTraverser::get_cull_handler(), get_draw_callback(), CullTraverser::get_gsg(), CullTraverserData::get_net_transform(), CullHandler::record_object(), and CullableObject::set_draw_callback().
void CallbackNode::clear_cull_callback | ( | ) | [inline] |
Removes the callback set by an earlier call to set_cull_callback().
Definition at line 59 of file callbackNode.I.
References PandaNode::set_cull_callback().
void CallbackNode::clear_draw_callback | ( | ) | [inline] |
Removes the callback set by an earlier call to set_draw_callback().
Definition at line 114 of file callbackNode.I.
References set_draw_callback().
bool CallbackNode::cull_callback | ( | CullTraverser * | trav, |
CullTraverserData & | data | ||
) | [virtual] |
This function will be called during the cull traversal to perform any additional operations that should be performed at cull time.
This may include additional manipulation of render state or additional visible/invisible decisions, or any other arbitrary operation.
Note that this function will *not* be called unless set_cull_callback() is called in the constructor of the derived class. It is necessary to call set_cull_callback() to indicated that we require cull_callback() to be called.
By the time this function is called, the node has already passed the bounding-volume test for the viewing frustum, and the node's transform and state have already been applied to the indicated CullTraverserData object.
The return value is true if this node should be visible, or false if it should be culled.
Reimplemented from PandaNode.
Definition at line 111 of file callbackNode.cxx.
References CallbackObject::do_callback(), and get_cull_callback().
void CallbackNode::fillin | ( | DatagramIterator & | scan, |
BamReader * | manager | ||
) | [protected, virtual] |
This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new CallbackNode.
Reimplemented from PandaNode.
Definition at line 235 of file callbackNode.cxx.
References BamReader::read_cdata().
Referenced by make_from_bam().
CallbackObject * CallbackNode::get_cull_callback | ( | ) | const [inline] |
Returns the CallbackObject set by set_cull_callback().
Definition at line 69 of file callbackNode.I.
Referenced by cull_callback().
CallbackObject * CallbackNode::get_draw_callback | ( | ) | const [inline] |
Returns the CallbackObject set by set_draw_callback().
Definition at line 124 of file callbackNode.I.
Referenced by add_for_draw(), and NodeCullCallbackData::upcall().
bool CallbackNode::is_renderable | ( | ) | const [virtual] |
Returns true if there is some value to visiting this particular node during the cull traversal for any camera, false otherwise.
This will be used to optimize the result of get_net_draw_show_mask(), so that any subtrees that contain only nodes for which is_renderable() is false need not be visited.
Reimplemented from PandaNode.
Definition at line 136 of file callbackNode.cxx.
PandaNode * CallbackNode::make_copy | ( | ) | const [virtual] |
TypedWritable * CallbackNode::make_from_bam | ( | const FactoryParams & | params | ) | [static, protected] |
This function is called by the BamReader's factory when a new object of type CallbackNode is encountered in the Bam file.
It should create the CallbackNode and extract its information from the file.
Reimplemented from PandaNode.
Definition at line 216 of file callbackNode.cxx.
References fillin().
Referenced by register_with_read_factory().
void CallbackNode::output | ( | ostream & | out | ) | const [virtual] |
Writes a brief description of the node to the indicated output stream.
This is invoked by the << operator. It may be overridden in derived classes to include some information relevant to the class.
Reimplemented from PandaNode.
Definition at line 180 of file callbackNode.cxx.
void CallbackNode::register_with_read_factory | ( | ) | [static] |
Tells the BamReader how to create objects of type CallbackNode.
Reimplemented from PandaNode.
Definition at line 191 of file callbackNode.cxx.
References BamReader::get_factory(), make_from_bam(), and Factory< Type >::register_factory().
bool CallbackNode::safe_to_combine | ( | ) | const [virtual] |
Returns true if it is generally safe to combine this particular kind of PandaNode with other kinds of PandaNodes of compatible type, adding children or whatever.
For instance, an LODNode should not be combined with any other PandaNode, because its set of children is meaningful.
Reimplemented from PandaNode.
Definition at line 81 of file callbackNode.cxx.
void CallbackNode::set_cull_callback | ( | CallbackObject * | object | ) | [inline] |
Sets the CallbackObject that will be notified when this node is visited during the cull traversal.
This callback will be made during the cull thread.
The cull traversal is responsible for determining which nodes are visible and within the view frustum, and for accumulating state and transform, and generally building up the list of CullableObjects that are to be eventually passed to the draw traversal for rendering.
At the time the cull traversal callback is made, the node has been determined to be visible and it has passed the bounding-volume test, so it lies within the view frustum.
The callback is passed an instance of a NodeCullCallbackData, which contains pointers to the CullTraverser and CullTraverserData--enough data to examine the current node and its place within the scene graph. The callback *replaces* the normal cull behavior, so if your callback does nothing, the cull traversal will not continue below this node. If you wish the cull traversal to continue to visit this node and below, you must call cbdata->upcall() from your callback.
Definition at line 47 of file callbackNode.I.
void CallbackNode::set_draw_callback | ( | CallbackObject * | object | ) | [inline] |
Sets the CallbackObject that will be notified when this node is visited during the draw traversal.
This callback will be made during the draw thread.
The draw traversal is responsible for actually issuing the commands to the graphics engine to draw primitives. Its job is to walk through the list of CullableObjects build up by the cull traversal, as quickly as possible, issuing the appropriate commands to draw each one.
At the time the draw traversal callback is made, the graphics state has been loaded with the correct modelview transform and render state, and the primitives (if any) in this node are ready to be drawn.
The callback is passed an instance of a GeomDrawCallbackData, which contains pointers to the current state and transform, as well as the current GSG. There is a Geom pointer as well, but it will always be NULL to this callback, since the CallbackNode does not itself contain any Geoms.
Definition at line 102 of file callbackNode.I.
Referenced by clear_draw_callback().
Writes the contents of this object to the datagram for shipping out to a Bam file.
Reimplemented from PandaNode.
Definition at line 202 of file callbackNode.cxx.
References BamWriter::write_cdata().