Panda3D

planeNode.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 planeNode.h
10 * @author drose
11 * @date 2002-07-11
12 */
13
14 #ifndef PLANENODE_H
15 #define PLANENODE_H
16
17 #include "pandabase.h"
18
19 #include "plane.h"
20 #include "pandaNode.h"
21 #include "updateSeq.h"
22 #include "geom.h"
23 #include "cycleData.h"
24 #include "cycleDataLockedReader.h"
25 #include "cycleDataReader.h"
26 #include "cycleDataWriter.h"
27 #include "cycleDataStageReader.h"
28 #include "cycleDataStageWriter.h"
29 #include "pipelineCycler.h"
30
31 /**
32 * A node that contains a plane. This is most often used as a clipping plane,
33 * but it can serve other purposes as well; whenever a plane is needed to be
34 * defined in some coordinate space in the world.
35 */
36 class EXPCL_PANDA_PGRAPH PlaneNode : public PandaNode {
37 PUBLISHED:
38 explicit PlaneNode(const std::string &name, const LPlane &plane = LPlane());
39
40 protected:
41 PlaneNode(const PlaneNode &copy);
42 public:
43 virtual void output(std::ostream &out) const;
44
45 virtual PandaNode *make_copy() 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 PUBLISHED:
52 INLINE void set_plane(const LPlane &plane);
53 INLINE const LPlane &get_plane() const;
54
55 INLINE void set_viz_scale(PN_stdfloat viz_scale);
56 INLINE PN_stdfloat get_viz_scale() const;
57
58 INLINE void set_priority(int priority);
59 INLINE int get_priority() const;
60
61 enum ClipEffect {
62 CE_visible = 0x0001,
63 CE_collision = 0x0002,
64 };
65 INLINE void set_clip_effect(int clip_effect);
66 INLINE int get_clip_effect() const;
67
68 public:
69 INLINE static UpdateSeq get_sort_seq();
70
71 protected:
72 virtual void compute_internal_bounds(CPT(BoundingVolume) &internal_bounds,
73 int &internal_vertices,
74 int pipeline_stage,
75 Thread *current_thread) const;
76 PT(Geom) get_viz(CullTraverser *trav, CullTraverserData &data);
77
78 private:
79 // The priority is not cycled, because there's no real reason to do so, and
80 // cycling it makes it difficult to synchronize with the ClipPlaneAttribs.
81 int _priority;
82 int _clip_effect;
83 static UpdateSeq _sort_seq;
84
85 // This is the data that must be cycled between pipeline stages.
86 class EXPCL_PANDA_PGRAPH CData : public CycleData {
87 public:
88 INLINE CData();
89 INLINE CData(const CData &copy);
90 virtual CycleData *make_copy() const;
91 virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
92 virtual void fillin(DatagramIterator &scan, BamReader *manager);
93 virtual TypeHandle get_parent_type() const {
94 return PlaneNode::get_class_type();
95 }
96
97 LPlane _plane;
98 PT(Geom) _front_viz, _back_viz;
99 PN_stdfloat _viz_scale;
100 };
101
102 PipelineCycler<CData> _cycler;
103 typedef CycleDataLockedReader<CData> CDLockedReader;
104 typedef CycleDataReader<CData> CDReader;
105 typedef CycleDataWriter<CData> CDWriter;
106 typedef CycleDataStageReader<CData> CDStageReader;
107 typedef CycleDataStageWriter<CData> CDStageWriter;
108
109 public:
110 static void register_with_read_factory();
111 virtual void write_datagram(BamWriter *manager, Datagram &dg);
112
113 protected:
114 static TypedWritable *make_from_bam(const FactoryParams &params);
115 void fillin(DatagramIterator &scan, BamReader *manager);
116
117 public:
118 static TypeHandle get_class_type() {
119 return _type_handle;
120 }
121 static void init_type() {
122 PandaNode::init_type();
123 register_type(_type_handle, "PlaneNode",
124 PandaNode::get_class_type());
125 }
126 virtual TypeHandle get_type() const {
127 return get_class_type();
128 }
129 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
130
131 private:
132 static TypeHandle _type_handle;
133 };
134
135 #include "planeNode.I"
136
137 #endif
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
BamWriter
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
BoundingVolume
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
Definition: boundingVolume.h:41
CullTraverserData
This collects together the pieces of data that are accumulated for each node while walking the scene ...
Definition: cullTraverserData.h:40
CullTraverser
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
Definition: cullTraverser.h:45
CycleDataLockedReader
This template class calls PipelineCycler::read() in the constructor and PipelineCycler::release_read(...
Definition: cycleDataLockedReader.h:40
CycleDataReader
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
Definition: cycleDataReader.h:35
CycleDataStageReader
This class is similar to CycleDataReader, except it allows reading from a particular stage of the pip...
Definition: cycleDataStageReader.h:27
CycleDataStageWriter
This class is similar to CycleDataWriter, except it allows writing to a particular stage of the pipel...
Definition: cycleDataStageWriter.h:31
CycleDataWriter
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
Definition: cycleDataWriter.h:34
CycleData
A single page of data maintained by a PipelineCycler.
Definition: cycleData.h:50
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition: datagramIterator.h:27
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
Geom
A container for geometry primitives.
Definition: geom.h:54
PandaNode
A basic node of the scene graph or data graph.
Definition: pandaNode.h:65
PandaNode::is_renderable
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
PandaNode::xform
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
PandaNode::make_copy
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Definition: pandaNode.cxx:481
PlaneNode
A node that contains a plane.
Definition: planeNode.h:36
Thread
A thread; that is, a lightweight process.
Definition: thread.h:46
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
TypedWritable
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
UpdateSeq
This is a sequence number that increments monotonically.
Definition: updateSeq.h:37
cycleDataLockedReader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
cycleDataReader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
cycleDataStageReader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
cycleDataStageWriter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
cycleDataWriter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
cycleData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
geom.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandaNode.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pipelineCycler.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
planeNode.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
plane.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
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
PipelineCycler< CData >
updateSeq.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.