Panda3D

cylindricalLens.h

00001 // Filename: cylindricalLens.h
00002 // Created by:  drose (12Dec01)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef CYLINDRICALLENS_H
00016 #define CYLINDRICALLENS_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "lens.h"
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //       Class : CylindricalLens
00024 // Description : A cylindrical lens.  This is the kind of lens
00025 //               generally used for extremely wide panoramic shots.
00026 //               It behaves like a normal perspective lens in the
00027 //               vertical direction, but it is non-linear in the
00028 //               horizontal dimension: a point on the film corresponds
00029 //               to a point in space in linear proportion to its angle
00030 //               to the camera, not to its straight-line distance from
00031 //               the center.
00032 //
00033 //               This allows up to 360 degree lenses in the horizontal
00034 //               dimension, with relatively little distortion.  The
00035 //               distortion is not very apparent between two
00036 //               relatively nearby points on the film, but it becomes
00037 //               increasingly evident as you compare points widely
00038 //               spaced on the film.
00039 ////////////////////////////////////////////////////////////////////
00040 class EXPCL_PANDAFX CylindricalLens : public Lens {
00041 PUBLISHED:
00042   INLINE CylindricalLens();
00043 
00044 public:
00045   INLINE CylindricalLens(const CylindricalLens &copy);
00046   INLINE void operator = (const CylindricalLens &copy);
00047 
00048 public:
00049   virtual PT(Lens) make_copy() const;
00050 
00051 protected:
00052   virtual bool extrude_impl(const LPoint3f &point2d,
00053                             LPoint3f &near_point, LPoint3f &far_point) const;
00054   virtual bool extrude_vec_impl(const LPoint3f &point2d, LVector3f &vec) const;
00055   virtual bool project_impl(const LPoint3f &point3d, LPoint3f &point2d) const;
00056 
00057   virtual float fov_to_film(float fov, float focal_length, bool horiz) const;
00058   virtual float fov_to_focal_length(float fov, float film_size, bool horiz) const;
00059   virtual float film_to_fov(float film_size, float focal_length, bool horiz) const;
00060 
00061 public:
00062   virtual TypeHandle get_type() const {
00063     return get_class_type();
00064   }
00065   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00066   static TypeHandle get_class_type() {
00067     return _type_handle;
00068   }
00069   static void init_type() {
00070     Lens::init_type();
00071     register_type(_type_handle, "CylindricalLens",
00072                   Lens::get_class_type());
00073   }
00074 
00075 private:
00076   static TypeHandle _type_handle;
00077 };
00078 
00079 #include "cylindricalLens.I"
00080 
00081 #endif
 All Classes Functions Variables Enumerations