16 #include "config_pfm.h"
27 set_program_brief(
"generate .bba files from .pfm files");
28 set_program_description
29 (
"pfm-bba generates a .bba file from a .pfm file that lists the "
30 "planar bounding volume of the pfm's internal data.");
34 "Treats (0,0,0) in the pfm file as a special don't-touch value.",
35 &PfmBba::dispatch_none, &_got_zero_special);
39 "Specify the filename to which the resulting bba file will be written.",
40 &PfmBba::dispatch_filename, &_got_output_filename, &_output_filename);
51 Filenames::const_iterator fi;
52 for (fi = _input_filenames.begin(); fi != _input_filenames.end(); ++fi) {
54 if (!file.
read(*fi)) {
55 nout <<
"Cannot read " << *fi <<
"\n";
74 if (_got_output_filename) {
75 bba_filename = _output_filename;
77 bba_filename = input_filename;
81 if (!bba_filename.empty()) {
88 cerr <<
"Unable to open " << bba_filename <<
"\n";
93 for (
int i = 0; i < 8; ++i) {
94 points[i] = bounds->get_point(i);
110 for (
int i = 0; i < 8; ++i) {
112 out << p[0] <<
"," << p[1] <<
"," << p[2] <<
"\n";
130 nout <<
"You must specify the pfm file(s) to read on the command line.\n";
134 if (args.size() > 1 && _got_output_filename) {
135 nout <<
"Cannot use -o when multiple pfm files are specified.\n";
139 Args::const_iterator ai;
140 for (ai = args.begin(); ai != args.end(); ++ai) {
148 int main(
int argc,
char *argv[]) {
void set_extension(const string &s)
Replaces the file extension.
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.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
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, or with a special extension, 2- or 4-component.
void set_zero_special(bool zero_special)
Sets the zero_special flag.
This is a two-component point in space.
bool open_write(ofstream &stream, bool truncate=true) const
Opens the indicated ifstream for writing the file, if possible.
This defines a bounding convex hexahedron.
bool process_pfm(const Filename &input_filename, PfmFile &file)
Handles a single pfm file.
static Filename from_os_specific(const string &os_specific, Type type=T_general)
This named constructor returns a Panda-style filename (that is, using forward slashes, and no drive letter) based on the supplied filename string that describes a filename in the local system conventions (for instance, on Windows, it may use backslashes or begin with a drive letter and a colon).