Panda3D
cylindricalLens.h
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 cylindricalLens.h
10  * @author drose
11  * @date 2001-12-12
12  */
13 
14 #ifndef CYLINDRICALLENS_H
15 #define CYLINDRICALLENS_H
16 
17 #include "pandabase.h"
18 
19 #include "lens.h"
20 
21 /**
22  * A cylindrical lens. This is the kind of lens generally used for extremely
23  * wide panoramic shots. It behaves like a normal perspective lens in the
24  * vertical direction, but it is non-linear in the horizontal dimension: a
25  * point on the film corresponds to a point in space in linear proportion to
26  * its angle to the camera, not to its straight-line distance from the center.
27  *
28  * This allows up to 360 degree lenses in the horizontal dimension, with
29  * relatively little distortion. The distortion is not very apparent between
30  * two relatively nearby points on the film, but it becomes increasingly
31  * evident as you compare points widely spaced on the film.
32  */
33 class EXPCL_PANDAFX CylindricalLens : public Lens {
34 PUBLISHED:
35  INLINE CylindricalLens();
36 
37 public:
38  INLINE CylindricalLens(const CylindricalLens &copy);
39  INLINE void operator = (const CylindricalLens &copy);
40 
41 public:
42  virtual PT(Lens) make_copy() const;
43 
44 protected:
45  virtual bool do_extrude(const Lens::CData *lens_cdata, const LPoint3 &point2d,
46  LPoint3 &near_point, LPoint3 &far_point) const;
47  virtual bool do_extrude_vec(const Lens::CData *lens_cdata, const LPoint3 &point2d,
48  LVector3 &vec) const;
49  virtual bool do_project(const Lens::CData *lens_cdata,
50  const LPoint3 &point3d, LPoint3 &point2d) const;
51 
52  virtual PN_stdfloat fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool horiz) const;
53  virtual PN_stdfloat fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool horiz) const;
54  virtual PN_stdfloat film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, bool horiz) const;
55 
56 public:
57  virtual TypeHandle get_type() const {
58  return get_class_type();
59  }
60  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
61  static TypeHandle get_class_type() {
62  return _type_handle;
63  }
64  static void init_type() {
65  Lens::init_type();
66  register_type(_type_handle, "CylindricalLens",
67  Lens::get_class_type());
68  }
69 
70 private:
71  static TypeHandle _type_handle;
72 };
73 
74 #include "cylindricalLens.I"
75 
76 #endif
A base class for any number of different kinds of lenses, linear and otherwise.
Definition: lens.h:41
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A cylindrical lens.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81