63 PortalNode(
const std::string &name, LPoint3 pos, PN_stdfloat scale) :
71 add_vertex(LPoint3(pos[0]-1.0*scale, pos[1], pos[2]-1.0*scale));
72 add_vertex(LPoint3(pos[0]+1.0*scale, pos[1], pos[2]-1.0*scale));
73 add_vertex(LPoint3(pos[0]+1.0*scale, pos[1], pos[2]+1.0*scale));
74 add_vertex(LPoint3(pos[0]-1.0*scale, pos[1], pos[2]+1.0*scale));
88 _from_portal_mask(copy._from_portal_mask),
89 _into_portal_mask(copy._into_portal_mask),
91 _vertices(copy._vertices),
92 _cell_in(copy._cell_in),
93 _cell_out(copy._cell_out),
94 _clip_plane(copy._clip_plane),
95 _visible(copy._visible),
97 _max_depth(copy._max_depth)
135 _bottom_plane_node =
new PlaneNode(
"bottom");
138 _left_plane_node =
new PlaneNode(
"left");
141 _right_plane_node =
new PlaneNode(
"right");
144 CPT(
RenderAttrib) plane_attrib = ClipPlaneAttrib::make();
150 _clip_state = RenderState::make(plane_attrib);
159 nassertv(!mat.is_nan());
180 if (get_name() == cother->get_name()) {
206 if (
is_open() && !_cell_out.
is_empty() && portal_viewer && data._portal_depth <= _max_depth) {
207 portal_cat.debug() <<
"checking portal node " << *
this << endl;
208 portal_cat.debug() <<
"portal_depth is " << data._portal_depth << endl;
214 LPoint2 old_reduced_viewport_min, old_reduced_viewport_max;
232 CPT(
TransformState) cell_transform = _cell_out.get_net_transform();
236 new_bh->xform(frustum_transform->get_mat());
246 CPT(
TransformState) temp_frustum_transform = data.get_node_path().get_net_transform()->invert_compose(portal_viewer->_scene_setup->
get_cull_center().get_net_transform());
248 portal_cat.spam() <<
"clipping plane frustum transform " << *temp_frustum_transform << endl;
249 portal_cat.spam() <<
"frustum before transform " << *temp_bh << endl;
251 temp_bh->xform(temp_frustum_transform->get_mat());
253 portal_cat.spam() <<
"frustum after transform " << *temp_bh << endl;
255 _left_plane_node->set_plane(-temp_bh->get_plane(4));
256 _right_plane_node->set_plane(-temp_bh->get_plane(2));
257 _top_plane_node->set_plane(-temp_bh->get_plane(3));
258 _bottom_plane_node->set_plane(-temp_bh->get_plane(1));
260 portal_cat.spam() <<
"left plane " << *_left_plane_node << endl;
261 portal_cat.spam() <<
"right plane " << *_right_plane_node << endl;
262 portal_cat.spam() <<
"top plane " << *_top_plane_node << endl;
263 portal_cat.spam() <<
"bottom plane " << *_bottom_plane_node << endl;
268 if (old_clip_state) {
269 portal_cat.spam() <<
"parent clip state " << *old_clip_state << endl;
271 portal_cat.spam() <<
"parent clip state None" << endl;
273 portal_cat.spam() <<
"own clip state " << *_clip_state << endl;
274 portal_cat.spam() <<
"next state " << *next_state << endl;
278 if (old_clip_state !=
nullptr) {
279 next_state = old_clip_state->invert_compose(next_state);
280 portal_cat.spam() <<
"next state after removing parent state " << *next_state << endl;
282 next_state = next_state->compose(_clip_state);
283 portal_cat.spam() <<
"next state after composition " << *next_state << endl;
290 next_data._portal_depth = data._portal_depth + 1;
293 portal_cat.spam() <<
"cull_callback: before traversing " << _cell_out.
get_name() << endl;
295 portal_cat.spam() <<
"cull_callback: after traversing " << _cell_out.
get_name() << endl;
329 PandaNode::output(out);
352 int &internal_vertices,
354 Thread *current_thread)
const {
362 const LPoint3 *vertices_begin = &_vertices[0];
363 const LPoint3 *vertices_end = vertices_begin + _vertices.size();
366 gbv->
around(vertices_begin, vertices_end);
368 internal_bounds = bound;
369 internal_vertices = 0;
378 get_last_pos_state() {
382 if (state ==
nullptr) {
383 state = RenderState::make
384 (ColorScaleAttrib::make(LVecBase4(1.0f, 1.0f, 1.0f, 0.5f)),
385 TransparencyAttrib::make(TransparencyAttrib::M_alpha));
409 for (Vertices::const_iterator vi = _vertices.begin();
410 vi != _vertices.end();
412 (*vi).write_datagram(dg);
439 node->fillin(scan, manager);
450 PandaNode::fillin(scan, manager);
453 _vertices.reserve(num_vertices);
454 for (
int i = 0; i < num_vertices; i++) {
456 vertex.read_datagram(scan);
457 _vertices.push_back(vertex);
A basic node of the scene graph or data graph.
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.
This is the base class for a number of render attributes (other than transform) that may be set on sc...
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.
CPT(RenderState) PortalNode
Returns a RenderState for rendering the ghosted portal rectangle that represents the previous frame's...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
virtual PandaNode * combine_with(PandaNode *other)
Collapses this PandaNode with the other PandaNode, if possible, and returns a pointer to the combined...
bool is_empty() const
Returns true if the NodePath contains no nodes.
Thread * get_current_thread() const
Returns the currently-executing thread object, as passed to the CullTraverser constructor.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
This functions similarly to a LightAttrib.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
PortalNode(const std::string &name)
Default constructor, just an empty node, no geo This is used to read portal from model.
virtual bool is_renderable() const
Returns true if there is some value to visiting this particular node during the cull traversal for an...
BoundingHexahedron * get_reduced_frustum() const
Return the reduced frustum.
is_open
Is this portal open from current camera zone.
static void register_with_read_factory()
Tells the BamReader how to create objects of type PortalNode.
void get_reduced_viewport(LPoint2 &min, LPoint2 &max) const
Return the reduced viewport.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
set_visible
this is set if the portal is facing camera
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
A node in the scene graph that can hold a Portal Polygon, which is a rectangle.
void add_uint16(uint16_t value)
Adds an unsigned 16-bit integer to the datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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,...
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...
get_name
Returns the name of the referenced node.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
virtual void output(std::ostream &out) const
Writes a brief description of the node to the indicated output stream.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
virtual PandaNode * combine_with(PandaNode *other)
Collapses this node with the other node, if possible, and returns a pointer to the combined node,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data)
This function will be called during the cull traversal to perform reduced frustum culling.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
const NodePath & get_cull_center() const
Returns the point from which the culling operations will be performed.
uint16_t get_uint16()
Extracts an unsigned 16-bit integer.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
virtual PandaNode * make_copy() const
Returns a newly-allocated Node 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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A thread; that is, a lightweight process.
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's name has extrinsic meaning and must be preserved across a flatten operatio...
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
void set_reduced_viewport(const LPoint2 &min, const LPoint2 &max)
Set the current viewport that is being used by the portal clipper.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
virtual void enable_clipping_planes()
initialize the clipping planes and renderstate
void add_vertex(const LPoint3 &vertex)
Adds a new vertex to the portal polygon.
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...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A node that contains a plane.
This defines a bounding convex hexahedron.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.