Panda3D
Loading...
Searching...
No Matches
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 */
17INLINE SceneSetup::
18SceneSetup() {
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 */
33INLINE void SceneSetup::
34set_display_region(DisplayRegion *display_region) {
35 _display_region = display_region;
36}
37
38/**
39 * Returns the display region for the scene.
40 */
42get_display_region() const {
43 return _display_region;
44}
45
46/**
47 * Specifies the size of the viewport (display region), in pixels.
48 */
49INLINE void SceneSetup::
50set_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 */
58INLINE int SceneSetup::
59get_viewport_width() const {
60 return _viewport_width;
61}
62
63/**
64 * Returns the height of the viewport (display region) in pixels.
65 */
66INLINE int SceneSetup::
67get_viewport_height() const {
68 return _viewport_height;
69}
70
71/**
72 * Specifies the root node of the scene.
73 */
74INLINE void SceneSetup::
75set_scene_root(const NodePath &scene_root) {
76 _scene_root = scene_root;
77}
78
79/**
80 * Returns the root node of the scene.
81 */
83get_scene_root() const {
84 return _scene_root;
85}
86
87/**
88 * Specifies the NodePath to the camera.
89 */
90INLINE void SceneSetup::
91set_camera_path(const NodePath &camera_path) {
92 _camera_path = camera_path;
93}
94
95/**
96 * Returns the NodePath to the camera.
97 */
99get_camera_path() const {
100 return _camera_path;
101}
102
103/**
104 * Specifies the camera used to render the scene.
105 */
106INLINE void SceneSetup::
107set_camera_node(Camera *camera_node) {
108 _camera_node = camera_node;
109}
110
111/**
112 * Returns the camera used to render the scene.
113 */
115get_camera_node() const {
116 return _camera_node;
117}
118
119/**
120 * Indicates the particular Lens used for rendering.
121 */
122INLINE void SceneSetup::
123set_lens(const Lens *lens) {
124 _lens = lens;
125}
126
127/**
128 * Returns the particular Lens used for rendering.
129 */
130INLINE const Lens *SceneSetup::
131get_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 */
140INLINE void SceneSetup::
141set_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 */
150INLINE bool SceneSetup::
151get_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 */
161get_cull_center() const {
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 */
175INLINE PT(BoundingVolume) SceneSetup::
176get_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 */
189INLINE void SceneSetup::
190set_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 */
198get_initial_state() const {
199 return _initial_state;
200}
201
202/**
203 * Specifies the position of the camera relative to the starting node.
204 */
205INLINE void SceneSetup::
206set_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 */
214get_camera_transform() const {
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 */
222INLINE void SceneSetup::
223set_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 */
232get_world_transform() const {
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 */
240INLINE void SceneSetup::
241set_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 */
250get_cs_transform() const {
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 */
258INLINE void SceneSetup::
259set_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 */
269 return _cs_world_transform;
270}
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
A node that can be positioned around in the scene graph to represent a point of view for rendering a ...
Definition camera.h:35
A rectangular subregion within a window for rendering into.
A base class for any number of different kinds of lenses, linear and otherwise.
Definition lens.h:41
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition nodePath.h:159
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition renderState.h:47
void set_world_transform(const TransformState *world_transform)
Specifies the position of the starting node relative to the camera.
Definition sceneSetup.I:223
const Lens * get_lens() const
Returns the particular Lens used for rendering.
Definition sceneSetup.I:131
void set_viewport_size(int width, int height)
Specifies the size of the viewport (display region), in pixels.
Definition sceneSetup.I:50
DisplayRegion * get_display_region() const
Returns the display region for the scene.
Definition sceneSetup.I:42
int get_viewport_width() const
Returns the width of the viewport (display region) in pixels.
Definition sceneSetup.I:59
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
const NodePath & get_scene_root() const
Returns the root node of the scene.
Definition sceneSetup.I:83
void set_scene_root(const NodePath &scene_root)
Specifies the root node of the scene.
Definition sceneSetup.I:75
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 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_lens(const Lens *lens)
Indicates the particular Lens used for rendering.
Definition sceneSetup.I:123
bool get_inverted() const
Returns the current setting of the inverted flag.
Definition sceneSetup.I:151
const TransformState * get_camera_transform() const
Returns the position of the camera relative to the starting node.
Definition sceneSetup.I:214
void set_camera_path(const NodePath &camera_path)
Specifies the NodePath to the camera.
Definition sceneSetup.I:91
const NodePath & get_cull_center() const
Returns the point from which the culling operations will be performed.
Definition sceneSetup.I:161
void set_display_region(DisplayRegion *display_region)
Specifies the display region for the scene.
Definition sceneSetup.I:34
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
int get_viewport_height() const
Returns the height of the viewport (display region) in pixels.
Definition sceneSetup.I:67
void set_camera_transform(const TransformState *camera_transform)
Specifies the position of the camera relative to the starting node.
Definition sceneSetup.I:206
const NodePath & get_camera_path() const
Returns the NodePath to the camera.
Definition sceneSetup.I:99
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
void set_inverted(bool inverted)
Changes the current setting of the inverted flag.
Definition sceneSetup.I:141
void set_camera_node(Camera *camera_node)
Specifies the camera used to render the scene.
Definition sceneSetup.I:107
Camera * get_camera_node() const
Returns the camera used to render the scene.
Definition sceneSetup.I:115
const TransformState * get_world_transform() const
Returns the position of the starting node relative to the camera.
Definition sceneSetup.I:232
Indicates a coordinate-system transform on vertices.