A node in the scene graph that can hold a Portal Polygon, which is a rectangle. More...

#include "portalNode.h"

Inheritance diagram for PortalNode:
PandaNode TypedWritable Namable LinkedListNode ReferenceCount TypedObject MemoryBase MemoryBase

List of all members.

Public Member Functions

 PortalNode (const string &name)
 Default constructor, just an empty node, no geo This is used to read portal from model.
 PortalNode (const string &name, LPoint3f pos, float scale=10.0)
 Create a default rectangle as portal.
void add_vertex (const LPoint3f &vertex)
 Adds a new vertex to the portal polygon.
void clear_vertices ()
 Resets the vertices of the portal to the empty list.
virtual PandaNodecombine_with (PandaNode *other)
 Collapses this node with the other node, if possible, and returns a pointer to the combined node, or NULL if the two nodes cannot safely be combined.
virtual int complete_pointers (TypedWritable **plist, BamReader *manager)
 Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
virtual bool cull_callback (CullTraverser *trav, CullTraverserData &data)
 This function will be called during the cull traversal to perform reduced frustum culling.
virtual void enable_clipping_planes ()
 initialize the clipping planes and renderstate
virtual TypeHandle force_init_type ()
NodePath get_cell_in () const
 Sets the cell that this portal belongs to.
NodePath get_cell_out () const
 Sets the cell that this portal leads out to.
PortalMask get_from_portal_mask () const
 Returns the current "from" PortalMask.
PortalMask get_into_portal_mask () const
 Returns the current "into" PortalMask.
int get_max_depth ()
 Returns the maximum depth this portal will be visible at.
int get_num_vertices () const
 Returns the number of vertices in the portal polygon.
bool get_portal_geom () const
 Returns the current state of the portal_geom flag.
virtual TypeHandle get_type () const
const LPoint3fget_vertex (int n) const
 Returns the nth vertex of the portal polygon.
bool is_clip_plane ()
 Is this portal clipping against its left-right planes.
bool is_open ()
 Is this portal open from current camera zone.
virtual bool is_renderable () const
 Returns true if there is some value to visiting this particular node during the cull traversal for any camera, false otherwise.
bool is_visible ()
 Is this portal facing the camera.
virtual PandaNodemake_copy () const
 Returns a newly-allocated Node that is a shallow copy of this one.
 MAKE_SEQ (get_vertices, get_num_vertices, get_vertex)
virtual void output (ostream &out) const
 Writes a brief description of the node to the indicated output stream.
virtual bool preserve_name () const
 Returns true if the node's name has extrinsic meaning and must be preserved across a flatten operation, false otherwise.
void set_cell_in (const NodePath &cell)
 Sets the cell that this portal belongs to.
void set_cell_out (const NodePath &cell)
 Sets the cell that this portal leads out to.
void set_clip_plane (bool value)
 this is set if the portal will clip against its left and right planes
void set_from_portal_mask (PortalMask mask)
 Sets the "from" PortalMask.
void set_into_portal_mask (PortalMask mask)
 Sets the "into" PortalMask.
void set_max_depth (int value)
 Set the maximum depth this portal will be visible at.
void set_open (bool value)
 Python sets this based on curent camera zone.
void set_portal_geom (bool flag)
 Sets the state of the "portal geom" flag for this PortalNode.
void set_portal_mask (PortalMask mask)
 Simultaneously sets both the "from" and "into" PortalMask values to the same thing.
void set_visible (bool value)
 this is set if the portal is facing camera
virtual void write_datagram (BamWriter *manager, Datagram &dg)
 Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual void xform (const LMatrix4f &mat)
 Transforms the contents of this node by the indicated matrix, if it means anything to do so.

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()
static void register_with_read_factory ()
 Tells the BamReader how to create objects of type PortalNode.

Protected Member Functions

 PortalNode (const PortalNode &copy)
