Panda3D
|
A node that can be positioned around in the scene graph to represent a point of view for rendering a scene. More...
#include "camera.h"
Public Member Functions | |
Camera (const string &name, Lens *lens=new PerspectiveLens()) | |
Camera (const Camera ©) | |
int | cleanup_aux_scene_data (Thread *current_thread=Thread::get_current_thread()) |
Walks through the list of currently-assigned AuxSceneData objects and releases any that are past their expiration times. | |
bool | clear_aux_scene_data (const NodePath &node_path) |
Removes the AuxSceneData associated with the indicated NodePath. | |
void | clear_tag_state (const string &tag_state) |
Removes the association established by a previous call to set_tag_state(). | |
CPT (RenderState) get_initial_state() const | |
CPT (RenderState) get_tag_state(const string &tag_state) const | |
virtual TypeHandle | force_init_type () |
AuxSceneData * | get_aux_scene_data (const NodePath &node_path) const |
Returns the AuxSceneData associated with the indicated NodePath, or NULL if nothing is associated. | |
DrawMask | get_camera_mask () const |
Returns the set of bits that represent the subset of the scene graph the camera will render. | |
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 volume was set. | |
const NodePath & | get_cull_center () const |
Returns the point from which the culling operations will be performed, if it was set by set_cull_center(), or the empty NodePath otherwise. | |
DisplayRegionBase * | get_display_region (int n) const |
Returns the nth display region associated with the camera. | |
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(), or the empty NodePath otherwise. | |
int | get_num_display_regions () const |
Returns the number of display regions associated with the camera. | |
const NodePath & | get_scene () const |
Returns the scene that will be rendered by the camera. | |
const string & | get_tag_state_key () const |
Returns the tag key as set by a previous call to set_tag_state_key(). | |
virtual TypeHandle | get_type () const |
bool | has_tag_state (const string &tag_state) const |
Returns true if set_tag_state() has previously been called with the indicated tag state, false otherwise. | |
bool | is_active () const |
Returns the current setting of the active flag on the camera. | |
void | list_aux_scene_data (ostream &out) const |
Outputs all of the NodePaths and AuxSceneDatas in use. | |
virtual PandaNode * | make_copy () const |
Returns a newly-allocated Node that is a shallow copy of this one. | |
MAKE_SEQ (get_display_regions, get_num_display_regions, get_display_region) | |
virtual bool | safe_to_flatten () const |
Returns true if it is generally safe to flatten out this particular kind of Node by duplicating instances, false otherwise (for instance, a Camera cannot be safely flattened, because the Camera pointer itself is meaningful). | |
virtual bool | safe_to_transform () const |
Returns true if it is generally safe to transform this particular kind of Node by calling the xform() method, false otherwise. | |
void | set_active (bool active) |
Sets the active flag on the camera. | |
void | set_aux_scene_data (const NodePath &node_path, AuxSceneData *data) |
Associates the indicated AuxSceneData object with the given NodePath, possibly replacing a previous data defined for the same NodePath, if any. | |
void | set_camera_mask (DrawMask mask) |
Changes the set of bits that represent the subset of the scene graph the camera will render. | |
void | set_cull_bounds (BoundingVolume *cull_bounds) |
Specifies the bounding volume that should be used to perform culling from this camera. | |
void | set_cull_center (const NodePath &cull_center) |
Specifies the point from which the culling operations are performed. | |
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 the scene graph. | |
void | set_lod_center (const NodePath &lod_center) |
Specifies the point from which the LOD distances are measured. | |
void | set_scene (const NodePath &scene) |
Sets the scene that will be rendered by the camera. | |
void | set_tag_state (const string &tag_state, const RenderState *state) |
Associates a particular state transition with the indicated tag value. | |
void | set_tag_state_key (const string &tag_state_key) |
Sets the tag key which, when encountered as a tag on nodes in the scene graph, causes this Camera to apply an arbitrary state transition based on the value of the tag (as specified to set_tag_state()). | |
virtual void | write_datagram (BamWriter *manager, Datagram &dg) |
Writes the contents of this object to the datagram for shipping out to a Bam file. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
static void | register_with_read_factory () |
Tells the BamReader how to create objects of type Camera. | |
Protected Member Functions | |
void | fillin (DatagramIterator &scan, BamReader *manager) |
This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new Camera. | |
Static Protected Member Functions | |
static TypedWritable * | make_from_bam (const FactoryParams ¶ms) |
This function is called by the BamReader's factory when a new object of type Camera is encountered in the Bam file. | |
Friends | |
class | DisplayRegion |
A node that can be positioned around in the scene graph to represent a point of view for rendering a scene.
int Camera::cleanup_aux_scene_data | ( | Thread * | current_thread = Thread::get_current_thread() | ) |
Walks through the list of currently-assigned AuxSceneData objects and releases any that are past their expiration times.
Returns the number of elements released.
Definition at line 246 of file camera.cxx.
References ClockObject::get_frame_time(), and ClockObject::get_global_clock().
bool Camera::clear_aux_scene_data | ( | const NodePath & | node_path | ) |
Removes the AuxSceneData associated with the indicated NodePath.
Returns true if it is removed successfully, false if it was already gone.
Definition at line 194 of file camera.cxx.
Referenced by set_aux_scene_data().
void Camera::clear_tag_state | ( | const string & | tag_state | ) |
Removes the association established by a previous call to set_tag_state().
Definition at line 136 of file camera.cxx.
void Camera::fillin | ( | DatagramIterator & | scan, |
BamReader * | manager | ||
) | [protected, virtual] |
This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new Camera.
Reimplemented from LensNode.
Reimplemented in Spotlight, DirectionalLight, PointLight, and LightLensNode.
Definition at line 349 of file camera.cxx.
References DatagramIterator::get_bool(), DatagramIterator::get_uint32(), and BitMask< WType, nbits >::set_word().
Referenced by make_from_bam().
AuxSceneData * Camera::get_aux_scene_data | ( | const NodePath & | node_path | ) | const |
Returns the AuxSceneData associated with the indicated NodePath, or NULL if nothing is associated.
Definition at line 212 of file camera.cxx.
Referenced by FadeLODNode::cull_callback().
DrawMask Camera::get_camera_mask | ( | ) | const [inline] |
Returns the set of bits that represent the subset of the scene graph the camera will render.
See set_camera_mask().
Definition at line 120 of file camera.I.
Referenced by CullTraverser::set_scene().
BoundingVolume * Camera::get_cull_bounds | ( | ) | const [inline] |
Returns the custom cull volume that was set by set_cull_bounds(), if any, or NULL if no custom cull volume was set.
const NodePath & Camera::get_cull_center | ( | ) | const [inline] |
Returns the point from which the culling operations will be performed, if it was set by set_cull_center(), or the empty NodePath otherwise.
DisplayRegionBase * Camera::get_display_region | ( | int | n | ) | const [inline] |
const NodePath & Camera::get_lod_center | ( | ) | const [inline] |
Returns the point from which the LOD distances will be measured, if it was set by set_lod_center(), or the empty NodePath otherwise.
int Camera::get_num_display_regions | ( | ) | const [inline] |
const NodePath & Camera::get_scene | ( | ) | const [inline] |
Returns the scene that will be rendered by the camera.
See set_scene().
Definition at line 64 of file camera.I.
Referenced by GraphicsEngine::render_frame().
const string & Camera::get_tag_state_key | ( | ) | const [inline] |
Returns the tag key as set by a previous call to set_tag_state_key().
Definition at line 250 of file camera.I.
Referenced by CullTraverser::set_scene().
bool Camera::has_tag_state | ( | const string & | tag_state | ) | const |
Returns true if set_tag_state() has previously been called with the indicated tag state, false otherwise.
Definition at line 147 of file camera.cxx.
bool Camera::is_active | ( | ) | const [inline] |
void Camera::list_aux_scene_data | ( | ostream & | out | ) | const |
Outputs all of the NodePaths and AuxSceneDatas in use.
Definition at line 229 of file camera.cxx.
PandaNode * Camera::make_copy | ( | ) | const [virtual] |
Returns a newly-allocated Node that is a shallow copy of this one.
It will be a different Node pointer, but its internal data may or may not be shared with that of the original Node.
Reimplemented from LensNode.
Reimplemented in Spotlight, DirectionalLight, and PointLight.
Definition at line 76 of file camera.cxx.
TypedWritable * Camera::make_from_bam | ( | const FactoryParams & | params | ) | [static, protected] |
This function is called by the BamReader's factory when a new object of type Camera is encountered in the Bam file.
It should create the Camera and extract its information from the file.
Reimplemented from LensNode.
Reimplemented in Spotlight, DirectionalLight, and PointLight.
Definition at line 330 of file camera.cxx.
References fillin().
Referenced by register_with_read_factory().
void Camera::register_with_read_factory | ( | ) | [static] |
Tells the BamReader how to create objects of type Camera.
Reimplemented from LensNode.
Reimplemented in Spotlight, DirectionalLight, and PointLight.
Definition at line 303 of file camera.cxx.
References BamReader::get_factory(), make_from_bam(), and Factory< Type >::register_factory().
bool Camera::safe_to_flatten | ( | ) | const [virtual] |
bool Camera::safe_to_transform | ( | ) | const [virtual] |
void Camera::set_active | ( | bool | active | ) | [inline] |
Sets the active flag on the camera.
When the camera is not active, nothing will be rendered.
Definition at line 23 of file camera.I.
Referenced by LightLensNode::set_shadow_caster().
void Camera::set_aux_scene_data | ( | const NodePath & | node_path, |
AuxSceneData * | data | ||
) |
Associates the indicated AuxSceneData object with the given NodePath, possibly replacing a previous data defined for the same NodePath, if any.
Definition at line 178 of file camera.cxx.
References clear_aux_scene_data().
Referenced by FadeLODNode::cull_callback().
void Camera::set_camera_mask | ( | DrawMask | mask | ) | [inline] |
Changes the set of bits that represent the subset of the scene graph the camera will render.
During the cull traversal, a node is not visited if none of its draw mask bits intersect with the camera's camera mask bits. These masks can be used to selectively hide and show different parts of the scene graph from different cameras that are otherwise viewing the same scene.
Definition at line 105 of file camera.I.
References PandaNode::get_overall_bit().
void Camera::set_cull_bounds | ( | BoundingVolume * | cull_bounds | ) | [inline] |
Specifies the bounding volume that should be used to perform culling from this camera.
Normally, this is the bounding volume returned from the active lens' make_bounds() call, but you may override this to specify a custom volume if you require. The specified bounding volume will be understood to be in the coordinate space of the get_cull_center() node.
void Camera::set_cull_center | ( | const NodePath & | cull_center | ) | [inline] |
Specifies the point from which the culling operations are performed.
Normally, this is the same as the camera, and that is the default if this is not specified; but it may sometimes be useful to perform the culling from some other viewpoint, particularly when you are debugging the culling itself.
void Camera::set_initial_state | ( | const RenderState * | state | ) | [inline] |
void Camera::set_lod_center | ( | const NodePath & | lod_center | ) | [inline] |
Specifies the point from which the LOD distances are measured.
Normally, this is the same as the camera, and that is the default if this is not specified; but it may sometimes be useful to perform the distance test from some other viewpoint. This may be used, for instance, to reduce LOD popping when the camera rotates in a small circle about an avatar.
void Camera::set_scene | ( | const NodePath & | scene | ) | [inline] |
Sets the scene that will be rendered by the camera.
This is normally the root node of a scene graph, typically a node called 'render', although it could represent the root of any subgraph.
Note that the use of this method is now deprecated. In the absence of an explicit scene set on the camera, the camera will render whatever scene it is parented into. This is the preferred way to specify the scene, since it is the more intuitive mechanism.
void Camera::set_tag_state | ( | const string & | tag_state, |
const RenderState * | state | ||
) |
Associates a particular state transition with the indicated tag value.
When a node is encountered during traversal with the tag key specified by set_tag_state_key(), if the value of that tag matches tag_state, then the indicated state is applied to this node--but only when it is rendered by this camera.
This can be used to apply special effects to nodes when they are rendered by certain cameras. It is particularly useful for multipass rendering, in which specialty cameras might be needed to render the scene with a particular set of effects.
Definition at line 125 of file camera.cxx.
void Camera::set_tag_state_key | ( | const string & | tag_state_key | ) | [inline] |
Sets the tag key which, when encountered as a tag on nodes in the scene graph, causes this Camera to apply an arbitrary state transition based on the value of the tag (as specified to set_tag_state()).
void Camera::write_datagram | ( | BamWriter * | manager, |
Datagram & | dg | ||
) | [virtual] |
Writes the contents of this object to the datagram for shipping out to a Bam file.
Reimplemented from LensNode.
Reimplemented in Spotlight, DirectionalLight, PointLight, and LightLensNode.
Definition at line 314 of file camera.cxx.
References Datagram::add_bool(), Datagram::add_uint32(), and BitMask< WType, nbits >::get_word().