// Filename: callbackNode.h // Created by: drose (13Mar09) // //////////////////////////////////////////////////////////////////// // // PANDA 3D SOFTWARE // Copyright (c) Carnegie Mellon University. All rights reserved. // // All use of this software is subject to the terms of the revised BSD // license. You should have received a copy of this license along // with this source code in a file named "LICENSE." // //////////////////////////////////////////////////////////////////// #ifndef CALLBACKNODE_H #define CALLBACKNODE_H #include "pandabase.h" #include "pandaNode.h" #include "callbackObject.h" #include "pointerTo.h" //////////////////////////////////////////////////////////////////// // Class : CallbackNode // Description : A special node that can issue arbitrary callbacks to // user code, either during the cull or draw traversals. //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_PGRAPHNODES CallbackNode : public PandaNode { PUBLISHED: CallbackNode(const string &name); INLINE void set_cull_callback(CallbackObject *object); INLINE void clear_cull_callback(); INLINE CallbackObject *get_cull_callback() const; INLINE void set_draw_callback(CallbackObject *object); INLINE void clear_draw_callback(); INLINE CallbackObject *get_draw_callback() const; public: CallbackNode(const CallbackNode ©); virtual PandaNode *make_copy() const; virtual bool safe_to_combine() const; virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); virtual bool is_renderable() const; virtual void add_for_draw(CullTraverser *trav, CullTraverserData &data); virtual void output(ostream &out) const; private: class EXPCL_PANDA_PGRAPHNODES CData : public CycleData { public: INLINE CData(); INLINE CData(const CData ©); virtual CycleData *make_copy() const; virtual void write_datagram(BamWriter *manager, Datagram &dg) const; virtual void fillin(DatagramIterator &scan, BamReader *manager); virtual TypeHandle get_parent_type() const { return CallbackNode::get_class_type(); } PT(CallbackObject) _cull_callback; PT(CallbackObject) _draw_callback; }; PipelineCycler _cycler; typedef CycleDataReader CDReader; typedef CycleDataWriter CDWriter; public: static void register_with_read_factory(); virtual void write_datagram(BamWriter *manager, Datagram &dg); protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PandaNode::init_type(); register_type(_type_handle, "CallbackNode", PandaNode::get_class_type()); } virtual TypeHandle get_type() const { return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} private: static TypeHandle _type_handle; }; #include "callbackNode.I" #endif