virtual void compute_internal_bounds (CPT(BoundingVolume)&internal_bounds, int &internal_vertices, int pipeline_stage, Thread *current_thread) const
 Called when needed to recompute the node's _internal_bound object.
void fillin (DatagramIterator &scan, BamReader *manager)
 This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new PortalNode.

Static Protected Member Functions

static TypedWritablemake_from_bam (const FactoryParams &params)
 This function is called by the BamReader's factory when a new object of type PortalNode is encountered in the Bam file.

Detailed Description

A node in the scene graph that can hold a Portal Polygon, which is a rectangle.

Other types of polygons are not supported for now. It also holds a PT(PandaNode) Cell that this portal is connected to

Definition at line 34 of file portalNode.h.


Constructor & Destructor Documentation

PortalNode::PortalNode ( const string &  name)

Default constructor, just an empty node, no geo This is used to read portal from model.

You can also use this from python to create an empty portal. Then you can set the vertices yourself, with addVertex.

Definition at line 44 of file portalNode.cxx.

References PandaNode::set_cull_callback().

Referenced by make_copy(), and make_from_bam().

PortalNode::PortalNode ( const string &  name,
LPoint3f  pos,
float  scale = 10.0 
)

Create a default rectangle as portal.

Use this to create an arbitrary portal and setup from Python

Definition at line 65 of file portalNode.cxx.

References add_vertex(), and PandaNode::set_cull_callback().


Member Function Documentation

void PortalNode::add_vertex ( const LPoint3f vertex) [inline]

Adds a new vertex to the portal polygon.

The vertices should be defined in a counterclockwise orientation when viewing through the portal.

Definition at line 142 of file portalNode.I.

Referenced by PortalNode().

void PortalNode::clear_vertices ( ) [inline]

Resets the vertices of the portal to the empty list.

Definition at line 130 of file portalNode.I.

PandaNode * PortalNode::combine_with ( PandaNode other) [virtual]

Collapses this node with the other node, if possible, and returns a pointer to the combined node, or NULL if the two nodes cannot safely be combined.

The return value may be this, other, or a new node altogether.

This function is called from GraphReducer::flatten(), and need not deal with children; its job is just to decide whether to collapse the two nodes and what the collapsed node should look like.

Reimplemented from PandaNode.

Definition at line 196 of file portalNode.cxx.

References TypedObject::is_exact_type().

int PortalNode::complete_pointers ( TypedWritable **  p_list,
BamReader manager 
) [virtual]

Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().

Returns the number of pointers processed.

Reimplemented from TypedWritable.

Definition at line 467 of file portalNode.cxx.

*void PortalNode::compute_internal_bounds ( CPT(BoundingVolume)&  internal_bounds,
int &  internal_vertices,
int  pipeline_stage,
Thread current_thread 
) const [protected, virtual]

Called when needed to recompute the node's _internal_bound object.

Nodes that contain anything of substance should redefine this to do the right thing.

Reimplemented from PandaNode.

Definition at line 386 of file portalNode.cxx.

References GeometricBoundingVolume::around().

bool PortalNode::cull_callback ( CullTraverser trav,
CullTraverserData data 
) [virtual]

This function will be called during the cull traversal to perform reduced frustum culling.

Basically, once the scenegraph comes across a portal node, it calculates a CulltraverserData with which cell, this portal leads out to and the new frustum. Then it traverses that child

The return value is true if this node should be visible, or false if it should be culled.

Reimplemented from PandaNode.

Definition at line 227 of file portalNode.cxx.

References PortalClipper::get_clip_state(), SceneSetup::get_cull_center(), CullTraverser::get_current_thread(), NodePath::get_name(), WorkingNodePath::get_node_path(), CullTraverser::get_portal_clipper(), PortalClipper::get_reduced_frustum(), PortalClipper::get_reduced_viewport(), CullTraverser::get_view_frustum(), NodePath::is_empty(), is_open(), PortalClipper::prepare_portal(), PortalClipper::set_clip_state(), PortalClipper::set_reduced_frustum(), PortalClipper::set_reduced_viewport(), set_visible(), and CullTraverser::traverse_below().

