34 return do_extrude(cdata,
LPoint3(point2d[0], point2d[1], 0.0f),
35 near_point, far_point);
58 return do_extrude(cdata, point2d, near_point, far_point);
73 return do_extrude_depth(cdata, point2d, point3d);
97 return do_extrude_vec(cdata,
LPoint3(point2d[0], point2d[1], 0.0f), vec);
123 return do_extrude_vec(cdata, point2d, vec);
144 bool okflag = do_project(cdata, point3d, result);
145 point2d.set(result[0], result[1]);
170 return do_project(cdata, point3d, point2d);
188 cdata->_change_event = event;
198 INLINE
const string &
Lens:: 201 return cdata->_change_event;
211 INLINE CoordinateSystem
Lens:: 228 do_set_film_size(cdata, width);
281 do_set_film_size(cdata, film_size);
293 return do_get_film_size(cdata);
322 do_set_film_offset(cdata, film_offset);
334 return do_get_film_offset(cdata);
350 do_set_focal_length(cdata, focal_length);
365 return do_get_focal_length(cdata);
378 do_set_fov(cdata, hfov);
413 do_set_fov(cdata, fov);
425 return do_get_fov(cdata);
461 do_set_aspect_ratio(cdata, aspect_ratio);
474 return do_get_aspect_ratio(cdata);
487 do_set_near(cdata, near_distance);
499 return do_get_near(cdata);
512 do_set_far(cdata, far_distance);
524 return do_get_far(cdata);
535 do_set_near_far(cdata, near_distance, far_distance);
563 set_view_vector(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat i, PN_stdfloat j, PN_stdfloat k) {
585 do_set_interocular_distance(cdata, interocular_distance);
586 do_throw_change_event(cdata);
597 return cdata->_interocular_distance;
637 do_set_convergence_distance(cdata, convergence_distance);
638 do_throw_change_event(cdata);
649 return cdata->_convergence_distance;
670 do_set_view_mat(cdata, view_mat);
681 return do_get_view_mat(cdata);
693 return cdata->_keystone;
705 return cdata->_custom_film_mat;
719 return do_get_projection_mat(cdata, channel);
732 return do_get_projection_mat_inv(cdata, stereo_channel);
744 return do_get_film_mat(cdata);
756 return do_get_film_mat_inv(cdata);
768 return do_get_lens_mat(cdata);
780 return do_get_lens_mat_inv(cdata);
794 return cdata->_last_change;
804 do_adjust_user_flags(CData *cdata,
int clear_flags,
int set_flags) {
805 cdata->_user_flags = (cdata->_user_flags & ~clear_flags) | set_flags;
815 do_adjust_comp_flags(CData *cdata,
int clear_flags,
int set_flags) {
816 cdata->_comp_flags = (cdata->_comp_flags & ~clear_flags) | set_flags;
825 do_set_film_offset(CData *cdata,
const LVecBase2 &film_offset) {
826 cdata->_film_offset = film_offset;
827 do_adjust_comp_flags(cdata, CF_mat, 0);
828 do_throw_change_event(cdata);
837 do_get_film_offset(
const CData *cdata)
const {
838 return cdata->_film_offset;
847 do_set_near(CData *cdata, PN_stdfloat near_distance) {
848 cdata->_near_distance = near_distance;
849 do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv, 0);
850 do_throw_change_event(cdata);
858 INLINE PN_stdfloat Lens::
859 do_get_near(
const CData *cdata)
const {
860 return cdata->_near_distance;
869 do_set_far(CData *cdata, PN_stdfloat far_distance) {
870 cdata->_far_distance = far_distance;
871 do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv, 0);
872 do_throw_change_event(cdata);
880 INLINE PN_stdfloat Lens::
881 do_get_far(
const CData *cdata)
const {
882 return cdata->_far_distance;
891 do_set_near_far(CData *cdata, PN_stdfloat near_distance, PN_stdfloat far_distance) {
892 cdata->_near_distance = near_distance;
893 cdata->_far_distance = far_distance;
894 do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv, 0);
895 do_throw_change_event(cdata);
899 operator << (ostream &out,
const Lens &lens) {
const LMatrix4 & get_custom_film_mat() const
Returns the custom_film_mat specified for the lens.
This is the base class for all three-component vectors and points.
void set_focal_length(PN_stdfloat focal_length)
Sets the focal length of the lens.
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 ri...
A base class for any number of different kinds of lenses, linear and otherwise.
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 LVecBase2 & get_film_size() const
Returns the horizontal and vertical film size of the virtual film.
void set_far(PN_stdfloat far_distance)
Defines the position of the far plane (or cylinder, sphere, whatever).
PN_stdfloat get_vfov() const
Returns the vertical component of fov only.
const LVecBase2 & get_fov() const
Returns the horizontal and vertical film size of the virtual film.
void set_film_size(PN_stdfloat width)
Sets the horizontal size of the film without changing its shape.
PN_stdfloat get_interocular_distance() const
See set_interocular_distance().
void set_interocular_distance(PN_stdfloat interocular_distance)
Sets the distance between the left and right eyes of a stereo camera.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
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...
PN_stdfloat get_hfov() const
Returns the horizontal component of fov only.
void set_view_mat(const LMatrix4 &view_mat)
Sets an arbitrary transformation on the lens.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
PN_stdfloat get_near() const
Returns the position of the near plane (or cylinder, sphere, whatever).
void set_aspect_ratio(PN_stdfloat aspect_ratio)
Sets the aspect ratio of the lens.
void set_near_far(PN_stdfloat near_distance, PN_stdfloat far_distance)
Simultaneously changes the near and far planes.
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.
void set_view_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r)
Sets the direction in which the lens is facing.
const LVector2 & get_film_offset() const
Returns the horizontal and vertical offset amounts of this Lens.
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...
const LMatrix4 & get_film_mat() const
Returns the matrix that transforms from a point behind the lens to a point on the film...
const string & get_change_event() const
Returns the name of the event that will be generated whenever any properties of this particular Lens ...
This is a 4-by-4 transform matrix.
UpdateSeq get_last_change() const
Returns the UpdateSeq that is incremented whenever the lens properties are changed.
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 (...
This is the base class for all two-component vectors and points.
PN_stdfloat get_aspect_ratio() const
Returns the aspect ratio of the Lens.
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
PN_stdfloat get_focal_length() const
Returns the focal length of the lens.
void set_film_offset(PN_stdfloat x, PN_stdfloat y)
Sets the horizontal and vertical offset amounts of this Lens.
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...
This is a two-component vector offset.
CoordinateSystem get_coordinate_system() const
Returns the coordinate system that all 3-d computations are performed within for this Lens...
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 (...
This is a two-component point in space.
const LVecBase2 & get_keystone() const
Returns the keystone correction specified for the lens.
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 ...
This is a sequence number that increments monotonically.
PN_stdfloat get_convergence_distance() const
See set_convergence_distance().
const LMatrix4 & get_lens_mat() const
Returns the matrix that transforms from a point in front of the lens to a point in space...
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.
PN_stdfloat get_far() const
Returns the position of the far plane (or cylinder, sphere, whatever).
void set_fov(PN_stdfloat fov)
Sets the horizontal field of view of the lens without changing the aspect ratio.
const LMatrix4 & get_film_mat_inv() const
Returns the matrix that transforms from a point on the film to a point behind the lens...
const LMatrix4 & get_view_mat() const
Returns the direction in which the lens is facing.
void set_near(PN_stdfloat near_distance)
Defines the position of the near plane (or cylinder, sphere, whatever).