24extrude(
const LPoint2 &point2d, LPoint3 &near_point, LPoint3 &far_point)
const {
26 return do_extrude(cdata, LPoint3(point2d[0], point2d[1], 0.0f),
27 near_point, far_point);
42extrude(
const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point)
const {
44 return do_extrude(cdata, point2d, near_point, far_point);
54extrude_depth(
const LPoint3 &point2d, LPoint3 &point3d)
const {
56 return do_extrude_depth(cdata, point2d, point3d);
72extrude_vec(
const LPoint2 &point2d, LVector3 &vec)
const {
74 return do_extrude_vec(cdata, LPoint3(point2d[0], point2d[1], 0.0f), vec);
92extrude_vec(
const LPoint3 &point2d, LVector3 &vec)
const {
94 return do_extrude_vec(cdata, point2d, vec);
108project(
const LPoint3 &point3d, LPoint2 &point2d)
const {
111 bool okflag = do_project(cdata, point3d, result);
112 point2d.set(result[0], result[1]);
131project(
const LPoint3 &point3d, LPoint3 &point2d)
const {
133 return do_project(cdata, point3d, point2d);
146 CDWriter cdata(_cycler,
true);
147 cdata->_change_event = event;
154INLINE
const std::string &
Lens::
156 CDReader cdata(_cycler);
157 return cdata->_change_event;
164INLINE CoordinateSystem
Lens::
166 CDReader cdata(_cycler);
177 CDWriter cdata(_cycler,
true);
178 do_set_film_size(cdata, width);
220 CDWriter cdata(_cycler,
true);
221 do_set_film_size(cdata, film_size);
228INLINE
const LVecBase2 &
Lens::
230 CDReader cdata(_cycler);
231 return do_get_film_size(cdata);
253 CDWriter cdata(_cycler,
true);
254 do_set_film_offset(cdata, film_offset);
261INLINE
const LVector2 &
Lens::
263 CDReader cdata(_cycler);
264 return do_get_film_offset(cdata);
276 CDWriter cdata(_cycler,
true);
277 do_set_focal_length(cdata, focal_length);
288 CDReader cdata(_cycler);
289 return do_get_focal_length(cdata);
299 CDWriter cdata(_cycler,
true);
300 do_set_fov(cdata, hfov);
312set_fov(PN_stdfloat hfov, PN_stdfloat vfov) {
313 set_fov(LVecBase2(hfov, vfov));
326 CDWriter cdata(_cycler,
true);
327 do_set_fov(cdata, fov);
334INLINE
const LVecBase2 &
Lens::
336 CDReader cdata(_cycler);
337 return do_get_fov(cdata);
363 CDWriter cdata(_cycler,
true);
364 do_set_aspect_ratio(cdata, aspect_ratio);
373 CDReader cdata(_cycler);
374 return do_get_aspect_ratio(cdata);
382set_near(PN_stdfloat near_distance) {
383 CDWriter cdata(_cycler,
true);
384 do_set_near(cdata, near_distance);
392 CDReader cdata(_cycler);
393 return do_get_near(cdata);
401set_far(PN_stdfloat far_distance) {
402 CDWriter cdata(_cycler,
true);
403 do_set_far(cdata, far_distance);
411 CDReader cdata(_cycler);
412 return do_get_far(cdata);
419set_near_far(PN_stdfloat near_distance, PN_stdfloat far_distance) {
421 do_set_near_far(cdata, near_distance, far_distance);
431set_view_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) {
442set_view_vector(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat i, PN_stdfloat j, PN_stdfloat k) {
459 CDWriter cdata(_cycler,
true);
460 do_set_interocular_distance(cdata, interocular_distance);
461 do_throw_change_event(cdata);
469 CDReader cdata(_cycler);
470 return cdata->_interocular_distance;
500 CDWriter cdata(_cycler,
true);
501 do_set_convergence_distance(cdata, convergence_distance);
502 do_throw_change_event(cdata);
510 CDReader cdata(_cycler);
511 return cdata->_convergence_distance;
526 CDWriter cdata(_cycler,
true);
527 do_set_view_mat(cdata, view_mat);
533INLINE
const LMatrix4 &
Lens::
535 CDReader cdata(_cycler);
536 return do_get_view_mat(cdata);
542INLINE
const LVecBase2 &
Lens::
544 CDReader cdata(_cycler);
545 return cdata->_keystone;
554 return cdata->_custom_film_mat;
565 return do_get_projection_mat(cdata, channel);
575 return do_get_projection_mat_inv(cdata, stereo_channel);
585 return do_get_film_mat(cdata);
595 return do_get_film_mat_inv(cdata);
605 return do_get_lens_mat(cdata);
615 return do_get_lens_mat_inv(cdata);
626 return cdata->_last_change;
634do_adjust_user_flags(CData *cdata,
int clear_flags,
int set_flags) {
635 cdata->_user_flags = (cdata->_user_flags & ~clear_flags) | (
short)set_flags;
643do_adjust_comp_flags(CData *cdata,
int clear_flags,
int set_flags) {
644 cdata->_comp_flags = (cdata->_comp_flags & ~clear_flags) | (
short)set_flags;
651do_set_film_offset(CData *cdata,
const LVecBase2 &film_offset) {
652 cdata->_film_offset = film_offset;
653 do_adjust_comp_flags(cdata, CF_mat, 0);
654 do_throw_change_event(cdata);
660INLINE
const LVector2 &Lens::
661do_get_film_offset(
const CData *cdata)
const {
662 return cdata->_film_offset;
669do_set_near(CData *cdata, PN_stdfloat near_distance) {
670 if (near_distance != cdata->_near_distance) {
671 cdata->_near_distance = near_distance;
672 do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv, 0);
673 do_throw_change_event(cdata);
680INLINE PN_stdfloat Lens::
681do_get_near(
const CData *cdata)
const {
682 return cdata->_near_distance;
689do_set_far(CData *cdata, PN_stdfloat far_distance) {
690 if (far_distance != cdata->_far_distance) {
691 cdata->_far_distance = far_distance;
692 do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv, 0);
693 do_throw_change_event(cdata);
700INLINE PN_stdfloat Lens::
701do_get_far(
const CData *cdata)
const {
702 return cdata->_far_distance;
709do_set_near_far(CData *cdata, PN_stdfloat near_distance, PN_stdfloat far_distance) {
710 if (near_distance != cdata->_near_distance || far_distance != cdata->_far_distance) {
711 cdata->_near_distance = near_distance;
712 cdata->_far_distance = far_distance;
713 do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv, 0);
714 do_throw_change_event(cdata);
719operator << (std::ostream &out,
const Lens &lens) {
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
A base class for any number of different kinds of lenses, linear and otherwise.
const LMatrix4 & get_custom_film_mat() const
Returns the custom_film_mat specified for the lens.
set_aspect_ratio
Sets the aspect ratio of the lens.
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,...
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 ...
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 (...
get_view_mat
Returns the direction in which the lens is facing.
get_keystone
Returns the keystone correction specified for the lens.
UpdateSeq get_last_change() const
Returns the UpdateSeq that is incremented whenever the lens properties are changed.
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,...
const LMatrix4 & get_film_mat() const
Returns the matrix that transforms from a point behind the lens to a point on the film.
set_view_hpr
Sets the direction in which the lens is facing.
get_change_event
Returns the name of the event that will be generated whenever any properties of this particular Lens ...
get_aspect_ratio
Returns the aspect ratio of the Lens.
set_film_offset
Sets the horizontal and vertical offset amounts of this Lens.
set_convergence_distance
Sets the distance between between the camera plane and the point in the distance that the left and ri...
get_far
Returns the position of the far plane (or cylinder, sphere, whatever).
const LMatrix4 & get_film_mat_inv() const
Returns the matrix that transforms from a point on the film to a point behind the lens.
set_focal_length
Sets the focal length of the lens.
set_fov
Sets the horizontal field of view of the lens without changing the aspect ratio.
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 (...
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.
set_interocular_distance
Sets the distance between the left and right eyes of a stereo camera.
get_film_offset
Returns the horizontal and vertical offset amounts of this Lens.
get_near
Returns the position of the near plane (or cylinder, sphere, whatever).
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,...
set_near
Defines the position of the near plane (or cylinder, sphere, whatever).
get_focal_length
Returns the focal length of the lens.
set_change_event
Sets the name of the event that will be generated whenever any properties of the Lens have changed.
PN_stdfloat get_hfov() const
Returns the horizontal component of fov only.
get_fov
Returns the horizontal and vertical film size of the virtual film.
get_interocular_distance
See set_interocular_distance().
get_coordinate_system
Returns the coordinate system that all 3-d computations are performed within for this Lens.
set_film_size
Sets the horizontal size of the film without changing its shape.
set_far
Defines the position of the far plane (or cylinder, sphere, whatever).
set_view_mat
Sets an arbitrary transformation on the lens.
void set_near_far(PN_stdfloat near_distance, PN_stdfloat far_distance)
Simultaneously changes the near and far planes.
get_convergence_distance
See set_convergence_distance().
get_film_size
Returns the horizontal and vertical film size of the virtual film.
const LMatrix4 & get_lens_mat() const
Returns the matrix that transforms from a point in front of the lens to a point in space.
PN_stdfloat get_vfov() const
Returns the vertical component of fov only.
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 sequence number that increments monotonically.