void PortalNode::enable_clipping_planes ( ) [virtual]

initialize the clipping planes and renderstate

Definition at line 145 of file portalNode.cxx.

References NodePath::attach_new_node().

Referenced by set_clip_plane().

void PortalNode::fillin ( DatagramIterator scan,
BamReader manager 
) [protected, virtual]

This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new PortalNode.

Reimplemented from PandaNode.

Definition at line 501 of file portalNode.cxx.

References DatagramIterator::get_uint16(), and LVecBase3f::read_datagram().

Referenced by make_from_bam().

NodePath PortalNode::get_cell_in ( ) const [inline]

Sets the cell that this portal belongs to.

Definition at line 181 of file portalNode.I.

NodePath PortalNode::get_cell_out ( ) const [inline]

Sets the cell that this portal leads out to.

Definition at line 198 of file portalNode.I.

PortalMask PortalNode::get_from_portal_mask ( ) const [inline]

Returns the current "from" PortalMask.

In order for a portal to be detected from this object into another object, the intersection of this object's "from" mask and the other object's "into" mask must be nonzero.

Definition at line 71 of file portalNode.I.

PortalMask PortalNode::get_into_portal_mask ( ) const [inline]

Returns the current "into" PortalMask.

In order for a portal to be detected from another object into this object, the intersection of the other object's "from" mask and this object's "into" mask must be nonzero.

Definition at line 85 of file portalNode.I.

int PortalNode::get_max_depth ( ) [inline]

Returns the maximum depth this portal will be visible at.

Definition at line 275 of file portalNode.I.

int PortalNode::get_num_vertices ( ) const [inline]

Returns the number of vertices in the portal polygon.

Definition at line 152 of file portalNode.I.

bool PortalNode::get_portal_geom ( ) const [inline]

Returns the current state of the portal_geom flag.

See set_portal_geom().

Definition at line 120 of file portalNode.I.

const LPoint3f & PortalNode::get_vertex ( int  n) const [inline]

Returns the nth vertex of the portal polygon.

Definition at line 162 of file portalNode.I.

References LPoint3f::zero().

Referenced by PortalClipper::draw_current_portal(), and PortalClipper::prepare_portal().

bool PortalNode::is_clip_plane ( ) [inline]

Is this portal clipping against its left-right planes.

Definition at line 220 of file portalNode.I.

bool PortalNode::is_open ( ) [inline]

Is this portal open from current camera zone.

Definition at line 257 of file portalNode.I.

Referenced by cull_callback().

bool PortalNode::is_renderable ( ) const [virtual]

Returns true if there is some value to visiting this particular node during the cull traversal for any camera, false otherwise.

This will be used to optimize the result of get_net_draw_show_mask(), so that any subtrees that contain only nodes for which is_renderable() is false need not be visited.

Reimplemented from PandaNode.

Definition at line 342 of file portalNode.cxx.

bool PortalNode::is_visible ( ) [inline]

Is this portal facing the camera.

Definition at line 239 of file portalNode.I.

PandaNode * PortalNode::make_copy ( ) const [virtual]

Returns a newly-allocated Node that is a shallow copy of this one.

It will be a different Node pointer, but its internal data may or may not be shared with that of the original Node.

Reimplemented from PandaNode.

Definition at line 123 of file portalNode.cxx.

References PortalNode().

TypedWritable * PortalNode::make_from_bam ( const FactoryParams params) [static, protected]

This function is called by the BamReader's factory when a new object of type PortalNode is encountered in the Bam file.

It should create the PortalNode and extract its information from the file.

Reimplemented from PandaNode.

Definition at line 482 of file portalNode.cxx.

References fillin(), and PortalNode().

