Panda3D
portalNode.cxx
1 // Filename: portalNode.cxx
2 // Created by: drose (16Mar02)
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 #include "portalNode.h"
16 
17 #include "geomNode.h"
18 #include "cullTraverserData.h"
19 #include "cullTraverser.h"
20 #include "renderState.h"
21 #include "portalClipper.h"
22 #include "transformState.h"
23 #include "clipPlaneAttrib.h"
24 #include "colorScaleAttrib.h"
25 #include "transparencyAttrib.h"
26 #include "datagram.h"
27 #include "datagramIterator.h"
28 #include "bamReader.h"
29 #include "bamWriter.h"
30 #include "boundingSphere.h"
31 
32 #include "plane.h"
33 
34 TypeHandle PortalNode::_type_handle;
35 
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: PortalNode::Constructor
39 // Access: Public
40 // Description: Default constructor, just an empty node, no geo
41 // This is used to read portal from model. You can also
42 // use this from python to create an empty portal. Then
43 // you can set the vertices yourself, with addVertex.
44 ////////////////////////////////////////////////////////////////////
46 PortalNode(const string &name) :
47  PandaNode(name),
48  _from_portal_mask(PortalMask::all_on()),
49  _into_portal_mask(PortalMask::all_on()),
50  _flags(0)
51 {
52  set_cull_callback();
53 
54  _visible = false;
55  _open = true;
56  _clip_plane = false;
57  _max_depth = 10;
58 }
59 
60 ////////////////////////////////////////////////////////////////////
61 // Function: PortalNode::Constructor
62 // Access: Public
63 // Description: Create a default rectangle as portal. Use this
64 // to create an arbitrary portal and setup from Python
65 ////////////////////////////////////////////////////////////////////
67 PortalNode(const string &name, LPoint3 pos, PN_stdfloat scale) :
68  PandaNode(name),
69  _from_portal_mask(PortalMask::all_on()),
70  _into_portal_mask(PortalMask::all_on()),
71  _flags(0)
72 {
73  set_cull_callback();
74 
75  add_vertex(LPoint3(pos[0]-1.0*scale, pos[1], pos[2]-1.0*scale));
76  add_vertex(LPoint3(pos[0]+1.0*scale, pos[1], pos[2]-1.0*scale));
77  add_vertex(LPoint3(pos[0]+1.0*scale, pos[1], pos[2]+1.0*scale));
78  add_vertex(LPoint3(pos[0]-1.0*scale, pos[1], pos[2]+1.0*scale));
79 
80  _visible = false;
81  _open = true;
82  _clip_plane = false;
83  _max_depth = 10;
84 }
85 
86 ////////////////////////////////////////////////////////////////////
87 // Function: PortalNode::Copy Constructor
88 // Access: Protected
89 // Description:
90 ////////////////////////////////////////////////////////////////////
92 PortalNode(const PortalNode &copy) :
93  PandaNode(copy),
94  _from_portal_mask(copy._from_portal_mask),
95  _into_portal_mask(copy._into_portal_mask),
96  _flags(copy._flags),
97  _vertices(copy._vertices),
98  _cell_in(copy._cell_in),
99  _cell_out(copy._cell_out),
100  _clip_plane(copy._clip_plane),
101  _visible(copy._visible),
102  _open(copy._open),
103  _max_depth(copy._max_depth)
104 {
105 }
106 
107 ////////////////////////////////////////////////////////////////////
108 // Function: PortalNode::Destructor
109 // Access: Public, Virtual
110 // Description:
111 ////////////////////////////////////////////////////////////////////
112 PortalNode::
113 ~PortalNode() {
114 }
115 
116 ////////////////////////////////////////////////////////////////////
117 // Function: PortalNode::make_copy
118 // Access: Public, Virtual
119 // Description: Returns a newly-allocated Node that is a shallow copy
120 // of this one. It will be a different Node pointer,
121 // but its internal data may or may not be shared with
122 // that of the original Node.
123 ////////////////////////////////////////////////////////////////////
125 make_copy() const {
126  return new PortalNode(*this);
127 }
128 
129 ////////////////////////////////////////////////////////////////////
130 // Function: PortalNode::preserve_name
131 // Access: Public, Virtual
132 // Description: Returns true if the node's name has extrinsic meaning
133 // and must be preserved across a flatten operation,
134 // false otherwise.
135 ////////////////////////////////////////////////////////////////////
136 bool PortalNode::
137 preserve_name() const {
138  return true;
139 }
140 
141 ////////////////////////////////////////////////////////////////////
142 // Function: PortalNode::enable_clipping_planes
143 // Access: Public, Virtual
144 // Description: initialize the clipping planes and renderstate
145 ////////////////////////////////////////////////////////////////////
146 void PortalNode::
148  _top_plane_node = new PlaneNode("top");
149  NodePath top_plane_np = NodePath(this).attach_new_node(_top_plane_node);
150 
151  _bottom_plane_node = new PlaneNode("bottom");
152  NodePath bottom_plane_np = NodePath(this).attach_new_node(_bottom_plane_node);
153 
154  _left_plane_node = new PlaneNode("left");
155  NodePath left_plane_np = NodePath(this).attach_new_node(_left_plane_node);
156 
157  _right_plane_node = new PlaneNode("right");
158  NodePath right_plane_np = NodePath(this).attach_new_node(_right_plane_node);
159 
160  CPT(RenderAttrib) plane_attrib = ClipPlaneAttrib::make();
161  plane_attrib = DCAST(ClipPlaneAttrib, plane_attrib)->add_on_plane(NodePath(top_plane_np));
162  plane_attrib = DCAST(ClipPlaneAttrib, plane_attrib)->add_on_plane(NodePath(bottom_plane_np));
163  plane_attrib = DCAST(ClipPlaneAttrib, plane_attrib)->add_on_plane(NodePath(left_plane_np));
164  plane_attrib = DCAST(ClipPlaneAttrib, plane_attrib)->add_on_plane(NodePath(right_plane_np));
165 
166  _clip_state = RenderState::make(plane_attrib);
167 }
168 
169 ////////////////////////////////////////////////////////////////////
170 // Function: PortalNode::xform
171 // Access: Public, Virtual
172 // Description: Transforms the contents of this node by the indicated
173 // matrix, if it means anything to do so. For most
174 // kinds of nodes, this does nothing.
175 ////////////////////////////////////////////////////////////////////
176 void PortalNode::
177 xform(const LMatrix4 &mat) {
178  nassertv(!mat.is_nan());
179 
180 }
181 
182 ////////////////////////////////////////////////////////////////////
183 // Function: PortalNode::combine_with
184 // Access: Public, Virtual
185 // Description: Collapses this node with the other node, if possible,
186 // and returns a pointer to the combined node, or NULL
187 // if the two nodes cannot safely be combined.
188 //
189 // The return value may be this, other, or a new node
190 // altogether.
191 //
192 // This function is called from GraphReducer::flatten(),
193 // and need not deal with children; its job is just to
194 // decide whether to collapse the two nodes and what the
195 // collapsed node should look like.
196 ////////////////////////////////////////////////////////////////////
199  if (is_exact_type(get_class_type()) &&
200  other->is_exact_type(get_class_type())) {
201  // Two PortalNodes can combine, but only if they have the same
202  // name, because the name is often meaningful.
203  PortalNode *cother = DCAST(PortalNode, other);
204  if (get_name() == cother->get_name()) {
205  return this;
206  }
207 
208  // Two PortalNodes with different names can't combine.
209  return (PandaNode *)NULL;
210  }
211 
212  return PandaNode::combine_with(other);
213 }
214 
215 ////////////////////////////////////////////////////////////////////
216 // Function: PortalNode::cull_callback
217 // Access: Public, Virtual
218 // Description: This function will be called during the cull
219 // traversal to perform reduced frustum
220 // culling. Basically, once the scenegraph comes across
221 // a portal node, it calculates a CulltraverserData with
222 // which cell, this portal leads out to and the new
223 // frustum. Then it traverses that child
224 //
225 // The return value is true if this node should be
226 // visible, or false if it should be culled.
227 ////////////////////////////////////////////////////////////////////
228 bool PortalNode::
230  Thread *current_thread = trav->get_current_thread();
231 
232  PortalClipper *portal_viewer = trav->get_portal_clipper();
233  set_visible(false);
234  if (is_open() && !_cell_out.is_empty() && portal_viewer && data._portal_depth <= _max_depth) {
235  portal_cat.debug() << "checking portal node " << *this << endl;
236  portal_cat.debug() << "portal_depth is " << data._portal_depth << endl;
237  PT(GeometricBoundingVolume) vf = trav->get_view_frustum();
238  PT(BoundingVolume) reduced_frustum;
239 
240  // remember old viewport and frustum, so we can restore them for the siblings. (it gets changed by the prepare_portal call)
241  LPoint2 old_reduced_viewport_min, old_reduced_viewport_max;
242  portal_viewer->get_reduced_viewport(old_reduced_viewport_min, old_reduced_viewport_max);
243  PT(BoundingHexahedron) old_bh = portal_viewer->get_reduced_frustum();
244 
245  if (portal_viewer->prepare_portal(data._node_path.get_node_path())) {
246  if ((reduced_frustum = portal_viewer->get_reduced_frustum())) {
247  // remember current clip state, we might change it
248  CPT(RenderState) old_clip_state = portal_viewer->get_clip_state();
249 
250  set_visible(true);
251  // The frustum is in camera space
252  vf = DCAST(GeometricBoundingVolume, reduced_frustum);
253 
254  // create a copy of this reduced frustum, we'll transform it from camera space to the cell_out space
255  PT(BoundingHexahedron) new_bh = DCAST(BoundingHexahedron, vf->make_copy());
256 
257  // Get the net trasform of the _cell_out as seen from the camera.
258  CPT(TransformState) cell_transform = _cell_out.get_net_transform();
259  CPT(TransformState) frustum_transform = cell_transform ->invert_compose(portal_viewer->_scene_setup->get_cull_center().get_net_transform());
260 
261  // transform to _cell_out space
262  new_bh->xform(frustum_transform->get_mat());
263 
264  CPT(RenderState) next_state = data._state;
265 
266  // set clipping planes, if desired..
267  if (_clip_plane) {
268  // create a copy of this reduced frustum, we'll transform it from camera space to this portal node's space (because the clip planes are attached to this node)
269  PT(BoundingHexahedron) temp_bh = DCAST(BoundingHexahedron, vf->make_copy());
270  CPT(TransformState) temp_frustum_transform = data._node_path.get_node_path().get_net_transform()->invert_compose(portal_viewer->_scene_setup->get_cull_center().get_net_transform());
271 
272  portal_cat.spam() << "clipping plane frustum transform " << *temp_frustum_transform << endl;
273  portal_cat.spam() << "frustum before transform " << *temp_bh << endl;
274  // transform to portalNode space
275  temp_bh->xform(temp_frustum_transform->get_mat());
276 
277  portal_cat.spam() << "frustum after transform " << *temp_bh << endl;
278 
279  _left_plane_node->set_plane(-temp_bh->get_plane(4)); // left plane of bh
280  _right_plane_node->set_plane(-temp_bh->get_plane(2));// right plane of bh
281  _top_plane_node->set_plane(-temp_bh->get_plane(3)); // top plane of bh
282  _bottom_plane_node->set_plane(-temp_bh->get_plane(1));// bottom plane of bh
283 
284  portal_cat.spam() << "left plane " << *_left_plane_node << endl;
285  portal_cat.spam() << "right plane " << *_right_plane_node << endl;
286  portal_cat.spam() << "top plane " << *_top_plane_node << endl;
287  portal_cat.spam() << "bottom plane " << *_bottom_plane_node << endl;
288 
289  // remember the clip state we just generated
290  portal_viewer->set_clip_state(_clip_state);
291 
292  if (old_clip_state) {
293  portal_cat.spam() << "parent clip state " << *old_clip_state << endl;
294  } else {
295  portal_cat.spam() << "parent clip state None" << endl;
296  }
297  portal_cat.spam() << "own clip state " << *_clip_state << endl;
298  portal_cat.spam() << "next state " << *next_state << endl;
299 
300  // undo parent clip state and compose our new clip state ito the new state
301  if (old_clip_state != NULL) {
302  next_state = old_clip_state->invert_compose(next_state);
303  portal_cat.spam() << "next state after removing parent state " << *next_state << endl;
304  }
305  next_state = next_state->compose(_clip_state);
306  portal_cat.spam() << "next state after composition " << *next_state << endl;
307  }
308 
309  CullTraverserData next_data(_cell_out,
310  cell_transform,
311  next_state, new_bh,
312  current_thread);
313  next_data._portal_depth = data._portal_depth + 1;
314 
315  portal_viewer->set_reduced_frustum(new_bh);
316  portal_cat.spam() << "cull_callback: before traversing " << _cell_out.get_name() << endl;
317  trav->traverse_below(next_data);
318  portal_cat.spam() << "cull_callback: after traversing " << _cell_out.get_name() << endl;
319 
320  // restore clip state
321  portal_viewer->set_clip_state(old_clip_state);
322  }
323  }
324  // reset portal viewer frustum for the siblings;
325  portal_viewer->set_reduced_frustum(old_bh);
326  // reset portal viewer viewport for the siblings;
327  portal_viewer->set_reduced_viewport(old_reduced_viewport_min, old_reduced_viewport_max);
328  }
329  // Now carry on to render our child nodes.
330  return true;
331 }
332 
333 ////////////////////////////////////////////////////////////////////
334 // Function: PortalNode::is_renderable
335 // Access: Public, Virtual
336 // Description: Returns true if there is some value to visiting this
337 // particular node during the cull traversal for any
338 // camera, false otherwise. This will be used to
339 // optimize the result of get_net_draw_show_mask(), so
340 // that any subtrees that contain only nodes for which
341 // is_renderable() is false need not be visited.
342 ////////////////////////////////////////////////////////////////////
343 bool PortalNode::
344 is_renderable() const {
345  return true;
346 }
347 
348 
349 ////////////////////////////////////////////////////////////////////
350 // Function: PortalNode::output
351 // Access: Public, Virtual
352 // Description: Writes a brief description of the node to the
353 // indicated output stream. This is invoked by the <<
354 // operator. It may be overridden in derived classes to
355 // include some information relevant to the class.
356 ////////////////////////////////////////////////////////////////////
357 void PortalNode::
358 output(ostream &out) const {
359  PandaNode::output(out);
360 }
361 
362 /*
363 ////////////////////////////////////////////////////////////////////
364 // Function: PortalNode::draw
365 // Access: Public
366 // Description: Draws the vertices of this portal rectangle to the
367 // screen with a line
368 
369 ////////////////////////////////////////////////////////////////////
370 void PortalNode::
371 draw() const {
372  move_to(get_vertex(0));
373  draw_to(get_vertex(1));
374  draw_to(get_vertex(2));
375  draw_to(get_vertex(3));
376 }
377 */
378 
379 ////////////////////////////////////////////////////////////////////
380 // Function: PortalNode::compute_internal_bounds
381 // Access: Protected, Virtual
382 // Description: Called when needed to recompute the node's
383 // _internal_bound object. Nodes that contain anything
384 // of substance should redefine this to do the right
385 // thing.
386 ////////////////////////////////////////////////////////////////////
387 void PortalNode::
388 compute_internal_bounds(CPT(BoundingVolume) &internal_bounds,
389  int &internal_vertices,
390  int pipeline_stage,
391  Thread *current_thread) const {
392  // First, get ourselves a fresh, empty bounding volume.
393  PT(BoundingVolume) bound = new BoundingSphere;
395 
396  // Now actually compute the bounding volume by putting it around all
397  // of our vertices.
398 
399  const LPoint3 *vertices_begin = &_vertices[0];
400  const LPoint3 *vertices_end = vertices_begin + _vertices.size();
401 
402  // Now actually compute the bounding volume by putting it around all
403  gbv->around(vertices_begin, vertices_end);
404 
405  internal_bounds = bound;
406  internal_vertices = 0;
407 }
408 
409 ////////////////////////////////////////////////////////////////////
410 // Function: PortalNode::get_last_pos_state
411 // Access: Protected
412 // Description: Returns a RenderState for rendering the ghosted
413 // portal rectangle that represents the previous frame's
414 // position, for those collision nodes that indicate a
415 // velocity.
416 ////////////////////////////////////////////////////////////////////
417 CPT(RenderState) PortalNode::
418 get_last_pos_state() {
419  // Once someone asks for this pointer, we hold its reference count
420  // and never free it.
421  static CPT(RenderState) state = (const RenderState *)NULL;
422  if (state == (const RenderState *)NULL) {
423  state = RenderState::make
424  (ColorScaleAttrib::make(LVecBase4(1.0f, 1.0f, 1.0f, 0.5f)),
425  TransparencyAttrib::make(TransparencyAttrib::M_alpha));
426  }
427 
428  return state;
429 }
430 
431 
432 ////////////////////////////////////////////////////////////////////
433 // Function: PortalNode::register_with_read_factory
434 // Access: Public, Static
435 // Description: Tells the BamReader how to create objects of type
436 // PortalNode.
437 ////////////////////////////////////////////////////////////////////
438 void PortalNode::
440  BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
441 }
442 
443 ////////////////////////////////////////////////////////////////////
444 // Function: PortalNode::write_datagram
445 // Access: Public, Virtual
446 // Description: Writes the contents of this object to the datagram
447 // for shipping out to a Bam file.
448 ////////////////////////////////////////////////////////////////////
449 void PortalNode::
451  PandaNode::write_datagram(manager, dg);
452 
453  dg.add_uint16(_vertices.size());
454  for (Vertices::const_iterator vi = _vertices.begin();
455  vi != _vertices.end();
456  ++vi) {
457  (*vi).write_datagram(dg);
458  }
459 }
460 
461 ////////////////////////////////////////////////////////////////////
462 // Function: PortalNode::complete_pointers
463 // Access: Public, Virtual
464 // Description: Receives an array of pointers, one for each time
465 // manager->read_pointer() was called in fillin().
466 // Returns the number of pointers processed.
467 ////////////////////////////////////////////////////////////////////
468 int PortalNode::
470  int pi = PandaNode::complete_pointers(p_list, manager);
471 
472  return pi;
473 }
474 
475 ////////////////////////////////////////////////////////////////////
476 // Function: PortalNode::make_from_bam
477 // Access: Protected, Static
478 // Description: This function is called by the BamReader's factory
479 // when a new object of type PortalNode is encountered
480 // in the Bam file. It should create the PortalNode
481 // and extract its information from the file.
482 ////////////////////////////////////////////////////////////////////
483 TypedWritable *PortalNode::
484 make_from_bam(const FactoryParams &params) {
485  PortalNode *node = new PortalNode("");
486  DatagramIterator scan;
487  BamReader *manager;
488 
489  parse_params(params, scan, manager);
490  node->fillin(scan, manager);
491 
492  return node;
493 }
494 
495 ////////////////////////////////////////////////////////////////////
496 // Function: PortalNode::fillin
497 // Access: Protected
498 // Description: This internal function is called by make_from_bam to
499 // read in all of the relevant data from the BamFile for
500 // the new PortalNode.
501 ////////////////////////////////////////////////////////////////////
502 void PortalNode::
503 fillin(DatagramIterator &scan, BamReader *manager) {
504  PandaNode::fillin(scan, manager);
505 
506  int num_vertices = scan.get_uint16();
507  _vertices.reserve(num_vertices);
508  for (int i = 0; i < num_vertices; i++) {
509  LPoint3 vertex;
510  vertex.read_datagram(scan);
511  _vertices.push_back(vertex);
512  }
513 
514  /*
515  _from_portal_mask.set_word(scan.get_uint32());
516  _into_portal_mask.set_word(scan.get_uint32());
517  _flags = scan.get_uint8();
518  */
519 }
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
bool is_open()
Is this portal open from current camera zone.
Definition: portalNode.I:257
const RenderState * get_clip_state() const
Returns the stored clip state.
bool is_exact_type(TypeHandle handle) const
Returns true if the current object is the indicated type exactly.
Definition: typedObject.I:74
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:60
bool prepare_portal(const NodePath &node_path)
Given the portal draw the frustum with line segs for now.
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:4164
virtual void traverse_below(CullTraverserData &data)
Traverses all the children of the indicated node, with the given data, which has been converted into ...
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this node by the indicated matrix, if it means anything to do so...
Definition: portalNode.cxx:177
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
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:397
bool is_empty() const
Returns true if the NodePath contains no nodes.
Definition: nodePath.I:236
void read_datagram(DatagramIterator &source)
Reads the vector from the Datagram using get_stdfloat().
Definition: lvecBase3.h:1389
Thread * get_current_thread() const
Returns the currently-executing thread object, as passed to the CullTraverser constructor.
Definition: cullTraverser.I:33
This defines a bounding sphere, consisting of a center and a radius.
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This collects together the pieces of data that are accumulated for each node while walking the scene ...
void set_reduced_frustum(BoundingHexahedron *bh)
Set the current view frustum that is being calculated by the portal clipper.
PortalNode(const string &name)
Default constructor, just an empty node, no geo This is used to read portal from model.
Definition: portalNode.cxx:46
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin()...
Definition: portalNode.cxx:469
This functions similarly to a LightAttrib.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
virtual bool is_renderable() const
Returns true if there is some value to visiting this particular node during the cull traversal for an...
Definition: portalNode.cxx:344
bool is_nan() const
Returns true if any component of the matrix is not-a-number, false otherwise.
Definition: lmatrix.h:1417
BoundingHexahedron * get_reduced_frustum() const
Return the reduced frustum.
PN_uint16 get_uint16()
Extracts an unsigned 16-bit integer.
static void register_with_read_factory()
Tells the BamReader how to create objects of type PortalNode.
Definition: portalNode.cxx:439
void get_reduced_viewport(LPoint2 &min, LPoint2 &max) const
Return the reduced viewport.
void set_clip_state(const RenderState *clip_state)
Set the clip state of the current portal node This is done to remember the state for the child portal...
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
PortalClipper * get_portal_clipper() const
Returns the _portal_clipper pointer.
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
A node in the scene graph that can hold a Portal Polygon, which is a rectangle.
Definition: portalNode.h:34
NodePath get_node_path() const
Constructs and returns an actual NodePath that represents the same path we have just traversed...
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()...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
Definition: portalClipper.h:52
NodePath attach_new_node(PandaNode *node, int sort=0, Thread *current_thread=Thread::get_current_thread()) const
Attaches a new node, with or without existing parents, to the scene graph below the referenced node o...
Definition: nodePath.cxx:723
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
string get_name() const
Returns the name of the referenced node.
Definition: nodePath.I:2580
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
virtual PandaNode * combine_with(PandaNode *other)
Collapses this node with the other node, if possible, and returns a pointer to the combined node...
Definition: portalNode.cxx:198
virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data)
This function will be called during the cull traversal to perform reduced frustum culling...
Definition: portalNode.cxx:229
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
Definition: factory.I:90
void add_uint16(PN_uint16 value)
Adds an unsigned 16-bit integer to the datagram.
Definition: datagram.I:181
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
const NodePath & get_cull_center() const
Returns the point from which the culling operations will be performed.
Definition: sceneSetup.I:203
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Definition: bamReader.I:213
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
Definition: portalNode.cxx:125
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: portalNode.cxx:450
A thread; that is, a lightweight process.
Definition: thread.h:51
GeometricBoundingVolume * get_view_frustum() const
Returns the bounding volume that corresponds to the view frustum, or NULL if the view frustum is not ...
virtual bool preserve_name() const
Returns true if the node&#39;s name has extrinsic meaning and must be preserved across a flatten operatio...
Definition: portalNode.cxx:137
A class to retrieve the individual data elements previously stored in a Datagram. ...
This is a two-component point in space.
Definition: lpoint2.h:92
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
void set_reduced_viewport(const LPoint2 &min, const LPoint2 &max)
Set the current viewport that is being used by the portal clipper.
virtual void output(ostream &out) const
Writes a brief description of the node to the indicated output stream.
Definition: portalNode.cxx:358
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
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
bool around(const GeometricBoundingVolume **first, const GeometricBoundingVolume **last)
Resets the volume to enclose only the volumes indicated.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
Definition: cullTraverser.h:48
A node that contains a plane.
Definition: planeNode.h:39
This defines a bounding convex hexahedron.
void set_visible(bool value)
this is set if the portal is facing camera
Definition: portalNode.I:230