23 set_program_brief(
"generate .bba files from .pfm files");
24 set_program_description
25 (
"pfm-bba generates a .bba file from a .pfm file that lists the " 26 "planar bounding volume of the pfm's internal data.");
30 "Treats (0,0,0) in the pfm file as a special don't-touch value.",
31 &PfmBba::dispatch_none, &_got_zero_special);
35 "Specify the filename to which the resulting bba file will be written.",
36 &PfmBba::dispatch_filename, &_got_output_filename, &_output_filename);
45 Filenames::const_iterator fi;
46 for (fi = _input_filenames.begin(); fi != _input_filenames.end(); ++fi) {
48 if (!file.
read(*fi)) {
49 nout <<
"Cannot read " << *fi <<
"\n";
66 if (_got_output_filename) {
67 bba_filename = _output_filename;
69 bba_filename = input_filename;
73 if (!bba_filename.empty()) {
75 PT(
BoundingHexahedron) bounds = file.compute_planar_bounds(LPoint2f(0.5, 0.5), pfm_bba_dist[0], pfm_bba_dist[1],
false);
76 nassertr(bounds !=
nullptr,
false);
80 std::cerr <<
"Unable to open " << bba_filename <<
"\n";
85 for (
int i = 0; i < 8; ++i) {
86 points[i] = bounds->get_point(i);
102 for (
int i = 0; i < 8; ++i) {
103 const LPoint3 &p = points[i];
104 out << p[0] <<
"," << p[1] <<
"," << p[2] <<
"\n";
119 nout <<
"You must specify the pfm file(s) to read on the command line.\n";
123 if (args.size() > 1 && _got_output_filename) {
124 nout <<
"Cannot use -o when multiple pfm files are specified.\n";
128 Args::const_iterator ai;
129 for (ai = args.begin(); ai != args.end(); ++ai) {
137 int main(
int argc,
char *argv[]) {
bool open_write(std::ofstream &stream, bool truncate=true) const
Opens the indicated ifstream for writing the file, if possible.
void set_extension(const std::string &s)
Replaces the file extension.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Generates a bounding-box description of a pfm file.
virtual void parse_command_line(int argc, char **argv)
Dispatches on each of the options on the command line, and passes the remaining parameters to handle_...
void set_text()
Indicates that the filename represents a text file.
bool read(const Filename &fullpath)
Reads the PFM data from the indicated file, returning true on success, false on failure.
The name of a file, such as a texture file or an Egg file.
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component,...
void set_zero_special(bool zero_special)
Sets the zero_special flag.
This defines a bounding convex hexahedron.
static Filename from_os_specific(const std::string &os_specific, Type type=T_general)
This named constructor returns a Panda-style filename (that is, using forward slashes,...
bool process_pfm(const Filename &input_filename, PfmFile &file)
Handles a single pfm file.