Panda3D
 All Classes Functions Variables Enumerations
camera.I
1 // Filename: camera.I
2 // Created by: drose (26Feb02)
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: Camera::set_active
18 // Access: Published
19 // Description: Sets the active flag on the camera. When the camera
20 // is not active, nothing will be rendered.
21 ////////////////////////////////////////////////////////////////////
22 INLINE void Camera::
23 set_active(bool active) {
24  _active = active;
25 }
26 
27 ////////////////////////////////////////////////////////////////////
28 // Function: Camera::is_active
29 // Access: Published
30 // Description: Returns the current setting of the active flag on the
31 // camera.
32 ////////////////////////////////////////////////////////////////////
33 INLINE bool Camera::
34 is_active() const {
35  return _active;
36 }
37 
38 ////////////////////////////////////////////////////////////////////
39 // Function: Camera::set_scene
40 // Access: Published
41 // Description: Sets the scene that will be rendered by the camera.
42 // This is normally the root node of a scene graph,
43 // typically a node called 'render', although it could
44 // represent the root of any subgraph.
45 //
46 // Note that the use of this method is now deprecated.
47 // In the absence of an explicit scene set on the
48 // camera, the camera will render whatever scene it is
49 // parented into. This is the preferred way to specify
50 // the scene, since it is the more intuitive mechanism.
51 ////////////////////////////////////////////////////////////////////
52 INLINE void Camera::
53 set_scene(const NodePath &scene) {
54  _scene = scene;
55 }
56 
57 ////////////////////////////////////////////////////////////////////
58 // Function: Camera::get_scene
59 // Access: Published
60 // Description: Returns the scene that will be rendered by the
61 // camera. See set_scene().
62 ////////////////////////////////////////////////////////////////////
63 INLINE const NodePath &Camera::
64 get_scene() const {
65  return _scene;
66 }
67 
68 ////////////////////////////////////////////////////////////////////
69 // Function: Camera::get_num_display_regions
70 // Access: Published
71 // Description: Returns the number of display regions associated with
72 // the camera.
73 ////////////////////////////////////////////////////////////////////
74 INLINE int Camera::
76  return _display_regions.size();
77 }
78 
79 ////////////////////////////////////////////////////////////////////
80 // Function: Camera::get_display_region
81 // Access: Published
82 // Description: Returns the nth display region associated with the
83 // camera.
84 ////////////////////////////////////////////////////////////////////
86 get_display_region(int n) const {
87  nassertr(n >= 0 && n < (int)_display_regions.size(), (DisplayRegionBase *)NULL);
88  return _display_regions[n];
89 }
90 
91 ////////////////////////////////////////////////////////////////////
92 // Function: Camera::set_camera_mask
93 // Access: Published
94 // Description: Changes the set of bits that represent the subset of
95 // the scene graph the camera will render.
96 //
97 // During the cull traversal, a node is not visited if
98 // none of its draw mask bits intersect with the
99 // camera's camera mask bits. These masks can be used
100 // to selectively hide and show different parts of the
101 // scene graph from different cameras that are otherwise
102 // viewing the same scene.
103 ////////////////////////////////////////////////////////////////////
104 INLINE void Camera::
106  // You shouldn't attempt to use Panda's reserved "overall" bit as a
107  // camera mask.
108  nassertv((mask & PandaNode::get_overall_bit()).is_zero());
109  _camera_mask = mask;
110 }
111 
112 ////////////////////////////////////////////////////////////////////
113 // Function: Camera::get_camera_mask
114 // Access: Published
115 // Description: Returns the set of bits that represent the subset of
116 // the scene graph the camera will render. See
117 // set_camera_mask().
118 ////////////////////////////////////////////////////////////////////
119 INLINE DrawMask Camera::
121  return _camera_mask;
122 }
123 
124 ////////////////////////////////////////////////////////////////////
125 // Function: Camera::set_cull_center
126 // Access: Published
127 // Description: Specifies the point from which the culling operations
128 // are performed. Normally, this is the same as the
129 // camera, and that is the default if this is not
130 // specified; but it may sometimes be useful to perform
131 // the culling from some other viewpoint, particularly
132 // when you are debugging the culling itself.
133 ////////////////////////////////////////////////////////////////////
134 INLINE void Camera::
135 set_cull_center(const NodePath &cull_center) {
136  _cull_center = cull_center;
137 }
138 
139 ////////////////////////////////////////////////////////////////////
140 // Function: Camera::get_cull_center
141 // Access: Published
142 // Description: Returns the point from which the culling operations
143 // will be performed, if it was set by
144 // set_cull_center(), or the empty NodePath otherwise.
145 ////////////////////////////////////////////////////////////////////
146 INLINE const NodePath &Camera::
148  return _cull_center;
149 }
150 
151 ////////////////////////////////////////////////////////////////////
152 // Function: Camera::set_cull_bounds
153 // Access: Published
154 // Description: Specifies the bounding volume that should be used to
155 // perform culling from this camera. Normally, this is
156 // the bounding volume returned from the active lens'
157 // make_bounds() call, but you may override this to
158 // specify a custom volume if you require. The
159 // specified bounding volume will be understood to be in
160 // the coordinate space of the get_cull_center() node.
161 ////////////////////////////////////////////////////////////////////
162 INLINE void Camera::
164  _cull_bounds = cull_bounds;
165 }
166 
167 ////////////////////////////////////////////////////////////////////
168 // Function: Camera::get_cull_bounds
169 // Access: Published
170 // Description: Returns the custom cull volume that was set by
171 // set_cull_bounds(), if any, or NULL if no custom cull
172 // volume was set.
173 ////////////////////////////////////////////////////////////////////
174 INLINE BoundingVolume *Camera::
176  return _cull_bounds;
177 }
178 
179 ////////////////////////////////////////////////////////////////////
180 // Function: Camera::set_lod_center
181 // Access: Published
182 // Description: Specifies the point from which the LOD distances
183 // are measured. Normally, this is the same as the
184 // camera, and that is the default if this is not
185 // specified; but it may sometimes be useful to perform
186 // the distance test from some other viewpoint. This
187 // may be used, for instance, to reduce LOD popping when
188 // the camera rotates in a small circle about an avatar.
189 ////////////////////////////////////////////////////////////////////
190 INLINE void Camera::
191 set_lod_center(const NodePath &lod_center) {
192  _lod_center = lod_center;
193 }
194 
195 ////////////////////////////////////////////////////////////////////
196 // Function: Camera::get_lod_center
197 // Access: Published
198 // Description: Returns the point from which the LOD distances will
199 // be measured, if it was set by set_lod_center(), or
200 // the empty NodePath otherwise.
201 ////////////////////////////////////////////////////////////////////
202 INLINE const NodePath &Camera::
203 get_lod_center() const {
204  return _lod_center;
205 }
206 
207 ////////////////////////////////////////////////////////////////////
208 // Function: Camera::set_initial_state
209 // Access: Published
210 // Description: Sets the initial state which is applied to all nodes
211 // in the scene, as if it were set at the top of the
212 // scene graph.
213 ////////////////////////////////////////////////////////////////////
214 INLINE void Camera::
216  _initial_state = state;
217 }
218 
219 ////////////////////////////////////////////////////////////////////
220 // Function: Camera::get_initial_state
221 // Access: Published
222 // Description: Returns the initial state as set by a previous call
223 // to set_initial_state().
224 ////////////////////////////////////////////////////////////////////
225 INLINE CPT(RenderState) Camera::
226 get_initial_state() const {
227  return _initial_state;
228 }
229 
230 ////////////////////////////////////////////////////////////////////
231 // Function: Camera::set_tag_state_key
232 // Access: Published
233 // Description: Sets the tag key which, when encountered as a tag on
234 // nodes in the scene graph, causes this Camera to apply
235 // an arbitrary state transition based on the value of
236 // the tag (as specified to set_tag_state()).
237 ////////////////////////////////////////////////////////////////////
238 INLINE void Camera::
239 set_tag_state_key(const string &tag_state_key) {
240  _tag_state_key = tag_state_key;
241 }
242 
243 ////////////////////////////////////////////////////////////////////
244 // Function: Camera::get_tag_state_key
245 // Access: Published
246 // Description: Returns the tag key as set by a previous call to
247 // set_tag_state_key().
248 ////////////////////////////////////////////////////////////////////
249 INLINE const string &Camera::
251  return _tag_state_key;
252 }
253 
254 ////////////////////////////////////////////////////////////////////
255 // Function: Camera::get_lod_scale
256 // Access: Published
257 // Description: Returns the multiplier for LOD distances.
258 ////////////////////////////////////////////////////////////////////
259 INLINE PN_stdfloat Camera::
260 get_lod_scale() const {
261  return _lod_scale;
262 }
263 
264 ////////////////////////////////////////////////////////////////////
265 // Function: Camera::set_lod_scale
266 // Access: Published
267 // Description: Sets the multiplier for LOD distances. This value
268 // is multiplied with the LOD scale set on LodNodes.
269 ////////////////////////////////////////////////////////////////////
270 INLINE void Camera::
271 set_lod_scale(PN_stdfloat value) {
272  _lod_scale = value;
273 }
const NodePath & get_scene() const
Returns the scene that will be rendered by the camera.
Definition: camera.I:64
const string & get_tag_state_key() const
Returns the tag key as set by a previous call to set_tag_state_key().
Definition: camera.I:250
void set_initial_state(const RenderState *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.I:215
BoundingVolume * get_cull_bounds() const
Returns the custom cull volume that was set by set_cull_bounds(), if any, or NULL if no custom cull v...
Definition: camera.I:175
static DrawMask get_overall_bit()
Returns the special bit that, when specifically cleared in the node&#39;s DrawMask, indicates that the no...
Definition: pandaNode.I:502
void set_active(bool active)
Sets the active flag on the camera.
Definition: camera.I:23
int get_num_display_regions() const
Returns the number of display regions associated with the camera.
Definition: camera.I:75
DisplayRegionBase * get_display_region(int n) const
Returns the nth display region associated with the camera.
Definition: camera.I:86
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
void set_lod_scale(PN_stdfloat value)
Sets the multiplier for LOD distances.
Definition: camera.I:271
bool is_active() const
Returns the current setting of the active flag on the camera.
Definition: camera.I:34
const NodePath & get_cull_center() const
Returns the point from which the culling operations will be performed, if it was set by set_cull_cent...
Definition: camera.I:147
void set_cull_bounds(BoundingVolume *cull_bounds)
Specifies the bounding volume that should be used to perform culling from this camera.
Definition: camera.I:163
PN_stdfloat get_lod_scale() const
Returns the multiplier for LOD distances.
Definition: camera.I:260
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
DrawMask get_camera_mask() const
Returns the set of bits that represent the subset of the scene graph the camera will render...
Definition: camera.I:120
void set_camera_mask(DrawMask mask)
Changes the set of bits that represent the subset of the scene graph the camera will render...
Definition: camera.I:105
void set_lod_center(const NodePath &lod_center)
Specifies the point from which the LOD distances are measured.
Definition: camera.I:191
void set_cull_center(const NodePath &cull_center)
Specifies the point from which the culling operations are performed.
Definition: camera.I:135
const NodePath & get_lod_center() const
Returns the point from which the LOD distances will be measured, if it was set by set_lod_center()...
Definition: camera.I:203
void set_scene(const NodePath &scene)
Sets the scene that will be rendered by the camera.
Definition: camera.I:53
An abstract base class for DisplayRegion, mainly so we can store DisplayRegion pointers in a Camera...
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