Panda3D
|
A node in the scene graph that can hold an occluder polygon, which must be a rectangle. More...
#include "occluderNode.h"
Public Member Functions | |
OccluderNode (const string &name) | |
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 any additional operations that should be performed at cull time. | |
virtual TypeHandle | force_init_type () |
PN_stdfloat | get_min_coverage () |
Returns the minimum screen coverage. | |
int | get_num_vertices () const |
Returns the number of vertices in the occluder polygon. | |
virtual TypeHandle | get_type () const |
const LPoint3 & | get_vertex (int n) const |
Returns the nth vertex of the occluder polygon. | |
bool | is_double_sided () |
Is this occluder double-sided. | |
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. | |
virtual PandaNode * | make_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_double_sided (bool value) |
If true, the back-face will also be used to occlude. | |
void | set_min_coverage (PN_stdfloat value) |
Minimum screen coverage needed before occluder used. | |
void | set_vertices (const LPoint3 &v0, const LPoint3 &v1, const LPoint3 &v2, const LPoint3 &v3) |
Replaces the four vertices of the occluder polygon. | |
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 LMatrix4 &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 OccluderNode. | |
Protected Member Functions | |
OccluderNode (const OccluderNode ©) | |
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. | |
CPT (RenderState) get_occluder_viz_state(CullTraverser *trav | |
CPT (RenderState) get_frame_viz_state(CullTraverser *trav | |
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 OccluderNode. | |
PT (Geom) get_occluder_viz(CullTraverser *trav | |
Static Protected Member Functions | |
static TypedWritable * | make_from_bam (const FactoryParams ¶ms) |
This function is called by the BamReader's factory when a new object of type OccluderNode is encountered in the Bam file. | |
Protected Attributes | |
CullTraverserData & | data |
A node in the scene graph that can hold an occluder polygon, which must be a rectangle.
When the occluder is activated with something like render.set_occluder(), then objects whose bouding volume lies entirely behind the occluder will not be rendered.
Definition at line 35 of file occluderNode.h.
int OccluderNode::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 403 of file occluderNode.cxx.
void OccluderNode::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 225 of file occluderNode.cxx.
References GeometricBoundingVolume::around().
bool OccluderNode::cull_callback | ( | CullTraverser * | trav, |
CullTraverserData & | data | ||
) | [virtual] |
This function will be called during the cull traversal to perform any additional operations that should be performed at cull time.
This may include additional manipulation of render state or additional visible/invisible decisions, or any other arbitrary operation.
Note that this function will *not* be called unless set_cull_callback() is called in the constructor of the derived class. It is necessary to call set_cull_callback() to indicated that we require cull_callback() to be called.
By the time this function is called, the node has already passed the bounding-volume test for the viewing frustum, and the node's transform and state have already been applied to the indicated CullTraverserData object.
The return value is true if this node should be visible, or false if it should be culled.
Reimplemented from PandaNode.
Definition at line 164 of file occluderNode.cxx.
References CullTraverser::get_cull_handler(), CullTraverser::get_gsg(), CullTraverserData::get_net_transform(), and CullHandler::record_object().
void OccluderNode::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 OccluderNode.
Reimplemented from PandaNode.
Definition at line 437 of file occluderNode.cxx.
References DatagramIterator::get_uint16(), and LVecBase3f::read_datagram().
Referenced by make_from_bam().
PN_stdfloat OccluderNode::get_min_coverage | ( | ) | [inline] |
Returns the minimum screen coverage.
Definition at line 91 of file occluderNode.I.
int OccluderNode::get_num_vertices | ( | ) | const [inline] |
Returns the number of vertices in the occluder polygon.
This should always return 4.
Definition at line 41 of file occluderNode.I.
const LPoint3 & OccluderNode::get_vertex | ( | int | n | ) | const [inline] |
Returns the nth vertex of the occluder polygon.
Definition at line 51 of file occluderNode.I.
References LPoint3f::zero().
bool OccluderNode::is_double_sided | ( | ) | [inline] |
Is this occluder double-sided.
Definition at line 70 of file occluderNode.I.
bool OccluderNode::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 198 of file occluderNode.cxx.
PandaNode * OccluderNode::make_copy | ( | ) | const [virtual] |
TypedWritable * OccluderNode::make_from_bam | ( | const FactoryParams & | params | ) | [static, protected] |
This function is called by the BamReader's factory when a new object of type OccluderNode is encountered in the Bam file.
It should create the OccluderNode and extract its information from the file.
Reimplemented from PandaNode.
Definition at line 418 of file occluderNode.cxx.
References fillin().
Referenced by register_with_read_factory().
void OccluderNode::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 212 of file occluderNode.cxx.
bool OccluderNode::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 116 of file occluderNode.cxx.
void OccluderNode::register_with_read_factory | ( | ) | [static] |
Tells the BamReader how to create objects of type OccluderNode.
Reimplemented from PandaNode.
Definition at line 373 of file occluderNode.cxx.
References BamReader::get_factory(), make_from_bam(), and Factory< Type >::register_factory().
void OccluderNode::set_double_sided | ( | bool | value | ) | [inline] |
If true, the back-face will also be used to occlude.
Definition at line 61 of file occluderNode.I.
void OccluderNode::set_min_coverage | ( | PN_stdfloat | value | ) | [inline] |
Minimum screen coverage needed before occluder used.
Range should be 0 to 1. For example, setting to 0.2 would mean that the occluder needs to cover 20% of the screen to be considered.
Definition at line 82 of file occluderNode.I.
void OccluderNode::set_vertices | ( | const LPoint3 & | v0, |
const LPoint3 & | v1, | ||
const LPoint3 & | v2, | ||
const LPoint3 & | v3 | ||
) | [inline] |
Replaces the four vertices of the occluder polygon.
The vertices should be defined in a counterclockwise orientation when looking at the face of the occluder.
Definition at line 24 of file occluderNode.I.
void OccluderNode::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 384 of file occluderNode.cxx.
References Datagram::add_uint16().
void OccluderNode::xform | ( | const LMatrix4 & | 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 128 of file occluderNode.cxx.
References LMatrix4f::is_nan().