21 INLINE PortalClipper::Point::
30 INLINE PortalClipper::Point::
32 _point(point[0], point[1], point[2]),
42 INLINE PortalClipper::Point::
43 Point(
const PortalClipper::Point ©) :
54 INLINE
void PortalClipper::Point::
55 operator = (
const PortalClipper::Point ©) {
69 move_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
83 draw_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
108 _reduced_frustum = frustum;
118 return _reduced_frustum;
130 _clip_state = clip_state;
152 _reduced_viewport_min = min;
153 _reduced_viewport_max = max;
164 min = _reduced_viewport_min;
165 max = _reduced_viewport_max;
178 portal_cat.debug() <<
"portal plane check value: " << portal_plane[3] <<
"\n";
179 return (portal_plane[3] > 0);
199 int result = _reduced_frustum->
contains(gbv);
201 portal_cat.spam() <<
"1st level test if portal: " << *_reduced_frustum <<
" is in view " << result << endl;
202 return (result != 0);
207 // Function: PortalClipper::is_partial_portal_in_view
209 // Description: checks if any of the _coords is within the view frustum.
210 // If so, then the portal is facing the camera. 2nd level
211 // test to make sure this portal is worth visiting
213 INLINE bool PortalClipper::
214 is_partial_portal_in_view() {
217 // check if any of the _coords in tested frustum
218 for (int j=0; j<_num_vert; ++j) {
219 result |= _reduced_frustum->contains(_coords[j]);
221 portal_cat.spam() << "frustum: " << *_reduced_frustum << " contains(coord) result = " << result << endl;
223 return (result != 0);
229 // Function: PortalClipper::get_plane_depth
231 // Description: Given the x and z, solve for y: from the plane
233 INLINE PN_stdfloat PortalClipper::
234 get_plane_depth(PN_stdfloat x, PN_stdfloat z, LPlane *portal_plane) {
236 // Plane equation: Ax + By + Cz + D = 0
237 // y = (Ax + Cz + D) / -B
238 portal_cat.spam() << *portal_plane << endl;
239 portal_cat.spam() << portal_plane->_v.v._0 << " " << portal_plane->_v.v._1 << " "
240 << portal_plane->_v.v._2 << " " << portal_plane->_v.v._3 << endl;
242 if (portal_plane->_v.v._1 != 0.0) {
243 y = (((portal_plane->_v.v._0*x)+(portal_plane->_v.v._2*z)+portal_plane->_v.v._3)
244 / -(portal_plane->_v.v._1));
void draw_camera_frustum()
Draw the current camera frustum in white color.
This is the base class for all three-component vectors and points.
void get_reduced_viewport(LPoint2 &min, LPoint2 &max) const
Return the reduced viewport.
void move_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Moves the pen to the given point without drawing a line.
bool is_facing_view(const LPlane &portal_plane)
checks if the portal plane (in camera space) is facing the camera's near plane
void set_reduced_frustum(BoundingHexahedron *bh)
Set the current view frustum that is being calculated by the portal clipper.
int contains(const GeometricBoundingVolume *vol) const
Returns the appropriate set of IntersectionFlags to indicate the amount of intersection with the indi...
void draw_hexahedron(BoundingHexahedron *frustum)
Given the BoundingHexahedron draw it using lines.
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...
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
const RenderState * get_clip_state() const
Returns the stored clip state.
This is a 4-by-4 transform matrix.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
This is the base class for all three-component vectors and points.
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 indica...
bool is_whole_portal_in_view(const LMatrix4 &cmat)
checks if portal_node is within the view frustum.
This is a two-component point in space.
BoundingHexahedron * get_reduced_frustum() const
Return the reduced frustum.
void set_reduced_viewport(const LPoint2 &min, const LPoint2 &max)
Set the current viewport that is being used by the portal clipper.
This defines a bounding convex hexahedron.