Panda3D

Loading...
Searching...
No Matches
portalNode.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 portalNode.h
10 * @author masad
11 * @date 2004-05-13
12 */
13
14#ifndef PORTALNODE_H
15#define PORTALNODE_H
16
17#include "pandabase.h"
18
19#include "portalMask.h"
20#include "pandaNode.h"
21#include "planeNode.h"
22#include "nodePath.h"
23#include "pvector.h"
24
25/**
26 * A node in the scene graph that can hold a Portal Polygon, which is a
27 * rectangle. Other types of polygons are not supported for now. It also
28 * holds a PT(PandaNode) Cell that this portal is connected to
29 */
30 class EXPCL_PANDA_PGRAPH PortalNode : public PandaNode {
31PUBLISHED:
32 explicit PortalNode(const std::string &name);
33 explicit PortalNode(const std::string &name, LPoint3 pos, PN_stdfloat scale=10.0);
34
35 protected:
36 PortalNode(const PortalNode &copy);
37
38 public:
39 virtual ~PortalNode();
40 virtual PandaNode *make_copy() const;
41 virtual bool preserve_name() const;
42 virtual void xform(const LMatrix4 &mat);
43 virtual PandaNode *combine_with(PandaNode *other);
44
45 virtual void enable_clipping_planes();
46
47 virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
48 virtual bool is_renderable() const;
49
50 virtual void output(std::ostream &out) const;
51
52PUBLISHED:
53 INLINE void set_portal_mask(PortalMask mask);
54 INLINE void set_from_portal_mask(PortalMask mask);
55 INLINE void set_into_portal_mask(PortalMask mask);
56 INLINE PortalMask get_from_portal_mask() const;
57 INLINE PortalMask get_into_portal_mask() const;
58
59 INLINE void set_portal_geom(bool flag);
60 INLINE bool get_portal_geom() const;
61
62 INLINE void clear_vertices();
63 INLINE void add_vertex(const LPoint3 &vertex);
64
65 INLINE int get_num_vertices() const;
66 INLINE const LPoint3 &get_vertex(int n) const;
67 MAKE_SEQ(get_vertices, get_num_vertices, get_vertex);
68
69 INLINE void set_cell_in(const NodePath &cell);
70 INLINE NodePath get_cell_in() const;
71
72 INLINE void set_cell_out(const NodePath &cell);
73 INLINE NodePath get_cell_out() const;
74
75 INLINE void set_clip_plane(bool value);
76 INLINE bool is_clip_plane();
77
78 INLINE void set_visible(bool value);
79 INLINE bool is_visible();
80
81 INLINE void set_max_depth(int value);
82 INLINE int get_max_depth();
83
84 INLINE void set_open(bool value);
85 INLINE bool is_open();
86
87 // void draw () const;
88
89 MAKE_PROPERTY(into_portal_mask, get_into_portal_mask, set_into_portal_mask);
90 MAKE_PROPERTY(from_portal_mask, get_from_portal_mask, set_from_portal_mask);
91 MAKE_PROPERTY(portal_geom, get_portal_geom, set_portal_geom);
92 MAKE_SEQ_PROPERTY(vertices, get_num_vertices, get_vertex);
93 MAKE_PROPERTY(cell_in, get_cell_in, set_cell_in);
94 MAKE_PROPERTY(cell_out, get_cell_out, set_cell_out);
95 MAKE_PROPERTY(clip_plane, is_clip_plane, set_clip_plane);
96 MAKE_PROPERTY(visible, is_visible, set_visible);
97 MAKE_PROPERTY(max_depth, get_max_depth, set_max_depth);
98 MAKE_PROPERTY(open, is_open, set_open);
99
100 protected:
101 virtual void compute_internal_bounds(CPT(BoundingVolume) &internal_bounds,
102 int &internal_vertices,
103 int pipeline_stage,
104 Thread *current_thread) const;
105
106 private:
107 CPT(RenderState) get_last_pos_state();
108
109 // This data is not cycled, for now. We assume the collision traversal will
110 // take place in App only. Perhaps we will revisit this later.
111 PortalMask _from_portal_mask;
112 PortalMask _into_portal_mask;
113
114 enum Flags {
115 F_portal_geom = 0x0001,
116 // Presently only 8 bits are written to the bam file.
117 };
118 int _flags;
119
120 typedef pvector<LPoint3> Vertices;
121 Vertices _vertices;
122
123 NodePath _cell_in; // This is the cell it resides in
124 NodePath _cell_out; // This is the cell it leads out to
125
126 // enable plane clipping on this portal
127 bool _clip_plane;
128 PT(PlaneNode) _left_plane_node;
129 PT(PlaneNode) _right_plane_node;
130 PT(PlaneNode) _top_plane_node;
131 PT(PlaneNode) _bottom_plane_node;
132 CPT(RenderState) _clip_state;
133
134 bool _visible;
135 bool _open;
136 int _max_depth;
137
138 public:
139 static void register_with_read_factory();
140 virtual void write_datagram(BamWriter *manager, Datagram &dg);
141 virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
142
143 protected:
144 static TypedWritable *make_from_bam(const FactoryParams &params);
145 void fillin(DatagramIterator &scan, BamReader *manager);
146
147 public:
148 static TypeHandle get_class_type() {
149 return _type_handle;
150 }
151 static void init_type() {
152 PandaNode::init_type();
153 register_type(_type_handle, "PortalNode",
154 PandaNode::get_class_type());
155 }
156 virtual TypeHandle get_type() const {
157 return get_class_type();
158 }
159 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
160
161 private:
162 static TypeHandle _type_handle;
163};
164
165#include "portalNode.I"
166
167#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
CullTraverser
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
Definition cullTraverser.h:45
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
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition factoryParams.h:36
NodePath
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition nodePath.h:159
PandaNode::preserve_name
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
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::combine_with
virtual PandaNode * combine_with(PandaNode *other)
Collapses this PandaNode with the other PandaNode, if possible, and returns a pointer to the combined...
Definition pandaNode.cxx:319
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
A node that contains a plane.
Definition planeNode.h:36
PortalNode::get_vertex
get_vertex
Returns the nth vertex of the portal polygon.
Definition portalNode.h:67
PortalNode::get_into_portal_mask
get_into_portal_mask
Returns the current "into" PortalMask.
Definition portalNode.h:89
PortalNode::set_from_portal_mask
set_from_portal_mask
Sets the "from" PortalMask.
Definition portalNode.h:90
PortalNode::set_open
set_open
Python sets this based on curent camera zone.
Definition portalNode.h:98
PortalNode::get_portal_geom
get_portal_geom
Returns the current state of the portal_geom flag.
Definition portalNode.h:91
PortalNode::is_visible
is_visible
Is this portal facing the camera.
Definition portalNode.h:96
PortalNode::add_vertex
void add_vertex(const LPoint3 &vertex)
Adds a new vertex to the portal polygon.
Definition portalNode.I:109
PortalNode::set_cell_in
set_cell_in
Sets the cell that this portal belongs to.
Definition portalNode.h:93
PortalNode::is_clip_plane
is_clip_plane
Is this portal clipping against its left-right planes.
Definition portalNode.h:95
PortalNode::get_num_vertices
get_num_vertices
Returns the number of vertices in the portal polygon.
Definition portalNode.h:67
PortalNode::enable_clipping_planes
virtual void enable_clipping_planes()
initialize the clipping planes and renderstate
Definition portalNode.cxx:131
PortalNode::set_into_portal_mask
set_into_portal_mask
Sets the "into" PortalMask.
Definition portalNode.h:89
PortalNode::set_visible
set_visible
this is set if the portal is facing camera
Definition portalNode.h:96
PortalNode::set_portal_geom
set_portal_geom
Sets the state of the "portal geom" flag for this PortalNode.
Definition portalNode.h:91
PortalNode::set_cell_out
set_cell_out
Sets the cell that this portal leads out to.
Definition portalNode.h:94
PortalNode::get_from_portal_mask
get_from_portal_mask
Returns the current "from" PortalMask.
Definition portalNode.h:90
PortalNode::set_max_depth
set_max_depth
Set the maximum depth this portal will be visible at.
Definition portalNode.h:97
PortalNode::PortalNode
PortalNode(const std::string &name)
Default constructor, just an empty node, no geo This is used to read portal from model.
Definition portalNode.cxx:44
PortalNode::get_cell_out
get_cell_out
Sets the cell that this portal leads out to.
Definition portalNode.h:94
PortalNode::get_cell_in
get_cell_in
Sets the cell that this portal belongs to.
Definition portalNode.h:93
PortalNode::clear_vertices
void clear_vertices()
Resets the vertices of the portal to the empty list.
Definition portalNode.I:100
PortalNode::get_max_depth
get_max_depth
Returns the maximum depth this portal will be visible at.
Definition portalNode.h:97
PortalNode::is_open
is_open
Is this portal open from current camera zone.
Definition portalNode.h:98
PortalNode::output
virtual void output(std::ostream &out) const
Writes a brief description of the node to the indicated output stream.
Definition portalNode.cxx:328
PortalNode::set_clip_plane
set_clip_plane
this is set if the portal will clip against its left and right planes
Definition portalNode.h:95
PortalNode::set_portal_mask
void set_portal_mask(PortalMask mask)
Simultaneously sets both the "from" and "into" PortalMask values to the same thing.
Definition portalNode.I:19
RenderState
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition renderState.h:47
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
TypedWritable::complete_pointers
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().
Definition typedWritable.cxx:81
plist
This is our own Panda specialization on the default STL list.
Definition plist.h:35
nodePath.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.
planeNode.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
portalMask.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
portalNode.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pvector.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