Panda3D
pSphereLens.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 pSphereLens.h
10  * @author drose
11  * @date 2001-12-12
12  */
13 
14 #ifndef PSPHERELENS_H
15 #define PSPHERELENS_H
16 
17 #include "pandabase.h"
18 
19 #include "lens.h"
20 
21 /**
22  * A PSphereLens is a special nonlinear lens that doesn't correspond to any
23  * real physical lenses. It's primarily useful for generating 360-degree
24  * wraparound images while avoiding the distortion associated with fisheye
25  * images.
26  *
27  * A PSphereLens is similar to a cylindrical lens, except it is also curved in
28  * the vertical direction. This allows it to extend to both poles in the
29  * vertical direction. The mapping is similar to what many modeling packages
30  * call a sphere mapping: the x coordinate is proportional to azimuth, while
31  * the y coordinate is proportional to altitude.
32  */
33 class EXPCL_PANDAFX PSphereLens : public Lens {
34 PUBLISHED:
35  INLINE PSphereLens();
36 
37 public:
38  INLINE PSphereLens(const PSphereLens &copy);
39  INLINE void operator = (const PSphereLens &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_project(const Lens::CData *lens_cdata,
48  const LPoint3 &point3d, LPoint3 &point2d) const;
49 
50  virtual PN_stdfloat fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool horiz) const;
51  virtual PN_stdfloat fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool horiz) const;
52  virtual PN_stdfloat film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, bool horiz) const;
53 
54 public:
55  virtual TypeHandle get_type() const {
56  return get_class_type();
57  }
58  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
59  static TypeHandle get_class_type() {
60  return _type_handle;
61  }
62  static void init_type() {
63  Lens::init_type();
64  register_type(_type_handle, "PSphereLens",
65  Lens::get_class_type());
66  }
67 
68 private:
69  static TypeHandle _type_handle;
70 };
71 
72 #include "pSphereLens.I"
73 
74 #endif
A PSphereLens is a special nonlinear lens that doesn't correspond to any real physical lenses.
Definition: pSphereLens.h:33
A base class for any number of different kinds of lenses, linear and otherwise.
Definition: lens.h:41
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81