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