Panda3D
Loading...
Searching...
No Matches
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"
25#include "cycleDataReader.h"
26#include "cycleDataWriter.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 */
36class EXPCL_PANDA_PGRAPH PlaneNode : public PandaNode {
37PUBLISHED:
38 explicit PlaneNode(const std::string &name, const LPlane &plane = LPlane());
39
40protected:
41 PlaneNode(const PlaneNode &copy);
42public:
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
51PUBLISHED:
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 MAKE_PROPERTY(plane, get_plane, set_plane);
69 MAKE_PROPERTY(viz_scale, get_viz_scale, set_viz_scale);
70 MAKE_PROPERTY(priority, get_priority, set_priority);
71 MAKE_PROPERTY(clip_effect, get_clip_effect, set_clip_effect);
72
73public:
74 INLINE static UpdateSeq get_sort_seq();
75
76protected:
77 virtual void compute_internal_bounds(CPT(BoundingVolume) &internal_bounds,
78 int &internal_vertices,
79 int pipeline_stage,
80 Thread *current_thread) const;
81 PT(Geom) get_viz(CullTraverser *trav, CullTraverserData &data);
82
83private:
84 // The priority is not cycled, because there's no real reason to do so, and
85 // cycling it makes it difficult to synchronize with the ClipPlaneAttribs.
86 int _priority;
87 int _clip_effect;
88 static UpdateSeq _sort_seq;
89
90 // This is the data that must be cycled between pipeline stages.
91 class EXPCL_PANDA_PGRAPH CData : public CycleData {
92 public:
93 INLINE CData();
94 INLINE CData(const CData &copy);
95 virtual CycleData *make_copy() const;
96 virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
97 virtual void fillin(DatagramIterator &scan, BamReader *manager);
98 virtual TypeHandle get_parent_type() const {
99 return PlaneNode::get_class_type();
100 }
101
102 LPlane _plane;
103 PT(Geom) _front_viz, _back_viz;
104 PN_stdfloat _viz_scale;
105 };
106
107 PipelineCycler<CData> _cycler;
108 typedef CycleDataLockedReader<CData> CDLockedReader;
109 typedef CycleDataReader<CData> CDReader;
110 typedef CycleDataWriter<CData> CDWriter;
111 typedef CycleDataStageReader<CData> CDStageReader;
112 typedef CycleDataStageWriter<CData> CDStageWriter;
113
114public:
115 static void register_with_read_factory();
116 virtual void write_datagram(BamWriter *manager, Datagram &dg);
117
118protected:
119 static TypedWritable *make_from_bam(const FactoryParams &params);
120 void fillin(DatagramIterator &scan, BamReader *manager);
121
122public:
123 static TypeHandle get_class_type() {
124 return _type_handle;
125 }
126 static void init_type() {
127 PandaNode::init_type();
128 register_type(_type_handle, "PlaneNode",
129 PandaNode::get_class_type());
130 }
131 virtual TypeHandle get_type() const {
132 return get_class_type();
133 }
134 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
135
136private:
137 static TypeHandle _type_handle;
138};
139
140#include "planeNode.I"
141
142#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,...
This template class calls PipelineCycler::read() in the constructor and PipelineCycler::release_read(...
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
This class is similar to CycleDataReader, except it allows reading from a particular stage of the pip...
This class is similar to CycleDataWriter, except it allows writing to a particular stage of the pipel...
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
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
An instance of this class is passed to the Factory when requesting it to do its business and construc...
A container for geometry primitives.
Definition geom.h:54
A basic node of the scene graph or data graph.
Definition pandaNode.h:65
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 void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so.
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
A node that contains a plane.
Definition planeNode.h:36
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.
This is a sequence number that increments monotonically.
Definition updateSeq.h:37
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.
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(),...
This class maintains different copies of a page of data between stages of the graphics pipeline (or a...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.