Panda3D
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
PortalClipper Class Reference

This object performs a depth-first traversal of the scene graph, with optional view-frustum culling, collecting CullState and searching for GeomNodes. More...

#include "portalClipper.h"

Inheritance diagram for PortalClipper:
TypedObject MemoryBase

Public Member Functions

 PortalClipper (GeometricBoundingVolume *frustum, SceneSetup *scene_setup)
 
void draw_camera_frustum ()
 Draw the current camera frustum in white color. More...
 
void draw_current_portal ()
 _portal_node is the current portal, draw it. More...
 
void draw_hexahedron (BoundingHexahedron *frustum)
 Given the BoundingHexahedron draw it using lines. More...
 
void draw_lines ()
 Draw all the lines in the buffer Cyan portal is the original geometry of the portal Yellow portal is the AA minmax & clipped portal Blue frustum is the frustum through portal White frustum is the camera frustum. More...
 
void draw_to (PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
 Draws a line segment from the pen's last position (the last call to move_to or draw_to) to the indicated point. More...
 
void draw_to (const LVecBase3 &v)
 Draws a line segment from the pen's last position (the last call to move_to or draw_to) to the indicated point. More...
 
virtual TypeHandle force_init_type ()
 
const RenderStateget_clip_state () const
 Returns the stored clip state. More...
 
BoundingHexahedronget_reduced_frustum () const
 Return the reduced frustum. More...
 
void get_reduced_viewport (LPoint2 &min, LPoint2 &max) const
 Return the reduced viewport. More...
 
virtual TypeHandle get_type () const
 
bool is_facing_view (const LPlane &portal_plane)
 checks if the portal plane (in camera space) is facing the camera's near plane More...
 
bool is_partial_portal_in_view ()
 
bool is_whole_portal_in_view (const LMatrix4 &cmat)
 checks if portal_node is within the view frustum. More...
 
void move_to (PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
 Moves the pen to the given point without drawing a line. More...
 
void move_to (const LVecBase3 &v)
 Moves the pen to the given point without drawing a line. More...
 
bool prepare_portal (const NodePath &node_path)
 Given the portal draw the frustum with line segs for now. More...
 
 PT (GeomNode) _previous
 
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 nodes. More...
 
void set_reduced_frustum (BoundingHexahedron *bh)
 Set the current view frustum that is being calculated by the portal clipper. More...
 
void set_reduced_viewport (const LPoint2 &min, const LPoint2 &max)
 Set the current viewport that is being used by the portal clipper. More...
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
int get_best_parent_from_Set (const std::set< int > &) const
 
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly. More...
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type. More...
 
void operator= (const TypedObject &copy)
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle get_class_type ()
 
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96. More...
 

Public Attributes

SceneSetup_scene_setup
 

Detailed Description

This object performs a depth-first traversal of the scene graph, with optional view-frustum culling, collecting CullState and searching for GeomNodes.

Each renderable Geom encountered is passed along with its associated RenderState to the CullHandler object.

Definition at line 52 of file portalClipper.h.

Member Function Documentation

◆ draw_camera_frustum()

void PortalClipper::draw_camera_frustum ( )
inline

Draw the current camera frustum in white color.

Definition at line 94 of file portalClipper.I.

References draw_hexahedron(), and set_reduced_frustum().

Referenced by draw_to(), and CullTraverser::traverse().

◆ draw_current_portal()

void PortalClipper::draw_current_portal ( )

_portal_node is the current portal, draw it.

Definition at line 143 of file portalClipper.cxx.

References draw_lines().

Referenced by draw_hexahedron().

◆ draw_hexahedron()

void PortalClipper::draw_hexahedron ( BoundingHexahedron frustum)

Given the BoundingHexahedron draw it using lines.

Definition at line 114 of file portalClipper.cxx.

References draw_current_portal(), and BoundingHexahedron::get_point().

Referenced by draw_camera_frustum(), and draw_to().

◆ draw_lines()

void PortalClipper::draw_lines ( )

Draw all the lines in the buffer Cyan portal is the original geometry of the portal Yellow portal is the AA minmax & clipped portal Blue frustum is the frustum through portal White frustum is the camera frustum.

Definition at line 161 of file portalClipper.cxx.

References GeomVertexWriter::add_data3(), GeomVertexWriter::add_data4(), and prepare_portal().

Referenced by draw_current_portal(), and CullTraverser::traverse().

◆ draw_to() [1/2]

void PortalClipper::draw_to ( PN_stdfloat  x,
PN_stdfloat  y,
PN_stdfloat  z 
)
inline

Draws a line segment from the pen's last position (the last call to move_to or draw_to) to the indicated point.

move_to() and draw_to() only update tables; the actual drawing is performed when create() is called.

Definition at line 83 of file portalClipper.I.

References draw_camera_frustum().

Referenced by move_to().

◆ draw_to() [2/2]

void PortalClipper::draw_to ( const LVecBase3 v)

Draws a line segment from the pen's last position (the last call to move_to or draw_to) to the indicated point.

move_to() and draw_to() only update tables; the actual drawing is performed when create() is called.

Definition at line 92 of file portalClipper.cxx.

References draw_hexahedron().

◆ get_clip_state()

const RenderState * PortalClipper::get_clip_state ( ) const
inline

Returns the stored clip state.

Definition at line 139 of file portalClipper.I.

References set_reduced_viewport().

Referenced by PortalNode::cull_callback(), and set_clip_state().

◆ get_reduced_frustum()

BoundingHexahedron * PortalClipper::get_reduced_frustum ( ) const
inline

Return the reduced frustum.

Definition at line 117 of file portalClipper.I.

References set_clip_state().

Referenced by PortalNode::cull_callback(), and set_reduced_frustum().

◆ get_reduced_viewport()

void PortalClipper::get_reduced_viewport ( LPoint2 min,
LPoint2 max 
) const
inline

Return the reduced viewport.

Definition at line 163 of file portalClipper.I.

References is_facing_view().

Referenced by PortalNode::cull_callback(), and set_reduced_viewport().

◆ is_facing_view()

bool PortalClipper::is_facing_view ( const LPlane &  portal_plane)
inline

checks if the portal plane (in camera space) is facing the camera's near plane

Definition at line 177 of file portalClipper.I.

References is_whole_portal_in_view().

Referenced by get_reduced_viewport().

◆ is_whole_portal_in_view()

bool PortalClipper::is_whole_portal_in_view ( const LMatrix4 cmat)
inline

checks if portal_node is within the view frustum.

If so, then the portal is worth considering. This is a 2nd level test to weed out most of the portals

Definition at line 190 of file portalClipper.I.

References GeometricBoundingVolume::contains().

Referenced by is_facing_view().

◆ move_to() [1/2]

void PortalClipper::move_to ( PN_stdfloat  x,
PN_stdfloat  y,
PN_stdfloat  z 
)
inline

Moves the pen to the given point without drawing a line.

When followed by draw_to(), this marks the first point of a line segment; when followed by move_to() or create(), this creates a single point.

Definition at line 69 of file portalClipper.I.

References draw_to().

◆ move_to() [2/2]

void PortalClipper::move_to ( const LVecBase3 v)

Moves the pen to the given point without drawing a line.

When followed by draw_to(), this marks the first point of a line segment; when followed by move_to() or create(), this creates a single point.

Definition at line 73 of file portalClipper.cxx.

References draw_to().

◆ prepare_portal()

bool PortalClipper::prepare_portal ( const NodePath node_path)

Given the portal draw the frustum with line segs for now.

More functionalities coming up

Definition at line 222 of file portalClipper.cxx.

References Lens::extrude(), LVector3f::forward(), Lens::get_coordinate_system(), NodePath::get_transform(), TypedObject::is_of_type(), NodePath::node(), and Lens::project().

Referenced by PortalNode::cull_callback(), and draw_lines().

◆ set_clip_state()

void PortalClipper::set_clip_state ( const RenderState clip_state)
inline

Set the clip state of the current portal node This is done to remember the state for the child portal nodes.

Definition at line 129 of file portalClipper.I.

References get_clip_state().

Referenced by PortalNode::cull_callback(), and get_reduced_frustum().

◆ set_reduced_frustum()

void PortalClipper::set_reduced_frustum ( BoundingHexahedron frustum)
inline

Set the current view frustum that is being calculated by the portal clipper.

Definition at line 107 of file portalClipper.I.

References get_reduced_frustum().

Referenced by PortalNode::cull_callback(), and draw_camera_frustum().

◆ set_reduced_viewport()

void PortalClipper::set_reduced_viewport ( const LPoint2 min,
const LPoint2 max 
)
inline

Set the current viewport that is being used by the portal clipper.

Definition at line 151 of file portalClipper.I.

References get_reduced_viewport().

Referenced by PortalNode::cull_callback(), and get_clip_state().


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