mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 09:23:03 -04:00
pfm-trans -nan
This commit is contained in:
parent
e0238675f3
commit
686b69fe84
@ -188,6 +188,7 @@ process(const Filename &filename) {
|
||||
_vn_table.clear();
|
||||
_rgb_table.clear();
|
||||
_vt_table.clear();
|
||||
_xvt_table.clear();
|
||||
_ref_plane_res.set(1.0, 1.0);
|
||||
_v4_given = false;
|
||||
_vt3_given = false;
|
||||
@ -592,6 +593,7 @@ process_node(const Filename &filename) {
|
||||
_vn_table.clear();
|
||||
_rgb_table.clear();
|
||||
_vt_table.clear();
|
||||
_xvt_table.clear();
|
||||
_ref_plane_res.set(1.0, 1.0);
|
||||
_v4_given = false;
|
||||
_vt3_given = false;
|
||||
|
@ -30,6 +30,7 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PfmTrans::
|
||||
PfmTrans() {
|
||||
_no_data_nan_num_channels = 0;
|
||||
_got_transform = false;
|
||||
_transform = LMatrix4::ident_mat();
|
||||
_rotate = 0;
|
||||
@ -46,6 +47,11 @@ PfmTrans() {
|
||||
"Treats (0,0,0) in the pfm file as a special don't-touch value.",
|
||||
&PfmTrans::dispatch_none, &_got_zero_special);
|
||||
|
||||
add_option
|
||||
("nan", "num_channels", 0,
|
||||
"Treats a NaN in any of the first num_channels channels as a special don't-touch value.",
|
||||
&PfmTrans::dispatch_int, &_got_no_data_nan, &_no_data_nan_num_channels);
|
||||
|
||||
add_option
|
||||
("resize", "width,height", 0,
|
||||
"Resamples the pfm file to scale it to the indicated grid size. "
|
||||
@ -62,7 +68,7 @@ PfmTrans() {
|
||||
add_option
|
||||
("autocrop", "", 0,
|
||||
"Automatically crops to the smallest possible rectangle that includes "
|
||||
"all points. Requires -z.",
|
||||
"all points. Requires -z or -nan.",
|
||||
&PfmTrans::dispatch_none, &_got_autocrop);
|
||||
|
||||
add_option
|
||||
@ -118,6 +124,11 @@ PfmTrans() {
|
||||
("vistex", "texture.jpg", 60,
|
||||
"Specifies the name of the texture to apply to the visualization.",
|
||||
&PfmTrans::dispatch_filename, &_got_vistex_filename, &_vistex_filename);
|
||||
|
||||
add_option
|
||||
("ls", "filename.txt", 60,
|
||||
"Lists the points in the file to the indicated text file.",
|
||||
&PfmTrans::dispatch_filename, &_got_ls_filename, &_ls_filename);
|
||||
}
|
||||
|
||||
|
||||
@ -162,7 +173,11 @@ run() {
|
||||
bool PfmTrans::
|
||||
process_pfm(const Filename &input_filename, PfmFile &file) {
|
||||
PfmVizzer vizzer(file);
|
||||
file.set_zero_special(_got_zero_special);
|
||||
if (_got_no_data_nan) {
|
||||
file.set_no_data_nan(_no_data_nan_num_channels);
|
||||
} else if (_got_zero_special) {
|
||||
file.set_zero_special(true);
|
||||
}
|
||||
vizzer.set_vis_inverse(_got_vis_inverse);
|
||||
vizzer.set_vis_2d(_got_vis_2d);
|
||||
|
||||
@ -238,6 +253,24 @@ process_pfm(const Filename &input_filename, PfmFile &file) {
|
||||
mesh.reparent_to(_mesh_root);
|
||||
}
|
||||
|
||||
if (_got_ls_filename) {
|
||||
pofstream out;
|
||||
_ls_filename.set_text();
|
||||
if (_ls_filename.open_write(out, true)) {
|
||||
for (int yi = 0; yi < file.get_y_size(); ++yi) {
|
||||
for (int xi = 0; xi < file.get_x_size(); ++xi) {
|
||||
if (file.has_point(xi, yi)) {
|
||||
out << "(" << xi << ", " << yi << "):";
|
||||
for (int ci = 0; ci < file.get_num_channels(); ++ci) {
|
||||
out << " " << file.get_channel(xi, yi, ci);
|
||||
}
|
||||
out << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Filename output_filename;
|
||||
if (_got_output_filename) {
|
||||
output_filename = _output_filename;
|
||||
|
@ -52,6 +52,8 @@ private:
|
||||
Filenames _input_filenames;
|
||||
|
||||
bool _got_zero_special;
|
||||
bool _got_no_data_nan;
|
||||
int _no_data_nan_num_channels;
|
||||
bool _got_vis_inverse;
|
||||
bool _got_vis_2d;
|
||||
bool _got_resize;
|
||||
@ -71,6 +73,8 @@ private:
|
||||
Filename _vis_filename;
|
||||
bool _got_vistex_filename;
|
||||
Filename _vistex_filename;
|
||||
bool _got_ls_filename;
|
||||
Filename _ls_filename;
|
||||
|
||||
bool _got_transform;
|
||||
LMatrix4 _transform;
|
||||
|
Loading…
x
Reference in New Issue
Block a user