15 #include "oSphereLens.h" 16 #include "deg_2_rad.h" 22 static const PN_stdfloat ospherical_k = 60.0f;
31 PT(
Lens) OSphereLens::
54 do_extrude(
const Lens::CData *lens_cdata,
58 LPoint3 f = point2d * do_get_film_mat_inv(lens_cdata);
60 PN_stdfloat focal_length = do_get_focal_length(lens_cdata);
61 PN_stdfloat angle = f[0] * cylindrical_k / focal_length;
62 PN_stdfloat sinAngle, cosAngle;
63 csincos(deg_2_rad(angle), &sinAngle, &cosAngle);
67 LPoint3 v(sinAngle, cosAngle, 0.0f);
69 near_point = (v * do_get_near(lens_cdata));
70 far_point = (v * do_get_far(lens_cdata));
76 const LMatrix4 &lens_mat = do_get_lens_mat(lens_cdata);
77 const LMatrix4 &proj_inv_mat = do_get_projection_mat_inv(lens_cdata);
79 near_point = near_point * proj_inv_mat * lens_mat;
80 far_point = far_point * proj_inv_mat * lens_mat;
102 do_project(
const Lens::CData *lens_cdata,
const LPoint3 &point3d,
LPoint3 &point2d)
const {
104 LPoint3 p = point3d * do_get_lens_mat_inv(lens_cdata) * do_get_projection_mat(lens_cdata);
111 PN_stdfloat dist = xy.length();
113 point2d.set(0.0f, 0.0f, 0.0f);
117 PN_stdfloat focal_length = do_get_focal_length(lens_cdata);
119 PN_stdfloat z = (dist - do_get_near(lens_cdata)) / (do_get_far(lens_cdata) - do_get_near(lens_cdata));
124 rad_2_deg(catan2(xy[0], xy[1])) * focal_length / ospherical_k,
133 point2d = point2d * do_get_film_mat(lens_cdata);
136 point2d[0] >= -1.0f && point2d[0] <= 1.0f &&
137 point2d[1] >= -1.0f && point2d[1] <= 1.0f;
149 PN_stdfloat OSphereLens::
150 fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length,
bool)
const {
151 return focal_length * fov / ospherical_k;
163 PN_stdfloat OSphereLens::
164 fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size,
bool)
const {
165 return film_size * ospherical_k / fov;
177 PN_stdfloat OSphereLens::
178 film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length,
bool)
const {
179 return film_size * ospherical_k / focal_length;
A base class for any number of different kinds of lenses, linear and otherwise.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
This is a 4-by-4 transform matrix.
A OSphereLens is a special nonlinear lens that doesn't correspond to any real physical lenses...
This is a two-component vector offset.
TypeHandle is the identifier used to differentiate C++ class types.