Panda3D
lens.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file lens.I
10  * @author drose
11  * @date 2001-11-29
12  */
13 
14 /**
15  * Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is
16  * the center of the lens and (-1,-1) is the lower-left corner, compute the
17  * corresponding vector in space that maps to this point, if such a vector can
18  * be determined. The vector is returned by indicating the points on the near
19  * plane and far plane that both map to the indicated 2-d point.
20  *
21  * Returns true if the vector is defined, or false otherwise.
22  */
23 INLINE bool Lens::
24 extrude(const LPoint2 &point2d, LPoint3 &near_point, LPoint3 &far_point) const {
25  CDReader cdata(_cycler);
26  return do_extrude(cdata, LPoint3(point2d[0], point2d[1], 0.0f),
27  near_point, far_point);
28 }
29 
30 /**
31  * Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is
32  * the center of the lens and (-1,-1) is the lower-left corner, compute the
33  * corresponding vector in space that maps to this point, if such a vector can
34  * be determined. The vector is returned by indicating the points on the near
35  * plane and far plane that both map to the indicated 2-d point.
36  *
37  * The z coordinate of the 2-d point is ignored.
38  *
39  * Returns true if the vector is defined, or false otherwise.
40  */
41 INLINE bool Lens::
42 extrude(const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point) const {
43  CDReader cdata(_cycler);
44  return do_extrude(cdata, point2d, near_point, far_point);
45 }
46 
47 /**
48  * Uses the depth component of the 3-d result from project() to compute the
49  * original point in 3-d space corresponding to a particular point on the
50  * lens. This exactly reverses project(), assuming the point does fall
51  * legitimately within the lens.
52  */
53 INLINE bool Lens::
54 extrude_depth(const LPoint3 &point2d, LPoint3 &point3d) const {
55  CDReader cdata(_cycler);
56  return do_extrude_depth(cdata, point2d, point3d);
57 }
58 
59 /**
60  * Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is
61  * the center of the lens and (-1,-1) is the lower-left corner, compute the
62  * vector that corresponds to the view direction. This will be parallel to
63  * the normal on the surface (the far plane) corresponding to the lens shape
64  * at this point.
65  *
66  * See the comment block on Lens::extrude_vec_impl() for a more in-depth
67  * comment on the meaning of this vector.
68  *
69  * Returns true if the vector is defined, or false otherwise.
70  */
71 INLINE bool Lens::
72 extrude_vec(const LPoint2 &point2d, LVector3 &vec) const {
73  CDReader cdata(_cycler);
74  return do_extrude_vec(cdata, LPoint3(point2d[0], point2d[1], 0.0f), vec);
75 }
76 
77 /**
78  * Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is
79  * the center of the lens and (-1,-1) is the lower-left corner, compute the
80  * vector that corresponds to the view direction. This will be parallel to
81  * the normal on the surface (the far plane) corresponding to the lens shape
82  * at this point.
83  *
84  * See the comment block on Lens::extrude_vec_impl() for a more in-depth
85  * comment on the meaning of this vector.
86  *
87  * The z coordinate of the 2-d point is ignored.
88  *
89  * Returns true if the vector is defined, or false otherwise.
90  */
91 INLINE bool Lens::
92 extrude_vec(const LPoint3 &point2d, LVector3 &vec) const {
93  CDReader cdata(_cycler);
94  return do_extrude_vec(cdata, point2d, vec);
95 }
96 
97 /**
98  * Given a 3-d point in space, determine the 2-d point this maps to, in the
99  * range (-1,1) in both dimensions, where (0,0) is the center of the lens and
100  * (-1,-1) is the lower-left corner.
101  *
102  * Returns true if the 3-d point is in front of the lens and within the
103  * viewing frustum (in which case point2d is filled in), or false otherwise
104  * (in which case point2d will be filled in with something, which may or may
105  * not be meaningful).
106  */
107 INLINE bool Lens::
108 project(const LPoint3 &point3d, LPoint2 &point2d) const {
109  CDReader cdata(_cycler);
110  LPoint3 result;
111  bool okflag = do_project(cdata, point3d, result);
112  point2d.set(result[0], result[1]);
113  return okflag;
114 }
115 
116 /**
117  * Given a 3-d point in space, determine the 2-d point this maps to, in the
118  * range (-1,1) in both dimensions, where (0,0) is the center of the lens and
119  * (-1,-1) is the lower-left corner.
120  *
121  * The z coordinate will also be set to a value in the range (-1, 1), where 1
122  * represents a point on the near plane, and -1 represents a point on the far
123  * plane.
124  *
125  * Returns true if the 3-d point is in front of the lens and within the
126  * viewing frustum (in which case point2d is filled in), or false otherwise
127  * (in which case point2d will be filled in with something, which may or may
128  * not be meaningful).
129  */
130 INLINE bool Lens::
131 project(const LPoint3 &point3d, LPoint3 &point2d) const {
132  CDReader cdata(_cycler);
133  return do_project(cdata, point3d, point2d);
134 }
135 
136 /**
137  * Sets the name of the event that will be generated whenever any properties
138  * of the Lens have changed. If this is not set for a particular lens, no
139  * event will be generated.
140  *
141  * The event is thrown with one parameter, the lens itself. This can be used
142  * to automatically track changes to camera fov, etc. in the application.
143  */
144 INLINE void Lens::
145 set_change_event(const std::string &event) {
146  CDWriter cdata(_cycler, true);
147  cdata->_change_event = event;
148 }
149 
150 /**
151  * Returns the name of the event that will be generated whenever any
152  * properties of this particular Lens have changed.
153  */
154 INLINE const std::string &Lens::
155 get_change_event() const {
156  CDReader cdata(_cycler);
157  return cdata->_change_event;
158 }
159 
160 /**
161  * Returns the coordinate system that all 3-d computations are performed
162  * within for this Lens. Normally, this is CS_default.
163  */
164 INLINE CoordinateSystem Lens::
165 get_coordinate_system() const {
166  CDReader cdata(_cycler);
167  return cdata->_cs;
168 }
169 
170 /**
171  * Sets the horizontal size of the film without changing its shape. The
172  * aspect ratio remains unchanged; this computes the vertical size of the film
173  * to automatically maintain the aspect ratio.
174  */
175 INLINE void Lens::
176 set_film_size(PN_stdfloat width) {
177  CDWriter cdata(_cycler, true);
178  do_set_film_size(cdata, width);
179 }
180 
181 /**
182  * Sets the size and shape of the "film" within the lens. This both
183  * establishes the units used by calls like set_focal_length(), and
184  * establishes the aspect ratio of the frame.
185  *
186  * In a physical camera, the field of view of a lens is determined by the
187  * lens' focal length and by the size of the film area exposed by the lens.
188  * For instance, a 35mm camera exposes a rectangle on the film about 24mm x
189  * 36mm, which means a 50mm lens gives about a 40-degree horizontal field of
190  * view.
191  *
192  * In the virtual camera, you may set the film size to any units here, and
193  * specify a focal length in the same units to simulate the same effect. Or,
194  * you may ignore this parameter, and specify the field of view and aspect
195  * ratio of the lens directly.
196  */
197 INLINE void Lens::
198 set_film_size(PN_stdfloat width, PN_stdfloat height) {
199  set_film_size(LVecBase2(width, height));
200 }
201 
202 /**
203  * Sets the size and shape of the "film" within the lens. This both
204  * establishes the units used by calls like set_focal_length(), and
205  * establishes the aspect ratio of the frame.
206  *
207  * In a physical camera, the field of view of a lens is determined by the
208  * lens' focal length and by the size of the film area exposed by the lens.
209  * For instance, a 35mm camera exposes a rectangle on the film about 24mm x
210  * 36mm, which means a 50mm lens gives about a 40-degree horizontal field of
211  * view.
212  *
213  * In the virtual camera, you may set the film size to any units here, and
214  * specify a focal length in the same units to simulate the same effect. Or,
215  * you may ignore this parameter, and specify the field of view and aspect
216  * ratio of the lens directly.
217  */
218 INLINE void Lens::
219 set_film_size(const LVecBase2 &film_size) {
220  CDWriter cdata(_cycler, true);
221  do_set_film_size(cdata, film_size);
222 }
223 
224 /**
225  * Returns the horizontal and vertical film size of the virtual film. See
226  * set_film_size().
227  */
228 INLINE const LVecBase2 &Lens::
229 get_film_size() const {
230  CDReader cdata(_cycler);
231  return do_get_film_size(cdata);
232 }
233 
234 /**
235  * Sets the horizontal and vertical offset amounts of this Lens. These are
236  * both in the same units specified in set_film_size().
237  *
238  * This can be used to establish an off-axis lens.
239  */
240 INLINE void Lens::
241 set_film_offset(PN_stdfloat x, PN_stdfloat y) {
242  set_film_offset(LVecBase2(x, y));
243 }
244 
245 /**
246  * Sets the horizontal and vertical offset amounts of this Lens. These are
247  * both in the same units specified in set_film_size().
248  *
249  * This can be used to establish an off-axis lens.
250  */
251 INLINE void Lens::
252 set_film_offset(const LVecBase2 &film_offset) {
253  CDWriter cdata(_cycler, true);
254  do_set_film_offset(cdata, film_offset);
255 }
256 
257 /**
258  * Returns the horizontal and vertical offset amounts of this Lens. See
259  * set_film_offset().
260  */
261 INLINE const LVector2 &Lens::
262 get_film_offset() const {
263  CDReader cdata(_cycler);
264  return do_get_film_offset(cdata);
265 }
266 
267 /**
268  * Sets the focal length of the lens. This may adjust the field-of-view
269  * correspondingly, and is an alternate way to specify field of view.
270  *
271  * For certain kinds of lenses (e.g. OrthographicLens), the focal length has
272  * no meaning.
273  */
274 INLINE void Lens::
275 set_focal_length(PN_stdfloat focal_length) {
276  CDWriter cdata(_cycler, true);
277  do_set_focal_length(cdata, focal_length);
278 }
279 
280 /**
281  * Returns the focal length of the lens. This may have been set explicitly by
282  * a previous call to set_focal_length(), or it may be computed based on the
283  * lens' fov and film_size. For certain kinds of lenses, the focal length has
284  * no meaning.
285  */
286 INLINE PN_stdfloat Lens::
287 get_focal_length() const {
288  CDReader cdata(_cycler);
289  return do_get_focal_length(cdata);
290 }
291 
292 /**
293  * Sets the horizontal field of view of the lens without changing the aspect
294  * ratio. The vertical field of view is adjusted to maintain the same aspect
295  * ratio.
296  */
297 INLINE void Lens::
298 set_fov(PN_stdfloat hfov) {
299  CDWriter cdata(_cycler, true);
300  do_set_fov(cdata, hfov);
301 }
302 
303 /**
304  * Sets the field of view of the lens in both dimensions. This establishes
305  * both the field of view and the aspect ratio of the lens. This is one way
306  * to specify the field of view of a lens; set_focal_length() is another way.
307  *
308  * For certain kinds of lenses (like OrthoLens), the field of view has no
309  * meaning.
310  */
311 INLINE void Lens::
312 set_fov(PN_stdfloat hfov, PN_stdfloat vfov) {
313  set_fov(LVecBase2(hfov, vfov));
314 }
315 
316 /**
317  * Sets the field of view of the lens in both dimensions. This establishes
318  * both the field of view and the aspect ratio of the lens. This is one way
319  * to specify the field of view of a lens; set_focal_length() is another way.
320  *
321  * For certain kinds of lenses (like OrthographicLens), the field of view has
322  * no meaning.
323  */
324 INLINE void Lens::
325 set_fov(const LVecBase2 &fov) {
326  CDWriter cdata(_cycler, true);
327  do_set_fov(cdata, fov);
328 }
329 
330 /**
331  * Returns the horizontal and vertical film size of the virtual film. See
332  * set_fov().
333  */
334 INLINE const LVecBase2 &Lens::
335 get_fov() const {
336  CDReader cdata(_cycler);
337  return do_get_fov(cdata);
338 }
339 
340 /**
341  * Returns the horizontal component of fov only. See get_fov().
342  */
343 INLINE PN_stdfloat Lens::
344 get_hfov() const {
345  return get_fov()[0];
346 }
347 
348 /**
349  * Returns the vertical component of fov only. See get_fov().
350  */
351 INLINE PN_stdfloat Lens::
352 get_vfov() const {
353  return get_fov()[1];
354 }
355 
356 /**
357  * Sets the aspect ratio of the lens. This is the ratio of the height to the
358  * width of the generated image. Setting this overrides the two-parameter fov
359  * or film size setting.
360  */
361 INLINE void Lens::
362 set_aspect_ratio(PN_stdfloat aspect_ratio) {
363  CDWriter cdata(_cycler, true);
364  do_set_aspect_ratio(cdata, aspect_ratio);
365 }
366 
367 /**
368  * Returns the aspect ratio of the Lens. This is determined based on the
369  * indicated film size; see set_film_size().
370  */
371 INLINE PN_stdfloat Lens::
372 get_aspect_ratio() const {
373  CDReader cdata(_cycler);
374  return do_get_aspect_ratio(cdata);
375 }
376 
377 /**
378  * Defines the position of the near plane (or cylinder, sphere, whatever).
379  * Points closer to the lens than this may not be rendered.
380  */
381 INLINE void Lens::
382 set_near(PN_stdfloat near_distance) {
383  CDWriter cdata(_cycler, true);
384  do_set_near(cdata, near_distance);
385 }
386 
387 /**
388  * Returns the position of the near plane (or cylinder, sphere, whatever).
389  */
390 INLINE PN_stdfloat Lens::
391 get_near() const {
392  CDReader cdata(_cycler);
393  return do_get_near(cdata);
394 }
395 
396 /**
397  * Defines the position of the far plane (or cylinder, sphere, whatever).
398  * Points farther from the lens than this may not be rendered.
399  */
400 INLINE void Lens::
401 set_far(PN_stdfloat far_distance) {
402  CDWriter cdata(_cycler, true);
403  do_set_far(cdata, far_distance);
404 }
405 
406 /**
407  * Returns the position of the far plane (or cylinder, sphere, whatever).
408  */
409 INLINE PN_stdfloat Lens::
410 get_far() const {
411  CDReader cdata(_cycler);
412  return do_get_far(cdata);
413 }
414 
415 /**
416  * Simultaneously changes the near and far planes.
417  */
418 INLINE void Lens::
419 set_near_far(PN_stdfloat near_distance, PN_stdfloat far_distance) {
420  CDWriter cdata(_cycler, true);
421  do_set_near_far(cdata, near_distance, far_distance);
422 }
423 
424 /**
425  * Sets the direction in which the lens is facing. Normally, this is down the
426  * forward axis (usually the Y axis), but it may be rotated. This is only one
427  * way of specifying the rotation; you may also specify an explicit vector in
428  * which to look, or you may give a complete transformation matrix.
429  */
430 INLINE void Lens::
431 set_view_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) {
432  set_view_hpr(LVecBase3(h, p, r));
433 }
434 
435 /**
436  * Specifies the direction in which the lens is facing by giving an axis to
437  * look along, and a perpendicular (or at least non-parallel) up axis.
438  *
439  * See also set_view_hpr().
440  */
441 INLINE void Lens::
442 set_view_vector(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat i, PN_stdfloat j, PN_stdfloat k) {
443  set_view_vector(LVector3(x, y, z), LVector3(i, j, k));
444 }
445 
446 /**
447  * Sets the distance between the left and right eyes of a stereo camera. This
448  * distance is used to apply a stereo effect when the lens is rendered on a
449  * stereo display region. It only has an effect on a PerspectiveLens.
450  *
451  * The left eye and the right eye are each offset along the X axis by half of
452  * this distance, so that this parameter specifies the total distance between
453  * them.
454  *
455  * Also see set_convergence_distance(), which relates.
456  */
457 INLINE void Lens::
458 set_interocular_distance(PN_stdfloat interocular_distance) {
459  CDWriter cdata(_cycler, true);
460  do_set_interocular_distance(cdata, interocular_distance);
461  do_throw_change_event(cdata);
462 }
463 
464 /**
465  * See set_interocular_distance().
466  */
467 INLINE PN_stdfloat Lens::
468 get_interocular_distance() const {
469  CDReader cdata(_cycler);
470  return cdata->_interocular_distance;
471 }
472 
473 /**
474  * Sets the distance between between the camera plane and the point in the
475  * distance that the left and right eyes are both looking at. This distance
476  * is used to apply a stereo effect when the lens is rendered on a stereo
477  * display region. It only has an effect on a PerspectiveLens.
478  *
479  * This parameter must be greater than 0, but may be as large as you like. It
480  * controls the distance at which the two stereo images will appear to
481  * converge, which is a normal property of stereo vision. Normally this
482  * should be set to the distance from the camera to the area of interest in
483  * your scene. Anything beyond this distance will appear to go into the
484  * screen, and anything closer will appear to come out of the screen. If you
485  * want to simulate parallel stereo, set this to infinity.
486  *
487  * Note that this creates an off-axis frustum, which means that the lenses are
488  * still pointing in the same direction, which is usually more desirable than
489  * the more naive toe-in approach, where the two lenses are simply tilted
490  * toward each other.
491  *
492  * Prior to Panda3D 1.9.0, the convergence was being calculated incorrectly.
493  * It has since been corrected. To restore the legacy behavior you can set
494  * the stereo-lens-old-convergence variable to true.
495  *
496  * Also see set_interocular_distance(), which relates.
497  */
498 INLINE void Lens::
499 set_convergence_distance(PN_stdfloat convergence_distance) {
500  CDWriter cdata(_cycler, true);
501  do_set_convergence_distance(cdata, convergence_distance);
502  do_throw_change_event(cdata);
503 }
504 
505 /**
506  * See set_convergence_distance().
507  */
508 INLINE PN_stdfloat Lens::
509 get_convergence_distance() const {
510  CDReader cdata(_cycler);
511  return cdata->_convergence_distance;
512 }
513 
514 /**
515  * Sets an arbitrary transformation on the lens. This replaces the individual
516  * transformation components like set_view_hpr().
517  *
518  * Setting a transformation here will have a slightly different effect than
519  * putting one on the LensNode that contains this lens. In particular,
520  * lighting and other effects computations will still be performed on the lens
521  * in its untransformed (facing forward) position, but the actual projection
522  * matrix will be transformed by this matrix.
523  */
524 INLINE void Lens::
525 set_view_mat(const LMatrix4 &view_mat) {
526  CDWriter cdata(_cycler, true);
527  do_set_view_mat(cdata, view_mat);
528 }
529 
530 /**
531  * Returns the direction in which the lens is facing.
532  */
533 INLINE const LMatrix4 &Lens::
534 get_view_mat() const {
535  CDReader cdata(_cycler);
536  return do_get_view_mat(cdata);
537 }
538 
539 /**
540  * Returns the keystone correction specified for the lens.
541  */
542 INLINE const LVecBase2 &Lens::
543 get_keystone() const {
544  CDReader cdata(_cycler);
545  return cdata->_keystone;
546 }
547 
548 /**
549  * Returns the custom_film_mat specified for the lens.
550  */
551 INLINE const LMatrix4 &Lens::
553  CDReader cdata(_cycler);
554  return cdata->_custom_film_mat;
555 }
556 
557 /**
558  * Returns the complete transformation matrix from a 3-d point in space to a
559  * point on the film, if such a matrix exists, or the identity matrix if the
560  * lens is nonlinear.
561  */
562 INLINE const LMatrix4 &Lens::
563 get_projection_mat(StereoChannel channel) const {
564  CDReader cdata(_cycler);
565  return do_get_projection_mat(cdata, channel);
566 }
567 
568 /**
569  * Returns the matrix that transforms from a 2-d point on the film to a 3-d
570  * vector in space, if such a matrix exists.
571  */
572 INLINE const LMatrix4 &Lens::
573 get_projection_mat_inv(StereoChannel stereo_channel) const {
574  CDReader cdata(_cycler);
575  return do_get_projection_mat_inv(cdata, stereo_channel);
576 }
577 
578 /**
579  * Returns the matrix that transforms from a point behind the lens to a point
580  * on the film.
581  */
582 INLINE const LMatrix4 &Lens::
583 get_film_mat() const {
584  CDReader cdata(_cycler);
585  return do_get_film_mat(cdata);
586 }
587 
588 /**
589  * Returns the matrix that transforms from a point on the film to a point
590  * behind the lens.
591  */
592 INLINE const LMatrix4 &Lens::
594  CDReader cdata(_cycler);
595  return do_get_film_mat_inv(cdata);
596 }
597 
598 /**
599  * Returns the matrix that transforms from a point in front of the lens to a
600  * point in space.
601  */
602 INLINE const LMatrix4 &Lens::
603 get_lens_mat() const {
604  CDReader cdata(_cycler);
605  return do_get_lens_mat(cdata);
606 }
607 
608 /**
609  * Returns the matrix that transforms from a point in space to a point in
610  * front of the lens.
611  */
612 INLINE const LMatrix4 &Lens::
614  CDReader cdata(_cycler);
615  return do_get_lens_mat_inv(cdata);
616 }
617 
618 /**
619  * Returns the UpdateSeq that is incremented whenever the lens properties are
620  * changed. As long as this number remains the same, you may assume the lens
621  * properties are unchanged.
622  */
623 INLINE UpdateSeq Lens::
625  CDReader cdata(_cycler);
626  return cdata->_last_change;
627 }
628 
629 /**
630  * Clears from _user_flags the bits in the first parameter, and sets the bits
631  * in the second parameter.
632  */
633 INLINE void Lens::
634 do_adjust_user_flags(CData *cdata, int clear_flags, int set_flags) {
635  cdata->_user_flags = (cdata->_user_flags & ~clear_flags) | (short)set_flags;
636 }
637 
638 /**
639  * Clears from _comp_flags the bits in the first parameter, and sets the bits
640  * in the second parameter.
641  */
642 INLINE void Lens::
643 do_adjust_comp_flags(CData *cdata, int clear_flags, int set_flags) {
644  cdata->_comp_flags = (cdata->_comp_flags & ~clear_flags) | (short)set_flags;
645 }
646 
647 /**
648  *
649  */
650 INLINE void Lens::
651 do_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);
655 }
656 
657 /**
658  *
659  */
660 INLINE const LVector2 &Lens::
661 do_get_film_offset(const CData *cdata) const {
662  return cdata->_film_offset;
663 }
664 
665 /**
666  *
667  */
668 INLINE void Lens::
669 do_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);
674  }
675 }
676 
677 /**
678  *
679  */
680 INLINE PN_stdfloat Lens::
681 do_get_near(const CData *cdata) const {
682  return cdata->_near_distance;
683 }
684 
685 /**
686  *
687  */
688 INLINE void Lens::
689 do_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);
694  }
695 }
696 
697 /**
698  *
699  */
700 INLINE PN_stdfloat Lens::
701 do_get_far(const CData *cdata) const {
702  return cdata->_far_distance;
703 }
704 
705 /**
706  *
707  */
708 INLINE void Lens::
709 do_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);
715  }
716 }
717 
718 INLINE std::ostream &
719 operator << (std::ostream &out, const Lens &lens) {
720  lens.output(out);
721  return out;
722 }
const LMatrix4 & get_custom_film_mat() const
Returns the custom_film_mat specified for the lens.
Definition: lens.I:552
set_focal_length
Sets the focal length of the lens.
Definition: lens.h:91
A base class for any number of different kinds of lenses, linear and otherwise.
Definition: lens.h:41
PN_stdfloat get_vfov() const
Returns the vertical component of fov only.
Definition: lens.I:352
set_view_hpr
Sets the direction in which the lens is facing.
Definition: lens.h:122
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.
Definition: lens.I:613
PN_stdfloat get_hfov() const
Returns the horizontal component of fov only.
Definition: lens.I:344
set_interocular_distance
Sets the distance between the left and right eyes of a stereo camera.
Definition: lens.h:135
set_aspect_ratio
Sets the aspect ratio of the lens.
Definition: lens.h:106
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
void set_near_far(PN_stdfloat near_distance, PN_stdfloat far_distance)
Simultaneously changes the near and far planes.
Definition: lens.I:419
get_fov
Returns the horizontal and vertical film size of the virtual film.
Definition: lens.h:101
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,...
Definition: lens.I:131
set_near
Defines the position of the near plane (or cylinder, sphere, whatever).
Definition: lens.h:113
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,...
Definition: lens.I:573
set_film_size
Sets the horizontal size of the film without changing its shape.
Definition: lens.h:82
const LMatrix4 & get_film_mat() const
Returns the matrix that transforms from a point behind the lens to a point on the film.
Definition: lens.I:583
set_film_offset
Sets the horizontal and vertical offset amounts of this Lens.
Definition: lens.h:87
set_convergence_distance
Sets the distance between between the camera plane and the point in the distance that the left and ri...
Definition: lens.h:136
UpdateSeq get_last_change() const
Returns the UpdateSeq that is incremented whenever the lens properties are changed.
Definition: lens.I:624
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 (...
Definition: lens.I:72
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
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,...
Definition: lens.I:563
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 (...
Definition: lens.I:24
set_far
Defines the position of the far plane (or cylinder, sphere, whatever).
Definition: lens.h:114
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 ...
Definition: lens.I:54
This is a sequence number that increments monotonically.
Definition: updateSeq.h:37
set_view_mat
Sets an arbitrary transformation on the lens.
Definition: lens.h:141
const LMatrix4 & get_lens_mat() const
Returns the matrix that transforms from a point in front of the lens to a point in space.
Definition: lens.I:603
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,...
Definition: lens.I:442
const LMatrix4 & get_film_mat_inv() const
Returns the matrix that transforms from a point on the film to a point behind the lens.
Definition: lens.I:593
set_change_event
Sets the name of the event that will be generated whenever any properties of the Lens have changed.
Definition: lens.h:69
set_fov
Sets the horizontal field of view of the lens without changing the aspect ratio.
Definition: lens.h:101