Camera

class Camera

Bases: LensNode

A node that can be positioned around in the scene graph to represent a point of view for rendering a scene.

Inheritance diagram

Inheritance diagram of Camera

explicit Camera(std::string const &name, Lens *lens = (new PerspectiveLens()))
Camera(Camera const &copy)
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. Returns the number of elements released.

bool clear_aux_scene_data(NodePath const &node_path)

Removes the AuxSceneData associated with the indicated NodePath. Returns true if it is removed successfully, false if it was already gone.

void clear_tag_state(std::string const &tag_state)

Removes the association established by a previous call to set_tag_state().

void clear_tag_states(void)

Removes all associations established by previous calls to set_tag_state().

AuxSceneData *get_aux_scene_data(NodePath const &node_path) const

Returns the AuxSceneData associated with the indicated NodePath, or NULL if nothing is associated.

DrawMask get_camera_mask(void) const

Returns the set of bits that represent the subset of the scene graph the camera will render. See set_camera_mask().

static TypeHandle get_class_type(void)
BoundingVolume *get_cull_bounds(void) const

Returns the custom cull volume that was set by set_cull_bounds(), if any, or NULL if no custom cull volume was set.

NodePath const &get_cull_center(void) 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.

DisplayRegion *get_display_region(std::size_t n) const

Returns the nth display region associated with the camera.

ConstPointerTo<RenderState> get_initial_state(void) const

Returns the initial state as set by a previous call to set_initial_state().

NodePath const &get_lod_center(void) 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.

PN_stdfloat get_lod_scale(void) const

Returns the multiplier for LOD distances.

std::size_t get_num_display_regions(void) const

Returns the number of display regions associated with the camera.

NodePath const &get_scene(void) const

Returns the scene that will be rendered by the camera. See set_scene().

ConstPointerTo<RenderState> get_tag_state(std::string const &tag_state) const

Returns the state associated with the indicated tag state by a previous call to set_tag_state(), or the empty state if nothing has been associated.

std::string const &get_tag_state_key(void) const

Returns the tag key as set by a previous call to set_tag_state_key().

bool has_tag_state(std::string const &tag_state) const

Returns true if set_tag_state() has previously been called with the indicated tag state, false otherwise.

bool is_active(void) const

Returns the current setting of the active flag on the camera.

void list_aux_scene_data(std::ostream &out) const

Outputs all of the NodePaths and AuxSceneDatas in use.

void set_active(bool active)

Sets the active flag on the camera. When the camera is not active, nothing will be rendered.

void set_aux_scene_data(NodePath const &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.

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.

void set_cull_bounds(BoundingVolume *cull_bounds)

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 set_cull_center(NodePath const &cull_center)

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 set_initial_state(RenderState const *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(NodePath const &lod_center)

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 set_lod_scale(PN_stdfloat value)

Sets the multiplier for LOD distances. This value is multiplied with the LOD scale set on LodNodes.

void set_scene(NodePath const &scene)

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 set_tag_state(std::string const &tag_state, RenderState const *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.

void set_tag_state_key(std::string const &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()).