45 void operator = (
const Lens ©);
55 virtual PT(
Lens) make_copy()
const=0;
57 INLINE
bool extrude(
const LPoint2 &point2d,
58 LPoint3 &near_point, LPoint3 &far_point)
const;
59 INLINE
bool extrude(
const LPoint3 &point2d,
60 LPoint3 &near_point, LPoint3 &far_point)
const;
61 INLINE
bool extrude_depth(
const LPoint3 &point2d, LPoint3 &point3d)
const;
62 INLINE
bool extrude_vec(
const LPoint2 &point2d, LVector3 &vec3d)
const;
63 INLINE
bool extrude_vec(
const LPoint3 &point2d, LVector3 &vec3d)
const;
64 INLINE
bool project(
const LPoint3 &point3d, LPoint3 &point2d)
const;
65 INLINE
bool project(
const LPoint3 &point3d, LPoint2 &point2d)
const;
67 INLINE
void set_change_event(
const std::string &event);
68 INLINE
const std::string &get_change_event()
const;
69 MAKE_PROPERTY(change_event, get_change_event, set_change_event);
71 void set_coordinate_system(CoordinateSystem cs);
72 INLINE CoordinateSystem get_coordinate_system()
const;
73 MAKE_PROPERTY(coordinate_system, get_coordinate_system,
74 set_coordinate_system);
78 INLINE
void set_film_size(PN_stdfloat width);
79 INLINE
void set_film_size(PN_stdfloat width, PN_stdfloat height);
80 INLINE
void set_film_size(
const LVecBase2 &film_size);
81 INLINE
const LVecBase2 &get_film_size()
const;
82 MAKE_PROPERTY(film_size, get_film_size, set_film_size);
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;
87 MAKE_PROPERTY(film_offset, get_film_offset, set_film_offset);
89 INLINE
void set_focal_length(PN_stdfloat focal_length);
90 INLINE PN_stdfloat get_focal_length()
const;
91 MAKE_PROPERTY(focal_length, get_focal_length, set_focal_length);
93 void set_min_fov(PN_stdfloat min_fov);
94 INLINE
void set_fov(PN_stdfloat fov);
95 INLINE
void set_fov(PN_stdfloat hfov, PN_stdfloat vfov);
96 INLINE
void set_fov(
const LVecBase2 &fov);
97 INLINE
const LVecBase2 &get_fov()
const;
98 INLINE PN_stdfloat get_hfov()
const;
99 INLINE PN_stdfloat get_vfov()
const;
100 PN_stdfloat get_min_fov()
const;
101 MAKE_PROPERTY(fov, get_fov, set_fov);
102 MAKE_PROPERTY(min_fov, get_min_fov, set_min_fov);
104 INLINE
void set_aspect_ratio(PN_stdfloat aspect_ratio);
105 INLINE PN_stdfloat get_aspect_ratio()
const;
106 MAKE_PROPERTY(aspect_ratio, get_aspect_ratio, set_aspect_ratio);
108 INLINE
void set_near(PN_stdfloat near_distance);
109 INLINE PN_stdfloat get_near()
const;
110 INLINE
void set_far(PN_stdfloat far_distance);
111 INLINE PN_stdfloat get_far()
const;
112 INLINE
void set_near_far(PN_stdfloat near_distance, PN_stdfloat far_distance);
113 MAKE_PROPERTY(near, get_near, set_near);
114 MAKE_PROPERTY(far, get_far, set_far);
116 static PN_stdfloat get_default_near();
117 static PN_stdfloat get_default_far();
119 INLINE
void set_view_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r);
120 void set_view_hpr(
const LVecBase3 &view_hpr);
121 const LVecBase3 &get_view_hpr()
const;
122 MAKE_PROPERTY(view_hpr, get_view_hpr, set_view_hpr);
124 INLINE
void set_view_vector(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat i, PN_stdfloat j, PN_stdfloat k);
125 void set_view_vector(
const LVector3 &view_vector,
const LVector3 &up_vector);
126 const LVector3 &get_view_vector()
const;
127 const LVector3 &get_up_vector()
const;
128 LPoint3 get_nodal_point()
const;
129 MAKE_PROPERTY(nodal_point, get_nodal_point);
131 INLINE
void set_interocular_distance(PN_stdfloat interocular_distance);
132 INLINE PN_stdfloat get_interocular_distance()
const;
133 INLINE
void set_convergence_distance(PN_stdfloat convergence_distance);
134 INLINE PN_stdfloat get_convergence_distance()
const;
135 MAKE_PROPERTY(interocular_distance, get_interocular_distance, set_interocular_distance);
136 MAKE_PROPERTY(convergence_distance, get_convergence_distance, set_convergence_distance);
138 INLINE
void set_view_mat(
const LMatrix4 &view_mat);
139 INLINE
const LMatrix4 &get_view_mat()
const;
140 void clear_view_mat();
141 MAKE_PROPERTY(view_mat, get_view_mat, set_view_mat);
143 void set_keystone(
const LVecBase2 &keystone);
144 INLINE
const LVecBase2 &get_keystone()
const;
145 void clear_keystone();
146 MAKE_PROPERTY(keystone, get_keystone, set_keystone);
148 void set_custom_film_mat(
const LMatrix4 &custom_film_mat);
149 INLINE
const LMatrix4 &get_custom_film_mat()
const;
150 void clear_custom_film_mat();
157 FC_camera_plane = 0x0002,
158 FC_off_axis = 0x0004,
159 FC_aspect_ratio = 0x0008,
161 FC_keystone = 0x0020,
163 void set_frustum_from_corners(
const LVecBase3 &ul,
const LVecBase3 &ur,
164 const LVecBase3 &ll,
const LVecBase3 &lr,
167 void recompute_all();
169 virtual bool is_linear()
const;
170 virtual bool is_perspective()
const;
171 virtual bool is_orthographic()
const;
172 virtual PT(
Geom) make_geometry();
176 INLINE
const LMatrix4 &get_projection_mat(StereoChannel channel = SC_mono)
const;
177 INLINE
const LMatrix4 &get_projection_mat_inv(StereoChannel channel = SC_mono)
const;
179 INLINE
const LMatrix4 &get_film_mat()
const;
180 INLINE
const LMatrix4 &get_film_mat_inv()
const;
182 INLINE
const LMatrix4 &get_lens_mat()
const;
183 INLINE
const LMatrix4 &get_lens_mat_inv()
const;
185 virtual void output(std::ostream &out)
const;
186 virtual void write(std::ostream &out,
int indent_level = 0)
const;
188 INLINE
UpdateSeq get_last_change()
const;
193 INLINE
void do_adjust_user_flags(CData *cdata,
int clear_flags,
int set_flags);
194 INLINE
void do_adjust_comp_flags(CData *cdata,
int clear_flags,
int set_flags);
196 void do_set_film_size(CData *cdata, PN_stdfloat width);
197 void do_set_film_size(CData *cdata,
const LVecBase2 &film_size);
198 const LVecBase2 &do_get_film_size(
const CData *cdata)
const;
200 INLINE
void do_set_film_offset(CData *cdata,
const LVecBase2 &film_offset);
201 INLINE
const LVector2 &do_get_film_offset(
const CData *cdata)
const;
203 void do_set_focal_length(CData *cdata, PN_stdfloat focal_length);
204 PN_stdfloat do_get_focal_length(
const CData *cdata)
const;
206 void do_set_fov(CData *cdata, PN_stdfloat fov);
207 void do_set_fov(CData *cdata,
const LVecBase2 &fov);
208 const LVecBase2 &do_get_fov(
const CData *cdata)
const;
210 void do_set_aspect_ratio(CData *cdata, PN_stdfloat aspect_ratio);
211 PN_stdfloat do_get_aspect_ratio(
const CData *cdata)
const;
213 INLINE
void do_set_near(CData *cdata, PN_stdfloat near_distance);
214 INLINE PN_stdfloat do_get_near(
const CData *cdata)
const;
215 INLINE
void do_set_far(CData *cdata, PN_stdfloat far_distance);
216 INLINE PN_stdfloat do_get_far(
const CData *cdata)
const;
217 INLINE
void do_set_near_far(CData *cdata, PN_stdfloat near_distance, PN_stdfloat far_distance);
219 const LMatrix4 &do_get_projection_mat(
const CData *cdata, StereoChannel channel = SC_mono)
const;
220 const LMatrix4 &do_get_projection_mat_inv(
const CData *cdata, StereoChannel channel = SC_mono)
const;
222 const LMatrix4 &do_get_film_mat(
const CData *cdata)
const;
223 const LMatrix4 &do_get_film_mat_inv(
const CData *cdata)
const;
225 const LMatrix4 &do_get_lens_mat(
const CData *cdata)
const;
226 const LMatrix4 &do_get_lens_mat_inv(
const CData *cdata)
const;
228 void do_set_interocular_distance(CData *cdata, PN_stdfloat interocular_distance);
229 void do_set_convergence_distance(CData *cdata, PN_stdfloat convergence_distance);
231 void do_set_view_mat(CData *cdata,
const LMatrix4 &view_mat);
232 const LMatrix4 &do_get_view_mat(
const CData *cdata)
const;
234 void do_throw_change_event(CData *cdata);
236 virtual bool do_extrude(
const CData *cdata,
const LPoint3 &point2d,
237 LPoint3 &near_point, LPoint3 &far_point)
const;
238 virtual bool do_extrude_depth(
const CData *cdata,
const LPoint3 &point2d,
239 LPoint3 &point3d)
const;
240 bool do_extrude_depth_with_mat(
const CData *cdata,
const LPoint3 &point2d,
241 LPoint3 &point3d)
const;
242 virtual bool do_extrude_vec(
const CData *cdata,
243 const LPoint3 &point2d, LVector3 &vec)
const;
244 virtual bool do_project(
const CData *cdata,
245 const LPoint3 &point3d, LPoint3 &point2d)
const;
247 virtual void do_compute_film_size(CData *cdata);
248 virtual void do_compute_focal_length(CData *cdata);
249 virtual void do_compute_fov(CData *cdata);
250 virtual void do_compute_aspect_ratio(CData *cdata);
251 virtual void do_compute_view_hpr(CData *cdata);
252 virtual void do_compute_view_vector(CData *cdata);
253 virtual void do_compute_projection_mat(CData *cdata);
254 virtual void do_compute_film_mat(CData *cdata);
255 virtual void do_compute_lens_mat(CData *cdata);
257 virtual PN_stdfloat fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length,
bool horiz)
const;
258 virtual PN_stdfloat fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size,
bool horiz)
const;
259 virtual PN_stdfloat film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length,
bool horiz)
const;
262 void do_resequence_fov_triad(
const CData *cdata,
263 char &newest,
char &older_a,
char &older_b)
const;
264 int do_define_geom_data(CData *cdata);
265 static void build_shear_mat(LMatrix4 &shear_mat,
266 const LPoint3 &cul,
const LPoint3 &cur,
267 const LPoint3 &cll,
const LPoint3 &clr);
268 static PN_stdfloat sqr_dist_to_line(
const LPoint3 &point,
const LPoint3 &origin,
269 const LVector3 &vec);
274 UF_film_width = 0x0001,
275 UF_film_height = 0x0002,
276 UF_focal_length = 0x0004,
279 UF_aspect_ratio = 0x0020,
280 UF_view_hpr = 0x0040,
281 UF_view_vector = 0x0080,
282 UF_interocular_distance = 0x0100,
283 UF_convergence_distance = 0x0200,
284 UF_view_mat = 0x0400,
285 UF_keystone = 0x0800,
287 UF_custom_film_mat = 0x2000,
292 CF_film_mat = 0x0001,
293 CF_film_mat_inv = 0x0002,
294 CF_lens_mat = 0x0004,
295 CF_lens_mat_inv = 0x0008,
296 CF_projection_mat = 0x0010,
297 CF_projection_mat_inv = 0x0020,
298 CF_projection_mat_left_inv = 0x0040,
299 CF_projection_mat_right_inv = 0x0080,
302 CF_film_size = 0x0100,
303 CF_aspect_ratio = 0x0200,
304 CF_view_hpr = 0x0400,
305 CF_view_vector = 0x0800,
306 CF_focal_length = 0x1000,
311 class EXPCL_PANDA_GOBJ CData :
public CycleData {
314 CData(
const CData ©);
315 ALLOC_DELETED_CHAIN(CData);
320 return Lens::get_class_type();
325 std::string _change_event;
327 CoordinateSystem _cs;
329 LVecBase2 _film_size;
330 LVector2 _film_offset;
331 PN_stdfloat _focal_length;
333 PN_stdfloat _min_fov;
334 PN_stdfloat _aspect_ratio;
335 PN_stdfloat _near_distance, _far_distance;
338 LVector3 _view_vector, _up_vector;
339 PN_stdfloat _interocular_distance;
340 PN_stdfloat _convergence_distance;
342 LMatrix4 _custom_film_mat;
344 LMatrix4 _film_mat, _film_mat_inv;
345 LMatrix4 _lens_mat, _lens_mat_inv;
346 LMatrix4 _projection_mat, _projection_mat_inv;
347 LMatrix4 _projection_mat_left, _projection_mat_left_inv;
348 LMatrix4 _projection_mat_right, _projection_mat_right_inv;
357 char _focal_length_seq, _fov_seq, _film_size_seq;
365 static void init_type() {
385 return get_class_type();
387 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
391 static void init_type() {
392 TypedWritableReferenceCount::init_type();
394 TypedWritableReferenceCount::get_class_type());
402 EXPCL_PANDA_GOBJ INLINE std::ostream &operator << (std::ostream &out,
const Lens &lens);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A single page of data maintained by a PipelineCycler.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual TypeHandle get_parent_type() const
Returns the type of the container that owns the CycleData.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
A class to retrieve the individual data elements previously stored in a Datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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 ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.