mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
add project()
This commit is contained in:
parent
f1c5c8ecaf
commit
5cbc418073
@ -26,6 +26,7 @@
|
||||
#include "geomPoints.h"
|
||||
#include "geomTriangles.h"
|
||||
#include "geomVertexWriter.h"
|
||||
#include "lens.h"
|
||||
#include "look_at.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -524,6 +525,39 @@ xform(const LMatrix4 &transform) {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PfmFile::project
|
||||
// Access: Published
|
||||
// Description: Adjusts each (x, y, z) point of the Pfm file by
|
||||
// projecting it through the indicated lens, converting
|
||||
// each point to a (u, v, 0) texture coordinate. The
|
||||
// resulting file can be generated to a mesh (with
|
||||
// set_vis_inverse(true) and generate_vis_mesh(true))
|
||||
// that will apply the lens distortion to an arbitrary
|
||||
// texture image.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PfmFile::
|
||||
project(const Lens *lens) {
|
||||
nassertv(is_valid());
|
||||
|
||||
static LMatrix4 to_uv(0.5, 0.0, 0.0, 0.0,
|
||||
0.0, 0.5, 0.0, 0.0,
|
||||
0.0, 0.0, 0.0, 0.0,
|
||||
0.5, 0.5, 0.0, 1.0);
|
||||
|
||||
Table::iterator ti;
|
||||
for (ti = _table.begin(); ti != _table.end(); ++ti) {
|
||||
if (_zero_special && (*ti) == LPoint3::zero()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LPoint3 &p = (*ti);
|
||||
LPoint3 film;
|
||||
lens->project(p, film);
|
||||
p = to_uv.xform_point(film);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PfmFile::compute_planar_bounds
|
||||
// Access: Published
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "boundingHexahedron.h"
|
||||
|
||||
class GeomNode;
|
||||
class Lens;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : PfmFile
|
||||
@ -62,6 +63,7 @@ PUBLISHED:
|
||||
void resize(int new_x_size, int new_y_size);
|
||||
void reverse_rows();
|
||||
void xform(const LMatrix4 &transform);
|
||||
void project(const Lens *lens);
|
||||
|
||||
PT(BoundingHexahedron) compute_planar_bounds(double point_dist, double sample_radius) const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user