Panda3D
|
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component. More...
#include "pfmFile.h"
Classes | |
class | MiniGridCell |
Public Types | |
enum | MeshFace { MF_front = 0x01, MF_back = 0x02, MF_both = 0x03 } |
Public Member Functions | |
PfmFile (const PfmFile ©) | |
bool | calc_average_point (LPoint3 &result, PN_stdfloat x, PN_stdfloat y, PN_stdfloat radius) const |
Computes the unweighted average point of all points within the box centered at (x, y) with the indicated Manhattan-distance radius. | |
bool | calc_min_max (LVecBase3 &min_points, LVecBase3 &max_points) const |
Calculates the minimum and maximum x, y, and z depth component values, representing the bounding box of depth values, and places them in the indicated vectors. | |
void | clear () |
Eliminates all data in the file. | |
void | clear (int x_size, int y_size, int num_channels) |
Resets to an empty table with a specific size. | |
void | clear_flat_texcoord_name () |
Resets the flat_texcoord_name to empty, so that additional texture coordinates are not created. | |
void | compute_sample_point (LPoint3 &result, PN_stdfloat x, PN_stdfloat y, PN_stdfloat sample_radius) const |
Computes the average of all the point within sample_radius (manhattan distance) and the indicated point. | |
NodePath | generate_vis_mesh (MeshFace face=MF_front) const |
Creates a triangle mesh with the points of the pfm as 3-d coordinates in space, and texture coordinates ranging from 0 . | |
NodePath | generate_vis_points () const |
Creates a point cloud with the points of the pfm as 3-d coordinates in space, and texture coordinates ranging from 0 . | |
InternalName * | get_flat_texcoord_name () const |
Returns the flat_texcoord_name. | |
int | get_num_channels () const |
A pfm file can be either 1-channel (get_num_channels() == 1) or 3-channel (get_num_channels() == 3). | |
const LPoint3 & | get_point (int x, int y) const |
Returns the 3-component point value at the indicated point. | |
PN_stdfloat | get_scale () const |
The "scale" is reported in the pfm header and is probably meaningless. | |
bool | get_vis_2d () const |
Returns the vis_2d flag. | |
bool | get_vis_inverse () const |
Returns the vis_inverse flag. | |
int | get_x_size () const |
int | get_y_size () const |
bool | get_zero_special () const |
Returns the zero_special flag. | |
bool | has_point (int x, int y) const |
Returns true if there is a valid point at x, y. | |
bool | is_valid () const |
void | merge (const PfmFile &other) |
Wherever there is missing data in this PfmFile (that is, wherever has_point() returns false), copy data from the other PfmFile, which must be exactly the same dimensions as this one. | |
LPoint3 & | modify_point (int x, int y) |
Returns a modifiable 3-component point value at the indicated point. | |
void | operator= (const PfmFile ©) |
void | project (const Lens *lens) |
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. | |
PT (BoundingHexahedron) compute_planar_bounds(PN_stdfloat point_dist | |
PT (BoundingHexahedron) compute_planar_bounds(const LPoint2 ¢er | |
bool | read (istream &in) |
Reads the PFM data from the indicated stream, returning true on success, false on failure. | |
bool | read (const Filename &fullpath) |
Reads the PFM data from the indicated file, returning true on success, false on failure. | |
void | resize (int new_x_size, int new_y_size) |
Applies a simple filter to resample the pfm file in-place to the indicated size. | |
void | reverse_rows () |
Performs an in-place reversal of the row (y) data. | |
void | set_flat_texcoord_name (InternalName *flat_texcoord_name) |
If the flat_texcoord_name is specified, it is the name of an additional vertex column that will be created for the "flat" texture coordinates, i.e. | |
void | set_point (int x, int y, const LVecBase3 &point) |
Replaces the 3-component point value at the indicated point. | |
void | set_vis_2d (bool vis_2d) |
Sets the vis_2d flag. | |
void | set_vis_inverse (bool vis_inverse) |
Sets the vis_inverse flag. | |
void | set_zero_special (bool zero_special) |
Sets the zero_special flag. | |
bool | write (ostream &out) |
Writes the PFM data to the indicated stream, returning true on success, false on failure. | |
bool | write (const Filename &fullpath) |
Writes the PFM data to the indicated file, returning true on success, false on failure. | |
void | xform (const LMatrix4 &transform) |
Applies the indicated transform matrix to all points in-place. | |
Public Attributes | |
PN_stdfloat sample_radius | const |
PN_stdfloat PN_stdfloat bool points_only | const |
PN_stdfloat | point_dist |
PN_stdfloat PN_stdfloat | sample_radius |
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component.
bool PfmFile::calc_average_point | ( | LPoint3 & | result, |
PN_stdfloat | x, | ||
PN_stdfloat | y, | ||
PN_stdfloat | radius | ||
) | const |
Computes the unweighted average point of all points within the box centered at (x, y) with the indicated Manhattan-distance radius.
Missing points are assigned the value of their nearest neighbor. Returns true if successful, or false if the point value cannot be determined.
Definition at line 321 of file pfmFile.cxx.
References LPoint3f::zero().
Calculates the minimum and maximum x, y, and z depth component values, representing the bounding box of depth values, and places them in the indicated vectors.
Returns true if successful, false if the mesh contains no points.
Definition at line 407 of file pfmFile.cxx.
References LPoint3f::zero(), and LVecBase3f::zero().
void PfmFile::clear | ( | ) |
void PfmFile::clear | ( | int | x_size, |
int | y_size, | ||
int | num_channels | ||
) |
Resets to an empty table with a specific size.
Definition at line 100 of file pfmFile.cxx.
References LPoint3f::zero().
void PfmFile::clear_flat_texcoord_name | ( | ) | [inline] |
void PfmFile::compute_sample_point | ( | LPoint3 & | result, |
PN_stdfloat | x, | ||
PN_stdfloat | y, | ||
PN_stdfloat | sample_radius | ||
) | const |
Computes the average of all the point within sample_radius (manhattan distance) and the indicated point.
The point coordinates are given in UV space, in the range 0..1.
Definition at line 751 of file pfmFile.cxx.
NodePath PfmFile::generate_vis_mesh | ( | MeshFace | face = MF_front | ) | const |
Creates a triangle mesh with the points of the pfm as 3-d coordinates in space, and texture coordinates ranging from 0 .
. 1 based on the position within the pfm grid.
Definition at line 842 of file pfmFile.cxx.
References generate_vis_points().
Referenced by PfmTrans::process_pfm().
NodePath PfmFile::generate_vis_points | ( | ) | const |
Creates a point cloud with the points of the pfm as 3-d coordinates in space, and texture coordinates ranging from 0 .
. 1 based on the position within the pfm grid.
Definition at line 770 of file pfmFile.cxx.
References GeomVertexWriter::add_data2(), GeomVertexWriter::add_data3(), get_point(), and GeomVertexFormat::get_v3t2().
Referenced by generate_vis_mesh().
InternalName * PfmFile::get_flat_texcoord_name | ( | ) | const [inline] |
Returns the flat_texcoord_name.
int PfmFile::get_num_channels | ( | ) | const [inline] |
A pfm file can be either 1-channel (get_num_channels() == 1) or 3-channel (get_num_channels() == 3).
In the case of a 1-channel file, the values can be found in the x component of each point, and the y and z components are unused.
const LPoint3 & PfmFile::get_point | ( | int | x, |
int | y | ||
) | const [inline] |
Returns the 3-component point value at the indicated point.
In a 1-channel image, the channel value is in the x component.
Definition at line 97 of file pfmFile.I.
References LPoint3f::zero().
Referenced by generate_vis_points().
PN_stdfloat PfmFile::get_scale | ( | ) | const [inline] |
bool PfmFile::get_vis_2d | ( | ) | const [inline] |
bool PfmFile::get_vis_inverse | ( | ) | const [inline] |
bool PfmFile::get_zero_special | ( | ) | const [inline] |
bool PfmFile::has_point | ( | int | x, |
int | y | ||
) | const [inline] |
Returns true if there is a valid point at x, y.
This always returns true unless the zero_special flag is enabled, in which case it returns false if the point at x, y is zero.
Definition at line 81 of file pfmFile.I.
References LPoint3f::zero().
void PfmFile::merge | ( | const PfmFile & | other | ) |
Wherever there is missing data in this PfmFile (that is, wherever has_point() returns false), copy data from the other PfmFile, which must be exactly the same dimensions as this one.
Definition at line 581 of file pfmFile.cxx.
References LPoint3f::zero().
LPoint3 & PfmFile::modify_point | ( | int | x, |
int | y | ||
) | [inline] |
Returns a modifiable 3-component point value at the indicated point.
Definition at line 125 of file pfmFile.I.
References LPoint3f::zero().
void PfmFile::project | ( | const Lens * | lens | ) |
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()) that will apply the lens distortion to an arbitrary texture image.
Definition at line 551 of file pfmFile.cxx.
References Lens::project(), LMatrix4f::xform_point(), and LPoint3f::zero().
bool PfmFile::read | ( | const Filename & | fullpath | ) |
Reads the PFM data from the indicated file, returning true on success, false on failure.
Definition at line 120 of file pfmFile.cxx.
References VirtualFileSystem::close_read_file(), and VirtualFileSystem::get_global_ptr().
bool PfmFile::read | ( | istream & | in | ) |
Reads the PFM data from the indicated stream, returning true on success, false on failure.
Definition at line 151 of file pfmFile.cxx.
References clear(), ReversedNumericData::store_value(), NativeNumericData::store_value(), and LPoint3f::zero().
void PfmFile::resize | ( | int | new_x_size, |
int | new_y_size | ||
) | [inline] |
Applies a simple filter to resample the pfm file in-place to the indicated size.
Don't confuse this with applying a scale to all of the points via xform().
Definition at line 264 of file pointerToArray.I.
References PointerToBase< T >::reassign().
Referenced by PfmTrans::process_pfm().
void PfmFile::reverse_rows | ( | ) |
Performs an in-place reversal of the row (y) data.
Definition at line 503 of file pfmFile.cxx.
Referenced by PfmTrans::process_pfm().
void PfmFile::set_flat_texcoord_name | ( | InternalName * | flat_texcoord_name | ) | [inline] |
If the flat_texcoord_name is specified, it is the name of an additional vertex column that will be created for the "flat" texture coordinates, i.e.
the original 0..1 values that correspond to the 2-D index position of each point in the original pfm file.
These are the same values that will be assigned to the default texture coordinates if the vis_inverse flag is *not* true.
void PfmFile::set_point | ( | int | x, |
int | y, | ||
const LVecBase3 & | point | ||
) | [inline] |
Replaces the 3-component point value at the indicated point.
In a 1-channel image, the channel value is in the x component.
Definition at line 111 of file pfmFile.I.
References LVecBase3f::is_nan().
void PfmFile::set_vis_2d | ( | bool | vis_2d | ) | [inline] |
Sets the vis_2d flag.
When this flag is true, only the first two (x, y) value of each depth point is considered meaningful; the z component is ignored. This is only relevant for generating visualizations.
Definition at line 233 of file pfmFile.I.
Referenced by PfmTrans::process_pfm().
void PfmFile::set_vis_inverse | ( | bool | vis_inverse | ) | [inline] |
Sets the vis_inverse flag.
When this flag is true, vis meshes and point clouds are generated with the 3-d depth value in the texture coordinates, and the 2-d index value in the vertex position. When it is false, meshes are generated normally, with the 3-d depth value in the vertex position and the 2-d index value in the texture coordinates.
Definition at line 171 of file pfmFile.I.
Referenced by PfmTrans::process_pfm().
void PfmFile::set_zero_special | ( | bool | zero_special | ) | [inline] |
Sets the zero_special flag.
When this flag is true, values of (0, 0, 0) in the pfm file are treated as a special case, and are not processed.
Definition at line 143 of file pfmFile.I.
Referenced by PfmTrans::process_pfm(), and PfmBba::process_pfm().
bool PfmFile::write | ( | ostream & | out | ) |
Writes the PFM data to the indicated stream, returning true on success, false on failure.
Definition at line 273 of file pfmFile.cxx.
bool PfmFile::write | ( | const Filename & | fullpath | ) |
Writes the PFM data to the indicated file, returning true on success, false on failure.
Definition at line 249 of file pfmFile.cxx.
References Filename::open_write().
Referenced by PfmTrans::process_pfm().
void PfmFile::xform | ( | const LMatrix4 & | transform | ) |
Applies the indicated transform matrix to all points in-place.
Definition at line 526 of file pfmFile.cxx.
References LPoint3f::zero().
Referenced by PfmTrans::process_pfm().