Panda3D
occluderNode.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 occluderNode.h
10  * @author jenes
11  * @date 2011-03-11
12  */
13 
14 #ifndef OCCLUDERNODE_H
15 #define OCCLUDERNODE_H
16 
17 #include "pandabase.h"
18 
19 #include "pandaNode.h"
20 #include "nodePath.h"
21 #include "pvector.h"
22 #include "geom.h"
23 #include "texture.h"
24 
25 /**
26  * A node in the scene graph that can hold an occluder polygon, which must be
27  * a rectangle. When the occluder is activated with something like
28  * render.set_occluder(), then objects whose bouding volume lies entirely
29  * behind the occluder will not be rendered.
30  */
31 class EXPCL_PANDA_PGRAPH OccluderNode : public PandaNode {
32 PUBLISHED:
33  explicit OccluderNode(const std::string &name);
34 
35 protected:
36  OccluderNode(const OccluderNode &copy);
37 
38 public:
39  virtual ~OccluderNode();
40  virtual PandaNode *make_copy() const;
41  virtual bool preserve_name() const;
42  virtual void xform(const LMatrix4 &mat);
43 
44  virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
45  virtual bool is_renderable() const;
46 
47  virtual void output(std::ostream &out) const;
48 
49 PUBLISHED:
50  INLINE void set_double_sided(bool value);
51  INLINE bool is_double_sided();
52  INLINE void set_min_coverage(PN_stdfloat value);
53  INLINE PN_stdfloat get_min_coverage();
54  INLINE void set_vertices(const LPoint3 &v0, const LPoint3 &v1,
55  const LPoint3 &v2, const LPoint3 &v3);
56  INLINE size_t get_num_vertices() const;
57  INLINE const LPoint3 &get_vertex(size_t n) const;
58  INLINE void set_vertex(size_t n, const LPoint3 &v);
59  MAKE_SEQ(get_vertices, get_num_vertices, get_vertex);
60 
61  MAKE_PROPERTY(double_sided, is_double_sided, set_double_sided);
62  MAKE_PROPERTY(min_coverage, get_min_coverage, set_min_coverage);
63  MAKE_SEQ_PROPERTY(vertices, get_num_vertices, get_vertex, set_vertex);
64 
65 protected:
66  virtual void compute_internal_bounds(CPT(BoundingVolume) &internal_bounds,
67  int &internal_vertices,
68  int pipeline_stage,
69  Thread *current_thread) const;
70  PT(Geom) get_occluder_viz(CullTraverser *trav, CullTraverserData &data);
71  CPT(RenderState) get_occluder_viz_state(CullTraverser *trav, CullTraverserData &data);
72  CPT(RenderState) get_frame_viz_state(CullTraverser *trav, CullTraverserData &data);
73 
74 private:
75  bool _double_sided;
76  PN_stdfloat _min_coverage;
77  typedef pvector<LPoint3> Vertices;
78  Vertices _vertices;
79 
80  PT(Geom) _occluder_viz, _frame_viz;
81  static PT(Texture) _viz_tex;
82 
83 public:
84  static void register_with_read_factory();
85  virtual void write_datagram(BamWriter *manager, Datagram &dg);
86  virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
87 
88 protected:
89  static TypedWritable *make_from_bam(const FactoryParams &params);
90  void fillin(DatagramIterator &scan, BamReader *manager);
91 
92 public:
93  static TypeHandle get_class_type() {
94  return _type_handle;
95  }
96  static void init_type() {
97  PandaNode::init_type();
98  register_type(_type_handle, "OccluderNode",
99  PandaNode::get_class_type());
100  }
101  virtual TypeHandle get_type() const {
102  return get_class_type();
103  }
104  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
105 
106 private:
107  static TypeHandle _type_handle;
108 };
109 
110 #include "occluderNode.I"
111 
112 #endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
Definition: cullTraverser.h:45
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
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
A container for geometry primitives.
Definition: geom.h:54
A node in the scene graph that can hold an occluder polygon, which must be a rectangle.
Definition: occluderNode.h:31
A basic node of the scene graph or data graph.
Definition: pandaNode.h:65
virtual bool preserve_name() const
Returns true if the node's name has extrinsic meaning and must be preserved across a flatten operatio...
Definition: pandaNode.cxx:256
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:462
static void register_with_read_factory()
Tells the BamReader how to create objects of type PandaNode.
Definition: pandaNode.cxx:3574
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:304
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Definition: pandaNode.cxx:481
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:3583
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:47
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:71
A thread; that is, a lightweight process.
Definition: thread.h:46
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
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 our own Panda specialization on the default STL list.
Definition: plist.h:35
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.