Panda3D
 All Classes Functions Variables Enumerations
portalNode.I
00001 // Filename: portalNode.I
00002 // Created by:  masad (13May04)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: PortalNode::set_portal_mask
00018 //       Access: Published
00019 //  Description: Simultaneously sets both the "from" and "into"
00020 //               PortalMask values to the same thing.
00021 ////////////////////////////////////////////////////////////////////
00022 INLINE void PortalNode::
00023 set_portal_mask(PortalMask mask) {
00024   set_from_portal_mask(mask);
00025   set_into_portal_mask(mask);
00026 }
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //     Function: PortalNode::set_from_portal_mask
00030 //       Access: Published
00031 //  Description: Sets the "from" PortalMask.  In order for a
00032 //               portal to be detected from this object into
00033 //               another object, the intersection of this object's
00034 //               "from" mask and the other object's "into" mask must
00035 //               be nonzero.
00036 ////////////////////////////////////////////////////////////////////
00037 INLINE void PortalNode::
00038 set_from_portal_mask(PortalMask mask) {
00039   _from_portal_mask = mask;
00040 }
00041 
00042 ////////////////////////////////////////////////////////////////////
00043 //     Function: PortalNode::set_into_portal_mask
00044 //       Access: Published
00045 //  Description: Sets the "into" PortalMask.  In order for a
00046 //               portal to be detected from another object into
00047 //               this object, the intersection of the other object's
00048 //               "from" mask and this object's "into" mask must be
00049 //               nonzero.
00050 ////////////////////////////////////////////////////////////////////
00051 INLINE void PortalNode::
00052 set_into_portal_mask(PortalMask mask) {
00053   _into_portal_mask = mask;
00054 
00055   // We mark the bound stale when this changes, not because the actual
00056   // bounding volume changes, but rather because we piggyback the
00057   // computing of the _net_portal_mask on the bounding volume.
00058   mark_bounds_stale();
00059 }
00060 
00061 ////////////////////////////////////////////////////////////////////
00062 //     Function: PortalNode::get_from_portal_mask
00063 //       Access: Published
00064 //  Description: Returns the current "from" PortalMask.  In order for
00065 //               a portal to be detected from this object into
00066 //               another object, the intersection of this object's
00067 //               "from" mask and the other object's "into" mask must
00068 //               be nonzero.
00069 ////////////////////////////////////////////////////////////////////
00070 INLINE PortalMask PortalNode::
00071 get_from_portal_mask() const {
00072   return _from_portal_mask;
00073 }
00074 
00075 ////////////////////////////////////////////////////////////////////
00076 //     Function: PortalNode::get_into_portal_mask
00077 //       Access: Published
00078 //  Description: Returns the current "into" PortalMask.  In order for
00079 //               a portal to be detected from another object into
00080 //               this object, the intersection of the other object's
00081 //               "from" mask and this object's "into" mask must be
00082 //               nonzero.
00083 ////////////////////////////////////////////////////////////////////
00084 INLINE PortalMask PortalNode::
00085 get_into_portal_mask() const {
00086   return _into_portal_mask;
00087 }
00088 
00089 ////////////////////////////////////////////////////////////////////
00090 //     Function: PortalNode::set_portal_geom
00091 //       Access: Published
00092 //  Description: Sets the state of the "portal geom" flag for this
00093 //               PortalNode.  Normally, this is false; when this is
00094 //               set true, the PortalSolids in this node will test
00095 //               for portals with actual renderable geometry, in
00096 //               addition to whatever PortalSolids may be indicated
00097 //               by the from_portal_mask.
00098 //
00099 //               Setting this to true causes this to test *all*
00100 //               GeomNodes for portals.  It is an all-or-none
00101 //               thing; there is no way to portal with only some
00102 //               GeomNodes, as GeomNodes have no into_portal_mask.
00103 ////////////////////////////////////////////////////////////////////
00104 INLINE void PortalNode::
00105 set_portal_geom(bool flag) {
00106   if (flag) {
00107     _flags |= F_portal_geom;
00108   } else {
00109     _flags &= ~F_portal_geom;
00110   }
00111 }
00112 
00113 ////////////////////////////////////////////////////////////////////
00114 //     Function: PortalNode::get_portal_geom
00115 //       Access: Published
00116 //  Description: Returns the current state of the portal_geom flag.
00117 //               See set_portal_geom().
00118 ////////////////////////////////////////////////////////////////////
00119 INLINE bool PortalNode::
00120 get_portal_geom() const {
00121   return (_flags & F_portal_geom) != 0;
00122 }
00123 
00124 ////////////////////////////////////////////////////////////////////
00125 //     Function: PortalNode::clear_vertices
00126 //       Access: Published
00127 //  Description: Resets the vertices of the portal to the empty list.
00128 ////////////////////////////////////////////////////////////////////
00129 INLINE void PortalNode::
00130 clear_vertices() {
00131   _vertices.clear();
00132 }
00133 
00134 ////////////////////////////////////////////////////////////////////
00135 //     Function: PortalNode::add_vertex
00136 //       Access: Published
00137 //  Description: Adds a new vertex to the portal polygon.  The
00138 //               vertices should be defined in a counterclockwise
00139 //               orientation when viewing through the portal.
00140 ////////////////////////////////////////////////////////////////////
00141 INLINE void PortalNode::
00142 add_vertex(const LPoint3 &vertex) {
00143   _vertices.push_back(vertex);
00144 }
00145 
00146 ////////////////////////////////////////////////////////////////////
00147 //     Function: PortalNode::get_num_vertices
00148 //       Access: Published
00149 //  Description: Returns the number of vertices in the portal polygon.
00150 ////////////////////////////////////////////////////////////////////
00151 INLINE int PortalNode::
00152 get_num_vertices() const {
00153   return _vertices.size();
00154 }
00155 
00156 ////////////////////////////////////////////////////////////////////
00157 //     Function: PortalNode::get_vertex
00158 //       Access: Published
00159 //  Description: Returns the nth vertex of the portal polygon.
00160 ////////////////////////////////////////////////////////////////////
00161 INLINE const LPoint3 &PortalNode::
00162 get_vertex(int n) const {
00163   nassertr(n >= 0 && n < (int)_vertices.size(), LPoint3::zero());
00164   return _vertices[n];
00165 }
00166 
00167 ////////////////////////////////////////////////////////////////////
00168 //     Function: PortalNode::set_cell_in
00169 //       Access: Published
00170 //  Description: Sets the cell that this portal belongs to
00171 ////////////////////////////////////////////////////////////////////
00172 INLINE void PortalNode::set_cell_in(const NodePath &cell) {
00173   _cell_in = cell;
00174 }
00175 
00176 ////////////////////////////////////////////////////////////////////
00177 //     Function: PortalNode::get_cell_in
00178 //       Access: Published
00179 //  Description: Sets the cell that this portal belongs to
00180 ////////////////////////////////////////////////////////////////////
00181 INLINE NodePath PortalNode::get_cell_in() const {
00182   return _cell_in;
00183 }
00184 ////////////////////////////////////////////////////////////////////
00185 //     Function: PortalNode::set_cell_out
00186 //       Access: Published
00187 //  Description: Sets the cell that this portal leads out to
00188 ////////////////////////////////////////////////////////////////////
00189 INLINE void PortalNode::set_cell_out(const NodePath &cell) {
00190   _cell_out = cell;
00191 }
00192 
00193 ////////////////////////////////////////////////////////////////////
00194 //     Function: PortalNode::get_cell_out
00195 //       Access: Published
00196 //  Description: Sets the cell that this portal leads out to
00197 ////////////////////////////////////////////////////////////////////
00198 INLINE NodePath PortalNode::get_cell_out() const {
00199   return _cell_out;
00200 }
00201 
00202 ////////////////////////////////////////////////////////////////////
00203 //     Function: PortalNode::set_clip_plane
00204 //       Access: Published
00205 //  Description: this is set if the portal will clip against its 
00206 //               left and right planes
00207 ////////////////////////////////////////////////////////////////////
00208 INLINE void PortalNode::set_clip_plane(bool value) {
00209   _clip_plane = value;
00210   if (_clip_plane) {
00211     enable_clipping_planes();
00212   }
00213 }
00214 
00215 ////////////////////////////////////////////////////////////////////
00216 //     Function: PortalNode::is_clip_plane
00217 //       Access: Published
00218 //  Description: Is this portal clipping against its left-right planes
00219 ////////////////////////////////////////////////////////////////////
00220 INLINE bool PortalNode::is_clip_plane() {
00221   return _clip_plane;
00222 }
00223 
00224 
00225 ////////////////////////////////////////////////////////////////////
00226 //     Function: PortalNode::set_visible
00227 //       Access: Published
00228 //  Description: this is set if the portal is facing camera
00229 ////////////////////////////////////////////////////////////////////
00230 INLINE void PortalNode::set_visible(bool value) {
00231   _visible = value;
00232 }
00233 
00234 ////////////////////////////////////////////////////////////////////
00235 //     Function: PortalNode::is_visible
00236 //       Access: Published
00237 //  Description: Is this portal facing the camera
00238 ////////////////////////////////////////////////////////////////////
00239 INLINE bool PortalNode::is_visible() {
00240   return _visible;
00241 }
00242 
00243 ////////////////////////////////////////////////////////////////////
00244 //     Function: PortalNode::set_open
00245 //       Access: Published
00246 //  Description: Python sets this based on curent camera zone
00247 ////////////////////////////////////////////////////////////////////
00248 INLINE void PortalNode::set_open(bool value) {
00249   _open = value;
00250 }
00251 
00252 ////////////////////////////////////////////////////////////////////
00253 //     Function: PortalNode::is_open
00254 //       Access: Published
00255 //  Description: Is this portal open from current camera zone
00256 ////////////////////////////////////////////////////////////////////
00257 INLINE bool PortalNode::is_open() {
00258   return _open;
00259 }
00260 
00261 ////////////////////////////////////////////////////////////////////
00262 //     Function: PortalNode::set_max_depth
00263 //       Access: Published
00264 //  Description: Set the maximum depth this portal will be visible at
00265 ////////////////////////////////////////////////////////////////////
00266 INLINE void PortalNode::set_max_depth(int value) {
00267   _max_depth = value;
00268 }
00269 
00270 ////////////////////////////////////////////////////////////////////
00271 //     Function: PortalNode::get_max_depth
00272 //       Access: Published
00273 //  Description: Returns the maximum depth this portal will be visible at
00274 ////////////////////////////////////////////////////////////////////
00275 INLINE int PortalNode::get_max_depth() {
00276   return _max_depth;
00277 }
00278 
 All Classes Functions Variables Enumerations