00001 // Filename: cullTraverser.I 00002 // Created by: drose (23Feb02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: CullTraverser::set_scene 00022 // Access: Public 00023 // Description: Sets the SceneSetup object that indicates the initial 00024 // camera position, etc. This must be called before 00025 // traversal begins. 00026 //////////////////////////////////////////////////////////////////// 00027 INLINE void CullTraverser:: 00028 set_scene(SceneSetup *scene_setup) { 00029 _scene_setup = scene_setup; 00030 } 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Function: CullTraverser::get_scene 00034 // Access: Public 00035 // Description: Returns the SceneSetup object. 00036 //////////////////////////////////////////////////////////////////// 00037 INLINE SceneSetup *CullTraverser:: 00038 get_scene() const { 00039 return _scene_setup; 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: CullTraverser::get_camera_transform 00044 // Access: Public 00045 // Description: Returns the position of the camera relative to the 00046 // starting node, without any compensating 00047 // coordinate-system transforms that might have been 00048 // introduced for the purposes of rendering. 00049 //////////////////////////////////////////////////////////////////// 00050 INLINE const TransformState *CullTraverser:: 00051 get_camera_transform() const { 00052 return _scene_setup->get_camera_transform(); 00053 } 00054 00055 //////////////////////////////////////////////////////////////////// 00056 // Function: CullTraverser::get_render_transform 00057 // Access: Public 00058 // Description: Returns the position of the starting node relative 00059 // to the camera, pretransformed as appropriate for 00060 // rendering. 00061 // 00062 // Note that this value is always the position of the 00063 // starting node, not the current node, even if it is 00064 // sampled during a traversal. To get the render 00065 // transform of the current node check in the current 00066 // CullTraverserData. 00067 //////////////////////////////////////////////////////////////////// 00068 INLINE const TransformState *CullTraverser:: 00069 get_render_transform() const { 00070 return _scene_setup->get_render_transform(); 00071 } 00072 00073 //////////////////////////////////////////////////////////////////// 00074 // Function: CullTraverser::set_initial_state 00075 // Access: Public 00076 // Description: Sets the initial RenderState at the top of the scene 00077 // graph we are traversing. If this is not set, the 00078 // default is the empty state. 00079 //////////////////////////////////////////////////////////////////// 00080 INLINE void CullTraverser:: 00081 set_initial_state(const RenderState *initial_state) { 00082 _initial_state = initial_state; 00083 } 00084 00085 //////////////////////////////////////////////////////////////////// 00086 // Function: CullTraverser::get_initial_state 00087 // Access: Public 00088 // Description: Returns the initial RenderState at the top of the 00089 // scene graph we are traversing, or the empty state if 00090 // the initial state was never set. 00091 //////////////////////////////////////////////////////////////////// 00092 INLINE const RenderState *CullTraverser:: 00093 get_initial_state() const { 00094 return _initial_state; 00095 } 00096 00097 //////////////////////////////////////////////////////////////////// 00098 // Function: CullTraverser::set_depth_offset_decals 00099 // Access: Public 00100 // Description: Sets the depth_offset_decals flag. If this is true, 00101 // decals will be rendered using DepthOffsetAttribs; 00102 // otherwise, decals will be rendered with a more 00103 // expensive three-pass system. This is normally set 00104 // from the corresponding flag in the GSG. 00105 //////////////////////////////////////////////////////////////////// 00106 INLINE void CullTraverser:: 00107 set_depth_offset_decals(bool flag) { 00108 _depth_offset_decals = flag; 00109 } 00110 00111 //////////////////////////////////////////////////////////////////// 00112 // Function: CullTraverser::get_depth_offset_decals 00113 // Access: Public 00114 // Description: Returns the depth_offset_decals flag. See 00115 // set_depth_offset_decals(). 00116 //////////////////////////////////////////////////////////////////// 00117 INLINE bool CullTraverser:: 00118 get_depth_offset_decals() const { 00119 return _depth_offset_decals; 00120 } 00121 00122 //////////////////////////////////////////////////////////////////// 00123 // Function: CullTraverser::set_camera_mask 00124 // Access: Public 00125 // Description: Specifies the visibility mask from the camera viewing 00126 // the scene. Any nodes that do not have at least some 00127 // bits in common with this mask will not be drawn. 00128 //////////////////////////////////////////////////////////////////// 00129 INLINE void CullTraverser:: 00130 set_camera_mask(const DrawMask &camera_mask) { 00131 _camera_mask = camera_mask; 00132 } 00133 00134 //////////////////////////////////////////////////////////////////// 00135 // Function: CullTraverser::get_camera_mask 00136 // Access: Public 00137 // Description: Returns the visibility mask from the camera viewing 00138 // the scene. 00139 //////////////////////////////////////////////////////////////////// 00140 INLINE const DrawMask &CullTraverser:: 00141 get_camera_mask() const { 00142 return _camera_mask; 00143 } 00144 00145 //////////////////////////////////////////////////////////////////// 00146 // Function: CullTraverser::set_view_frustum 00147 // Access: Public 00148 // Description: Specifies the bounding volume that corresponds to the 00149 // view frustum. Any primitives that fall entirely 00150 // outside of this volume are not drawn. 00151 //////////////////////////////////////////////////////////////////// 00152 INLINE void CullTraverser:: 00153 set_view_frustum(GeometricBoundingVolume *view_frustum) { 00154 _view_frustum = view_frustum; 00155 } 00156 00157 //////////////////////////////////////////////////////////////////// 00158 // Function: CullTraverser::get_view_frustum 00159 // Access: Public 00160 // Description: Returns the bounding volume that corresponds to the 00161 // view frustum, or NULL if the view frustum is not in 00162 // use or has not been set. 00163 // 00164 // Note that the view frustum returned here is always in 00165 // the coordinate space of the starting node, not the 00166 // current node, even if it is sampled during a 00167 // traversal. To get the view frustum in the current 00168 // node's coordinate space, check in the current 00169 // CullTraverserData. 00170 //////////////////////////////////////////////////////////////////// 00171 INLINE GeometricBoundingVolume *CullTraverser:: 00172 get_view_frustum() const { 00173 return _view_frustum; 00174 } 00175 00176 //////////////////////////////////////////////////////////////////// 00177 // Function: CullTraverser::set_guard_band 00178 // Access: Public 00179 // Description: Specifies the bounding volume to use for detecting 00180 // guard band clipping. This is a render optimization 00181 // for certain cards that support this feature; the 00182 // guard band is a 2-d area than the frame buffer. 00183 // If a primitive will appear entirely within the guard 00184 // band after perspective transform, it may be drawn 00185 // correctly with clipping disabled, for a small 00186 // performance gain. 00187 // 00188 // This is the bounding volume that corresponds to the 00189 // 2-d guard band. If a primitive is entirely within 00190 // this area, clipping will be disabled on the GSG. 00191 //////////////////////////////////////////////////////////////////// 00192 INLINE void CullTraverser:: 00193 set_guard_band(GeometricBoundingVolume *guard_band) { 00194 _guard_band = guard_band; 00195 } 00196 00197 //////////////////////////////////////////////////////////////////// 00198 // Function: CullTraverser::get_guard_band 00199 // Access: Public 00200 // Description: Returns the bounding volume that corresponds to the 00201 // guard band, or NULL if the guard band is not in 00202 // use or has not been set. 00203 // 00204 // Note that the guard band returned here is always in 00205 // the coordinate space of the starting node, not the 00206 // current node, even if it is sampled during a 00207 // traversal. To get the guard band in the current 00208 // node's coordinate space, check in the current 00209 // CullTraverserData. 00210 //////////////////////////////////////////////////////////////////// 00211 INLINE GeometricBoundingVolume *CullTraverser:: 00212 get_guard_band() const { 00213 return _guard_band; 00214 } 00215 00216 //////////////////////////////////////////////////////////////////// 00217 // Function: CullTraverser::set_cull_handler 00218 // Access: Public 00219 // Description: Specifies the object that will receive the culled 00220 // Geoms. This must be set before calling traverse(). 00221 //////////////////////////////////////////////////////////////////// 00222 INLINE void CullTraverser:: 00223 set_cull_handler(CullHandler *cull_handler) { 00224 _cull_handler = cull_handler; 00225 } 00226 00227 //////////////////////////////////////////////////////////////////// 00228 // Function: CullTraverser::get_cull_handler 00229 // Access: Public 00230 // Description: Returns the object that will receive the culled 00231 // Geoms. 00232 //////////////////////////////////////////////////////////////////// 00233 INLINE CullHandler *CullTraverser:: 00234 get_cull_handler() const { 00235 return _cull_handler; 00236 }