00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 INLINE PortalClipper::Point::
00022 Point() {
00023 }
00024
00025
00026
00027
00028
00029
00030 INLINE PortalClipper::Point::
00031 Point(const LVecBase3 &point, const LColor &color) :
00032 _point(point[0], point[1], point[2]),
00033 _color(color)
00034 {
00035 }
00036
00037
00038
00039
00040
00041
00042 INLINE PortalClipper::Point::
00043 Point(const PortalClipper::Point ©) :
00044 _point(copy._point),
00045 _color(copy._color)
00046 {
00047 }
00048
00049
00050
00051
00052
00053
00054 INLINE void PortalClipper::Point::
00055 operator = (const PortalClipper::Point ©) {
00056 _point = copy._point;
00057 _color = copy._color;
00058 }
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 INLINE void PortalClipper::
00069 move_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
00070 move_to(LVertex(x, y, z));
00071 }
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 INLINE void PortalClipper::
00083 draw_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
00084 draw_to(LVertex(x, y, z));
00085 }
00086
00087
00088
00089
00090
00091
00092
00093 INLINE void PortalClipper::
00094 draw_camera_frustum() {
00095 _color = LColor(1,1,1,1);
00096 draw_hexahedron(_view_frustum);
00097 }
00098
00099
00100
00101
00102
00103
00104
00105
00106 INLINE void PortalClipper::
00107 set_reduced_frustum(BoundingHexahedron *frustum) {
00108 _reduced_frustum = frustum;
00109 }
00110
00111
00112
00113
00114
00115
00116 INLINE BoundingHexahedron *PortalClipper::
00117 get_reduced_frustum() const {
00118 return _reduced_frustum;
00119 }
00120
00121
00122
00123
00124
00125
00126
00127
00128 INLINE void PortalClipper::
00129 set_clip_state(const RenderState* clip_state) {
00130 _clip_state = clip_state;
00131 }
00132
00133
00134
00135
00136
00137
00138 INLINE const RenderState *PortalClipper::
00139 get_clip_state() const {
00140 return _clip_state;
00141 }
00142
00143
00144
00145
00146
00147
00148
00149
00150 INLINE void PortalClipper::
00151 set_reduced_viewport(const LPoint2& min, const LPoint2& max) {
00152 _reduced_viewport_min = min;
00153 _reduced_viewport_max = max;
00154 }
00155
00156
00157
00158
00159
00160
00161
00162 INLINE void PortalClipper::
00163 get_reduced_viewport(LPoint2& min, LPoint2& max) const {
00164 min = _reduced_viewport_min;
00165 max = _reduced_viewport_max;
00166 }
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 INLINE bool PortalClipper::
00177 is_facing_view(const LPlane &portal_plane) {
00178 portal_cat.debug() << "portal plane check value: " << portal_plane[3] << "\n";
00179 return (portal_plane[3] > 0);
00180 }
00181
00182
00183
00184
00185
00186
00187
00188
00189 INLINE bool PortalClipper::
00190 is_whole_portal_in_view(const LMatrix4 &cmat) {
00191
00192 const BoundingVolume *bv = _portal_node->get_bounds();
00193 BoundingVolume *cbv = bv->make_copy();
00194 GeometricBoundingVolume *gbv = DCAST(GeometricBoundingVolume, cbv);
00195
00196
00197 gbv->xform(cmat);
00198
00199 int result = _reduced_frustum->contains(gbv);
00200
00201 portal_cat.spam() << "1st level test if portal: " << *_reduced_frustum << " is in view " << result << endl;
00202 return (result != 0);
00203 }
00204
00205
00206
00207 // Function: PortalClipper::is_partial_portal_in_view
00208 // Access: Public
00209 // Description: checks if any of the _coords is within the view frustum.
00210 // If so, then the portal is facing the camera. 2nd level
00211 // test to make sure this portal is worth visiting
00212
00213 INLINE bool PortalClipper::
00214 is_partial_portal_in_view() {
00215 int result = 0;
00216
00217 // check if any of the _coords in tested frustum
00218 for (int j=0; j<_num_vert; ++j) {
00219 result |= _reduced_frustum->contains(_coords[j]);
00220 }
00221 portal_cat.spam() << "frustum: " << *_reduced_frustum << " contains(coord) result = " << result << endl;
00222
00223 return (result != 0);
00224 }
00225 */
00226
00227
00228
00229 // Function: PortalClipper::get_plane_depth
00230 // Access: Public
00231 // Description: Given the x and z, solve for y: from the plane
00232
00233 INLINE PN_stdfloat PortalClipper::
00234 get_plane_depth(PN_stdfloat x, PN_stdfloat z, LPlane *portal_plane) {
00235 PN_stdfloat y = 0.0;
00236 // Plane equation: Ax + By + Cz + D = 0
00237 // y = (Ax + Cz + D) / -B
00238 portal_cat.spam() << *portal_plane << endl;
00239 portal_cat.spam() << portal_plane->_v.v._0 << " " << portal_plane->_v.v._1 << " "
00240 << portal_plane->_v.v._2 << " " << portal_plane->_v.v._3 << endl;
00241
00242 if (portal_plane->_v.v._1 != 0.0) {
00243 y = (((portal_plane->_v.v._0*x)+(portal_plane->_v.v._2*z)+portal_plane->_v.v._3)
00244 / -(portal_plane->_v.v._1));
00245 }
00246 return y;
00247 }
00248 */
00249