Panda3D
camera.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 camera.I
10  * @author drose
11  * @date 2002-02-26
12  */
13 
14 /**
15  * Sets the active flag on the camera. When the camera is not active, nothing
16  * will be rendered.
17  */
18 INLINE void Camera::
19 set_active(bool active) {
20  _active = active;
21 }
22 
23 /**
24  * Returns the current setting of the active flag on the camera.
25  */
26 INLINE bool Camera::
27 is_active() const {
28  return _active;
29 }
30 
31 /**
32  * Sets the scene that will be rendered by the camera. This is normally the
33  * root node of a scene graph, typically a node called 'render', although it
34  * could represent the root of any subgraph.
35  *
36  * Note that the use of this method is now deprecated. In the absence of an
37  * explicit scene set on the camera, the camera will render whatever scene it
38  * is parented into. This is the preferred way to specify the scene, since it
39  * is the more intuitive mechanism.
40  */
41 INLINE void Camera::
42 set_scene(const NodePath &scene) {
43  _scene = scene;
44 }
45 
46 /**
47  * Returns the scene that will be rendered by the camera. See set_scene().
48  */
49 INLINE const NodePath &Camera::
50 get_scene() const {
51  return _scene;
52 }
53 
54 /**
55  * Returns the number of display regions associated with the camera.
56  */
57 INLINE size_t Camera::
58 get_num_display_regions() const {
59  return _display_regions.size();
60 }
61 
62 /**
63  * Returns the nth display region associated with the camera.
64  */
65 INLINE DisplayRegion *Camera::
66 get_display_region(size_t n) const {
67  nassertr(n < _display_regions.size(), nullptr);
68  return _display_regions[n];
69 }
70 
71 /**
72  * Changes the set of bits that represent the subset of the scene graph the
73  * camera will render.
74  *
75  * During the cull traversal, a node is not visited if none of its draw mask
76  * bits intersect with the camera's camera mask bits. These masks can be used
77  * to selectively hide and show different parts of the scene graph from
78  * different cameras that are otherwise viewing the same scene.
79  */
80 INLINE void Camera::
82  // You shouldn't attempt to use Panda's reserved "overall" bit as a camera
83  // mask.
84  nassertv((mask & PandaNode::get_overall_bit()).is_zero());
85  _camera_mask = mask;
86 }
87 
88 /**
89  * Returns the set of bits that represent the subset of the scene graph the
90  * camera will render. See set_camera_mask().
91  */
92 INLINE DrawMask Camera::
93 get_camera_mask() const {
94  return _camera_mask;
95 }
96 
97 /**
98  * Specifies the point from which the culling operations are performed.
99  * Normally, this is the same as the camera, and that is the default if this
100  * is not specified; but it may sometimes be useful to perform the culling
101  * from some other viewpoint, particularly when you are debugging the culling
102  * itself.
103  */
104 INLINE void Camera::
105 set_cull_center(const NodePath &cull_center) {
106  _cull_center = cull_center;
107 }
108 
109 /**
110  * Returns the point from which the culling operations will be performed, if
111  * it was set by set_cull_center(), or the empty NodePath otherwise.
112  */
113 INLINE const NodePath &Camera::
114 get_cull_center() const {
115  return _cull_center;
116 }
117 
118 /**
119  * Specifies the bounding volume that should be used to perform culling from
120  * this camera. Normally, this is the bounding volume returned from the
121  * active lens' make_bounds() call, but you may override this to specify a
122  * custom volume if you require. The specified bounding volume will be
123  * understood to be in the coordinate space of the get_cull_center() node.
124  */
125 INLINE void Camera::
126 set_cull_bounds(BoundingVolume *cull_bounds) {
127  _cull_bounds = cull_bounds;
128 }
129 
130 /**
131  * Returns the custom cull volume that was set by set_cull_bounds(), if any,
132  * or NULL if no custom cull volume was set.
133  */
134 INLINE BoundingVolume *Camera::
135 get_cull_bounds() const {
136  return _cull_bounds;
137 }
138 
139 /**
140  * Specifies the point from which the LOD distances are measured. Normally,
141  * this is the same as the camera, and that is the default if this is not
142  * specified; but it may sometimes be useful to perform the distance test from
143  * some other viewpoint. This may be used, for instance, to reduce LOD
144  * popping when the camera rotates in a small circle about an avatar.
145  */
146 INLINE void Camera::
147 set_lod_center(const NodePath &lod_center) {
148  _lod_center = lod_center;
149 }
150 
151 /**
152  * Returns the point from which the LOD distances will be measured, if it was
153  * set by set_lod_center(), or the empty NodePath otherwise.
154  */
155 INLINE const NodePath &Camera::
156 get_lod_center() const {
157  return _lod_center;
158 }
159 
160 /**
161  * Sets the initial state which is applied to all nodes in the scene, as if it
162  * were set at the top of the scene graph.
163  */
164 INLINE void Camera::
165 set_initial_state(const RenderState *state) {
166  _initial_state = state;
167 }
168 
169 /**
170  * Returns the initial state as set by a previous call to set_initial_state().
171  */
172 INLINE CPT(RenderState) Camera::
173 get_initial_state() const {
174  return _initial_state;
175 }
176 
177 /**
178  * Sets the tag key which, when encountered as a tag on nodes in the scene
179  * graph, causes this Camera to apply an arbitrary state transition based on
180  * the value of the tag (as specified to set_tag_state()).
181  */
182 INLINE void Camera::
183 set_tag_state_key(const std::string &tag_state_key) {
184  _tag_state_key = tag_state_key;
185 }
186 
187 /**
188  * Returns the tag key as set by a previous call to set_tag_state_key().
189  */
190 INLINE const std::string &Camera::
191 get_tag_state_key() const {
192  return _tag_state_key;
193 }
194 
195 /**
196  * Returns the multiplier for LOD distances.
197  */
198 INLINE PN_stdfloat Camera::
199 get_lod_scale() const {
200  return _lod_scale;
201 }
202 
203 /**
204  * Sets the multiplier for LOD distances. This value is multiplied with the
205  * LOD scale set on LodNodes.
206  */
207 INLINE void Camera::
208 set_lod_scale(PN_stdfloat value) {
209  _lod_scale = value;
210 }
set_cull_bounds
Specifies the bounding volume that should be used to perform culling from this camera.
Definition: camera.h:71
set_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: camera.h:79
get_display_region
Returns the nth display region associated with the camera.
Definition: camera.h:58
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
set_lod_scale
Sets the multiplier for LOD distances.
Definition: camera.h:87
set_camera_mask
Changes the set of bits that represent the subset of the scene graph the camera will render.
Definition: camera.h:63
set_lod_center
Specifies the point from which the LOD distances are measured.
Definition: camera.h:75
set_scene
Sets the scene that will be rendered by the camera.
Definition: camera.h:54
set_cull_center
Specifies the point from which the culling operations are performed.
Definition: camera.h:67
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:47
set_active
Sets the active flag on the camera.
Definition: camera.h:50
A rectangular subregion within a window for rendering into.
Definition: displayRegion.h:57
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:161
CPT(RenderState) Camera
Returns the initial state as set by a previous call to set_initial_state().
Definition: camera.I:172