Panda3D
 All Classes Functions Variables Enumerations
sceneSetup.I
1 // Filename: sceneSetup.I
2 // Created by: drose (27Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: SceneSetup::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE SceneSetup::
22 SceneSetup() {
23  _display_region = NULL;
24  _viewport_width = 0;
25  _viewport_height = 0;
26  _inverted = false;
27  _initial_state = RenderState::make_empty();
28  _camera_transform = TransformState::make_identity();
29  _world_transform = TransformState::make_identity();
30  _cs_transform = TransformState::make_identity();
31  _cs_world_transform = TransformState::make_identity();
32 }
33 
34 ////////////////////////////////////////////////////////////////////
35 // Function: SceneSetup::set_display_region
36 // Access: Published
37 // Description: Specifies the display region for the scene.
38 ////////////////////////////////////////////////////////////////////
39 INLINE void SceneSetup::
41  _display_region = display_region;
42 }
43 
44 ////////////////////////////////////////////////////////////////////
45 // Function: SceneSetup::get_display_region
46 // Access: Published
47 // Description: Returns the display region for the scene.
48 ////////////////////////////////////////////////////////////////////
51  return _display_region;
52 }
53 
54 ////////////////////////////////////////////////////////////////////
55 // Function: SceneSetup::set_viewport_size
56 // Access: Published
57 // Description: Specifies the size of the viewport (display region),
58 // in pixels.
59 ////////////////////////////////////////////////////////////////////
60 INLINE void SceneSetup::
61 set_viewport_size(int width, int height) {
62  _viewport_width = width;
63  _viewport_height = height;
64 }
65 
66 ////////////////////////////////////////////////////////////////////
67 // Function: SceneSetup::get_viewport_width
68 // Access: Published
69 // Description: Returns the width of the viewport (display region) in
70 // pixels.
71 ////////////////////////////////////////////////////////////////////
72 INLINE int SceneSetup::
74  return _viewport_width;
75 }
76 
77 ////////////////////////////////////////////////////////////////////
78 // Function: SceneSetup::get_viewport_height
79 // Access: Published
80 // Description: Returns the height of the viewport (display region) in
81 // pixels.
82 ////////////////////////////////////////////////////////////////////
83 INLINE int SceneSetup::
85  return _viewport_height;
86 }
87 
88 ////////////////////////////////////////////////////////////////////
89 // Function: SceneSetup::set_scene_root
90 // Access: Published
91 // Description: Specifies the root node of the scene.
92 ////////////////////////////////////////////////////////////////////
93 INLINE void SceneSetup::
94 set_scene_root(const NodePath &scene_root) {
95  _scene_root = scene_root;
96 }
97 
98 ////////////////////////////////////////////////////////////////////
99 // Function: SceneSetup::get_scene_root
100 // Access: Published
101 // Description: Returns the root node of the scene.
102 ////////////////////////////////////////////////////////////////////
103 INLINE const NodePath &SceneSetup::
104 get_scene_root() const {
105  return _scene_root;
106 }
107 
108 ////////////////////////////////////////////////////////////////////
109 // Function: SceneSetup::set_camera_path
110 // Access: Published
111 // Description: Specifies the NodePath to the camera.
112 ////////////////////////////////////////////////////////////////////
113 INLINE void SceneSetup::
114 set_camera_path(const NodePath &camera_path) {
115  _camera_path = camera_path;
116 }
117 
118 ////////////////////////////////////////////////////////////////////
119 // Function: SceneSetup::get_camera_path
120 // Access: Published
121 // Description: Returns the NodePath to the camera.
122 ////////////////////////////////////////////////////////////////////
123 INLINE const NodePath &SceneSetup::
125  return _camera_path;
126 }
127 
128 ////////////////////////////////////////////////////////////////////
129 // Function: SceneSetup::set_camera_node
130 // Access: Published
131 // Description: Specifies the camera used to render the scene.
132 ////////////////////////////////////////////////////////////////////
133 INLINE void SceneSetup::
134 set_camera_node(Camera *camera_node) {
135  _camera_node = camera_node;
136 }
137 
138 ////////////////////////////////////////////////////////////////////
139 // Function: SceneSetup::get_camera_node
140 // Access: Published
141 // Description: Returns the camera used to render the scene.
142 ////////////////////////////////////////////////////////////////////
143 INLINE Camera *SceneSetup::
145  return _camera_node;
146 }
147 
148 ////////////////////////////////////////////////////////////////////
149 // Function: SceneSetup::set_lens
150 // Access: Published
151 // Description: Indicates the particular Lens used for rendering.
152 ////////////////////////////////////////////////////////////////////
153 INLINE void SceneSetup::
154 set_lens(const Lens *lens) {
155  _lens = lens;
156 }
157 
158 ////////////////////////////////////////////////////////////////////
159 // Function: SceneSetup::get_lens
160 // Access: Published
161 // Description: Returns the particular Lens used for rendering.
162 ////////////////////////////////////////////////////////////////////
163 INLINE const Lens *SceneSetup::
164 get_lens() const {
165  return _lens;
166 }
167 
168 ////////////////////////////////////////////////////////////////////
169 // Function: SceneSetup::set_inverted
170 // Access: Published
171 // Description: Changes the current setting of the inverted flag.
172 // When this is true, the scene is rendered into the
173 // window upside-down and backwards, that is, inverted
174 // as if viewed through a mirror placed on the floor.
175 ////////////////////////////////////////////////////////////////////
176 INLINE void SceneSetup::
177 set_inverted(bool inverted) {
178  _inverted = inverted;
179 }
180 
181 ////////////////////////////////////////////////////////////////////
182 // Function: SceneSetup::get_inverted
183 // Access: Published
184 // Description: Returns the current setting of the inverted flag.
185 // When this is true, the scene is rendered into the
186 // window upside-down, flipped like a mirror along the X
187 // axis.
188 ////////////////////////////////////////////////////////////////////
189 INLINE bool SceneSetup::
190 get_inverted() const {
191  return _inverted;
192 }
193 
194 ////////////////////////////////////////////////////////////////////
195 // Function: SceneSetup::get_cull_center
196 // Access: Published
197 // Description: Returns the point from which the culling operations
198 // will be performed. This is normally the camera, but
199 // if camera->set_cull_center() has been specified, it
200 // will be that special node instead.
201 ////////////////////////////////////////////////////////////////////
202 INLINE const NodePath &SceneSetup::
204  if (_camera_node->get_cull_center().is_empty()) {
205  return _camera_path;
206  } else {
207  return _camera_node->get_cull_center();
208  }
209 }
210 
211 ////////////////////////////////////////////////////////////////////
212 // Function: SceneSetup::get_cull_bounds
213 // Access: Published
214 // Description: Returns the bounding volume that should be used to
215 // perform view-frustum culling (in the space of
216 // get_cull_center()). This is normally the current
217 // lens' bounding volume, but it may be overridden with
218 // Camera::set_cull_bounds().
219 ////////////////////////////////////////////////////////////////////
220 INLINE PT(BoundingVolume) SceneSetup::
221 get_cull_bounds() const {
222  PT(BoundingVolume) bounds = _camera_node->get_cull_bounds();
223  if (bounds != (BoundingVolume *)NULL) {
224  return bounds;
225  }
226 
227  return _lens->make_bounds();
228 }
229 
230 ////////////////////////////////////////////////////////////////////
231 // Function: SceneSetup::set_initial_state
232 // Access: Published
233 // Description: Sets the initial state which is applied to all nodes
234 // in the scene, as if it were set at the top of the
235 // scene graph.
236 ////////////////////////////////////////////////////////////////////
237 INLINE void SceneSetup::
239  _initial_state = state;
240 }
241 
242 ////////////////////////////////////////////////////////////////////
243 // Function: SceneSetup::get_initial_state
244 // Access: Published
245 // Description: Returns the initial state as set by a previous call
246 // to set_initial_state().
247 ////////////////////////////////////////////////////////////////////
248 INLINE const RenderState *SceneSetup::
250  return _initial_state;
251 }
252 
253 ////////////////////////////////////////////////////////////////////
254 // Function: SceneSetup::set_camera_transform
255 // Access: Published
256 // Description: Specifies the position of the camera relative to the
257 // starting node.
258 ////////////////////////////////////////////////////////////////////
259 INLINE void SceneSetup::
260 set_camera_transform(const TransformState *camera_transform) {
261  _camera_transform = camera_transform;
262 }
263 
264 ////////////////////////////////////////////////////////////////////
265 // Function: SceneSetup::get_camera_transform
266 // Access: Published
267 // Description: Returns the position of the camera relative to the
268 // starting node.
269 ////////////////////////////////////////////////////////////////////
270 INLINE const TransformState *SceneSetup::
272  return _camera_transform;
273 }
274 
275 ////////////////////////////////////////////////////////////////////
276 // Function: SceneSetup::set_world_transform
277 // Access: Published
278 // Description: Specifies the position of the starting node relative
279 // to the camera. This is the inverse of the camera
280 // transform.
281 ////////////////////////////////////////////////////////////////////
282 INLINE void SceneSetup::
283 set_world_transform(const TransformState *world_transform) {
284  _world_transform = world_transform;
285 }
286 
287 ////////////////////////////////////////////////////////////////////
288 // Function: SceneSetup::get_world_transform
289 // Access: Published
290 // Description: Returns the position of the starting node relative
291 // to the camera. This is the inverse of the camera
292 // transform.
293 ////////////////////////////////////////////////////////////////////
294 INLINE const TransformState *SceneSetup::
296  return _world_transform;
297 }
298 
299 ////////////////////////////////////////////////////////////////////
300 // Function: SceneSetup::set_cs_transform
301 // Access: Published
302 // Description: Specifies the transform from the camera's coordinate
303 // system to the GSG's internal coordinate system.
304 ////////////////////////////////////////////////////////////////////
305 INLINE void SceneSetup::
306 set_cs_transform(const TransformState *cs_transform) {
307  _cs_transform = cs_transform;
308 }
309 
310 ////////////////////////////////////////////////////////////////////
311 // Function: SceneSetup::get_cs_transform
312 // Access: Published
313 // Description: Returns the transform from the camera's coordinate
314 // system to the GSG's internal coordinate system.
315 ////////////////////////////////////////////////////////////////////
316 INLINE const TransformState *SceneSetup::
318  return _cs_transform;
319 }
320 
321 ////////////////////////////////////////////////////////////////////
322 // Function: SceneSetup::set_cs_world_transform
323 // Access: Published
324 // Description: Specifies the position from the starting node
325 // relative to the camera, in the GSG's internal
326 // coordinate system.
327 ////////////////////////////////////////////////////////////////////
328 INLINE void SceneSetup::
329 set_cs_world_transform(const TransformState *cs_world_transform) {
330  _cs_world_transform = cs_world_transform;
331 }
332 
333 ////////////////////////////////////////////////////////////////////
334 // Function: SceneSetup::get_cs_world_transform
335 // Access: Published
336 // Description: Returns the position from the starting node
337 // relative to the camera, in the GSG's internal
338 // coordinate system.
339 ////////////////////////////////////////////////////////////////////
340 INLINE const TransformState *SceneSetup::
342  return _cs_world_transform;
343 }
const TransformState * get_cs_world_transform() const
Returns the position from the starting node relative to the camera, in the GSG's internal coordinate ...
Definition: sceneSetup.I:341
void set_camera_node(Camera *camera_node)
Specifies the camera used to render the scene.
Definition: sceneSetup.I:134
void set_display_region(DisplayRegion *display_region)
Specifies the display region for the scene.
Definition: sceneSetup.I:40
bool get_inverted() const
Returns the current setting of the inverted flag.
Definition: sceneSetup.I:190
int get_viewport_height() const
Returns the height of the viewport (display region) in pixels.
Definition: sceneSetup.I:84
int get_viewport_width() const
Returns the width of the viewport (display region) in pixels.
Definition: sceneSetup.I:73
A base class for any number of different kinds of lenses, linear and otherwise.
Definition: lens.h:45
void set_cs_world_transform(const TransformState *cs_world_transform)
Specifies the position from the starting node relative to the camera, in the GSG's internal coordinat...
Definition: sceneSetup.I:329
void set_world_transform(const TransformState *world_transform)
Specifies the position of the starting node relative to the camera.
Definition: sceneSetup.I:283
const RenderState * get_initial_state() const
Returns the initial state as set by a previous call to set_initial_state().
Definition: sceneSetup.I:249
void set_cs_transform(const TransformState *cs_transform)
Specifies the transform from the camera's coordinate system to the GSG's internal coordinate system...
Definition: sceneSetup.I:306
const NodePath & get_camera_path() const
Returns the NodePath to the camera.
Definition: sceneSetup.I:124
void set_lens(const Lens *lens)
Indicates the particular Lens used for rendering.
Definition: sceneSetup.I:154
DisplayRegion * get_display_region() const
Returns the display region for the scene.
Definition: sceneSetup.I:50
Camera * get_camera_node() const
Returns the camera used to render the scene.
Definition: sceneSetup.I:144
const NodePath & get_scene_root() const
Returns the root node of the scene.
Definition: sceneSetup.I:104
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
void set_camera_path(const NodePath &camera_path)
Specifies the NodePath to the camera.
Definition: sceneSetup.I:114
void set_camera_transform(const TransformState *camera_transform)
Specifies the position of the camera relative to the starting node.
Definition: sceneSetup.I:260
const TransformState * get_world_transform() const
Returns the position of the starting node relative to the camera.
Definition: sceneSetup.I:295
const NodePath & get_cull_center() const
Returns the point from which the culling operations will be performed.
Definition: sceneSetup.I:203
void set_scene_root(const NodePath &scene_root)
Specifies the root node of the scene.
Definition: sceneSetup.I:94
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
void set_inverted(bool inverted)
Changes the current setting of the inverted flag.
Definition: sceneSetup.I:177
void set_viewport_size(int width, int height)
Specifies the size of the viewport (display region), in pixels.
Definition: sceneSetup.I:61
void set_initial_state(const RenderState *initial_state)
Sets the initial state which is applied to all nodes in the scene, as if it were set at the top of th...
Definition: sceneSetup.I:238
const TransformState * get_camera_transform() const
Returns the position of the camera relative to the starting node.
Definition: sceneSetup.I:271
const TransformState * get_cs_transform() const
Returns the transform from the camera's coordinate system to the GSG's internal coordinate system...
Definition: sceneSetup.I:317
A rectangular subregion within a window for rendering into.
Definition: displayRegion.h:61
This object holds the camera position, etc., and other general setup information for rendering a part...
Definition: sceneSetup.h:35
A node that can be positioned around in the scene graph to represent a point of view for rendering a ...
Definition: camera.h:37
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
const Lens * get_lens() const
Returns the particular Lens used for rendering.
Definition: sceneSetup.I:164