#include <lens.h>
Inheritance diagram for Lens:
Public Types | |
enum | FromCorners { FC_roll = 0x0001, FC_camera_plane = 0x0002, FC_off_axis = 0x0004, FC_aspect_ratio = 0x0008, FC_shear = 0x0010 } |
Public Member Functions | |
Lens () | |
Lens (const Lens ©) | |
void | operator= (const Lens ©) |
virtual PointerTo< Lens > | make_copy () const=0 |
bool | extrude (const LPoint2f &point2d, LPoint3f &near_point, LPoint3f &far_point) const |
Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner, compute the corresponding vector in space that maps to this point, if such a vector can be determined. | |
bool | extrude (const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) const |
Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner, compute the corresponding vector in space that maps to this point, if such a vector can be determined. | |
bool | project (const LPoint3f &point3d, LPoint3f &point2d) const |
Given a 3-d point in space, determine the 2-d point this maps to, in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner. | |
bool | project (const LPoint3f &point3d, LPoint2f &point2d) const |
Given a 3-d point in space, determine the 2-d point this maps to, in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner. | |
void | set_change_event (const string &event) |
Sets the name of the event that will be generated whenever any properties of the Lens have changed. | |
const string & | get_change_event () const |
Returns the name of the event that will be generated whenever any properties of this particular Lens have changed. | |
void | set_coordinate_system (CoordinateSystem cs) |
Specifies the coordinate system that all 3-d computations are performed within for this Lens. | |
CoordinateSystem | get_coordinate_system () const |
Returns the coordinate system that all 3-d computations are performed within for this Lens. | |
void | clear () |
Resets all lens parameters to their initial default settings. | |
void | set_film_size (float width) |
Sets the horizontal size of the film without changing its shape. | |
void | set_film_size (float width, float height) |
Sets the size and shape of the "film" within the lens. | |
void | set_film_size (const LVecBase2f &film_size) |
Sets the size and shape of the "film" within the lens. | |
const LVecBase2f & | get_film_size () const |
Returns the horizontal and vertical film size of the virtual film. | |
void | set_film_offset (float x, float y) |
Sets the horizontal and vertical offset amounts of this Lens. | |
void | set_film_offset (const LVecBase2f &film_offset) |
Sets the horizontal and vertical offset amounts of this Lens. | |
const LVector2f & | get_film_offset () const |
Returns the horizontal and vertical offset amounts of this Lens. | |
void | set_focal_length (float focal_length) |
Sets the focal length of the lens. | |
float | get_focal_length () const |
Returns the focal length of the lens. | |
void | set_fov (float fov) |
Sets the horizontal field of view of the lens without changing the aspect ratio. | |
void | set_fov (float hfov, float vfov) |
Sets the field of view of the lens in both dimensions. | |
void | set_fov (const LVecBase2f &fov) |
Sets the field of view of the lens in both dimensions. | |
const LVecBase2f & | get_fov () const |
Returns the horizontal and vertical film size of the virtual film. | |
float | get_hfov () const |
Returns the horizontal component of fov only. | |
float | get_vfov () const |
Returns the vertical component of fov only. | |
void | set_aspect_ratio (float aspect_ratio) |
Sets the aspect ratio of the lens. | |
float | get_aspect_ratio () const |
Returns the aspect ratio of the Lens. | |
void | set_near (float near_distance) |
Defines the position of the near plane (or cylinder, sphere, whatever). | |
float | get_near () const |
Returns the position of the near plane (or cylinder, sphere, whatever). | |
void | set_far (float far_distance) |
Defines the position of the far plane (or cylinder, sphere, whatever). | |
float | get_far () const |
Returns the position of the far plane (or cylinder, sphere, whatever). | |
void | set_near_far (float near_distance, float far_distance) |
Simultaneously changes the near and far planes. | |
void | set_view_hpr (float h, float p, float r) |
Sets the direction in which the lens is facing. | |
void | set_view_hpr (const LVecBase3f &view_hpr) |
Sets the direction in which the lens is facing. | |
const LVecBase3f & | get_view_hpr () const |
Returns the direction in which the lens is facing. | |
void | set_view_vector (float x, float y, float z, float i, float j, float k) |
Specifies the direction in which the lens is facing by giving an axis to look along, and a perpendicular (or at least non-parallel) up axis. | |
void | set_view_vector (const LVector3f &view_vector, const LVector3f &up_vector) |
Specifies the direction in which the lens is facing by giving an axis to look along, and a perpendicular (or at least non-parallel) up axis. | |
const LVector3f & | get_view_vector () const |
Returns the axis along which the lens is facing. | |
const LVector3f & | get_up_vector () const |
Returns the axis perpendicular to the camera's view vector that indicates the "up" direction. | |
LPoint3f | get_nodal_point () const |
Returns the center point of the lens: the point from which the lens is viewing. | |
void | set_iod_offset (float offset) |
Sets the amount by which the lens is shifted to the right, perpendicular to its view vector and up vector. | |
float | get_iod_offset () const |
Returns the aspect ratio of the Lens. | |
void | set_view_mat (const LMatrix4f &view_mat) |
Sets an arbitrary transformation on the lens. | |
const LMatrix4f & | get_view_mat () const |
Returns the direction in which the lens is facing. | |
void | set_frustum_from_corners (const LVecBase3f &ul, const LVecBase3f &ur, const LVecBase3f &ll, const LVecBase3f &lr, int flags) |
Sets up the lens to use the frustum defined by the four indicated points. | |
void | recompute_all () |
Forces all internal parameters of the Lens to be recomputed. | |
virtual bool | is_linear () const |
Returns true if the lens represents a linear projection (e.g. | |
virtual PointerTo< Geom > | make_geometry () |
Allocates and returns a new Geom that can be rendered to show a visible representation of the frustum used for this kind of lens, if it makes sense to do so. | |
virtual PointerTo< BoundingVolume > | make_bounds () const |
Allocates and returns a new BoundingVolume that encloses the frustum used for this kind of lens, if possible. | |
const LMatrix4f & | get_projection_mat () const |
Returns the complete transformation matrix from a 3-d point in space to a point on the film, if such a matrix exists, or the identity matrix if the lens is nonlinear. | |
const LMatrix4f & | get_projection_mat_inv () const |
Returns the matrix that transforms from a 2-d point on the film to a 3-d vector in space, if such a matrix exists. | |
virtual void | output (ostream &out) const |
virtual void | write (ostream &out, int indent_level=0) const |
const UpdateSeq & | get_last_change () const |
Returns the UpdateSeq that is incremented whenever the lens properties are changed. | |
virtual TypeHandle | get_type () const |
virtual TypeHandle | force_init_type () |
int | get_type_index () const |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. | |
bool | is_of_type (TypeHandle handle) const |
Returns true if the current object is or derives from the indicated type. | |
bool | is_exact_type (TypeHandle handle) const |
Returns true if the current object is the indicated type exactly. | |
int | get_ref_count () const |
Returns the current reference count. | |
int | ref () const |
Explicitly increments the reference count. | |
int | unref () const |
Explicitly decrements the reference count. | |
void | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. | |
Static Public Member Functions | |
float | get_default_near () |
Returns the default near plane distance that will be assigned to each newly-created lens. | |
float | get_default_far () |
Returns the default far plane distance that will be assigned to each newly-created lens. | |
TypeHandle | get_class_type () |
void | init_type () |
Protected Types | |
enum | UserFlags { UF_film_width = 0x0001, UF_film_height = 0x0002, UF_focal_length = 0x0004, UF_hfov = 0x0008, UF_vfov = 0x0010, UF_aspect_ratio = 0x0020, UF_view_hpr = 0x0040, UF_view_vector = 0x0080, UF_iod_offset = 0x0100, UF_view_mat = 0x0200 } |
enum | CompFlags { CF_film_mat = 0x0001, CF_film_mat_inv = 0x0002, CF_lens_mat = 0x0004, CF_lens_mat_inv = 0x0008, CF_projection_mat = 0x0010, CF_projection_mat_inv = 0x0020, CF_mat = 0x003f, CF_focal_length = 0x0040, CF_fov = 0x0080, CF_film_size = 0x0100, CF_aspect_ratio = 0x0200, CF_view_hpr = 0x0400, CF_view_vector = 0x0800, CF_iod_offset = 0x1000 } |
Protected Member Functions | |
void | adjust_user_flags (int clear_flags, int set_flags) |
Clears from _user_flags the bits in the first parameter, and sets the bits in the second parameter. | |
void | adjust_comp_flags (int clear_flags, int set_flags) |
Clears from _comp_flags the bits in the first parameter, and sets the bits in the second parameter. | |
void | throw_change_event () |
Throws the event associated with changing properties on this Lens, if any. | |
const LMatrix4f & | get_film_mat () const |
Returns the matrix that transforms from a point behind the lens to a point on the film. | |
const LMatrix4f & | get_film_mat_inv () const |
Returns the matrix that transforms from a point on the film to a point behind the lens. | |
const LMatrix4f & | get_lens_mat () const |
Returns the matrix that transforms from a point in front of the lens to a point in space. | |
const LMatrix4f & | get_lens_mat_inv () const |
Returns the matrix that transforms from a point in space to a point in front of the lens. | |
virtual bool | extrude_impl (const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) const |
Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner, compute the corresponding vector in space that maps to this point, if such a vector can be determined. | |
virtual bool | project_impl (const LPoint3f &point3d, LPoint3f &point2d) const |
Given a 3-d point in space, determine the 2-d point this maps to, in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner. | |
virtual void | compute_film_size () |
Computes the size and shape of the film behind the camera, based on the aspect ratio and fov. | |
virtual void | compute_focal_length () |
Computes the focal length of the lens, based on the fov and film size. | |
virtual void | compute_fov () |
Computes the field of view of the lens, based on the film size and focal length. | |
virtual void | compute_aspect_ratio () |
Computes the aspect ratio of the film rectangle, as a ratio of width to height. | |
virtual void | compute_view_hpr () |
Computes the Euler angles representing the lens' rotation. | |
virtual void | compute_view_vector () |
Computes the view vector and up vector for the lens. | |
virtual void | compute_iod_offset () |
Computes the IOD offset: the translation along the "right" axis. | |
virtual void | compute_projection_mat () |
Computes the complete transformation matrix from 3-d point to 2-d point, if the lens is linear. | |
virtual void | compute_film_mat () |
Computes the matrix that transforms from a point behind the lens to a point on the film. | |
virtual void | compute_lens_mat () |
Computes the matrix that transforms from a point in front of the lens to a point in space. | |
virtual float | fov_to_film (float fov, float focal_length, bool horiz) const |
Given a field of view in degrees and a focal length, compute the corresponding width (or height) on the film. | |
virtual float | fov_to_focal_length (float fov, float film_size, bool horiz) const |
Given a field of view in degrees and a width (or height) on the film, compute the focal length of the lens. | |
virtual float | film_to_fov (float film_size, float focal_length, bool horiz) const |
Given a width (or height) on the film and a focal length, compute the field of view in degrees. | |
Protected Attributes | |
string | _change_event |
UpdateSeq | _last_change |
CoordinateSystem | _cs |
LVecBase2f | _film_size |
LVector2f | _film_offset |
float | _focal_length |
LVecBase2f | _fov |
float | _aspect_ratio |
float | _near_distance |
float | _far_distance |
LVecBase3f | _view_hpr |
LVector3f | _view_vector |
LVector3f | _up_vector |
float | _iod_offset |
LMatrix4f | _film_mat |
LMatrix4f | _film_mat_inv |
LMatrix4f | _lens_mat |
LMatrix4f | _lens_mat_inv |
LMatrix4f | _projection_mat |
LMatrix4f | _projection_mat_inv |
short | _user_flags |
short | _comp_flags |
char | _focal_length_seq |
char | _fov_seq |
char | _film_size_seq |
PTA_Vertexf | _geom_coords |
Static Protected Attributes | |
const float | _default_fov = 40.0f |
Private Member Functions | |
int | define_geom_coords () |
Adjusts (or defines for the first time) all the vertices in the _geom_coords array to match the properties of the lens. | |
Static Private Member Functions | |
void | resequence_fov_triad (char &newest, char &older_a, char &older_b) |
Called whenever the user changes one of the three FOV parameters: fov, focal length, or film size. | |
void | build_shear_mat (LMatrix4f &shear_mat, const LPoint3f &cul, const LPoint3f &cur, const LPoint3f &cll, const LPoint3f &clr) |
A support function for set_frustum_from_corners(), this computes a matrix that will shear the four indicated points to the most nearly rectangular. | |
float | sqr_dist_to_line (const LPoint3f &point, const LPoint3f &origin, const LVector3f &vec) |
A support function for build_shear_mat(), this computes the minimum distance from a point to a line, and returns the distance squared. | |
Static Private Attributes | |
TypeHandle | _type_handle |
Presently, this includes perspective and orthographic lenses.
A Lens object is the main part of a Camera node (defined in sgraph), which defines the fundamental interface to point-of-view for rendering. Lenses are also used in other contexts, however; for instance, a Spotlight is also defined using a lens.
Definition at line 57 of file lens.h.
|
|
|
|
|
|
|
|
|
Definition at line 58 of file lens.cxx. References _aspect_ratio, _change_event, _comp_flags, _cs, _far_distance, _film_offset, _film_size, _focal_length, _fov, _near_distance, and _user_flags. |
|
Clears from _comp_flags the bits in the first parameter, and sets the bits in the second parameter.
Definition at line 561 of file lens.I. Referenced by get_default_far(), get_view_hpr(), is_linear(), MatrixLens::operator=(), output(), set_aspect_ratio(), set_change_event(), set_film_offset(), and set_film_size(). |
|
Clears from _user_flags the bits in the first parameter, and sets the bits in the second parameter.
Definition at line 546 of file lens.I. Referenced by get_default_far(), get_view_hpr(), set_aspect_ratio(), and set_film_size(). |
|
A support function for set_frustum_from_corners(), this computes a matrix that will shear the four indicated points to the most nearly rectangular.
|
|
Resets all lens parameters to their initial default settings.
|
|
Computes the aspect ratio of the film rectangle, as a ratio of width to height.
Definition at line 1586 of file lens.cxx. References length. Referenced by set_film_size(). |
|
Computes the matrix that transforms from a point behind the lens to a point on the film.
|
|
Computes the size and shape of the film behind the camera, based on the aspect ratio and fov.
|
|
Computes the focal length of the lens, based on the fov and film size. This is based on the horizontal dimension. |
|
Computes the field of view of the lens, based on the film size and focal length.
Definition at line 1550 of file lens.cxx. References _geom_coords. |
|
Computes the IOD offset: the translation along the "right" axis.
|
|
Computes the matrix that transforms from a point in front of the lens to a point in space.
|
|
Computes the complete transformation matrix from 3-d point to 2-d point, if the lens is linear.
Reimplemented in MatrixLens, OrthographicLens, and PerspectiveLens. Definition at line 1668 of file lens.cxx. References t. |
|
Computes the Euler angles representing the lens' rotation.
Definition at line 1609 of file lens.cxx. References csqrt(). |
|
Computes the view vector and up vector for the lens.
|
|
Adjusts (or defines for the first time) all the vertices in the _geom_coords array to match the properties of the lens. This will update the visual representation of the lens's frustum to match the changing parameters. Returns the number of line segments per edge. |
|
Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner, compute the corresponding vector in space that maps to this point, if such a vector can be determined. The vector is returned by indicating the points on the near plane and far plane that both map to the indicated 2-d point. The z coordinate of the 2-d point is ignored. Returns true if the vector is defined, or false otherwise. Definition at line 90 of file lens.I. References INLINE, and project_impl(). |
|
Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner, compute the corresponding vector in space that maps to this point, if such a vector can be determined. The vector is returned by indicating the points on the near plane and far plane that both map to the indicated 2-d point. Returns true if the vector is defined, or false otherwise. Definition at line 52 of file lens.I. References extrude_impl(), and INLINE. Referenced by ProjectionScreen::set_projector(). |
|
Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner, compute the corresponding vector in space that maps to this point, if such a vector can be determined. The vector is returned by indicating the points on the near plane and far plane that both map to the indicated 2-d point. The z coordinate of the 2-d point is ignored. Returns true if the vector is defined, or false otherwise. Reimplemented in CylindricalLens, FisheyeLens, and PSphereLens. Definition at line 1395 of file lens.cxx. Referenced by extrude(). |
|
Given a width (or height) on the film and a focal length, compute the field of view in degrees. If horiz is true, this is in the horizontal direction; otherwise, it is in the vertical direction (some lenses behave differently in each direction). Reimplemented in CylindricalLens, FisheyeLens, PSphereLens, and PerspectiveLens. Definition at line 1805 of file lens.cxx. Referenced by get_projection_mat_inv(), and output(). |
|
Reimplemented from TypedReferenceCount. Reimplemented in CylindricalLens, FisheyeLens, PSphereLens, MatrixLens, OrthographicLens, and PerspectiveLens. Definition at line 265 of file lens.h. References EXPCL_PANDA, and INLINE. |
|
Given a field of view in degrees and a focal length, compute the corresponding width (or height) on the film. If horiz is true, this is in the horizontal direction; otherwise, it is in the vertical direction (some lenses behave differently in each direction). Reimplemented in CylindricalLens, FisheyeLens, PSphereLens, and PerspectiveLens. |
|
Given a field of view in degrees and a width (or height) on the film, compute the focal length of the lens. If horiz is true, this is in the horizontal direction; otherwise, it is in the vertical direction (some lenses behave differently in each direction). Reimplemented in CylindricalLens, FisheyeLens, PSphereLens, and PerspectiveLens. Definition at line 1784 of file lens.cxx. Referenced by output(). |
|
Returns the aspect ratio of the Lens. This is determined based on the indicated film size; see set_film_size(). |
|
Returns the name of the event that will be generated whenever any properties of this particular Lens have changed.
Definition at line 207 of file lens.I. References _film_offset, and INLINE. |
|
Reimplemented from TypedReferenceCount. Reimplemented in CylindricalLens, FisheyeLens, PSphereLens, MatrixLens, OrthographicLens, and PerspectiveLens. |
|
Returns the coordinate system that all 3-d computations are performed within for this Lens. Normally, this is CS_default. |
|
Returns the default far plane distance that will be assigned to each newly-created lens. This is read from the Configrc file. Definition at line 515 of file lens.cxx. References _iod_offset, adjust_comp_flags(), adjust_user_flags(), CF_iod_offset, CF_mat, CF_view_hpr, CF_view_vector, throw_change_event(), UF_iod_offset, and UF_view_mat. |
|
Returns the default near plane distance that will be assigned to each newly-created lens. This is read from the Configrc file. Definition at line 498 of file lens.cxx. References get_view_mat(). |
|
Returns the position of the far plane (or cylinder, sphere, whatever).
Definition at line 453 of file lens.I. Referenced by ProjectionScreen::cull_callback(), and PSphereLens::extrude_impl(). |
|
Returns the matrix that transforms from a point behind the lens to a point on the film.
Definition at line 1295 of file lens.cxx. Referenced by PSphereLens::extrude_impl(), and is_linear(). |
|
Returns the matrix that transforms from a point on the film to a point behind the lens.
|
|
Returns the horizontal and vertical offset amounts of this Lens. See set_film_offset(). Definition at line 328 of file lens.I. References INLINE, and set_view_hpr(). Referenced by get_lens_mat(). |
|
Returns the horizontal and vertical film size of the virtual film. See set_film_size(). Definition at line 257 of file lens.cxx. References _comp_flags, _focal_length, and CF_focal_length. Referenced by get_lens_mat(), get_projection_mat_inv(), and write(). |
|
Returns the focal length of the lens. This may have been set explicitly by a previous call to set_focal_length(), or it may be computed based on the lens' fov and film_size. For certain kinds of lenses, the focal length has no meaning. Definition at line 326 of file lens.cxx. Referenced by PSphereLens::extrude_impl(). |
|
Returns the horizontal and vertical film size of the virtual film. See set_fov(). Definition at line 433 of file lens.cxx. References _comp_flags, _view_hpr, and CF_view_hpr. |
|
Returns the horizontal component of fov only. See get_fov(). Definition at line 370 of file lens.I. References _comp_flags, and INLINE. Referenced by GLGraphicsStateGuardian::issue_cull_face(). |
|
Returns the aspect ratio of the Lens. This is determined based on the indicated film size; see set_film_size(). Definition at line 682 of file lens.cxx. References FC_shear. |
|
Returns the UpdateSeq that is incremented whenever the lens properties are changed. As long as this number remains the same, you may assume the lens properties are unchanged. |
|
Returns the matrix that transforms from a point in front of the lens to a point in space.
Definition at line 1334 of file lens.cxx. References get_film_offset(), and get_film_size(). |
|
Returns the matrix that transforms from a point in space to a point in front of the lens.
Definition at line 1352 of file lens.cxx. References _film_mat. Referenced by PSphereLens::extrude_impl(), and get_nodal_point(). |
|
Returns the position of the near plane (or cylinder, sphere, whatever).
Definition at line 419 of file lens.I. Referenced by ProjectionScreen::cull_callback(), and PSphereLens::extrude_impl(). |
|
Returns the center point of the lens: the point from which the lens is viewing.
Definition at line 635 of file lens.cxx. References FC_camera_plane, and get_lens_mat_inv(). Referenced by GLGraphicsStateGuardian::issue_cull_face(), and DXGraphicsStateGuardian8::issue_depth_write(). |
|
Returns the complete transformation matrix from a 3-d point in space to a point on the film, if such a matrix exists, or the identity matrix if the lens is nonlinear.
|
|
Returns the matrix that transforms from a 2-d point on the film to a 3-d vector in space, if such a matrix exists.
Definition at line 1216 of file lens.cxx. References _default_fov, _focal_length, _fov, _user_flags, film_to_fov(), get_film_size(), UF_focal_length, and UF_hfov. |
|
Returns the current reference count.
Definition at line 183 of file referenceCount.I. Referenced by RenderState::determine_bin_index(), RenderEffects::determine_show_bounds(), FontPool::ns_garbage_collect(), TexturePool::ns_garbage_collect(), MaterialPool::ns_get_material(), and TexturePool::ns_release_texture(). |
|
Reimplemented from TypedReferenceCount. Reimplemented in CylindricalLens, FisheyeLens, PSphereLens, MatrixLens, OrthographicLens, and PerspectiveLens. |
|
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. This is equivalent to get_type().get_index(). Definition at line 71 of file typedObject.I. References TypeHandle::get_name(), TypedObject::get_type(), and INLINE. |
|
Returns the axis perpendicular to the camera's view vector that indicates the "up" direction.
|
|
Returns the vertical component of fov only. See get_fov(). |
|
Returns the direction in which the lens is facing.
Definition at line 556 of file lens.cxx. References _lens_mat, adjust_comp_flags(), adjust_user_flags(), CF_iod_offset, CF_lens_mat, CF_lens_mat_inv, CF_view_hpr, CF_view_vector, throw_change_event(), UF_iod_offset, UF_view_hpr, UF_view_mat, and UF_view_vector. |
|
Returns the direction in which the lens is facing.
Definition at line 736 of file lens.cxx. Referenced by get_default_near(). |
|
Returns the axis along which the lens is facing.
Definition at line 599 of file lens.cxx. Referenced by GLGraphicsStateGuardian::issue_cull_face(). |
|
Reimplemented from TypedReferenceCount. Reimplemented in CylindricalLens, FisheyeLens, PSphereLens, MatrixLens, OrthographicLens, and PerspectiveLens. |
|
Returns true if the current object is the indicated type exactly.
Definition at line 101 of file typedObject.I. Referenced by PT(), and CollisionNode::xform(). |
|
Returns true if the lens represents a linear projection (e.g. PerspectiveLens, OrthographicLens), and therefore there is a valid matrix returned by get_projection_mat(), or false otherwise. Reimplemented in MatrixLens, OrthographicLens, and PerspectiveLens. Definition at line 1034 of file lens.cxx. References _comp_flags, _film_mat_inv, adjust_comp_flags(), CF_film_mat_inv, and get_film_mat(). |
|
|
Allocates and returns a new BoundingVolume that encloses the frustum used for this kind of lens, if possible. If a suitable bounding volume cannot be created, returns NULL. |
|
Implemented in MatrixLens, OrthographicLens, and PerspectiveLens. |
|
Allocates and returns a new Geom that can be rendered to show a visible representation of the frustum used for this kind of lens, if it makes sense to do so. If a visible representation cannot be created, returns NULL. Definition at line 1055 of file lens.cxx. References _comp_flags, _lens_mat, and CF_lens_mat. |
|
Definition at line 71 of file lens.cxx. Referenced by CylindricalLens::CylindricalLens(), FisheyeLens::FisheyeLens(), MatrixLens::MatrixLens(), OrthographicLens::OrthographicLens(), PerspectiveLens::PerspectiveLens(), and PSphereLens::PSphereLens(). |
|
Definition at line 1235 of file lens.cxx. References _comp_flags, _focal_length, _fov, _user_flags, adjust_comp_flags(), CF_focal_length, film_to_fov(), fov_to_focal_length(), UF_focal_length, and UF_vfov. |
|
Given a 3-d point in space, determine the 2-d point this maps to, in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner. Returns true if the 3-d point is in front of the lens and within the viewing frustum (in which case point2d is filled in), or false otherwise (in which case point2d will be filled in with something, which may or may not be meaningful). Definition at line 121 of file lens.I. References _change_event. |
|
Given a 3-d point in space, determine the 2-d point this maps to, in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner. The z coordinate will also be set to a value in the range (-1, 1), where 1 represents a point on the near plane, and -1 represents a point on the far plane. Returns true if the 3-d point is in front of the lens and within the viewing frustum (in which case point2d is filled in), or false otherwise (in which case point2d will be filled in with something, which may or may not be meaningful). Definition at line 163 of file lens.I. References height, INLINE, set_film_size(), and width. |
|
Given a 3-d point in space, determine the 2-d point this maps to, in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner. The z coordinate will also be set to a value in the range (-1, 1), where 1 represents a point on the near plane, and -1 represents a point on the far plane. Returns true if the 3-d point is in front of the lens and within the viewing frustum (in which case point2d is filled in), or false otherwise (in which case point2d will be filled in with something, which may or may not be meaningful). Reimplemented in CylindricalLens, FisheyeLens, and PSphereLens. Definition at line 1454 of file lens.cxx. Referenced by extrude(). |
|
Forces all internal parameters of the Lens to be recomputed. Normally, this should never need to be called; it is provided only to assist in debugging. |
|
Explicitly increments the reference count. User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically. This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it. The return value is the new reference count. Definition at line 225 of file referenceCount.I. Referenced by ClientDevice::ClientDevice(), EggGroupNode::find_textures(), EggGroupNode::r_apply_texmats(), EggGroupNode::r_flatten_transforms(), and EggGroupNode::reverse_vertex_ordering(). |
|
Called whenever the user changes one of the three FOV parameters: fov, focal length, or film size. This rearranges the three sequence numbers so the newest parameter has value 2, and the older parameters are kept in sequence order. This is used to determine which two parameters of the three are the most recently changed, and conversely, which one the user has *not* changed recently. It is this third value which should be discarded. Definition at line 1836 of file lens.cxx. Referenced by set_film_size(). |
|
Sets the aspect ratio of the lens. This is the ratio of the height to the width of the generated image. Setting this overrides the two-parameter fov or film size setting. Definition at line 456 of file lens.cxx. References _up_vector, _view_vector, adjust_comp_flags(), adjust_user_flags(), CF_iod_offset, CF_mat, CF_view_hpr, CF_view_vector, throw_change_event(), UF_view_hpr, UF_view_mat, and UF_view_vector. |
|
Sets the name of the event that will be generated whenever any properties of the Lens have changed. If this is not set for a particular lens, no event will be generated. The event is thrown with one parameter, the lens itself. This can be used to automatically track changes to camera fov, etc. in the application. Definition at line 190 of file lens.I. References _film_offset, adjust_comp_flags(), CF_mat, INLINE, and throw_change_event(). |
|
Specifies the coordinate system that all 3-d computations are performed within for this Lens. Normally, this is CS_default. Definition at line 101 of file lens.cxx. References _aspect_ratio, _comp_flags, _far_distance, _film_size_seq, _focal_length, _focal_length_seq, _fov, _fov_seq, _iod_offset, _near_distance, _up_vector, _user_flags, _view_hpr, _view_vector, CF_fov, default_far, and default_near. |
|
Defines the position of the far plane (or cylinder, sphere, whatever). Points farther from the lens than this may not be rendered. |
|
Sets the horizontal and vertical offset amounts of this Lens. These are both in the same units specified in set_film_size(). This can be used to establish an off-axis lens. Definition at line 311 of file lens.I. References _far_distance, _near_distance, adjust_comp_flags(), CF_projection_mat, CF_projection_mat_inv, and throw_change_event(). |
|
Sets the horizontal and vertical offset amounts of this Lens. These are both in the same units specified in set_film_size(). This can be used to establish an off-axis lens. |
|
Sets the size and shape of the "film" within the lens. This both establishes the units used by calls like set_focal_length(), and establishes the aspect ratio of the frame. In a physical camera, the field of view of a lens is determined by the lens' focal length and by the size of the film area exposed by the lens. For instance, a 35mm camera exposes a rectangle on the film about 24mm x 36mm, which means a 50mm lens gives about a 40-degree horizontal field of view. In the virtual camera, you may set the film size to any units here, and specify a focal length in the same units to simulate the same effect. Or, you may ignore this parameter, and specify the field of view and aspect ratio of the lens directly. Definition at line 218 of file lens.cxx. References _film_size_seq, _focal_length, _focal_length_seq, _fov_seq, adjust_comp_flags(), adjust_user_flags(), CF_film_size, CF_focal_length, CF_fov, CF_mat, nassertv, resequence_fov_triad(), throw_change_event(), UF_film_height, UF_film_width, UF_focal_length, UF_hfov, and UF_vfov. |
|
Sets the size and shape of the "film" within the lens. This both establishes the units used by calls like set_focal_length(), and establishes the aspect ratio of the frame. In a physical camera, the field of view of a lens is determined by the lens' focal length and by the size of the film area exposed by the lens. For instance, a 35mm camera exposes a rectangle on the film about 24mm x 36mm, which means a 50mm lens gives about a 40-degree horizontal field of view. In the virtual camera, you may set the film size to any units here, and specify a focal length in the same units to simulate the same effect. Or, you may ignore this parameter, and specify the field of view and aspect ratio of the lens directly. Definition at line 269 of file lens.I. References _near_distance, and INLINE. |
|
Sets the horizontal size of the film without changing its shape. The aspect ratio remains unchanged; this computes the vertical size of the film to automatically maintain the aspect ratio. Definition at line 155 of file lens.cxx. References _film_size, _film_size_seq, _focal_length_seq, _fov_seq, adjust_comp_flags(), adjust_user_flags(), CF_aspect_ratio, CF_film_size, CF_focal_length, CF_fov, CF_mat, compute_aspect_ratio(), nassertv, resequence_fov_triad(), throw_change_event(), UF_aspect_ratio, UF_film_height, UF_film_width, UF_focal_length, UF_hfov, and UF_vfov. Referenced by project(), and WindowFramework::set_one_sided_reverse(). |
|
Sets the focal length of the lens. This may adjust the field-of-view correspondingly, and is an alternate way to specify field of view. For certain kinds of lenses (e.g. OrthographicLens), the focal length has no meaning. |
|
Sets the field of view of the lens in both dimensions. This establishes both the field of view and the aspect ratio of the lens. This is one way to specify the field of view of a lens; set_focal_length() is another way. For certain kinds of lenses (like OrthographicLens), the field of view has no meaning. Definition at line 394 of file lens.cxx. References default_near. |
|
Sets the field of view of the lens in both dimensions. This establishes both the field of view and the aspect ratio of the lens. This is one way to specify the field of view of a lens; set_focal_length() is another way. For certain kinds of lenses (like OrthoLens), the field of view has no meaning. Definition at line 355 of file lens.I. References _last_change. |
|
Sets the horizontal field of view of the lens without changing the aspect ratio. The vertical field of view is adjusted to maintain the same aspect ratio. Definition at line 346 of file lens.cxx. References _comp_flags, _fov, and CF_fov. Referenced by get_coordinate_system(). |
|
Sets up the lens to use the frustum defined by the four indicated points. This is most useful for a PerspectiveLens, but it may be called for other kinds of lenses as well. The frustum will be rooted at the origin (or offset by iod_offset, or by whatever translation might have been specified in a previous call to set_view_mat). It is legal for the four points not to be arranged in a rectangle; if this is the case, the frustum will be fitted as tightly as possible to cover all four points. The flags parameter contains the union of one or more of the following bits to control the behavior of this function: FC_roll - If this is included, the camera may be rotated so that its up vector is perpendicular to the top line. Otherwise, the standard up vector is used. FC_camera_plane - This allows the camera plane to be adjusted to be as nearly perpendicular to the center of the frustum as possible. Without this bit, the orientation camera plane is defined by position of the four points (which should all be coplanar). With this bit, the camera plane is arbitarary, and may be chosen so that the four points do not themselves lie in the camera plane (but the points will still be within the frustum). FC_off_axis - This allows the resulting frustum to be off-axis to get the tightest possible fit. Without this bit, the viewing axis will be centered within the frustum, but there may be more wasted space along the edges. FC_aspect_ratio - This allows the frustum to be scaled non-proportionately in the vertical and horizontal dimensions, if necessary, to get a tighter fit. Without this bit, the current aspect ratio will be preserved. FC_shear - This allows the frustum to be sheared, if necessary, to get the tightest possible fit. This may result in a parallelogram-based frustum, which will give a slanted appearance to the rendered image. Without this bit, the frustum will be rectangle-based. In general, if 0 is passed in as the value for flags, the generated frustum will be a loose fit but sane; if -1 is passed in, it will be a tighter fit and possibly screwy. |
|
Sets the amount by which the lens is shifted to the right, perpendicular to its view vector and up vector. This is normally used to shift one or both lens of a stereo camera to generate parallax. You can also simply set a complete transformation matrix (via set_view_mat()) that includes an arbitrary translation. |
|
Defines the position of the near plane (or cylinder, sphere, whatever). Points closer to the lens than this may not be rendered. |
|
Simultaneously changes the near and far planes.
|
|
Sets the direction in which the lens is facing. Normally, this is down the forward axis (usually the Y axis), but it may be rotated. This is only one way of specifying the rotation; you may also specify an explicit vector in which to look, or you may give a complete transformation matrix. Definition at line 538 of file lens.cxx. References _iod_offset. |
|
Sets the direction in which the lens is facing. Normally, this is down the forward axis (usually the Y axis), but it may be rotated. This is only one way of specifying the rotation; you may also specify an explicit vector in which to look, or you may give a complete transformation matrix. Definition at line 492 of file lens.I. Referenced by get_film_offset(). |
|
Sets an arbitrary transformation on the lens. This replaces the individual transformation components like set_view_hpr() or set_iod_offset(). Setting a transformation here will have a slightly different effect than putting one on the LensNode that contains this lens. In particular, lighting and other effects computations will still be performed on the lens in its untransformed (facing forward) position, but the actual projection matrix will be transformed by this matrix. Definition at line 718 of file lens.cxx. References FC_off_axis. |
|
Specifies the direction in which the lens is facing by giving an axis to look along, and a perpendicular (or at least non-parallel) up axis. See also set_view_hpr(). |
|
Specifies the direction in which the lens is facing by giving an axis to look along, and a perpendicular (or at least non-parallel) up axis. See also set_view_hpr(). |
|
A support function for build_shear_mat(), this computes the minimum distance from a point to a line, and returns the distance squared.
|
|
Does some easy checks to make sure that the reference count isn't completely bogus.
Definition at line 328 of file referenceCount.I. References INLINE. Referenced by EggNode::determine_bin(), and ReferenceCount::~ReferenceCount(). |
|
Throws the event associated with changing properties on this Lens, if any.
Definition at line 1263 of file lens.cxx. Referenced by get_default_far(), get_view_hpr(), set_aspect_ratio(), set_change_event(), set_film_offset(), and set_film_size(). |
|
Explicitly decrements the reference count. Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic; plus, we don't have a virtual destructor anyway.) However, see the helper function unref_delete(). User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically. This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it. The return value is the new reference count. Definition at line 293 of file referenceCount.I. References INLINE. Referenced by RenderState::determine_bin_index(), and RenderEffects::determine_show_bounds(). |
|
Reimplemented in MatrixLens, and OrthographicLens. Definition at line 1248 of file lens.cxx. References _aspect_ratio, _user_flags, get_film_size(), and UF_aspect_ratio. |
|
Definition at line 205 of file lens.h. Referenced by Lens(), set_coordinate_system(), and write(). |
|
|
|
Definition at line 249 of file lens.h. Referenced by get_film_size(), get_fov(), get_hfov(), is_linear(), Lens(), make_geometry(), output(), set_coordinate_system(), and set_fov(). |
|
Definition at line 199 of file lens.h. Referenced by PerspectiveLens::is_linear(), and Lens(). |
|
Definition at line 34 of file lens.cxx. Referenced by get_projection_mat_inv(). |
|
Definition at line 206 of file lens.h. Referenced by Lens(), set_coordinate_system(), and set_film_offset(). |
|
Definition at line 212 of file lens.h. Referenced by get_lens_mat_inv(). |
|
Definition at line 212 of file lens.h. Referenced by is_linear(). |
|
Definition at line 202 of file lens.h. Referenced by get_change_event(), Lens(), and set_change_event(). |
|
Definition at line 201 of file lens.h. Referenced by Lens(), and set_film_size(). |
|
Definition at line 255 of file lens.h. Referenced by set_coordinate_system(), and set_film_size(). |
|
Definition at line 203 of file lens.h. Referenced by get_film_size(), get_projection_mat_inv(), Lens(), output(), set_coordinate_system(), and set_film_size(). |
|
Definition at line 255 of file lens.h. Referenced by set_coordinate_system(), and set_film_size(). |
|
Definition at line 204 of file lens.h. Referenced by get_projection_mat_inv(), Lens(), output(), set_coordinate_system(), and set_fov(). |
|
Definition at line 255 of file lens.h. Referenced by set_coordinate_system(), and set_film_size(). |
|
Definition at line 257 of file lens.h. Referenced by compute_fov(). |
|
Definition at line 210 of file lens.h. Referenced by get_default_far(), set_coordinate_system(), and set_view_hpr(). |
|
Definition at line 198 of file lens.h. Referenced by set_fov(). |
|
Definition at line 213 of file lens.h. Referenced by get_view_hpr(), and make_geometry(). |
|
|
|
Definition at line 206 of file lens.h. Referenced by Lens(), set_coordinate_system(), set_film_offset(), and set_film_size(). |
|
Definition at line 214 of file lens.h. Referenced by MatrixLens::is_linear(). |
|
|
|
Reimplemented from TypedReferenceCount. Reimplemented in CylindricalLens, FisheyeLens, PSphereLens, MatrixLens, OrthographicLens, and PerspectiveLens. |
|
Definition at line 209 of file lens.h. Referenced by set_aspect_ratio(), and set_coordinate_system(). |
|
Definition at line 248 of file lens.h. Referenced by get_projection_mat_inv(), Lens(), output(), set_coordinate_system(), and write(). |
|
Definition at line 208 of file lens.h. Referenced by get_fov(), and set_coordinate_system(). |
|
Definition at line 209 of file lens.h. Referenced by set_aspect_ratio(), and set_coordinate_system(). |