From 704e907451a68ff4ca343b3864386b492e2bf8de Mon Sep 17 00:00:00 2001 From: cxgeorge <> Date: Fri, 1 Feb 2002 02:18:21 +0000 Subject: [PATCH] use composite bld --- panda/src/distort/Sources.pp | 19 ++++++++++++------- panda/src/distort/cylindricalLens.cxx | 14 +++++++------- panda/src/distort/distort_composite1.cxx | 8 ++++++++ panda/src/distort/fisheyeLens.cxx | 14 +++++++------- panda/src/distort/pSphereLens.cxx | 18 +++++++++--------- 5 files changed, 43 insertions(+), 30 deletions(-) create mode 100644 panda/src/distort/distort_composite1.cxx diff --git a/panda/src/distort/Sources.pp b/panda/src/distort/Sources.pp index 7858716e19..7af9977e1d 100644 --- a/panda/src/distort/Sources.pp +++ b/panda/src/distort/Sources.pp @@ -5,14 +5,19 @@ #define TARGET distort #define LOCAL_LIBS \ sgraphutil sgraph sgattrib gobj linmath + + #define COMBINED_SOURCES $[TARGET]_composite1.cxx - #define SOURCES \ - config_distort.cxx config_distort.h \ - cylindricalLens.cxx cylindricalLens.h cylindricalLens.I \ - fisheyeLens.cxx fisheyeLens.h fisheyeLens.I \ - nonlinearImager.cxx nonlinearImager.h nonlinearImager.I \ - pSphereLens.cxx pSphereLens.h pSphereLens.I \ - projectionScreen.cxx projectionScreen.h projectionScreen.I + #define SOURCES config_distort.h \ + projectionScreen.h projectionScreen.I \ + cylindricalLens.h cylindricalLens.I \ + fisheyeLens.h fisheyeLens.I \ + nonlinearImager.h nonlinearImager.I \ + pSphereLens.h pSphereLens.I + + #define INCLUDED_SOURCES \ + config_distort.cxx cylindricalLens.cxx fisheyeLens.cxx nonlinearImager.cxx \ + projectionScreen.cxx pSphereLens.cxx #define INSTALL_HEADERS diff --git a/panda/src/distort/cylindricalLens.cxx b/panda/src/distort/cylindricalLens.cxx index 34853ae268..8ab2bc04a2 100644 --- a/panda/src/distort/cylindricalLens.cxx +++ b/panda/src/distort/cylindricalLens.cxx @@ -23,8 +23,8 @@ TypeHandle CylindricalLens::_type_handle; // This is the focal-length constant for fisheye lenses. See // fisheyeLens.cxx. -static const float k = 60.0f; -// focal_length = film_size * k / fov; +static const float cylindrical_k = 60.0f; +// focal_length = film_size * cylindrical_k / fov; //////////////////////////////////////////////////////////////////// @@ -61,7 +61,7 @@ extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) LPoint3f f = point2d * get_film_mat_inv(); float focal_length = get_focal_length(); - float angle = f[0] * k / focal_length; + float angle = f[0] * cylindrical_k / focal_length; float sinAngle, cosAngle; csincos(deg_2_rad(angle), &sinAngle, &cosAngle); @@ -118,7 +118,7 @@ project_impl(const LPoint3f &point3d, LPoint3f &point2d) const { point2d.set ( // The x position is the angle about the Z axis. - rad_2_deg(catan2(xy[0], xy[1])) * focal_length / k, + rad_2_deg(catan2(xy[0], xy[1])) * focal_length / cylindrical_k, // The y position is the Z height divided by the perspective // distance. p[2] * focal_length / pdist, @@ -147,7 +147,7 @@ project_impl(const LPoint3f &point3d, LPoint3f &point2d) const { float CylindricalLens:: fov_to_film(float fov, float focal_length, bool horiz) const { if (horiz) { - return focal_length * fov / k; + return focal_length * fov / cylindrical_k; } else { return (ctan(deg_2_rad(fov * 0.5f)) * focal_length) * 2.0f; } @@ -165,7 +165,7 @@ fov_to_film(float fov, float focal_length, bool horiz) const { float CylindricalLens:: fov_to_focal_length(float fov, float film_size, bool horiz) const { if (horiz) { - return film_size * k / fov; + return film_size * cylindrical_k / fov; } else { return film_size * 0.5f / ctan(deg_2_rad(fov * 0.5f)); } @@ -183,7 +183,7 @@ fov_to_focal_length(float fov, float film_size, bool horiz) const { float CylindricalLens:: film_to_fov(float film_size, float focal_length, bool horiz) const { if (horiz) { - return film_size * k / focal_length; + return film_size * cylindrical_k / focal_length; } else { return rad_2_deg(catan(film_size * 0.5f / focal_length)) * 2.0f; } diff --git a/panda/src/distort/distort_composite1.cxx b/panda/src/distort/distort_composite1.cxx new file mode 100644 index 0000000000..b365c7d04b --- /dev/null +++ b/panda/src/distort/distort_composite1.cxx @@ -0,0 +1,8 @@ + +#include "config_distort.cxx" +#include "cylindricalLens.cxx" +#include "fisheyeLens.cxx" +#include "pSphereLens.cxx" +#include "nonlinearImager.cxx" +#include "projectionScreen.cxx" + diff --git a/panda/src/distort/fisheyeLens.cxx b/panda/src/distort/fisheyeLens.cxx index 0ebe9c8efb..4a4554d0ce 100644 --- a/panda/src/distort/fisheyeLens.cxx +++ b/panda/src/distort/fisheyeLens.cxx @@ -36,8 +36,8 @@ TypeHandle FisheyeLens::_type_handle; // know how well this extends to other lenses and other negative // sizes. -static const float k = 60.0f; -// focal_length = film_size * k / fov; +static const float fisheye_k = 60.0f; +// focal_length = film_size * fisheye_k / fov; //////////////////////////////////////////////////////////////////// @@ -89,7 +89,7 @@ extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) // Now get the point r units around the circle in the YZ plane. float focal_length = get_focal_length(); - float angle = r * k / focal_length; + float angle = r * fisheye_k / focal_length; float sinAngle, cosAngle; csincos(deg_2_rad(angle), &sinAngle, &cosAngle); @@ -166,7 +166,7 @@ project_impl(const LPoint3f &point3d, LPoint3f &point2d) const { float r = 90.0f - rad_2_deg(catan2(x[0], x[1])); float focal_length = get_focal_length(); - float factor = r * focal_length / k; + float factor = r * focal_length / fisheye_k; point2d.set (y[0] * factor, @@ -195,7 +195,7 @@ project_impl(const LPoint3f &point3d, LPoint3f &point2d) const { //////////////////////////////////////////////////////////////////// float FisheyeLens:: fov_to_film(float fov, float focal_length, bool) const { - return focal_length * fov / k; + return focal_length * fov / fisheye_k; } //////////////////////////////////////////////////////////////////// @@ -209,7 +209,7 @@ fov_to_film(float fov, float focal_length, bool) const { //////////////////////////////////////////////////////////////////// float FisheyeLens:: fov_to_focal_length(float fov, float film_size, bool) const { - return film_size * k / fov; + return film_size * fisheye_k / fov; } //////////////////////////////////////////////////////////////////// @@ -223,6 +223,6 @@ fov_to_focal_length(float fov, float film_size, bool) const { //////////////////////////////////////////////////////////////////// float FisheyeLens:: film_to_fov(float film_size, float focal_length, bool) const { - return film_size * k / focal_length; + return film_size * fisheye_k / focal_length; } diff --git a/panda/src/distort/pSphereLens.cxx b/panda/src/distort/pSphereLens.cxx index a6e119e06d..bec9f346d5 100644 --- a/panda/src/distort/pSphereLens.cxx +++ b/panda/src/distort/pSphereLens.cxx @@ -23,8 +23,8 @@ TypeHandle PSphereLens::_type_handle; // This is the focal-length constant for fisheye lenses. See // fisheyeLens.cxx. -static const float k = 60.0f; -// focal_length = film_size * k / fov; +static const float spherical_k = 60.0f; +// focal_length = film_size * spherical_k / fov; //////////////////////////////////////////////////////////////////// @@ -65,8 +65,8 @@ extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) // Rotate the forward vector through the rotation angles // corresponding to this point. LPoint3f v = LPoint3f(0.0f, 1.0f, 0.0f) * - LMatrix3f::rotate_mat(f[1] * k / focal_length, LVector3f(1.0f, 0.0f, 0.0f)) * - LMatrix3f::rotate_mat(f[0] * k / focal_length, LVector3f(0.0f, 0.0f, -1.0f)); + LMatrix3f::rotate_mat(f[1] * spherical_k / focal_length, LVector3f(1.0f, 0.0f, 0.0f)) * + LMatrix3f::rotate_mat(f[0] * spherical_k / focal_length, LVector3f(0.0f, 0.0f, -1.0f)); // And we'll need to account for the lens's rotations, etc. at the // end of the day. @@ -121,9 +121,9 @@ project_impl(const LPoint3f &point3d, LPoint3f &point2d) const { point2d.set ( // The x position is the angle about the Z axis. - rad_2_deg(catan2(xy[0], xy[1])) * focal_length / k, + rad_2_deg(catan2(xy[0], xy[1])) * focal_length / spherical_k, // The y position is the angle about the X axis. - rad_2_deg(catan2(yz[1], yz[0])) * focal_length / k, + rad_2_deg(catan2(yz[1], yz[0])) * focal_length / spherical_k, // Z is the distance scaled into the range (1, -1). (get_near() - dist) / (get_far() - get_near()) ); @@ -148,7 +148,7 @@ project_impl(const LPoint3f &point3d, LPoint3f &point2d) const { //////////////////////////////////////////////////////////////////// float PSphereLens:: fov_to_film(float fov, float focal_length, bool) const { - return focal_length * fov / k; + return focal_length * fov / spherical_k; } //////////////////////////////////////////////////////////////////// @@ -162,7 +162,7 @@ fov_to_film(float fov, float focal_length, bool) const { //////////////////////////////////////////////////////////////////// float PSphereLens:: fov_to_focal_length(float fov, float film_size, bool) const { - return film_size * k / fov; + return film_size * spherical_k / fov; } //////////////////////////////////////////////////////////////////// @@ -176,5 +176,5 @@ fov_to_focal_length(float fov, float film_size, bool) const { //////////////////////////////////////////////////////////////////// float PSphereLens:: film_to_fov(float film_size, float focal_length, bool) const { - return film_size * k / focal_length; + return film_size * spherical_k / focal_length; }