00001 // Filename: portalNode.I00002 // Created by: masad (13May04)00003 //00004 ////////////////////////////////////////////////////////////////////00005 //00006 // PANDA 3D SOFTWARE00007 // Copyright (c) Carnegie Mellon University. All rights reserved.00008 //00009 // All use of this software is subject to the terms of the revised BSD00010 // license. You should have received a copy of this license along00011 // with this source code in a file named "LICENSE."00012 //00013 ////////////////////////////////////////////////////////////////////00014
00015
00016 ////////////////////////////////////////////////////////////////////00017 // Function: PortalNode::set_portal_mask00018 // Access: Published00019 // Description: Simultaneously sets both the "from" and "into"00020 // PortalMask values to the same thing.00021 ////////////////////////////////////////////////////////////////////00022 INLINE voidPortalNode::00023set_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_mask00030 // Access: Published00031 // Description: Sets the "from" PortalMask. In order for a00032 // portal to be detected from this object into00033 // another object, the intersection of this object's00034 // "from" mask and the other object's "into" mask must00035 // be nonzero.00036 ////////////////////////////////////////////////////////////////////00037 INLINE voidPortalNode::00038set_from_portal_mask(PortalMask mask) {
00039 _from_portal_mask = mask;
00040 }
00041
00042 ////////////////////////////////////////////////////////////////////00043 // Function: PortalNode::set_into_portal_mask00044 // Access: Published00045 // Description: Sets the "into" PortalMask. In order for a00046 // portal to be detected from another object into00047 // this object, the intersection of the other object's00048 // "from" mask and this object's "into" mask must be00049 // nonzero.00050 ////////////////////////////////////////////////////////////////////00051 INLINE voidPortalNode::00052set_into_portal_mask(PortalMask mask) {
00053 _into_portal_mask = mask;
00054
00055 // We mark the bound stale when this changes, not because the actual00056 // bounding volume changes, but rather because we piggyback the00057 // computing of the _net_portal_mask on the bounding volume.00058 mark_bounds_stale();
00059 }
00060
00061 ////////////////////////////////////////////////////////////////////00062 // Function: PortalNode::get_from_portal_mask00063 // Access: Published00064 // Description: Returns the current "from" PortalMask. In order for00065 // a portal to be detected from this object into00066 // another object, the intersection of this object's00067 // "from" mask and the other object's "into" mask must00068 // be nonzero.00069 ////////////////////////////////////////////////////////////////////00070 INLINE PortalMaskPortalNode::00071get_from_portal_mask() const {
00072 return _from_portal_mask;
00073 }
00074
00075 ////////////////////////////////////////////////////////////////////00076 // Function: PortalNode::get_into_portal_mask00077 // Access: Published00078 // Description: Returns the current "into" PortalMask. In order for00079 // a portal to be detected from another object into00080 // this object, the intersection of the other object's00081 // "from" mask and this object's "into" mask must be00082 // nonzero.00083 ////////////////////////////////////////////////////////////////////00084 INLINE PortalMaskPortalNode::00085get_into_portal_mask() const {
00086 return _into_portal_mask;
00087 }
00088
00089 ////////////////////////////////////////////////////////////////////00090 // Function: PortalNode::set_portal_geom00091 // Access: Published00092 // Description: Sets the state of the "portal geom" flag for this00093 // PortalNode. Normally, this is false; when this is00094 // set true, the PortalSolids in this node will test00095 // for portals with actual renderable geometry, in00096 // addition to whatever PortalSolids may be indicated00097 // 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-none00101 // thing; there is no way to portal with only some00102 // GeomNodes, as GeomNodes have no into_portal_mask.00103 ////////////////////////////////////////////////////////////////////00104 INLINE voidPortalNode::00105set_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_geom00115 // Access: Published00116 // Description: Returns the current state of the portal_geom flag.00117 // See set_portal_geom().00118 ////////////////////////////////////////////////////////////////////00119 INLINE boolPortalNode::00120get_portal_geom() const {
00121 return (_flags & F_portal_geom) != 0;
00122 }
00123
00124 ////////////////////////////////////////////////////////////////////00125 // Function: PortalNode::clear_vertices00126 // Access: Published00127 // Description: Resets the vertices of the portal to the empty list.00128 ////////////////////////////////////////////////////////////////////00129 INLINE voidPortalNode::00130clear_vertices() {
00131 _vertices.clear();
00132 }
00133
00134 ////////////////////////////////////////////////////////////////////00135 // Function: PortalNode::add_vertex00136 // Access: Published00137 // Description: Adds a new vertex to the portal polygon. The00138 // vertices should be defined in a counterclockwise00139 // orientation when viewing through the portal.00140 ////////////////////////////////////////////////////////////////////00141 INLINE voidPortalNode::00142add_vertex(constLPoint3 &vertex) {
00143 _vertices.push_back(vertex);
00144 }
00145
00146 ////////////////////////////////////////////////////////////////////00147 // Function: PortalNode::get_num_vertices00148 // Access: Published00149 // Description: Returns the number of vertices in the portal polygon.00150 ////////////////////////////////////////////////////////////////////00151 INLINE intPortalNode::00152get_num_vertices() const {
00153 return _vertices.size();
00154 }
00155
00156 ////////////////////////////////////////////////////////////////////00157 // Function: PortalNode::get_vertex00158 // Access: Published00159 // Description: Returns the nth vertex of the portal polygon.00160 ////////////////////////////////////////////////////////////////////00161 INLINE constLPoint3 &PortalNode::00162get_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_in00169 // Access: Published00170 // Description: Sets the cell that this portal belongs to00171 ////////////////////////////////////////////////////////////////////00172 INLINE voidPortalNode::set_cell_in(constNodePath &cell) {
00173 _cell_in = cell;
00174 }
00175
00176 ////////////////////////////////////////////////////////////////////00177 // Function: PortalNode::get_cell_in00178 // Access: Published00179 // Description: Sets the cell that this portal belongs to00180 ////////////////////////////////////////////////////////////////////00181 INLINE NodePathPortalNode::get_cell_in() const {
00182 return _cell_in;
00183 }
00184 ////////////////////////////////////////////////////////////////////00185 // Function: PortalNode::set_cell_out00186 // Access: Published00187 // Description: Sets the cell that this portal leads out to00188 ////////////////////////////////////////////////////////////////////00189 INLINE voidPortalNode::set_cell_out(constNodePath &cell) {
00190 _cell_out = cell;
00191 }
00192
00193 ////////////////////////////////////////////////////////////////////00194 // Function: PortalNode::get_cell_out00195 // Access: Published00196 // Description: Sets the cell that this portal leads out to00197 ////////////////////////////////////////////////////////////////////00198 INLINE NodePathPortalNode::get_cell_out() const {
00199 return _cell_out;
00200 }
00201
00202 ////////////////////////////////////////////////////////////////////00203 // Function: PortalNode::set_clip_plane00204 // Access: Published00205 // Description: this is set if the portal will clip against its 00206 // left and right planes00207 ////////////////////////////////////////////////////////////////////00208 INLINE voidPortalNode::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_plane00217 // Access: Published00218 // Description: Is this portal clipping against its left-right planes00219 ////////////////////////////////////////////////////////////////////00220 INLINE boolPortalNode::is_clip_plane() {
00221 return _clip_plane;
00222 }
00223
00224
00225 ////////////////////////////////////////////////////////////////////00226 // Function: PortalNode::set_visible00227 // Access: Published00228 // Description: this is set if the portal is facing camera00229 ////////////////////////////////////////////////////////////////////00230 INLINE voidPortalNode::set_visible(bool value) {
00231 _visible = value;
00232 }
00233
00234 ////////////////////////////////////////////////////////////////////00235 // Function: PortalNode::is_visible00236 // Access: Published00237 // Description: Is this portal facing the camera00238 ////////////////////////////////////////////////////////////////////00239 INLINE boolPortalNode::is_visible() {
00240 return _visible;
00241 }
00242
00243 ////////////////////////////////////////////////////////////////////00244 // Function: PortalNode::set_open00245 // Access: Published00246 // Description: Python sets this based on curent camera zone00247 ////////////////////////////////////////////////////////////////////00248 INLINE voidPortalNode::set_open(bool value) {
00249 _open = value;
00250 }
00251
00252 ////////////////////////////////////////////////////////////////////00253 // Function: PortalNode::is_open00254 // Access: Published00255 // Description: Is this portal open from current camera zone00256 ////////////////////////////////////////////////////////////////////00257 INLINE boolPortalNode::is_open() {
00258 return _open;
00259 }
00260
00261 ////////////////////////////////////////////////////////////////////00262 // Function: PortalNode::set_max_depth00263 // Access: Published00264 // Description: Set the maximum depth this portal will be visible at00265 ////////////////////////////////////////////////////////////////////00266 INLINE voidPortalNode::set_max_depth(int value) {
00267 _max_depth = value;
00268 }
00269
00270 ////////////////////////////////////////////////////////////////////00271 // Function: PortalNode::get_max_depth00272 // Access: Published00273 // Description: Returns the maximum depth this portal will be visible at00274 ////////////////////////////////////////////////////////////////////00275 INLINE intPortalNode::get_max_depth() {
00276 return _max_depth;
00277 }
00278