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"
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 {
37PUBLISHED:
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
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
73 public:
74 INLINE static UpdateSeq get_sort_seq();
75
76 protected:
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
83 private:
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
114 public:
115 static void register_with_read_factory();
116 virtual void write_datagram(BamWriter *manager, Datagram &dg);
117
118 protected:
119 static TypedWritable *make_from_bam(const FactoryParams &params);
120 void fillin(DatagramIterator &scan, BamReader *manager);
121
122 public:
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
136 private:
137 static TypeHandle _type_handle;
138};
139
140#include "planeNode.I"
141
142#endif
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
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
CullTraverser
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
Definition cullTraverser.h:45
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:30
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
Geom
A container for geometry primitives.
Definition geom.h:54
PandaNode::cull_callback
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:386
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::register_with_read_factory
static void register_with_read_factory()
Tells the BamReader how to create objects of type PandaNode.
Definition pandaNode.cxx:3593
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
PandaNode::write_datagram
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:3602
PlaneNode::get_priority
get_priority
Returns the priority associated with this clip plane.
Definition planeNode.h:70
PlaneNode::get_clip_effect
get_clip_effect
Returns the clip_effect bits for this clip plane.
Definition planeNode.h:71
PlaneNode::set_priority
set_priority
Changes the relative importance of this PlaneNode (when it is used as a clip plane) relative to the o...
Definition planeNode.h:70
PlaneNode::get_sort_seq
static UpdateSeq get_sort_seq()
Returns a global sequence number that is incremented any time any PlaneNode in the world changes sort...
Definition planeNode.I:138
PlaneNode::set_viz_scale
set_viz_scale
Specifies the size of the visual representation of the plane that is drawn if the PlaneNode is shown.
Definition planeNode.h:69
PlaneNode::get_viz_scale
get_viz_scale
Returns the size of the visual representation of the plane that is drawn if the PlaneNode is shown.
Definition planeNode.h:69
PlaneNode::get_plane
get_plane
Returns the plane represented by the PlaneNode.
Definition planeNode.h:68
PlaneNode::set_clip_effect
set_clip_effect
Specifies the sort of things this plane will actually clip (when it is used as a clip plane).
Definition planeNode.h:71
PlaneNode::set_plane
set_plane
Sets the particular plane represented by the PlaneNode.
Definition planeNode.h:68
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
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
updateSeq.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.