Panda3D
Loading...
Searching...
No Matches
callbackNode.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file callbackNode.h
10 * @author drose
11 * @date 2009-03-13
12 */
13
14#ifndef CALLBACKNODE_H
15#define CALLBACKNODE_H
16
17#include "pandabase.h"
18#include "pandaNode.h"
19#include "callbackObject.h"
20#include "pointerTo.h"
21
22/**
23 * A special node that can issue arbitrary callbacks to user code, either
24 * during the cull or draw traversals.
25 */
26class EXPCL_PANDA_PGRAPHNODES CallbackNode : public PandaNode {
27PUBLISHED:
28 explicit CallbackNode(const std::string &name);
29
30 INLINE void set_cull_callback(CallbackObject *object);
31 INLINE void clear_cull_callback();
32 INLINE CallbackObject *get_cull_callback() const;
34
35 INLINE void set_draw_callback(CallbackObject *object);
36 INLINE void clear_draw_callback();
37 INLINE CallbackObject *get_draw_callback() const;
38 MAKE_PROPERTY(draw_callback, get_draw_callback, set_draw_callback);
39
40public:
41 CallbackNode(const CallbackNode &copy);
42
43 virtual PandaNode *make_copy() const;
44 virtual bool safe_to_combine() const;
45
46 virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
47 virtual bool is_renderable() const;
48 virtual void add_for_draw(CullTraverser *trav, CullTraverserData &data);
49
50 virtual void output(std::ostream &out) const;
51
52private:
53 class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
54 public:
55 INLINE CData();
56 INLINE CData(const CData &copy);
57 virtual CycleData *make_copy() const;
58 virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
59 virtual void fillin(DatagramIterator &scan, BamReader *manager);
60 virtual TypeHandle get_parent_type() const {
61 return CallbackNode::get_class_type();
62 }
63
64 PT(CallbackObject) _cull_callback;
65 PT(CallbackObject) _draw_callback;
66 };
67
68 PipelineCycler<CData> _cycler;
69 typedef CycleDataReader<CData> CDReader;
70 typedef CycleDataWriter<CData> CDWriter;
71
72public:
73 static void register_with_read_factory();
74 virtual void write_datagram(BamWriter *manager, Datagram &dg);
75
76protected:
77 static TypedWritable *make_from_bam(const FactoryParams &params);
78 void fillin(DatagramIterator &scan, BamReader *manager);
79
80public:
81 static TypeHandle get_class_type() {
82 return _type_handle;
83 }
84 static void init_type() {
85 PandaNode::init_type();
86 register_type(_type_handle, "CallbackNode",
87 PandaNode::get_class_type());
88 }
89 virtual TypeHandle get_type() const {
90 return get_class_type();
91 }
92 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
93
94private:
95 static TypeHandle _type_handle;
96};
97
98#include "callbackNode.I"
99
100#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
get_cull_callback
Returns the CallbackObject set by set_cull_callback().
get_draw_callback
Returns the CallbackObject set by set_draw_callback().
set_cull_callback
Sets the CallbackObject that will be notified when this node is visited during the cull traversal.
void clear_draw_callback()
Removes the callback set by an earlier call to set_draw_callback().
set_draw_callback
Sets the CallbackObject that will be notified when this node is visited during the draw traversal.
virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data)
This function will be called during the cull traversal to perform any additional operations that shou...
virtual void output(std::ostream &out) const
Writes a brief description of the node to the indicated output stream.
void clear_cull_callback()
Removes the callback set by an earlier call to set_cull_callback().
This is a generic object that can be assigned to a callback at various points in the rendering proces...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
A single page of data maintained by a PipelineCycler.
Definition cycleData.h:50
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data)
This function will be called during the cull traversal to perform any additional operations that shou...
virtual bool safe_to_combine() const
Returns true if it is generally safe to combine this particular kind of PandaNode with other kinds of...
virtual bool is_renderable() const
Returns true if there is some value to visiting this particular node during the cull traversal for an...
static void register_with_read_factory()
Tells the BamReader how to create objects of type PandaNode.
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
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,...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...