Panda3D
|
A base class for any number of different kinds of lenses, linear and otherwise. More...
#include "lens.h"
Public Member Functions | |
Lens (const Lens ©) | |
void | clear () |
Resets all lens parameters to their initial default settings. More... | |
void | clear_custom_film_mat () |
Disables the lens custom_film_mat correction. More... | |
void | clear_keystone () |
Disables the lens keystone correction. More... | |
void | clear_view_mat () |
Resets the lens transform to identity. More... | |
bool | extrude (const LPoint2 &point2d, LPoint3 &near_point, LPoint3 &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. More... | |
bool | extrude (const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &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. More... | |
bool | extrude_depth (const LPoint3 &point2d, LPoint3 &point3d) const |
Uses the depth component of the 3-d result from project() to compute the original point in 3-d space corresponding to a particular point on the lens. More... | |
bool | extrude_vec (const LPoint2 &point2d, LVector3 &vec3d) 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 vector that corresponds to the view direction. More... | |
bool | extrude_vec (const LPoint3 &point2d, LVector3 &vec3d) 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 vector that corresponds to the view direction. More... | |
virtual TypeHandle | force_init_type () |
PN_stdfloat | get_aspect_ratio () const |
Returns the aspect ratio of the Lens. More... | |
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. More... | |
PN_stdfloat | get_convergence_distance () const |
See set_convergence_distance(). More... | |
CoordinateSystem | get_coordinate_system () const |
Returns the coordinate system that all 3-d computations are performed within for this Lens. More... | |
const LMatrix4 & | get_custom_film_mat () const |
Returns the custom_film_mat specified for the lens. More... | |
PN_stdfloat | get_far () const |
Returns the position of the far plane (or cylinder, sphere, whatever). More... | |
const LMatrix4 & | get_film_mat () const |
Returns the matrix that transforms from a point behind the lens to a point on the film. More... | |
const LMatrix4 & | get_film_mat_inv () const |
Returns the matrix that transforms from a point on the film to a point behind the lens. More... | |
const LVector2 & | get_film_offset () const |
Returns the horizontal and vertical offset amounts of this Lens. More... | |
const LVecBase2 & | get_film_size () const |
Returns the horizontal and vertical film size of the virtual film. More... | |
PN_stdfloat | get_focal_length () const |
Returns the focal length of the lens. More... | |
const LVecBase2 & | get_fov () const |
Returns the horizontal and vertical film size of the virtual film. More... | |
PN_stdfloat | get_hfov () const |
Returns the horizontal component of fov only. More... | |
PN_stdfloat | get_interocular_distance () const |
See set_interocular_distance(). More... | |
const LVecBase2 & | get_keystone () const |
Returns the keystone correction specified for the lens. More... | |
UpdateSeq | get_last_change () const |
Returns the UpdateSeq that is incremented whenever the lens properties are changed. More... | |
const LMatrix4 & | get_lens_mat () const |
Returns the matrix that transforms from a point in front of the lens to a point in space. More... | |
const LMatrix4 & | get_lens_mat_inv () const |
Returns the matrix that transforms from a point in space to a point in front of the lens. More... | |
PN_stdfloat | get_min_fov () const |
Returns the field of view of the narrowest dimension of the window. More... | |
PN_stdfloat | get_near () const |
Returns the position of the near plane (or cylinder, sphere, whatever). More... | |
LPoint3 | get_nodal_point () const |
Returns the center point of the lens: the point from which the lens is viewing. More... | |
const LMatrix4 & | get_projection_mat (StereoChannel channel=SC_mono) 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. More... | |
const LMatrix4 & | get_projection_mat_inv (StereoChannel channel=SC_mono) 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. More... | |
virtual TypeHandle | get_type () const |
const LVector3 & | get_up_vector () const |
Returns the axis perpendicular to the camera's view vector that indicates the "up" direction. More... | |
PN_stdfloat | get_vfov () const |
Returns the vertical component of fov only. More... | |
const LVecBase3 & | get_view_hpr () const |
Returns the direction in which the lens is facing. More... | |
const LMatrix4 & | get_view_mat () const |
Returns the direction in which the lens is facing. More... | |
const LVector3 & | get_view_vector () const |
Returns the axis along which the lens is facing. More... | |
virtual bool | is_linear () const |
Returns true if the lens represents a linear projection (e.g. More... | |
virtual bool | is_orthographic () const |
Returns true if the lens represents a orthographic projection (i.e. More... | |
virtual bool | is_perspective () const |
Returns true if the lens represents a perspective projection (i.e. More... | |
void | operator= (const Lens ©) |
virtual void | output (ostream &out) const |
bool | project (const LPoint3 &point3d, LPoint3 &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. More... | |
bool | project (const LPoint3 &point3d, LPoint2 &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. More... | |
virtual | PT (Lens) make_copy() const =0 |
virtual | PT (Geom) make_geometry() |
virtual | PT (BoundingVolume) make_bounds() const |
void | recompute_all () |
Forces all internal parameters of the Lens to be recomputed. More... | |
void | set_aspect_ratio (PN_stdfloat aspect_ratio) |
Sets the aspect ratio of the lens. More... | |
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. More... | |
void | set_convergence_distance (PN_stdfloat convergence_distance) |
Sets the distance between between the camera plane and the point in the distance that the left and right eyes are both looking at. More... | |
void | set_coordinate_system (CoordinateSystem cs) |
Specifies the coordinate system that all 3-d computations are performed within for this Lens. More... | |
void | set_custom_film_mat (const LMatrix4 &custom_film_mat) |
Specifies a custom matrix to transform the points on the film after they have been converted into nominal film space (-1 . More... | |
void | set_far (PN_stdfloat far_distance) |
Defines the position of the far plane (or cylinder, sphere, whatever). More... | |
void | set_film_offset (PN_stdfloat x, PN_stdfloat y) |
Sets the horizontal and vertical offset amounts of this Lens. More... | |
void | set_film_offset (const LVecBase2 &film_offset) |
Sets the horizontal and vertical offset amounts of this Lens. More... | |
void | set_film_size (PN_stdfloat width) |
Sets the horizontal size of the film without changing its shape. More... | |
void | set_film_size (PN_stdfloat width, PN_stdfloat height) |
Sets the size and shape of the "film" within the lens. More... | |
void | set_film_size (const LVecBase2 &film_size) |
Sets the size and shape of the "film" within the lens. More... | |
void | set_focal_length (PN_stdfloat focal_length) |
Sets the focal length of the lens. More... | |
void | set_fov (PN_stdfloat fov) |
Sets the horizontal field of view of the lens without changing the aspect ratio. More... | |
void | set_fov (PN_stdfloat hfov, PN_stdfloat vfov) |
Sets the field of view of the lens in both dimensions. More... | |
void | set_fov (const LVecBase2 &fov) |
Sets the field of view of the lens in both dimensions. More... | |
void | set_frustum_from_corners (const LVecBase3 &ul, const LVecBase3 &ur, const LVecBase3 &ll, const LVecBase3 &lr, int flags) |
Sets up the lens to use the frustum defined by the four indicated points. More... | |
void | set_interocular_distance (PN_stdfloat interocular_distance) |
Sets the distance between the left and right eyes of a stereo camera. More... | |
void | set_keystone (const LVecBase2 &keystone) |
Indicates the ratio of keystone correction to perform on the lens, in each of three axes. More... | |
void | set_min_fov (PN_stdfloat min_fov) |
Sets the field of view of the smallest dimension of the window. More... | |
void | set_near (PN_stdfloat near_distance) |
Defines the position of the near plane (or cylinder, sphere, whatever). More... | |
void | set_near_far (PN_stdfloat near_distance, PN_stdfloat far_distance) |
Simultaneously changes the near and far planes. More... | |
void | set_view_hpr (PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) |
Sets the direction in which the lens is facing. More... | |
void | set_view_hpr (const LVecBase3 &view_hpr) |
Sets the direction in which the lens is facing. More... | |
void | set_view_mat (const LMatrix4 &view_mat) |
Sets an arbitrary transformation on the lens. More... | |
void | set_view_vector (PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat i, PN_stdfloat j, PN_stdfloat 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. More... | |
void | set_view_vector (const LVector3 &view_vector, const LVector3 &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. More... | |
virtual void | write (ostream &out, int indent_level=0) const |
virtual void | write_datagram (BamWriter *manager, Datagram &dg) |
Writes the contents of this object to the datagram for shipping out to a Bam file. More... | |
![]() | |
TypedWritableReferenceCount (const TypedWritableReferenceCount ©) | |
virtual ReferenceCount * | as_reference_count () |
Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type. More... | |
void | operator= (const TypedWritableReferenceCount ©) |
![]() | |
TypedWritable (const TypedWritable ©) | |
virtual int | complete_pointers (TypedWritable **p_list, BamReader *manager) |
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin(). More... | |
string | encode_to_bam_stream () const |
Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a string string. More... | |
bool | encode_to_bam_stream (string &data, BamWriter *writer=NULL) const |
Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. More... | |
virtual void | finalize (BamReader *manager) |
Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed. More... | |
UpdateSeq | get_bam_modified () const |
Returns the current bam_modified counter. More... | |
void | mark_bam_modified () |
Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. More... | |
void | operator= (const TypedWritable ©) |
virtual bool | require_fully_complete () const |
Some objects require all of their nested pointers to have been completed before the objects themselves can be completed. More... | |
virtual void | update_bam_nested (BamWriter *manager) |
Called by the BamWriter when this object has not itself been modified recently, but it should check its nested objects for updates. More... | |
![]() | |
TypedObject (const TypedObject ©) | |
TypedObject * | as_typed_object () |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
const TypedObject * | as_typed_object () const |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
int | get_best_parent_from_Set (const std::set< int > &) const |
int | get_type_index () const |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More... | |
bool | is_exact_type (TypeHandle handle) const |
Returns true if the current object is the indicated type exactly. More... | |
bool | is_of_type (TypeHandle handle) const |
Returns true if the current object is or derives from the indicated type. More... | |
void | operator= (const TypedObject ©) |
![]() | |
int | get_ref_count () const |
Returns the current reference count. More... | |
WeakReferenceList * | get_weak_list () const |
Returns the WeakReferenceList associated with this ReferenceCount object. More... | |
bool | has_weak_list () const |
Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More... | |
void | local_object () |
This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More... | |
void | ref () const |
Explicitly increments the reference count. More... | |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. More... | |
bool | test_ref_count_nonzero () const |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More... | |
virtual bool | unref () const |
Explicitly decrements the reference count. More... | |
void | weak_ref (WeakPointerToVoid *ptv) |
Adds the indicated PointerToVoid as a weak reference to this object. More... | |
void | weak_unref (WeakPointerToVoid *ptv) |
Removes the indicated PointerToVoid as a weak reference to this object. More... | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static PN_stdfloat | get_default_far () |
Returns the default far plane distance that will be assigned to each newly-created lens. More... | |
static PN_stdfloat | get_default_near () |
Returns the default near plane distance that will be assigned to each newly-created lens. More... | |
static void | init_type () |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
static | PT (TypedWritableReferenceCount) decode_from_bam_stream(const string &data |
![]() | |
static bool | decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, const string &data, BamReader *reader=NULL) |
Reads the string created by a previous call to encode_to_bam_stream(), and extracts the single object on that string. More... | |
static TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. More... | |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
Additional Inherited Members | |
![]() | |
static BamReader * | reader = NULL) |
![]() | |
static TypedWritable *const | Null = (TypedWritable*)0L |
A base class for any number of different kinds of lenses, linear and otherwise.
Presently, this includes perspective and orthographic lenses.
A Lens object is the main part of a Camera node, 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.
void Lens::clear | ( | ) |
Resets all lens parameters to their initial default settings.
Definition at line 88 of file lens.cxx.
References set_min_fov().
Referenced by set_coordinate_system().
void Lens::clear_custom_film_mat | ( | ) |
Disables the lens custom_film_mat correction.
Definition at line 373 of file lens.cxx.
References LMatrix4f::ident_mat(), and set_frustum_from_corners().
Referenced by set_custom_film_mat().
void Lens::clear_keystone | ( | ) |
Disables the lens keystone correction.
Definition at line 333 of file lens.cxx.
References set_custom_film_mat().
Referenced by set_keystone().
void Lens::clear_view_mat | ( | ) |
Resets the lens transform to identity.
Definition at line 287 of file lens.cxx.
References LMatrix4f::ident_mat(), and set_keystone().
Referenced by get_nodal_point().
|
inline |
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 32 of file lens.I.
Referenced by PortalClipper::prepare_portal(), CollisionRay::set_from_lens(), CollisionSegment::set_from_lens(), ProjectionScreen::set_projector(), and ScissorEffect::write_datagram().
|
inline |
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 56 of file lens.I.
References extrude_depth().
Uses the depth component of the 3-d result from project() to compute the original point in 3-d space corresponding to a particular point on the lens.
This exactly reverses project(), assuming the point does fall legitimately within the lens.
Definition at line 71 of file lens.I.
References extrude_vec().
Referenced by PfmVizzer::extrude(), and extrude().
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 vector that corresponds to the view direction.
This will be parallel to the normal on the surface (the far plane) corresponding to the lens shape at this point.
See the comment block on Lens::extrude_vec_impl() for a more in-depth comment on the meaning of this vector.
Returns true if the vector is defined, or false otherwise.
Definition at line 95 of file lens.I.
Referenced by extrude_depth(), and 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 vector that corresponds to the view direction.
This will be parallel to the normal on the surface (the far plane) corresponding to the lens shape at this point.
See the comment block on Lens::extrude_vec_impl() for a more in-depth comment on the meaning of this vector.
The z coordinate of the 2-d point is ignored.
Returns true if the vector is defined, or false otherwise.
Definition at line 121 of file lens.I.
References project().
|
inline |
Returns the aspect ratio of the Lens.
This is determined based on the indicated film size; see set_film_size().
Definition at line 472 of file lens.I.
References set_near().
Referenced by set_aspect_ratio().
|
inline |
Returns the name of the event that will be generated whenever any properties of this particular Lens have changed.
Definition at line 199 of file lens.I.
References get_coordinate_system().
Referenced by set_change_event().
|
inline |
See set_convergence_distance().
Definition at line 647 of file lens.I.
References set_view_mat().
Referenced by set_convergence_distance().
|
inline |
Returns the coordinate system that all 3-d computations are performed within for this Lens.
Normally, this is CS_default.
Definition at line 212 of file lens.I.
References set_film_size().
Referenced by SpeedTreeNode::cull_callback(), GraphicsEngine::do_cull(), get_change_event(), CullableObject::munge_geom(), and PortalClipper::prepare_portal().
|
inline |
Returns the custom_film_mat specified for the lens.
Definition at line 703 of file lens.I.
References get_projection_mat().
Referenced by get_keystone().
|
static |
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 179 of file lens.cxx.
References set_view_hpr().
Referenced by WindowFramework::center_trackball(), and get_default_near().
|
static |
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 167 of file lens.cxx.
References get_default_far().
Referenced by WindowFramework::center_trackball(), and get_min_fov().
|
inline |
Returns the position of the far plane (or cylinder, sphere, whatever).
Definition at line 522 of file lens.I.
References set_near_far().
Referenced by SpeedTreeNode::cull_callback(), set_far(), and ProjectionScreen::set_projector().
|
inline |
Returns the matrix that transforms from a point behind the lens to a point on the film.
Definition at line 742 of file lens.I.
References get_film_mat_inv().
Referenced by get_projection_mat_inv().
|
inline |
Returns the matrix that transforms from a point on the film to a point behind the lens.
Definition at line 754 of file lens.I.
References get_lens_mat().
Referenced by get_film_mat().
|
inline |
Returns the horizontal and vertical offset amounts of this Lens.
See set_film_offset().
Definition at line 332 of file lens.I.
References set_focal_length().
Referenced by set_film_offset().
|
inline |
Returns the horizontal and vertical film size of the virtual film.
See set_film_size().
Definition at line 291 of file lens.I.
References set_film_offset().
Referenced by set_film_size().
|
inline |
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 363 of file lens.I.
References set_fov().
Referenced by set_focal_length().
|
inline |
Returns the horizontal and vertical film size of the virtual film.
See set_fov().
Definition at line 423 of file lens.I.
References get_hfov().
Referenced by WindowFramework::center_trackball(), get_hfov(), get_vfov(), and set_fov().
|
inline |
Returns the horizontal component of fov only.
See get_fov().
Definition at line 435 of file lens.I.
References get_fov(), and get_vfov().
Referenced by TinyGraphicsStateGuardian::bind_light(), DXGraphicsStateGuardian9::bind_light(), and get_fov().
|
inline |
See set_interocular_distance().
Definition at line 595 of file lens.I.
References set_convergence_distance().
Referenced by set_interocular_distance().
|
inline |
Returns the keystone correction specified for the lens.
Definition at line 691 of file lens.I.
References get_custom_film_mat().
Referenced by get_view_mat().
|
inline |
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.
Definition at line 792 of file lens.I.
Referenced by get_lens_mat_inv().
|
inline |
Returns the matrix that transforms from a point in front of the lens to a point in space.
Definition at line 766 of file lens.I.
References get_lens_mat_inv().
Referenced by get_film_mat_inv().
|
inline |
Returns the matrix that transforms from a point in space to a point in front of the lens.
Definition at line 778 of file lens.I.
References get_last_change().
Referenced by get_lens_mat().
PN_stdfloat Lens::get_min_fov | ( | ) | const |
Returns the field of view of the narrowest dimension of the window.
See set_min_fov().
Definition at line 150 of file lens.cxx.
References get_default_near(), and CycleDataReader< CycleDataType >::p().
Referenced by set_min_fov().
|
inline |
Returns the position of the near plane (or cylinder, sphere, whatever).
Definition at line 497 of file lens.I.
References set_far().
Referenced by SpeedTreeNode::cull_callback(), set_near(), and ProjectionScreen::set_projector().
LPoint3 Lens::get_nodal_point | ( | ) | const |
Returns the center point of the lens: the point from which the lens is viewing.
Definition at line 277 of file lens.cxx.
References clear_view_mat().
Referenced by TinyGraphicsStateGuardian::bind_light(), DXGraphicsStateGuardian9::bind_light(), get_up_vector(), and PlaneNode::is_renderable().
|
inline |
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.
Definition at line 717 of file lens.I.
References get_projection_mat_inv().
Referenced by SpeedTreeNode::cull_callback(), get_custom_film_mat(), CullableObject::munge_geom(), TinyGraphicsStateGuardian::prepare_display_region(), and DXGraphicsStateGuardian9::prepare_display_region().
|
inline |
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 730 of file lens.I.
References get_film_mat().
Referenced by PfmVizzer::extrude(), and get_projection_mat().
const LVector3 & Lens::get_up_vector | ( | ) | const |
Returns the axis perpendicular to the camera's view vector that indicates the "up" direction.
Definition at line 262 of file lens.cxx.
References get_nodal_point(), and CycleDataReader< CycleDataType >::p().
Referenced by get_view_vector().
|
inline |
Returns the vertical component of fov only.
See get_fov().
Definition at line 446 of file lens.I.
References get_fov(), and set_aspect_ratio().
Referenced by get_hfov().
const LVecBase3 & Lens::get_view_hpr | ( | ) | const |
Returns the direction in which the lens is facing.
Definition at line 211 of file lens.cxx.
References CycleDataReader< CycleDataType >::p(), and set_view_vector().
Referenced by set_view_hpr().
|
inline |
Returns the direction in which the lens is facing.
Definition at line 679 of file lens.I.
References get_keystone().
Referenced by set_view_mat().
const LVector3 & Lens::get_view_vector | ( | ) | const |
Returns the axis along which the lens is facing.
Definition at line 247 of file lens.cxx.
References get_up_vector(), and CycleDataReader< CycleDataType >::p().
Referenced by TinyGraphicsStateGuardian::bind_light(), DXGraphicsStateGuardian9::bind_light(), and set_view_vector().
|
virtual |
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 615 of file lens.cxx.
References is_perspective().
Referenced by PfmVizzer::extrude(), TinyGraphicsStateGuardian::prepare_display_region(), DXGraphicsStateGuardian9::prepare_display_region(), GraphicsStateGuardian::prepare_lens(), and recompute_all().
|
virtual |
Returns true if the lens represents a orthographic projection (i.e.
it is a OrthographicLens), false otherwise.
Reimplemented in OrthographicLens.
Definition at line 639 of file lens.cxx.
References LMatrix4f::convert_mat(), LVector3f::forward(), LMatrix4f::ident_mat(), LVecBase2f::is_nan(), LMatrix4f::is_nan(), LVecBase3f::length_squared(), LVecBase3f::normalize(), GeomVertexWriter::set_data3(), LMatrix4f::set_row(), LVector3f::up(), write_datagram(), LMatrix4f::xform(), and LMatrix4f::xform_point_general().
Referenced by is_perspective(), and CullableObject::munge_geom().
|
virtual |
Returns true if the lens represents a perspective projection (i.e.
it is a PerspectiveLens), false otherwise.
Reimplemented in PerspectiveLens.
Definition at line 627 of file lens.cxx.
References is_orthographic().
Referenced by is_linear().
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 168 of file lens.I.
References set_change_event().
Referenced by extrude_vec(), MeshDrawer::link_segment(), PortalClipper::prepare_portal(), PfmVizzer::project(), project(), and ProjectionScreen::recompute_if_stale().
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 141 of file lens.I.
References project().
void Lens::recompute_all | ( | ) |
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.
Definition at line 601 of file lens.cxx.
References is_linear().
Referenced by set_frustum_from_corners().
|
inline |
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 459 of file lens.I.
References get_aspect_ratio().
Referenced by WindowFramework::adjust_dimensions(), get_vfov(), and WindowFramework::make_camera().
|
inline |
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 186 of file lens.I.
References get_change_event().
Referenced by project().
|
inline |
Sets the distance between between the camera plane and the point in the distance that the left and right eyes are both looking at.
This distance is used to apply a stereo effect when the lens is rendered on a stereo display region. It only has an effect on a PerspectiveLens.
This parameter must be greater than 0, but may be as large as you like. It controls the distance at which the two stereo images will appear to converge, which is a normal property of stereo vision. Normally this should be set to the distance from the camera to the area of interest in your scene. Anything beyond this distance will appear to go into the screen, and anything closer will appear to come out of the screen. If you want to simulate parallel stereo, set this to infinity.
Note that this creates an off-axis frustum, which means that the lenses are still pointing in the same direction, which is usually more desirable than the more naive toe-in approach, where the two lenses are simply tilted toward each other.
Prior to Panda3D 1.9.0, the convergence was being calculated incorrectly. It has since been corrected. To restore the legacy behavior you can set the stereo-lens-old-convergence variable to true.
Also see set_interocular_distance(), which relates.
Definition at line 635 of file lens.I.
References get_convergence_distance().
Referenced by get_interocular_distance().
void Lens::set_coordinate_system | ( | CoordinateSystem | cs | ) |
void Lens::set_custom_film_mat | ( | const LMatrix4 & | custom_film_mat | ) |
Specifies a custom matrix to transform the points on the film after they have been converted into nominal film space (-1 .
. 1 in U and V). This can be used to introduce arbitrary scales, rotations, or other linear transforms to the media plane. This is normally a 2-d matrix, but a full 4x4 matrix may be specified. This is applied on top of any film size, lens shift, and/or keystone correction.
Definition at line 356 of file lens.cxx.
References clear_custom_film_mat(), and LMatrix4f::is_nan().
Referenced by clear_keystone().
|
inline |
Defines the position of the far plane (or cylinder, sphere, whatever).
Points farther from the lens than this may not be rendered.
Definition at line 510 of file lens.I.
References get_far().
Referenced by WindowFramework::center_trackball(), and get_near().
|
inline |
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 306 of file lens.I.
Referenced by get_film_size().
|
inline |
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 320 of file lens.I.
References get_film_offset().
|
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 226 of file lens.I.
Referenced by WindowFramework::adjust_dimensions(), get_coordinate_system(), WindowFramework::get_render_2d(), set_film_size(), FrameRateMeter::setup_window(), and SceneGraphAnalyzerMeter::setup_window().
|
inline |
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 253 of file lens.I.
References set_film_size().
|
inline |
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 279 of file lens.I.
References get_film_size().
|
inline |
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.
Definition at line 348 of file lens.I.
References get_focal_length().
Referenced by get_film_offset().
|
inline |
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 376 of file lens.I.
Referenced by get_focal_length(), and set_fov().
|
inline |
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 394 of file lens.I.
References set_fov().
|
inline |
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 411 of file lens.I.
References get_fov().
void Lens::set_frustum_from_corners | ( | const LVecBase3 & | ul, |
const LVecBase3 & | ur, | ||
const LVecBase3 & | ll, | ||
const LVecBase3 & | lr, | ||
int | flags | ||
) |
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 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.
Definition at line 443 of file lens.cxx.
References LMatrix4f::get_row3(), LMatrix4f::ident_mat(), LMatrix4f::invert_affine_from(), LMatrix4f::invert_from(), LVecBase3f::is_nan(), LVecBase3f::length_squared(), recompute_all(), LMatrix4f::set_row(), LVector3f::up(), and LMatrix4f::xform_point().
Referenced by clear_custom_film_mat().
|
inline |
Sets the distance between the left and right eyes of a stereo camera.
This distance is used to apply a stereo effect when the lens is rendered on a stereo display region. It only has an effect on a PerspectiveLens.
The left eye and the right eye are each offset along the X axis by half of this distance, so that this parameter specifies the total distance between them.
Also see set_convergence_distance(), which relates.
Definition at line 583 of file lens.I.
References get_interocular_distance().
Referenced by set_view_vector().
void Lens::set_keystone | ( | const LVecBase2 & | keystone | ) |
Indicates the ratio of keystone correction to perform on the lens, in each of three axes.
This will build a special non-affine scale factor into the projection matrix that will compensate for keystoning of a projected image; this can be used to compensate for a projector that for physical reasons cannot be aimed directly at its screen.
The default value is taken from the default-keystone Config variable. 0, 0 indicates no keystone correction; specify a small value (usually in the range -1 .. 1) in either the x or y position to generate a keystone correction in that axis.
Definition at line 316 of file lens.cxx.
References clear_keystone(), and LVecBase2f::is_nan().
Referenced by clear_view_mat().
void Lens::set_min_fov | ( | PN_stdfloat | min_fov | ) |
Sets the field of view of the smallest dimension of the window.
If the window is wider than it is tall, this specifies the vertical field of view; if it is taller than it is wide, this specifies the horizontal field of view.
In many cases, this is preferable to setting either the horizontal or vertical field of view explicitly. Setting this parameter means that pulling the window wider will widen the field of view, which is usually what you expect to happen.
Definition at line 113 of file lens.cxx.
References get_min_fov().
Referenced by clear().
|
inline |
Defines the position of the near plane (or cylinder, sphere, whatever).
Points closer to the lens than this may not be rendered.
Definition at line 485 of file lens.I.
References get_near().
Referenced by WindowFramework::center_trackball(), and get_aspect_ratio().
|
inline |
Simultaneously changes the near and far planes.
Definition at line 533 of file lens.I.
References set_view_hpr().
Referenced by get_far().
|
inline |
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 549 of file lens.I.
References set_view_vector().
Referenced by get_default_far(), and set_near_far().
void Lens::set_view_hpr | ( | const LVecBase3 & | view_hpr | ) |
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 194 of file lens.cxx.
References get_view_hpr(), and LVecBase3f::is_nan().
|
inline |
Sets an arbitrary transformation on the lens.
This replaces the individual transformation components like set_view_hpr().
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 668 of file lens.I.
References get_view_mat().
Referenced by get_convergence_distance().
|
inline |
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().
Definition at line 563 of file lens.I.
References set_interocular_distance().
Referenced by get_view_hpr(), and 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().
Definition at line 229 of file lens.cxx.
References get_view_vector(), and LVecBase3f::is_nan().
Writes the contents of this object to the datagram for shipping out to a Bam file.
Reimplemented from TypedWritable.
Definition at line 2065 of file lens.cxx.
References Datagram::add_stdfloat(), Datagram::add_string(), Datagram::add_uint16(), Datagram::add_uint8(), TypedWritable::fillin(), DatagramIterator::get_stdfloat(), DatagramIterator::get_string(), DatagramIterator::get_uint16(), DatagramIterator::get_uint8(), ConfigVariableBase::has_value(), LMatrix4f::ident_mat(), BamReader::read_cdata(), BamWriter::write_cdata(), and TypedWritable::write_datagram().
Referenced by is_orthographic().