mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
use composite bld
This commit is contained in:
parent
a5a770b622
commit
704e907451
@ -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
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
8
panda/src/distort/distort_composite1.cxx
Normal file
8
panda/src/distort/distort_composite1.cxx
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
#include "config_distort.cxx"
|
||||
#include "cylindricalLens.cxx"
|
||||
#include "fisheyeLens.cxx"
|
||||
#include "pSphereLens.cxx"
|
||||
#include "nonlinearImager.cxx"
|
||||
#include "projectionScreen.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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user