Panda3D
|
00001 // Filename: matrixLens.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 MATRIXLENS_H 00016 #define MATRIXLENS_H 00017 00018 #include "pandabase.h" 00019 00020 #include "lens.h" 00021 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Class : MatrixLens 00025 // Description : A completely generic linear lens. This is provided 00026 // for the benefit of low-level code that wants to 00027 // specify a perspective or orthographic frustum via an 00028 // explicit projection matrix, but not mess around with 00029 // fov's or focal lengths or any of that nonsense. 00030 //////////////////////////////////////////////////////////////////// 00031 class EXPCL_PANDA_GOBJ MatrixLens : public Lens { 00032 PUBLISHED: 00033 INLINE MatrixLens(); 00034 00035 public: 00036 INLINE MatrixLens(const MatrixLens ©); 00037 INLINE void operator = (const MatrixLens ©); 00038 00039 PUBLISHED: 00040 INLINE void set_user_mat(const LMatrix4 &user_mat); 00041 INLINE const LMatrix4 &get_user_mat() const; 00042 00043 INLINE void set_left_eye_mat(const LMatrix4 &user_mat); 00044 INLINE void clear_left_eye_mat(); 00045 INLINE bool has_left_eye_mat() const; 00046 INLINE const LMatrix4 &get_left_eye_mat() const; 00047 00048 INLINE void set_right_eye_mat(const LMatrix4 &user_mat); 00049 INLINE void clear_right_eye_mat(); 00050 INLINE bool has_right_eye_mat() const; 00051 INLINE const LMatrix4 &get_right_eye_mat() const; 00052 00053 public: 00054 virtual PT(Lens) make_copy() const; 00055 virtual bool is_linear() const; 00056 00057 virtual void write(ostream &out, int indent_level = 0) const; 00058 00059 protected: 00060 virtual void do_compute_projection_mat(Lens::CData *lens_cdata); 00061 00062 private: 00063 LMatrix4 _user_mat; 00064 LMatrix4 _left_eye_mat; 00065 LMatrix4 _right_eye_mat; 00066 00067 enum MLFlags { 00068 MF_has_left_eye = 0x001, 00069 MF_has_right_eye = 0x002, 00070 }; 00071 int _ml_flags; 00072 00073 public: 00074 static void register_with_read_factory(); 00075 00076 protected: 00077 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00078 00079 public: 00080 virtual TypeHandle get_type() const { 00081 return get_class_type(); 00082 } 00083 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00084 static TypeHandle get_class_type() { 00085 return _type_handle; 00086 } 00087 static void init_type() { 00088 Lens::init_type(); 00089 register_type(_type_handle, "MatrixLens", 00090 Lens::get_class_type()); 00091 } 00092 00093 private: 00094 static TypeHandle _type_handle; 00095 }; 00096 00097 #include "matrixLens.I" 00098 00099 #endif