20 static const PN_stdfloat ospherical_k = 60.0f;
27 PT(
Lens) OSphereLens::
44 do_extrude(
const Lens::CData *lens_cdata,
45 const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point)
const {
48 LPoint3 f = point2d * do_get_film_mat_inv(lens_cdata);
50 PN_stdfloat focal_length = do_get_focal_length(lens_cdata);
51 PN_stdfloat angle = f[0] * cylindrical_k / focal_length;
52 PN_stdfloat sinAngle, cosAngle;
53 csincos(deg_2_rad(angle), &sinAngle, &cosAngle);
57 LPoint3 v(sinAngle, cosAngle, 0.0f);
59 near_point = (v * do_get_near(lens_cdata));
60 far_point = (v * do_get_far(lens_cdata));
66 const LMatrix4 &lens_mat = do_get_lens_mat(lens_cdata);
67 const LMatrix4 &proj_inv_mat = do_get_projection_mat_inv(lens_cdata);
69 near_point = near_point * proj_inv_mat * lens_mat;
70 far_point = far_point * proj_inv_mat * lens_mat;
87 do_project(
const Lens::CData *lens_cdata,
const LPoint3 &point3d, LPoint3 &point2d)
const {
89 LPoint3 p = point3d * do_get_lens_mat_inv(lens_cdata) * do_get_projection_mat(lens_cdata);
94 LVector2 xy(p[0], p[1]);
96 PN_stdfloat dist = xy.length();
98 point2d.set(0.0f, 0.0f, 0.0f);
102 PN_stdfloat focal_length = do_get_focal_length(lens_cdata);
104 PN_stdfloat z = (dist - do_get_near(lens_cdata)) / (do_get_far(lens_cdata) - do_get_near(lens_cdata));
109 rad_2_deg(catan2(xy[0], xy[1])) * focal_length / ospherical_k,
117 point2d = point2d * do_get_film_mat(lens_cdata);
120 point2d[0] >= -1.0f && point2d[0] <= 1.0f &&
121 point2d[1] >= -1.0f && point2d[1] <= 1.0f;
130 PN_stdfloat OSphereLens::
131 fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length,
bool)
const {
132 return focal_length * fov / ospherical_k;
141 PN_stdfloat OSphereLens::
142 fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size,
bool)
const {
143 return film_size * ospherical_k / fov;
152 PN_stdfloat OSphereLens::
153 film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length,
bool)
const {
154 return film_size * ospherical_k / focal_length;
A base class for any number of different kinds of lenses, linear and otherwise.
A OSphereLens is a special nonlinear lens that doesn't correspond to any real physical lenses.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.