Panda3D
 All Classes Functions Variables Enumerations
matrixLens.h
1 // Filename: matrixLens.h
2 // Created by: drose (12Dec01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef MATRIXLENS_H
16 #define MATRIXLENS_H
17 
18 #include "pandabase.h"
19 
20 #include "lens.h"
21 
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : MatrixLens
25 // Description : A completely generic linear lens. This is provided
26 // for the benefit of low-level code that wants to
27 // specify a perspective or orthographic frustum via an
28 // explicit projection matrix, but not mess around with
29 // fov's or focal lengths or any of that nonsense.
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_PANDA_GOBJ MatrixLens : public Lens {
32 PUBLISHED:
33  INLINE MatrixLens();
34 
35 public:
36  INLINE MatrixLens(const MatrixLens &copy);
37  INLINE void operator = (const MatrixLens &copy);
38 
39 PUBLISHED:
40  INLINE void set_user_mat(const LMatrix4 &user_mat);
41  INLINE const LMatrix4 &get_user_mat() const;
42 
43  INLINE void set_left_eye_mat(const LMatrix4 &user_mat);
44  INLINE void clear_left_eye_mat();
45  INLINE bool has_left_eye_mat() const;
46  INLINE const LMatrix4 &get_left_eye_mat() const;
47 
48  INLINE void set_right_eye_mat(const LMatrix4 &user_mat);
49  INLINE void clear_right_eye_mat();
50  INLINE bool has_right_eye_mat() const;
51  INLINE const LMatrix4 &get_right_eye_mat() const;
52 
53 public:
54  virtual PT(Lens) make_copy() const;
55  virtual bool is_linear() const;
56 
57  virtual void write(ostream &out, int indent_level = 0) const;
58 
59 protected:
60  virtual void do_compute_projection_mat(Lens::CData *lens_cdata);
61 
62 private:
63  LMatrix4 _user_mat;
64  LMatrix4 _left_eye_mat;
65  LMatrix4 _right_eye_mat;
66 
67  enum MLFlags {
68  MF_has_left_eye = 0x001,
69  MF_has_right_eye = 0x002,
70  };
71  int _ml_flags;
72 
73 public:
74  static void register_with_read_factory();
75 
76 protected:
77  static TypedWritable *make_from_bam(const FactoryParams &params);
78 
79 public:
80  virtual TypeHandle get_type() const {
81  return get_class_type();
82  }
83  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
84  static TypeHandle get_class_type() {
85  return _type_handle;
86  }
87  static void init_type() {
88  Lens::init_type();
89  register_type(_type_handle, "MatrixLens",
90  Lens::get_class_type());
91  }
92 
93 private:
94  static TypeHandle _type_handle;
95 };
96 
97 #include "matrixLens.I"
98 
99 #endif
A base class for any number of different kinds of lenses, linear and otherwise.
Definition: lens.h:45
A completely generic linear lens.
Definition: matrixLens.h:31
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
virtual bool is_linear() const
Returns true if the lens represents a linear projection (e.g.
Definition: lens.cxx:615
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85