Panda3D
occluderNode.h
1 // Filename: occluderNode.h
2 // Created by: jenes (11Mar11)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef OCCLUDERNODE_H
16 #define OCCLUDERNODE_H
17 
18 #include "pandabase.h"
19 
20 #include "pandaNode.h"
21 #include "nodePath.h"
22 #include "pvector.h"
23 #include "geom.h"
24 #include "texture.h"
25 
26 ////////////////////////////////////////////////////////////////////
27 // Class : OccluderNode
28 // Description : A node in the scene graph that can hold an
29 // occluder polygon, which must be a rectangle. When
30 // the occluder is activated with something like
31 // render.set_occluder(), then objects whose bouding
32 // volume lies entirely behind the occluder will not be
33 // rendered.
34 ////////////////////////////////////////////////////////////////////
35 class EXPCL_PANDA_PGRAPH OccluderNode : public PandaNode {
36 PUBLISHED:
37  OccluderNode(const string &name);
38 
39 protected:
40  OccluderNode(const OccluderNode &copy);
41 
42 public:
43  virtual ~OccluderNode();
44  virtual PandaNode *make_copy() const;
45  virtual bool preserve_name() const;
46  virtual void xform(const LMatrix4 &mat);
47 
48  virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
49  virtual bool is_renderable() const;
50 
51  virtual void output(ostream &out) const;
52 
53 PUBLISHED:
54  INLINE void set_double_sided(bool value);
55  INLINE bool is_double_sided();
56  INLINE void set_min_coverage(PN_stdfloat value);
57  INLINE PN_stdfloat get_min_coverage();
58  INLINE void set_vertices(const LPoint3 &v0, const LPoint3 &v1,
59  const LPoint3 &v2, const LPoint3 &v3);
60  INLINE int get_num_vertices() const;
61  INLINE const LPoint3 &get_vertex(int n) const;
62  MAKE_SEQ(get_vertices, get_num_vertices, get_vertex);
63 
64 protected:
65  virtual void compute_internal_bounds(CPT(BoundingVolume) &internal_bounds,
66  int &internal_vertices,
67  int pipeline_stage,
68  Thread *current_thread) const;
69  PT(Geom) get_occluder_viz(CullTraverser *trav, CullTraverserData &data);
70  CPT(RenderState) get_occluder_viz_state(CullTraverser *trav, CullTraverserData &data);
71  CPT(RenderState) get_frame_viz_state(CullTraverser *trav, CullTraverserData &data);
72 
73 private:
74  bool _double_sided;
75  PN_stdfloat _min_coverage;
76  typedef pvector<LPoint3> Vertices;
77  Vertices _vertices;
78 
79  PT(Geom) _occluder_viz, _frame_viz;
80  static PT(Texture) _viz_tex;
81 
82 public:
83  static void register_with_read_factory();
84  virtual void write_datagram(BamWriter *manager, Datagram &dg);
85  virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
86 
87 protected:
88  static TypedWritable *make_from_bam(const FactoryParams &params);
89  void fillin(DatagramIterator &scan, BamReader *manager);
90 
91 public:
92  static TypeHandle get_class_type() {
93  return _type_handle;
94  }
95  static void init_type() {
96  PandaNode::init_type();
97  register_type(_type_handle, "OccluderNode",
98  PandaNode::get_class_type());
99  }
100  virtual TypeHandle get_type() const {
101  return get_class_type();
102  }
103  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
104 
105 private:
106  static TypeHandle _type_handle;
107 };
108 
109 #include "occluderNode.I"
110 
111 #endif
virtual bool preserve_name() const
Returns true if the node&#39;s name has extrinsic meaning and must be preserved across a flatten operatio...
Definition: pandaNode.cxx:319
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: pandaNode.cxx:4164
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:75
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
This is our own Panda specialization on the default STL list.
Definition: plist.h:38
static void register_with_read_factory()
Tells the BamReader how to create objects of type PandaNode.
Definition: pandaNode.cxx:4153
A node in the scene graph that can hold an occluder polygon, which must be a rectangle.
Definition: occluderNode.h:35
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so...
Definition: pandaNode.cxx:377
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin()...
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
A container for geometry primitives.
Definition: geom.h:58
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Definition: pandaNode.cxx:604
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
A thread; that is, a lightweight process.
Definition: thread.h:51
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
virtual bool is_renderable() const
Returns true if there is some value to visiting this particular node during the cull traversal for an...
Definition: pandaNode.cxx:578
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
Definition: cullTraverser.h:48