18 #include "pandabase.h" 20 #include "typedWritableReferenceCount.h" 23 #include "updateSeq.h" 24 #include "geomVertexData.h" 25 #include "pointerTo.h" 26 #include "cycleData.h" 27 #include "cycleDataReader.h" 28 #include "cycleDataWriter.h" 29 #include "pipelineCycler.h" 49 void operator = (
const Lens ©);
59 virtual PT(
Lens) make_copy()
const=0;
61 INLINE
bool extrude(
const LPoint2 &point2d,
63 INLINE
bool extrude(
const LPoint3 &point2d,
65 INLINE
bool extrude_depth(
const LPoint3 &point2d,
LPoint3 &point3d)
const;
68 INLINE
bool project(
const LPoint3 &point3d,
LPoint3 &point2d)
const;
69 INLINE
bool project(
const LPoint3 &point3d,
LPoint2 &point2d)
const;
71 INLINE
void set_change_event(
const string &event);
72 INLINE
const string &get_change_event()
const;
74 void set_coordinate_system(CoordinateSystem cs);
75 INLINE CoordinateSystem get_coordinate_system()
const;
79 INLINE
void set_film_size(PN_stdfloat width);
80 INLINE
void set_film_size(PN_stdfloat width, PN_stdfloat height);
81 INLINE
void set_film_size(
const LVecBase2 &film_size);
82 INLINE
const LVecBase2 &get_film_size()
const;
84 INLINE
void set_film_offset(PN_stdfloat x, PN_stdfloat y);
85 INLINE
void set_film_offset(
const LVecBase2 &film_offset);
86 INLINE
const LVector2 &get_film_offset()
const;
88 INLINE
void set_focal_length(PN_stdfloat focal_length);
89 INLINE PN_stdfloat get_focal_length()
const;
91 void set_min_fov(PN_stdfloat min_fov);
92 INLINE
void set_fov(PN_stdfloat fov);
93 INLINE
void set_fov(PN_stdfloat hfov, PN_stdfloat vfov);
94 INLINE
void set_fov(
const LVecBase2 &fov);
96 INLINE PN_stdfloat get_hfov()
const;
97 INLINE PN_stdfloat get_vfov()
const;
98 PN_stdfloat get_min_fov()
const;
100 INLINE
void set_aspect_ratio(PN_stdfloat aspect_ratio);
101 INLINE PN_stdfloat get_aspect_ratio()
const;
103 INLINE
void set_near(PN_stdfloat near_distance);
104 INLINE PN_stdfloat get_near()
const;
105 INLINE
void set_far(PN_stdfloat far_distance);
106 INLINE PN_stdfloat get_far()
const;
107 INLINE
void set_near_far(PN_stdfloat near_distance, PN_stdfloat far_distance);
109 static PN_stdfloat get_default_near();
110 static PN_stdfloat get_default_far();
112 INLINE
void set_view_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r);
113 void set_view_hpr(
const LVecBase3 &view_hpr);
115 INLINE
void set_view_vector(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat i, PN_stdfloat j, PN_stdfloat k);
116 void set_view_vector(
const LVector3 &view_vector,
const LVector3 &up_vector);
117 const LVector3 &get_view_vector()
const;
118 const LVector3 &get_up_vector()
const;
119 LPoint3 get_nodal_point()
const;
121 INLINE
void set_interocular_distance(PN_stdfloat interocular_distance);
122 INLINE PN_stdfloat get_interocular_distance()
const;
123 INLINE
void set_convergence_distance(PN_stdfloat convergence_distance);
124 INLINE PN_stdfloat get_convergence_distance()
const;
126 INLINE
void set_view_mat(
const LMatrix4 &view_mat);
127 INLINE
const LMatrix4 &get_view_mat()
const;
128 void clear_view_mat();
130 void set_keystone(
const LVecBase2 &keystone);
131 INLINE
const LVecBase2 &get_keystone()
const;
132 void clear_keystone();
134 void set_custom_film_mat(
const LMatrix4 &custom_film_mat);
135 INLINE
const LMatrix4 &get_custom_film_mat()
const;
136 void clear_custom_film_mat();
143 FC_camera_plane = 0x0002,
144 FC_off_axis = 0x0004,
145 FC_aspect_ratio = 0x0008,
147 FC_keystone = 0x0020,
153 void recompute_all();
155 virtual bool is_linear()
const;
156 virtual bool is_perspective()
const;
157 virtual bool is_orthographic()
const;
158 virtual PT(
Geom) make_geometry();
162 INLINE
const LMatrix4 &get_projection_mat(StereoChannel channel = SC_mono)
const;
163 INLINE
const LMatrix4 &get_projection_mat_inv(StereoChannel channel = SC_mono)
const;
165 INLINE
const LMatrix4 &get_film_mat()
const;
166 INLINE
const LMatrix4 &get_film_mat_inv()
const;
168 INLINE
const LMatrix4 &get_lens_mat()
const;
169 INLINE
const LMatrix4 &get_lens_mat_inv()
const;
171 virtual void output(ostream &out)
const;
172 virtual void write(ostream &out,
int indent_level = 0)
const;
174 INLINE
UpdateSeq get_last_change()
const;
179 INLINE
void do_adjust_user_flags(CData *cdata,
int clear_flags,
int set_flags);
180 INLINE
void do_adjust_comp_flags(CData *cdata,
int clear_flags,
int set_flags);
182 void do_set_film_size(CData *cdata, PN_stdfloat width);
183 void do_set_film_size(CData *cdata,
const LVecBase2 &film_size);
184 const LVecBase2 &do_get_film_size(
const CData *cdata)
const;
186 INLINE
void do_set_film_offset(CData *cdata,
const LVecBase2 &film_offset);
187 INLINE
const LVector2 &do_get_film_offset(
const CData *cdata)
const;
189 void do_set_focal_length(CData *cdata, PN_stdfloat focal_length);
190 PN_stdfloat do_get_focal_length(
const CData *cdata)
const;
192 void do_set_fov(CData *cdata, PN_stdfloat fov);
193 void do_set_fov(CData *cdata,
const LVecBase2 &fov);
194 const LVecBase2 &do_get_fov(
const CData *cdata)
const;
196 void do_set_aspect_ratio(CData *cdata, PN_stdfloat aspect_ratio);
197 PN_stdfloat do_get_aspect_ratio(
const CData *cdata)
const;
199 INLINE
void do_set_near(CData *cdata, PN_stdfloat near_distance);
200 INLINE PN_stdfloat do_get_near(
const CData *cdata)
const;
201 INLINE
void do_set_far(CData *cdata, PN_stdfloat far_distance);
202 INLINE PN_stdfloat do_get_far(
const CData *cdata)
const;
203 INLINE
void do_set_near_far(CData *cdata, PN_stdfloat near_distance, PN_stdfloat far_distance);
205 const LMatrix4 &do_get_projection_mat(
const CData *cdata, StereoChannel channel = SC_mono)
const;
206 const LMatrix4 &do_get_projection_mat_inv(
const CData *cdata, StereoChannel channel = SC_mono)
const;
208 const LMatrix4 &do_get_film_mat(
const CData *cdata)
const;
209 const LMatrix4 &do_get_film_mat_inv(
const CData *cdata)
const;
211 const LMatrix4 &do_get_lens_mat(
const CData *cdata)
const;
212 const LMatrix4 &do_get_lens_mat_inv(
const CData *cdata)
const;
214 void do_set_interocular_distance(CData *cdata, PN_stdfloat interocular_distance);
215 void do_set_convergence_distance(CData *cdata, PN_stdfloat convergence_distance);
217 void do_set_view_mat(CData *cdata,
const LMatrix4 &view_mat);
218 const LMatrix4 &do_get_view_mat(
const CData *cdata)
const;
220 void do_throw_change_event(CData *cdata);
222 virtual bool do_extrude(
const CData *cdata,
const LPoint3 &point2d,
224 virtual bool do_extrude_depth(
const CData *cdata,
const LPoint3 &point2d,
226 bool do_extrude_depth_with_mat(
const CData *cdata,
const LPoint3 &point2d,
228 virtual bool do_extrude_vec(
const CData *cdata,
230 virtual bool do_project(
const CData *cdata,
233 virtual void do_compute_film_size(CData *cdata);
234 virtual void do_compute_focal_length(CData *cdata);
235 virtual void do_compute_fov(CData *cdata);
236 virtual void do_compute_aspect_ratio(CData *cdata);
237 virtual void do_compute_view_hpr(CData *cdata);
238 virtual void do_compute_view_vector(CData *cdata);
239 virtual void do_compute_projection_mat(CData *cdata);
240 virtual void do_compute_film_mat(CData *cdata);
241 virtual void do_compute_lens_mat(CData *cdata);
243 virtual PN_stdfloat fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length,
bool horiz)
const;
244 virtual PN_stdfloat fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size,
bool horiz)
const;
245 virtual PN_stdfloat film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length,
bool horiz)
const;
248 void do_resequence_fov_triad(
const CData *cdata,
249 char &newest,
char &older_a,
char &older_b)
const;
250 int do_define_geom_data(CData *cdata);
251 static void build_shear_mat(
LMatrix4 &shear_mat,
254 static PN_stdfloat sqr_dist_to_line(
const LPoint3 &point,
const LPoint3 &origin,
260 UF_film_width = 0x0001,
261 UF_film_height = 0x0002,
262 UF_focal_length = 0x0004,
265 UF_aspect_ratio = 0x0020,
266 UF_view_hpr = 0x0040,
267 UF_view_vector = 0x0080,
268 UF_interocular_distance = 0x0100,
269 UF_convergence_distance = 0x0200,
270 UF_view_mat = 0x0400,
271 UF_keystone = 0x0800,
273 UF_custom_film_mat = 0x2000,
278 CF_film_mat = 0x0001,
279 CF_film_mat_inv = 0x0002,
280 CF_lens_mat = 0x0004,
281 CF_lens_mat_inv = 0x0008,
282 CF_projection_mat = 0x0010,
283 CF_projection_mat_inv = 0x0020,
284 CF_projection_mat_left_inv = 0x0040,
285 CF_projection_mat_right_inv = 0x0080,
288 CF_film_size = 0x0100,
289 CF_aspect_ratio = 0x0200,
290 CF_view_hpr = 0x0400,
291 CF_view_vector = 0x0800,
292 CF_focal_length = 0x1000,
297 class EXPCL_PANDA_GOBJ CData :
public CycleData {
300 CData(
const CData ©);
301 ALLOC_DELETED_CHAIN(CData);
306 return Lens::get_class_type();
311 string _change_event;
313 CoordinateSystem _cs;
317 PN_stdfloat _focal_length;
319 PN_stdfloat _min_fov;
320 PN_stdfloat _aspect_ratio;
321 PN_stdfloat _near_distance, _far_distance;
325 PN_stdfloat _interocular_distance;
326 PN_stdfloat _convergence_distance;
332 LMatrix4 _projection_mat, _projection_mat_inv;
333 LMatrix4 _projection_mat_left, _projection_mat_left_inv;
334 LMatrix4 _projection_mat_right, _projection_mat_right_inv;
343 char _focal_length_seq, _fov_seq, _film_size_seq;
351 static void init_type() {
352 register_type(_type_handle,
"Lens::CData");
371 return get_class_type();
373 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
377 static void init_type() {
378 TypedWritableReferenceCount::init_type();
379 register_type(_type_handle,
"Lens",
380 TypedWritableReferenceCount::get_class_type());
388 EXPCL_PANDA_GOBJ INLINE ostream &operator << (ostream &out,
const Lens &lens);
This is the base class for all three-component vectors and points.
A base class for any number of different kinds of lenses, linear and otherwise.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
A single page of data maintained by a PipelineCycler.
virtual TypeHandle get_parent_type() const
Returns the type of the container that owns the CycleData.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
virtual void write_datagram(BamWriter *, Datagram &) const
Writes the contents of this object to the datagram for shipping out to a Bam file.
This is a 4-by-4 transform matrix.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
This is the base class for all two-component vectors and points.
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
This is a two-component vector offset.
A class to retrieve the individual data elements previously stored in a Datagram. ...
This is a two-component point in space.
TypeHandle is the identifier used to differentiate C++ class types.
This is a sequence number that increments monotonically.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...