Referenced by register_with_read_factory().

void PortalNode::output ( ostream &  out) const [virtual]

Writes a brief description of the node to the indicated output stream.

This is invoked by the << operator. It may be overridden in derived classes to include some information relevant to the class.

Reimplemented from PandaNode.

Definition at line 356 of file portalNode.cxx.

bool PortalNode::preserve_name ( ) const [virtual]

Returns true if the node's name has extrinsic meaning and must be preserved across a flatten operation, false otherwise.

Reimplemented from PandaNode.

Definition at line 135 of file portalNode.cxx.

void PortalNode::register_with_read_factory ( ) [static]

Tells the BamReader how to create objects of type PortalNode.

Reimplemented from PandaNode.

Definition at line 437 of file portalNode.cxx.

References BamReader::get_factory(), make_from_bam(), and Factory< Type >::register_factory().

void PortalNode::set_cell_in ( const NodePath cell) [inline]

Sets the cell that this portal belongs to.

Definition at line 172 of file portalNode.I.

void PortalNode::set_cell_out ( const NodePath cell) [inline]

Sets the cell that this portal leads out to.

Definition at line 189 of file portalNode.I.

void PortalNode::set_clip_plane ( bool  value) [inline]

this is set if the portal will clip against its left and right planes

Definition at line 208 of file portalNode.I.

References enable_clipping_planes().

void PortalNode::set_from_portal_mask ( PortalMask  mask) [inline]

Sets the "from" PortalMask.

In order for a portal to be detected from this object into another object, the intersection of this object's "from" mask and the other object's "into" mask must be nonzero.

Definition at line 38 of file portalNode.I.

Referenced by set_portal_mask().

void PortalNode::set_into_portal_mask ( PortalMask  mask) [inline]

Sets the "into" PortalMask.

In order for a portal to be detected from another object into this object, the intersection of the other object's "from" mask and this object's "into" mask must be nonzero.

Definition at line 52 of file portalNode.I.

References PandaNode::mark_bounds_stale().

Referenced by set_portal_mask().

void PortalNode::set_max_depth ( int  value) [inline]

Set the maximum depth this portal will be visible at.

Definition at line 266 of file portalNode.I.

void PortalNode::set_open ( bool  value) [inline]

Python sets this based on curent camera zone.

Definition at line 248 of file portalNode.I.

void PortalNode::set_portal_geom ( bool  flag) [inline]

Sets the state of the "portal geom" flag for this PortalNode.

Normally, this is false; when this is set true, the PortalSolids in this node will test for portals with actual renderable geometry, in addition to whatever PortalSolids may be indicated by the from_portal_mask.

Setting this to true causes this to test *all* GeomNodes for portals. It is an all-or-none thing; there is no way to portal with only some GeomNodes, as GeomNodes have no into_portal_mask.

Definition at line 105 of file portalNode.I.

void PortalNode::set_portal_mask ( PortalMask  mask) [inline]

Simultaneously sets both the "from" and "into" PortalMask values to the same thing.

Definition at line 23 of file portalNode.I.

References set_from_portal_mask(), and set_into_portal_mask().

void PortalNode::set_visible ( bool  value) [inline]

this is set if the portal is facing camera

Definition at line 230 of file portalNode.I.

Referenced by cull_callback().

void PortalNode::write_datagram ( BamWriter manager,
Datagram dg 
) [virtual]

Writes the contents of this object to the datagram for shipping out to a Bam file.

Reimplemented from PandaNode.

Definition at line 448 of file portalNode.cxx.

References Datagram::add_uint16().

void PortalNode::xform ( const LMatrix4f mat) [virtual]

Transforms the contents of this node by the indicated matrix, if it means anything to do so.

For most kinds of nodes, this does nothing.

Reimplemented from PandaNode.

Definition at line 175 of file portalNode.cxx.

References LMatrix4f::is_nan().


The documentation for this class was generated from the following files: