Panda3D
|
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::set_initial_state 00211 // Access: Published 00212 // Description: Sets the initial state which is applied to all nodes 00213 // in the scene, as if it were set at the top of the 00214 // scene graph. 00215 //////////////////////////////////////////////////////////////////// 00216 INLINE void SceneSetup:: 00217 set_initial_state(const RenderState *state) { 00218 _initial_state = state; 00219 } 00220 00221 //////////////////////////////////////////////////////////////////// 00222 // Function: SceneSetup::get_initial_state 00223 // Access: Published 00224 // Description: Returns the initial state as set by a previous call 00225 // to set_initial_state(). 00226 //////////////////////////////////////////////////////////////////// 00227 INLINE const RenderState *SceneSetup:: 00228 get_initial_state() const { 00229 return _initial_state; 00230 } 00231 00232 //////////////////////////////////////////////////////////////////// 00233 // Function: SceneSetup::set_camera_transform 00234 // Access: Published 00235 // Description: Specifies the position of the camera relative to the 00236 // starting node. 00237 //////////////////////////////////////////////////////////////////// 00238 INLINE void SceneSetup:: 00239 set_camera_transform(const TransformState *camera_transform) { 00240 _camera_transform = camera_transform; 00241 } 00242 00243 //////////////////////////////////////////////////////////////////// 00244 // Function: SceneSetup::get_camera_transform 00245 // Access: Published 00246 // Description: Returns the position of the camera relative to the 00247 // starting node. 00248 //////////////////////////////////////////////////////////////////// 00249 INLINE const TransformState *SceneSetup:: 00250 get_camera_transform() const { 00251 return _camera_transform; 00252 } 00253 00254 //////////////////////////////////////////////////////////////////// 00255 // Function: SceneSetup::set_world_transform 00256 // Access: Published 00257 // Description: Specifies the position of the starting node relative 00258 // to the camera. This is the inverse of the camera 00259 // transform. 00260 //////////////////////////////////////////////////////////////////// 00261 INLINE void SceneSetup:: 00262 set_world_transform(const TransformState *world_transform) { 00263 _world_transform = world_transform; 00264 } 00265 00266 //////////////////////////////////////////////////////////////////// 00267 // Function: SceneSetup::get_world_transform 00268 // Access: Published 00269 // Description: Returns the position of the starting node relative 00270 // to the camera. This is the inverse of the camera 00271 // transform. 00272 //////////////////////////////////////////////////////////////////// 00273 INLINE const TransformState *SceneSetup:: 00274 get_world_transform() const { 00275 return _world_transform; 00276 }