camera.I 5.8 KB

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