Panda3D
matrixLens.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 matrixLens.h
10 * @author drose
11 * @date 2001-12-12
12 */
13
14#ifndef MATRIXLENS_H
15#define MATRIXLENS_H
16
17#include "pandabase.h"
18
19#include "lens.h"
20
21
22/**
23 * A completely generic linear lens. This is provided for the benefit of low-
24 * level code that wants to specify a perspective or orthographic frustum via
25 * an explicit projection matrix, but not mess around with fov's or focal
26 * lengths or any of that nonsense.
27 */
28class EXPCL_PANDA_GOBJ MatrixLens : public Lens {
29PUBLISHED:
30 INLINE MatrixLens();
31
32public:
33 INLINE MatrixLens(const MatrixLens &copy);
34 INLINE void operator = (const MatrixLens &copy);
35
36PUBLISHED:
37 INLINE void set_user_mat(const LMatrix4 &user_mat);
38 INLINE const LMatrix4 &get_user_mat() const;
39 MAKE_PROPERTY(user_mat, get_user_mat, set_user_mat);
40
41 INLINE void set_left_eye_mat(const LMatrix4 &user_mat);
42 INLINE void clear_left_eye_mat();
43 INLINE bool has_left_eye_mat() const;
44 INLINE const LMatrix4 &get_left_eye_mat() const;
45
46 INLINE void set_right_eye_mat(const LMatrix4 &user_mat);
47 INLINE void clear_right_eye_mat();
48 INLINE bool has_right_eye_mat() const;
49 INLINE const LMatrix4 &get_right_eye_mat() const;
50
51public:
52 virtual PT(Lens) make_copy() const;
53 virtual bool is_linear() const;
54
55 virtual void write(std::ostream &out, int indent_level = 0) const;
56
57protected:
58 virtual void do_compute_projection_mat(Lens::CData *lens_cdata);
59
60private:
61 LMatrix4 _user_mat;
62 LMatrix4 _left_eye_mat;
63 LMatrix4 _right_eye_mat;
64
65 enum MLFlags {
66 MF_has_left_eye = 0x001,
67 MF_has_right_eye = 0x002,
68 };
69 int _ml_flags;
70
71public:
72 static void register_with_read_factory();
73 virtual void write_datagram(BamWriter *manager, Datagram &dg);
74
75protected:
76 static TypedWritable *make_from_bam(const FactoryParams &params);
77 void fillin(DatagramIterator &scan, BamReader *manager);
78
79public:
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
93private:
94 static TypeHandle _type_handle;
95};
96
97#include "matrixLens.I"
98
99#endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
A base class for any number of different kinds of lenses, linear and otherwise.
Definition: lens.h:41
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: lens.cxx:1852
A completely generic linear lens.
Definition: matrixLens.h:28
virtual bool is_linear() const
Returns true if the lens represents a linear projection (e.g.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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