00001 // Filename: sceneSetup.I 00002 // Created by: drose (27Mar02) 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: SceneSetup::Constructor 00018 // Access: Public 00019 // Description: 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE SceneSetup:: 00022 SceneSetup() { 00023 _display_region = NULL; 00024 _viewport_width = 0; 00025 _viewport_height = 0; 00026 _inverted = false; 00027 _initial_state = RenderState::make_empty(); 00028 _camera_transform = TransformState::make_identity(); 00029 _world_transform = TransformState::make_identity(); 00030 } 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Function: SceneSetup::set_display_region 00034 // Access: Published 00035 // Description: Specifies the display region for the scene. 00036 //////////////////////////////////////////////////////////////////// 00037 INLINE void SceneSetup:: 00038 set_display_region(DisplayRegion *display_region) { 00039 _display_region = display_region; 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: SceneSetup::get_display_region 00044 // Access: Published 00045 // Description: Returns the display region for the scene. 00046 //////////////////////////////////////////////////////////////////// 00047 INLINE DisplayRegion *SceneSetup:: 00048 get_display_region() const { 00049 return _display_region; 00050 } 00051 00052 //////////////////////////////////////////////////////////////////// 00053 // Function: SceneSetup::set_viewport_size 00054 // Access: Published 00055 // Description: Specifies the size of the viewport (display region), 00056 // in pixels. 00057 //////////////////////////////////////////////////////////////////// 00058 INLINE void SceneSetup:: 00059 set_viewport_size(int width, int height) { 00060 _viewport_width = width; 00061 _viewport_height = height; 00062 } 00063 00064 //////////////////////////////////////////////////////////////////// 00065 // Function: SceneSetup::get_viewport_width 00066 // Access: Published 00067 // Description: Returns the width of the viewport (display region) in 00068 // pixels. 00069 //////////////////////////////////////////////////////////////////// 00070 INLINE int SceneSetup:: 00071 get_viewport_width() const { 00072 return _viewport_width; 00073 } 00074 00075 //////////////////////////////////////////////////////////////////// 00076 // Function: SceneSetup::get_viewport_height 00077 // Access: Published 00078 // Description: Returns the height of the viewport (display region) in 00079 // pixels. 00080 //////////////////////////////////////////////////////////////////// 00081 INLINE int SceneSetup:: 00082 get_viewport_height() const { 00083 return _viewport_height; 00084 } 00085 00086 //////////////////////////////////////////////////////////////////// 00087 // Function: SceneSetup::set_scene_root 00088 // Access: Published 00089 // Description: Specifies the root node of the scene. 00090 //////////////////////////////////////////////////////////////////// 00091 INLINE void SceneSetup:: 00092 set_scene_root(const NodePath &scene_root) { 00093 _scene_root = scene_root; 00094 } 00095 00096 //////////////////////////////////////////////////////////////////// 00097 // Function: SceneSetup::get_scene_root 00098 // Access: Published 00099 // Description: Returns the root node of the scene. 00100 //////////////////////////////////////////////////////////////////// 00101 INLINE const NodePath &SceneSetup:: 00102 get_scene_root() const { 00103 return _scene_root; 00104 } 00105 00106 //////////////////////////////////////////////////////////////////// 00107 // Function: SceneSetup::set_camera_path 00108 // Access: Published 00109 // Description: Specifies the NodePath to the camera. 00110 //////////////////////////////////////////////////////////////////// 00111 INLINE void SceneSetup:: 00112 set_camera_path(const NodePath &camera_path) { 00113 _camera_path = camera_path; 00114 } 00115 00116 //////////////////////////////////////////////////////////////////// 00117 // Function: SceneSetup::get_camera_path 00118 // Access: Published 00119 // Description: Returns the NodePath to the camera. 00120 //////////////////////////////////////////////////////////////////// 00121 INLINE const NodePath &SceneSetup:: 00122 get_camera_path() const { 00123 return _camera_path; 00124 } 00125 00126 //////////////////////////////////////////////////////////////////// 00127 // Function: SceneSetup::set_camera_node 00128 // Access: Published 00129 // Description: Specifies the camera used to render the scene. 00130 //////////////////////////////////////////////////////////////////// 00131 INLINE void SceneSetup:: 00132 set_camera_node(Camera *camera_node) { 00133 _camera_node = camera_node; 00134 } 00135 00136 //////////////////////////////////////////////////////////////////// 00137 // Function: SceneSetup::get_camera_node 00138 // Access: Published 00139 // Description: Returns the camera used to render the scene. 00140 //////////////////////////////////////////////////////////////////// 00141 INLINE Camera *SceneSetup:: 00142 get_camera_node() const { 00143 return _camera_node; 00144 } 00145 00146 //////////////////////////////////////////////////////////////////// 00147 // Function: SceneSetup::set_lens 00148 // Access: Published 00149 // Description: Indicates the particular Lens used for rendering. 00150 //////////////////////////////////////////////////////////////////// 00151 INLINE void SceneSetup:: 00152 set_lens(const Lens *lens) { 00153 _lens = lens; 00154 } 00155 00156 //////////////////////////////////////////////////////////////////// 00157 // Function: SceneSetup::get_lens 00158 // Access: Published 00159 // Description: Returns the particular Lens used for rendering. 00160 //////////////////////////////////////////////////////////////////// 00161 INLINE const Lens *SceneSetup:: 00162 get_lens() const { 00163 return _lens; 00164 } 00165 00166 //////////////////////////////////////////////////////////////////// 00167 // Function: SceneSetup::set_inverted 00168 // Access: Published 00169 // Description: Changes the current setting of the inverted flag. 00170 // When this is true, the scene is rendered into the 00171 // window upside-down and backwards, that is, inverted 00172 // as if viewed through a mirror placed on the floor. 00173 //////////////////////////////////////////////////////////////////// 00174 INLINE void SceneSetup:: 00175 set_inverted(bool inverted) { 00176 _inverted = inverted; 00177 } 00178 00179 //////////////////////////////////////////////////////////////////// 00180 // Function: SceneSetup::get_inverted 00181 // Access: Published 00182 // Description: Returns the current setting of the inverted flag. 00183 // When this is true, the scene is rendered into the 00184 // window upside-down, flipped like a mirror along the X 00185 // axis. 00186 //////////////////////////////////////////////////////////////////// 00187 INLINE bool SceneSetup:: 00188 get_inverted() const { 00189 return _inverted; 00190 } 00191 00192 //////////////////////////////////////////////////////////////////// 00193 // Function: SceneSetup::get_cull_center 00194 // Access: Published 00195 // Description: Returns the point from which the culling operations 00196 // will be performed. This is normally the camera, but 00197 // if camera->set_cull_center() has been specified, it 00198 // will be that special node instead. 00199 //////////////////////////////////////////////////////////////////// 00200 INLINE const NodePath &SceneSetup:: 00201 get_cull_center() const { 00202 if (_camera_node->get_cull_center().is_empty()) { 00203 return _camera_path; 00204 } else { 00205 return _camera_node->get_cull_center(); 00206 } 00207 } 00208 00209 //////////////////////////////////////////////////////////////////// 00210 // Function: SceneSetup::get_cull_bounds 00211 // Access: Published 00212 // Description: Returns the bounding volume that should be used to 00213 // perform view-frustum culling (in the space of 00214 // get_cull_center()). This is normally the current 00215 // lens' bounding volume, but it may be overridden with 00216 // Camera::set_cull_bounds(). 00217 //////////////////////////////////////////////////////////////////// 00218 INLINE PT(BoundingVolume) SceneSetup:: 00219 get_cull_bounds() const { 00220 PT(BoundingVolume) bounds = _camera_node->get_cull_bounds(); 00221 if (bounds != (BoundingVolume *)NULL) { 00222 return bounds; 00223 } 00224 00225 return _lens->make_bounds(); 00226 } 00227 00228 //////////////////////////////////////////////////////////////////// 00229 // Function: SceneSetup::set_initial_state 00230 // Access: Published 00231 // Description: Sets the initial state which is applied to all nodes 00232 // in the scene, as if it were set at the top of the 00233 // scene graph. 00234 //////////////////////////////////////////////////////////////////// 00235 INLINE void SceneSetup:: 00236 set_initial_state(const RenderState *state) { 00237 _initial_state = state; 00238 } 00239 00240 //////////////////////////////////////////////////////////////////// 00241 // Function: SceneSetup::get_initial_state 00242 // Access: Published 00243 // Description: Returns the initial state as set by a previous call 00244 // to set_initial_state(). 00245 //////////////////////////////////////////////////////////////////// 00246 INLINE const RenderState *SceneSetup:: 00247 get_initial_state() const { 00248 return _initial_state; 00249 } 00250 00251 //////////////////////////////////////////////////////////////////// 00252 // Function: SceneSetup::set_camera_transform 00253 // Access: Published 00254 // Description: Specifies the position of the camera relative to the 00255 // starting node. 00256 //////////////////////////////////////////////////////////////////// 00257 INLINE void SceneSetup:: 00258 set_camera_transform(const TransformState *camera_transform) { 00259 _camera_transform = camera_transform; 00260 } 00261 00262 //////////////////////////////////////////////////////////////////// 00263 // Function: SceneSetup::get_camera_transform 00264 // Access: Published 00265 // Description: Returns the position of the camera relative to the 00266 // starting node. 00267 //////////////////////////////////////////////////////////////////// 00268 INLINE const TransformState *SceneSetup:: 00269 get_camera_transform() const { 00270 return _camera_transform; 00271 } 00272 00273 //////////////////////////////////////////////////////////////////// 00274 // Function: SceneSetup::set_world_transform 00275 // Access: Published 00276 // Description: Specifies the position of the starting node relative 00277 // to the camera. This is the inverse of the camera 00278 // transform. 00279 //////////////////////////////////////////////////////////////////// 00280 INLINE void SceneSetup:: 00281 set_world_transform(const TransformState *world_transform) { 00282 _world_transform = world_transform; 00283 } 00284 00285 //////////////////////////////////////////////////////////////////// 00286 // Function: SceneSetup::get_world_transform 00287 // Access: Published 00288 // Description: Returns the position of the starting node relative 00289 // to the camera. This is the inverse of the camera 00290 // transform. 00291 //////////////////////////////////////////////////////////////////// 00292 INLINE const TransformState *SceneSetup:: 00293 get_world_transform() const { 00294 return _world_transform; 00295 }