Panda3D
 All Classes Functions Variables Enumerations
planeNode.h
1 // Filename: planeNode.h
2 // Created by: drose (11Jul02)
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 PLANENODE_H
16 #define PLANENODE_H
17 
18 #include "pandabase.h"
19 
20 #include "plane.h"
21 #include "pandaNode.h"
22 #include "updateSeq.h"
23 #include "geom.h"
24 #include "cycleData.h"
25 #include "cycleDataLockedReader.h"
26 #include "cycleDataReader.h"
27 #include "cycleDataWriter.h"
28 #include "cycleDataStageReader.h"
29 #include "cycleDataStageWriter.h"
30 #include "pipelineCycler.h"
31 
32 ////////////////////////////////////////////////////////////////////
33 // Class : PlaneNode
34 // Description : A node that contains a plane. This is most often
35 // used as a clipping plane, but it can serve other
36 // purposes as well; whenever a plane is needed to be
37 // defined in some coordinate space in the world.
38 ////////////////////////////////////////////////////////////////////
39 class EXPCL_PANDA_PGRAPH PlaneNode : public PandaNode {
40 PUBLISHED:
41  PlaneNode(const string &name, const LPlane &plane = LPlane());
42 
43 protected:
44  PlaneNode(const PlaneNode &copy);
45 public:
46  virtual void output(ostream &out) const;
47 
48  virtual PandaNode *make_copy() const;
49  virtual void xform(const LMatrix4 &mat);
50 
51  virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
52  virtual bool is_renderable() const;
53 
54 PUBLISHED:
55  INLINE void set_plane(const LPlane &plane);
56  INLINE const LPlane &get_plane() const;
57 
58  INLINE void set_viz_scale(PN_stdfloat viz_scale);
59  INLINE PN_stdfloat get_viz_scale() const;
60 
61  INLINE void set_priority(int priority);
62  INLINE int get_priority() const;
63 
64  enum ClipEffect {
65  CE_visible = 0x0001,
66  CE_collision = 0x0002,
67  };
68  INLINE void set_clip_effect(int clip_effect);
69  INLINE int get_clip_effect() const;
70 
71 public:
72  INLINE static UpdateSeq get_sort_seq();
73 
74 protected:
75  virtual void compute_internal_bounds(CPT(BoundingVolume) &internal_bounds,
76  int &internal_vertices,
77  int pipeline_stage,
78  Thread *current_thread) const;
79  PT(Geom) get_viz(CullTraverser *trav, CullTraverserData &data);
80 
81 private:
82  // The priority is not cycled, because there's no real reason to do
83  // so, and cycling it makes it difficult to synchronize with the
84  // ClipPlaneAttribs.
85  int _priority;
86  int _clip_effect;
87  static UpdateSeq _sort_seq;
88 
89  // This is the data that must be cycled between pipeline stages.
90  class EXPCL_PANDA_PGRAPH CData : public CycleData {
91  public:
92  INLINE CData();
93  INLINE CData(const CData &copy);
94  virtual CycleData *make_copy() const;
95  virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
96  virtual void fillin(DatagramIterator &scan, BamReader *manager);
97  virtual TypeHandle get_parent_type() const {
98  return PlaneNode::get_class_type();
99  }
100 
101  LPlane _plane;
102  PT(Geom) _front_viz, _back_viz;
103  PN_stdfloat _viz_scale;
104  };
105 
106  PipelineCycler<CData> _cycler;
112 
113 public:
114  static void register_with_read_factory();
115  virtual void write_datagram(BamWriter *manager, Datagram &dg);
116 
117 protected:
118  static TypedWritable *make_from_bam(const FactoryParams &params);
119  void fillin(DatagramIterator &scan, BamReader *manager);
120 
121 public:
122  static TypeHandle get_class_type() {
123  return _type_handle;
124  }
125  static void init_type() {
126  PandaNode::init_type();
127  register_type(_type_handle, "PlaneNode",
128  PandaNode::get_class_type());
129  }
130  virtual TypeHandle get_type() const {
131  return get_class_type();
132  }
133  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
134 
135 private:
136  static TypeHandle _type_handle;
137 };
138 
139 #include "planeNode.I"
140 
141 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
This class is similar to CycleDataWriter, except it allows writing to a particular stage of the pipel...
A single page of data maintained by a PipelineCycler.
Definition: cycleData.h:50
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 ...
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Definition: pandaNode.cxx:604
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
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
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
This template class calls PipelineCycler::read() in the constructor and PipelineCycler::release_read(...
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 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 template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class&#39;s make_from_bam() method to read in all...
Definition: cycleData.cxx:68
This class is similar to CycleDataReader, except it allows reading from a particular stage of the pip...
A thread; that is, a lightweight process.
Definition: thread.h:51
A class to retrieve the individual data elements previously stored in a Datagram. ...
virtual void write_datagram(BamWriter *, Datagram &) const
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: cycleData.cxx:34
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This is a sequence number that increments monotonically.
Definition: updateSeq.h:43
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
Definition: cullTraverser.h:48
A node that contains a plane.
Definition: planeNode.h:39
virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data)
This function will be called during the cull traversal to perform any additional operations that shou...
Definition: pandaNode.cxx:477