00001 // Filename: sceneSetup.I 00002 // Created by: drose (27Mar02) 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: SceneSetup::Constructor 00022 // Access: Public 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 INLINE SceneSetup:: 00026 SceneSetup() { 00027 _camera_transform = TransformState::make_identity(); 00028 _world_transform = TransformState::make_identity(); 00029 _cs_transform = TransformState::make_identity(); 00030 } 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Function: SceneSetup::set_scene_root 00034 // Access: Public 00035 // Description: Specifies the root node of the scene. 00036 //////////////////////////////////////////////////////////////////// 00037 INLINE void SceneSetup:: 00038 set_scene_root(const NodePath &scene_root) { 00039 _scene_root = scene_root; 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: SceneSetup::get_scene_root 00044 // Access: Public 00045 // Description: Returns the root node of the scene. 00046 //////////////////////////////////////////////////////////////////// 00047 INLINE const NodePath &SceneSetup:: 00048 get_scene_root() const { 00049 return _scene_root; 00050 } 00051 00052 //////////////////////////////////////////////////////////////////// 00053 // Function: SceneSetup::set_camera_path 00054 // Access: Public 00055 // Description: Specifies the NodePath to the camera. 00056 //////////////////////////////////////////////////////////////////// 00057 INLINE void SceneSetup:: 00058 set_camera_path(const NodePath &camera_path) { 00059 _camera_path = camera_path; 00060 } 00061 00062 //////////////////////////////////////////////////////////////////// 00063 // Function: SceneSetup::get_camera_path 00064 // Access: Public 00065 // Description: Returns the NodePath to the camera. 00066 //////////////////////////////////////////////////////////////////// 00067 INLINE const NodePath &SceneSetup:: 00068 get_camera_path() const { 00069 return _camera_path; 00070 } 00071 00072 //////////////////////////////////////////////////////////////////// 00073 // Function: SceneSetup::set_camera_node 00074 // Access: Public 00075 // Description: Specifies the camera used to render the scene. 00076 //////////////////////////////////////////////////////////////////// 00077 INLINE void SceneSetup:: 00078 set_camera_node(const Camera *camera_node) { 00079 _camera_node = camera_node; 00080 } 00081 00082 //////////////////////////////////////////////////////////////////// 00083 // Function: SceneSetup::get_camera_node 00084 // Access: Public 00085 // Description: Returns the camera used to render the scene. 00086 //////////////////////////////////////////////////////////////////// 00087 INLINE const Camera *SceneSetup:: 00088 get_camera_node() const { 00089 return _camera_node; 00090 } 00091 00092 //////////////////////////////////////////////////////////////////// 00093 // Function: SceneSetup::set_lens 00094 // Access: Public 00095 // Description: Indicates the particular Lens used for rendering. 00096 //////////////////////////////////////////////////////////////////// 00097 INLINE void SceneSetup:: 00098 set_lens(const Lens *lens) { 00099 _lens = lens; 00100 } 00101 00102 //////////////////////////////////////////////////////////////////// 00103 // Function: SceneSetup::get_lens 00104 // Access: Public 00105 // Description: Returns the particular Lens used for rendering. 00106 //////////////////////////////////////////////////////////////////// 00107 INLINE const Lens *SceneSetup:: 00108 get_lens() const { 00109 return _lens; 00110 } 00111 00112 //////////////////////////////////////////////////////////////////// 00113 // Function: SceneSetup::set_camera_transform 00114 // Access: Public 00115 // Description: Specifies the position of the camera relative to the 00116 // starting node, without any compensating 00117 // coordinate-system transforms that might have been 00118 // introduced for the purposes of rendering. 00119 //////////////////////////////////////////////////////////////////// 00120 INLINE void SceneSetup:: 00121 set_camera_transform(const TransformState *camera_transform) { 00122 _camera_transform = camera_transform; 00123 } 00124 00125 //////////////////////////////////////////////////////////////////// 00126 // Function: SceneSetup::get_camera_transform 00127 // Access: Public 00128 // Description: Returns the position of the camera relative to the 00129 // starting node, without any compensating 00130 // coordinate-system transforms that might have been 00131 // introduced for the purposes of rendering. 00132 //////////////////////////////////////////////////////////////////// 00133 INLINE const TransformState *SceneSetup:: 00134 get_camera_transform() const { 00135 return _camera_transform; 00136 } 00137 00138 //////////////////////////////////////////////////////////////////// 00139 // Function: SceneSetup::set_world_transform 00140 // Access: Public 00141 // Description: Specifies the position of the starting node relative 00142 // to the camera. This is the inverse of the camera 00143 // transform. 00144 //////////////////////////////////////////////////////////////////// 00145 INLINE void SceneSetup:: 00146 set_world_transform(const TransformState *world_transform) { 00147 _world_transform = world_transform; 00148 _render_transform = _cs_transform->compose(_world_transform); 00149 } 00150 00151 //////////////////////////////////////////////////////////////////// 00152 // Function: SceneSetup::get_world_transform 00153 // Access: Public 00154 // Description: Returns the position of the starting node relative 00155 // to the camera. This is the inverse of the camera 00156 // transform. 00157 //////////////////////////////////////////////////////////////////// 00158 INLINE const TransformState *SceneSetup:: 00159 get_world_transform() const { 00160 return _world_transform; 00161 } 00162 00163 //////////////////////////////////////////////////////////////////// 00164 // Function: SceneSetup::set_cs_transform 00165 // Access: Public 00166 // Description: Specifies the pretransformation to apply to the world 00167 // transform to produce the appropriate transformation 00168 // for rendering. This is usually the appropriate 00169 // coordinate-system conversion for the current GSG. 00170 //////////////////////////////////////////////////////////////////// 00171 INLINE void SceneSetup:: 00172 set_cs_transform(const TransformState *cs_transform) { 00173 _cs_transform = cs_transform; 00174 _render_transform = _cs_transform->compose(_world_transform); 00175 } 00176 00177 //////////////////////////////////////////////////////////////////// 00178 // Function: SceneSetup::get_cs_transform 00179 // Access: Public 00180 // Description: Returns the pretransformation to apply to the world 00181 // transform to produce the appropriate transformation 00182 // for rendering. 00183 //////////////////////////////////////////////////////////////////// 00184 INLINE const TransformState *SceneSetup:: 00185 get_cs_transform() const { 00186 return _cs_transform; 00187 } 00188 00189 //////////////////////////////////////////////////////////////////// 00190 // Function: SceneSetup::get_render_transform 00191 // Access: Public 00192 // Description: Returns the position of the starting node relative 00193 // to the camera, pretransformed as appropriate for 00194 // rendering. This is the same as the world transform, 00195 // with a possible coordinate-system conversion applied. 00196 // 00197 // Note that this value is always the position of the 00198 // starting node, not the current node, even if it is 00199 // sampled during a traversal. To get the render 00200 // transform of the current node check in the current 00201 // CullTraverserData. 00202 //////////////////////////////////////////////////////////////////// 00203 INLINE const TransformState *SceneSetup:: 00204 get_render_transform() const { 00205 return _render_transform; 00206 }