Panda3D
 All Classes Functions Variables Enumerations
portalNode.I
1 // Filename: portalNode.I
2 // Created by: masad (13May04)
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: PortalNode::set_portal_mask
18 // Access: Published
19 // Description: Simultaneously sets both the "from" and "into"
20 // PortalMask values to the same thing.
21 ////////////////////////////////////////////////////////////////////
22 INLINE void PortalNode::
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: PortalNode::set_from_portal_mask
30 // Access: Published
31 // Description: Sets the "from" PortalMask. In order for a
32 // portal to be detected from this object into
33 // another object, the intersection of this object's
34 // "from" mask and the other object's "into" mask must
35 // be nonzero.
36 ////////////////////////////////////////////////////////////////////
37 INLINE void PortalNode::
39  _from_portal_mask = mask;
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: PortalNode::set_into_portal_mask
44 // Access: Published
45 // Description: Sets the "into" PortalMask. In order for a
46 // portal to be detected from another object into
47 // this object, the intersection of the other object's
48 // "from" mask and this object's "into" mask must be
49 // nonzero.
50 ////////////////////////////////////////////////////////////////////
51 INLINE void PortalNode::
53  _into_portal_mask = mask;
54 
55  // We mark the bound stale when this changes, not because the actual
56  // bounding volume changes, but rather because we piggyback the
57  // computing of the _net_portal_mask on the bounding volume.
59 }
60 
61 ////////////////////////////////////////////////////////////////////
62 // Function: PortalNode::get_from_portal_mask
63 // Access: Published
64 // Description: Returns the current "from" PortalMask. In order for
65 // a portal to be detected from this object into
66 // another object, the intersection of this object's
67 // "from" mask and the other object's "into" mask must
68 // be nonzero.
69 ////////////////////////////////////////////////////////////////////
72  return _from_portal_mask;
73 }
74 
75 ////////////////////////////////////////////////////////////////////
76 // Function: PortalNode::get_into_portal_mask
77 // Access: Published
78 // Description: Returns the current "into" PortalMask. In order for
79 // a portal to be detected from another object into
80 // this object, the intersection of the other object's
81 // "from" mask and this object's "into" mask must be
82 // nonzero.
83 ////////////////////////////////////////////////////////////////////
86  return _into_portal_mask;
87 }
88 
89 ////////////////////////////////////////////////////////////////////
90 // Function: PortalNode::set_portal_geom
91 // Access: Published
92 // Description: Sets the state of the "portal geom" flag for this
93 // PortalNode. Normally, this is false; when this is
94 // set true, the PortalSolids in this node will test
95 // for portals with actual renderable geometry, in
96 // addition to whatever PortalSolids may be indicated
97 // by the from_portal_mask.
98 //
99 // Setting this to true causes this to test *all*
100 // GeomNodes for portals. It is an all-or-none
101 // thing; there is no way to portal with only some
102 // GeomNodes, as GeomNodes have no into_portal_mask.
103 ////////////////////////////////////////////////////////////////////
104 INLINE void PortalNode::
105 set_portal_geom(bool flag) {
106  if (flag) {
107  _flags |= F_portal_geom;
108  } else {
109  _flags &= ~F_portal_geom;
110  }
111 }
112 
113 ////////////////////////////////////////////////////////////////////
114 // Function: PortalNode::get_portal_geom
115 // Access: Published
116 // Description: Returns the current state of the portal_geom flag.
117 // See set_portal_geom().
118 ////////////////////////////////////////////////////////////////////
119 INLINE bool PortalNode::
121  return (_flags & F_portal_geom) != 0;
122 }
123 
124 ////////////////////////////////////////////////////////////////////
125 // Function: PortalNode::clear_vertices
126 // Access: Published
127 // Description: Resets the vertices of the portal to the empty list.
128 ////////////////////////////////////////////////////////////////////
129 INLINE void PortalNode::
131  _vertices.clear();
132 }
133 
134 ////////////////////////////////////////////////////////////////////
135 // Function: PortalNode::add_vertex
136 // Access: Published
137 // Description: Adds a new vertex to the portal polygon. The
138 // vertices should be defined in a counterclockwise
139 // orientation when viewing through the portal.
140 ////////////////////////////////////////////////////////////////////
141 INLINE void PortalNode::
142 add_vertex(const LPoint3 &vertex) {
143  _vertices.push_back(vertex);
144 }
145 
146 ////////////////////////////////////////////////////////////////////
147 // Function: PortalNode::get_num_vertices
148 // Access: Published
149 // Description: Returns the number of vertices in the portal polygon.
150 ////////////////////////////////////////////////////////////////////
151 INLINE int PortalNode::
153  return _vertices.size();
154 }
155 
156 ////////////////////////////////////////////////////////////////////
157 // Function: PortalNode::get_vertex
158 // Access: Published
159 // Description: Returns the nth vertex of the portal polygon.
160 ////////////////////////////////////////////////////////////////////
161 INLINE const LPoint3 &PortalNode::
162 get_vertex(int n) const {
163  nassertr(n >= 0 && n < (int)_vertices.size(), LPoint3::zero());
164  return _vertices[n];
165 }
166 
167 ////////////////////////////////////////////////////////////////////
168 // Function: PortalNode::set_cell_in
169 // Access: Published
170 // Description: Sets the cell that this portal belongs to
171 ////////////////////////////////////////////////////////////////////
172 INLINE void PortalNode::set_cell_in(const NodePath &cell) {
173  _cell_in = cell;
174 }
175 
176 ////////////////////////////////////////////////////////////////////
177 // Function: PortalNode::get_cell_in
178 // Access: Published
179 // Description: Sets the cell that this portal belongs to
180 ////////////////////////////////////////////////////////////////////
182  return _cell_in;
183 }
184 ////////////////////////////////////////////////////////////////////
185 // Function: PortalNode::set_cell_out
186 // Access: Published
187 // Description: Sets the cell that this portal leads out to
188 ////////////////////////////////////////////////////////////////////
189 INLINE void PortalNode::set_cell_out(const NodePath &cell) {
190  _cell_out = cell;
191 }
192 
193 ////////////////////////////////////////////////////////////////////
194 // Function: PortalNode::get_cell_out
195 // Access: Published
196 // Description: Sets the cell that this portal leads out to
197 ////////////////////////////////////////////////////////////////////
199  return _cell_out;
200 }
201 
202 ////////////////////////////////////////////////////////////////////
203 // Function: PortalNode::set_clip_plane
204 // Access: Published
205 // Description: this is set if the portal will clip against its
206 // left and right planes
207 ////////////////////////////////////////////////////////////////////
208 INLINE void PortalNode::set_clip_plane(bool value) {
209  _clip_plane = value;
210  if (_clip_plane) {
212  }
213 }
214 
215 ////////////////////////////////////////////////////////////////////
216 // Function: PortalNode::is_clip_plane
217 // Access: Published
218 // Description: Is this portal clipping against its left-right planes
219 ////////////////////////////////////////////////////////////////////
221  return _clip_plane;
222 }
223 
224 
225 ////////////////////////////////////////////////////////////////////
226 // Function: PortalNode::set_visible
227 // Access: Published
228 // Description: this is set if the portal is facing camera
229 ////////////////////////////////////////////////////////////////////
230 INLINE void PortalNode::set_visible(bool value) {
231  _visible = value;
232 }
233 
234 ////////////////////////////////////////////////////////////////////
235 // Function: PortalNode::is_visible
236 // Access: Published
237 // Description: Is this portal facing the camera
238 ////////////////////////////////////////////////////////////////////
239 INLINE bool PortalNode::is_visible() {
240  return _visible;
241 }
242 
243 ////////////////////////////////////////////////////////////////////
244 // Function: PortalNode::set_open
245 // Access: Published
246 // Description: Python sets this based on curent camera zone
247 ////////////////////////////////////////////////////////////////////
248 INLINE void PortalNode::set_open(bool value) {
249  _open = value;
250 }
251 
252 ////////////////////////////////////////////////////////////////////
253 // Function: PortalNode::is_open
254 // Access: Published
255 // Description: Is this portal open from current camera zone
256 ////////////////////////////////////////////////////////////////////
257 INLINE bool PortalNode::is_open() {
258  return _open;
259 }
260 
261 ////////////////////////////////////////////////////////////////////
262 // Function: PortalNode::set_max_depth
263 // Access: Published
264 // Description: Set the maximum depth this portal will be visible at
265 ////////////////////////////////////////////////////////////////////
266 INLINE void PortalNode::set_max_depth(int value) {
267  _max_depth = value;
268 }
269 
270 ////////////////////////////////////////////////////////////////////
271 // Function: PortalNode::get_max_depth
272 // Access: Published
273 // Description: Returns the maximum depth this portal will be visible at
274 ////////////////////////////////////////////////////////////////////
276  return _max_depth;
277 }
278 
bool get_portal_geom() const
Returns the current state of the portal_geom flag.
Definition: portalNode.I:120
void set_into_portal_mask(PortalMask mask)
Sets the &quot;into&quot; PortalMask.
Definition: portalNode.I:52
bool is_open()
Is this portal open from current camera zone.
Definition: portalNode.I:257
void set_portal_mask(PortalMask mask)
Simultaneously sets both the &quot;from&quot; and &quot;into&quot; PortalMask values to the same thing.
Definition: portalNode.I:23
void set_open(bool value)
Python sets this based on curent camera zone.
Definition: portalNode.I:248
int get_num_vertices() const
Returns the number of vertices in the portal polygon.
Definition: portalNode.I:152
const LPoint3 & get_vertex(int n) const
Returns the nth vertex of the portal polygon.
Definition: portalNode.I:162
static const LPoint3f & zero()
Returns a zero-length point.
Definition: lpoint3.h:258
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
PortalMask get_from_portal_mask() const
Returns the current &quot;from&quot; PortalMask.
Definition: portalNode.I:71
void mark_bounds_stale(Thread *current_thread=Thread::get_current_thread()) const
Indicates that the bounding volume, or something that influences the bounding volume (or any of the o...
Definition: pandaNode.cxx:2443
bool is_clip_plane()
Is this portal clipping against its left-right planes.
Definition: portalNode.I:220
void set_clip_plane(bool value)
this is set if the portal will clip against its left and right planes
Definition: portalNode.I:208
void set_max_depth(int value)
Set the maximum depth this portal will be visible at.
Definition: portalNode.I:266
void set_cell_in(const NodePath &cell)
Sets the cell that this portal belongs to.
Definition: portalNode.I:172
void set_portal_geom(bool flag)
Sets the state of the &quot;portal geom&quot; flag for this PortalNode.
Definition: portalNode.I:105
NodePath get_cell_out() const
Sets the cell that this portal leads out to.
Definition: portalNode.I:198
PortalMask get_into_portal_mask() const
Returns the current &quot;into&quot; PortalMask.
Definition: portalNode.I:85
bool is_visible()
Is this portal facing the camera.
Definition: portalNode.I:239
NodePath get_cell_in() const
Sets the cell that this portal belongs to.
Definition: portalNode.I:181
void set_from_portal_mask(PortalMask mask)
Sets the &quot;from&quot; PortalMask.
Definition: portalNode.I:38
void clear_vertices()
Resets the vertices of the portal to the empty list.
Definition: portalNode.I:130
virtual void enable_clipping_planes()
initialize the clipping planes and renderstate
Definition: portalNode.cxx:147
void add_vertex(const LPoint3 &vertex)
Adds a new vertex to the portal polygon.
Definition: portalNode.I:142
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
int get_max_depth()
Returns the maximum depth this portal will be visible at.
Definition: portalNode.I:275
void set_visible(bool value)
this is set if the portal is facing camera
Definition: portalNode.I:230
void set_cell_out(const NodePath &cell)
Sets the cell that this portal leads out to.
Definition: portalNode.I:189