Panda3D
 All Classes Functions Variables Enumerations
camera.I
00001 // Filename: camera.I
00002 // Created by:  drose (26Feb02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: Camera::set_active
00018 //       Access: Published
00019 //  Description: Sets the active flag on the camera.  When the camera
00020 //               is not active, nothing will be rendered.
00021 ////////////////////////////////////////////////////////////////////
00022 INLINE void Camera::
00023 set_active(bool active) {
00024   _active = active;
00025 }
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //     Function: Camera::is_active
00029 //       Access: Published
00030 //  Description: Returns the current setting of the active flag on the
00031 //               camera.
00032 ////////////////////////////////////////////////////////////////////
00033 INLINE bool Camera::
00034 is_active() const {
00035   return _active;
00036 }
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //     Function: Camera::set_scene
00040 //       Access: Published
00041 //  Description: Sets the scene that will be rendered by the camera.
00042 //               This is normally the root node of a scene graph,
00043 //               typically a node called 'render', although it could
00044 //               represent the root of any subgraph.
00045 //
00046 //               Note that the use of this method is now deprecated.
00047 //               In the absence of an explicit scene set on the
00048 //               camera, the camera will render whatever scene it is
00049 //               parented into.  This is the preferred way to specify
00050 //               the scene, since it is the more intuitive mechanism.
00051 ////////////////////////////////////////////////////////////////////
00052 INLINE void Camera::
00053 set_scene(const NodePath &scene) {
00054   _scene = scene;
00055 }
00056 
00057 ////////////////////////////////////////////////////////////////////
00058 //     Function: Camera::get_scene
00059 //       Access: Published
00060 //  Description: Returns the scene that will be rendered by the
00061 //               camera.  See set_scene().
00062 ////////////////////////////////////////////////////////////////////
00063 INLINE const NodePath &Camera::
00064 get_scene() const {
00065   return _scene;
00066 }
00067 
00068 ////////////////////////////////////////////////////////////////////
00069 //     Function: Camera::get_num_display_regions
00070 //       Access: Published
00071 //  Description: Returns the number of display regions associated with
00072 //               the camera.
00073 ////////////////////////////////////////////////////////////////////
00074 INLINE int Camera::
00075 get_num_display_regions() const {
00076   return _display_regions.size();
00077 }
00078 
00079 ////////////////////////////////////////////////////////////////////
00080 //     Function: Camera::get_display_region
00081 //       Access: Published
00082 //  Description: Returns the nth display region associated with the
00083 //               camera.
00084 ////////////////////////////////////////////////////////////////////
00085 INLINE DisplayRegionBase *Camera::
00086 get_display_region(int n) const {
00087   nassertr(n >= 0 && n < (int)_display_regions.size(), (DisplayRegionBase *)NULL);
00088   return _display_regions[n];
00089 }
00090 
00091 ////////////////////////////////////////////////////////////////////
00092 //     Function: Camera::set_camera_mask
00093 //       Access: Published
00094 //  Description: Changes the set of bits that represent the subset of
00095 //               the scene graph the camera will render.
00096 //
00097 //               During the cull traversal, a node is not visited if
00098 //               none of its draw mask bits intersect with the
00099 //               camera's camera mask bits.  These masks can be used
00100 //               to selectively hide and show different parts of the
00101 //               scene graph from different cameras that are otherwise
00102 //               viewing the same scene.
00103 ////////////////////////////////////////////////////////////////////
00104 INLINE void Camera::
00105 set_camera_mask(DrawMask mask) {
00106   // You shouldn't attempt to use Panda's reserved "overall" bit as a
00107   // camera mask.
00108   nassertv((mask & PandaNode::get_overall_bit()).is_zero());
00109   _camera_mask = mask;
00110 }
00111 
00112 ////////////////////////////////////////////////////////////////////
00113 //     Function: Camera::get_camera_mask
00114 //       Access: Published
00115 //  Description: Returns the set of bits that represent the subset of
00116 //               the scene graph the camera will render.  See
00117 //               set_camera_mask().
00118 ////////////////////////////////////////////////////////////////////
00119 INLINE DrawMask Camera::
00120 get_camera_mask() const {
00121   return _camera_mask;
00122 }
00123 
00124 ////////////////////////////////////////////////////////////////////
00125 //     Function: Camera::set_cull_center
00126 //       Access: Published
00127 //  Description: Specifies the point from which the culling operations
00128 //               are performed.  Normally, this is the same as the
00129 //               camera, and that is the default if this is not
00130 //               specified; but it may sometimes be useful to perform
00131 //               the culling from some other viewpoint, particularly
00132 //               when you are debugging the culling itself.
00133 ////////////////////////////////////////////////////////////////////
00134 INLINE void Camera::
00135 set_cull_center(const NodePath &cull_center) {
00136   _cull_center = cull_center;
00137 }
00138 
00139 ////////////////////////////////////////////////////////////////////
00140 //     Function: Camera::get_cull_center
00141 //       Access: Published
00142 //  Description: Returns the point from which the culling operations
00143 //               will be performed, if it was set by
00144 //               set_cull_center(), or the empty NodePath otherwise.
00145 ////////////////////////////////////////////////////////////////////
00146 INLINE const NodePath &Camera::
00147 get_cull_center() const {
00148   return _cull_center;
00149 }
00150 
00151 ////////////////////////////////////////////////////////////////////
00152 //     Function: Camera::set_cull_bounds
00153 //       Access: Published
00154 //  Description: Specifies the bounding volume that should be used to
00155 //               perform culling from this camera.  Normally, this is
00156 //               the bounding volume returned from the active lens'
00157 //               make_bounds() call, but you may override this to
00158 //               specify a custom volume if you require.  The
00159 //               specified bounding volume will be understood to be in
00160 //               the coordinate space of the get_cull_center() node.
00161 ////////////////////////////////////////////////////////////////////
00162 INLINE void Camera::
00163 set_cull_bounds(BoundingVolume *cull_bounds) {
00164   _cull_bounds = cull_bounds;
00165 }
00166 
00167 ////////////////////////////////////////////////////////////////////
00168 //     Function: Camera::get_cull_bounds
00169 //       Access: Published
00170 //  Description: Returns the custom cull volume that was set by
00171 //               set_cull_bounds(), if any, or NULL if no custom cull
00172 //               volume was set.
00173 ////////////////////////////////////////////////////////////////////
00174 INLINE BoundingVolume *Camera::
00175 get_cull_bounds() const {
00176   return _cull_bounds;
00177 }
00178 
00179 ////////////////////////////////////////////////////////////////////
00180 //     Function: Camera::set_lod_center
00181 //       Access: Published
00182 //  Description: Specifies the point from which the LOD distances
00183 //               are measured.  Normally, this is the same as the
00184 //               camera, and that is the default if this is not
00185 //               specified; but it may sometimes be useful to perform
00186 //               the distance test from some other viewpoint.  This
00187 //               may be used, for instance, to reduce LOD popping when
00188 //               the camera rotates in a small circle about an avatar.
00189 ////////////////////////////////////////////////////////////////////
00190 INLINE void Camera::
00191 set_lod_center(const NodePath &lod_center) {
00192   _lod_center = lod_center;
00193 }
00194 
00195 ////////////////////////////////////////////////////////////////////
00196 //     Function: Camera::get_lod_center
00197 //       Access: Published
00198 //  Description: Returns the point from which the LOD distances will
00199 //               be measured, if it was set by set_lod_center(), or
00200 //               the empty NodePath otherwise.
00201 ////////////////////////////////////////////////////////////////////
00202 INLINE const NodePath &Camera::
00203 get_lod_center() const {
00204   return _lod_center;
00205 }
00206 
00207 ////////////////////////////////////////////////////////////////////
00208 //     Function: Camera::set_initial_state
00209 //       Access: Published
00210 //  Description: Sets the initial state which is applied to all nodes
00211 //               in the scene, as if it were set at the top of the
00212 //               scene graph.
00213 ////////////////////////////////////////////////////////////////////
00214 INLINE void Camera::
00215 set_initial_state(const RenderState *state) {
00216   _initial_state = state;
00217 }
00218 
00219 ////////////////////////////////////////////////////////////////////
00220 //     Function: Camera::get_initial_state
00221 //       Access: Published
00222 //  Description: Returns the initial state as set by a previous call
00223 //               to set_initial_state().
00224 ////////////////////////////////////////////////////////////////////
00225 INLINE CPT(RenderState) Camera::
00226 get_initial_state() const {
00227   return _initial_state;
00228 }
00229 
00230 ////////////////////////////////////////////////////////////////////
00231 //     Function: Camera::set_tag_state_key
00232 //       Access: Published
00233 //  Description: Sets the tag key which, when encountered as a tag on
00234 //               nodes in the scene graph, causes this Camera to apply
00235 //               an arbitrary state transition based on the value of
00236 //               the tag (as specified to set_tag_state()).
00237 ////////////////////////////////////////////////////////////////////
00238 INLINE void Camera::
00239 set_tag_state_key(const string &tag_state_key) {
00240   _tag_state_key = tag_state_key;
00241 }
00242 
00243 ////////////////////////////////////////////////////////////////////
00244 //     Function: Camera::get_tag_state_key
00245 //       Access: Published
00246 //  Description: Returns the tag key as set by a previous call to
00247 //               set_tag_state_key().
00248 ////////////////////////////////////////////////////////////////////
00249 INLINE const string &Camera::
00250 get_tag_state_key() const {
00251   return _tag_state_key;
00252 }
 All Classes Functions Variables Enumerations