Panda3D
Loading...
Searching...
No Matches
fltToEgg.cxx
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file fltToEgg.cxx
10 * @author drose
11 * @date 2001-04-17
12 */
13
14#include "fltToEgg.h"
15
16#include "fltToEggConverter.h"
17#include "config_flt.h"
18
19/**
20 *
21 */
22FltToEgg::
23FltToEgg() :
24 SomethingToEgg("MultiGen", ".flt")
25{
26 add_path_replace_options();
27 add_path_store_options();
28 add_units_options();
29 add_normals_options();
30 add_transform_options();
31 add_merge_externals_options();
32
33 set_program_brief("convert a MultiGen .flt file to .egg");
34 set_program_description
35 ("This program converts MultiGen OpenFlight (.flt) files to egg. Most "
36 "features of MultiGen that are also recognized by egg are supported.");
37
38 redescribe_option
39 ("cs",
40 "Specify the coordinate system of the input " + _format_name +
41 " file. Normally, this is z-up.");
42
43 // Does anyone really care about this option? It's mainly useful for
44 // debugging the flt2egg logic.
45 /*
46 add_option
47 ("C", "", 0,
48 "Compose node transforms into a single matrix before writing them to "
49 "the egg file, instead of writing them as individual scale, rotate, and "
50 "translate operations.",
51 &FltToEgg::dispatch_none, &_compose_transforms);
52 */
53 _compose_transforms = false;
54
55 _coordinate_system = CS_zup_right;
56}
57
58/**
59 *
60 */
61void FltToEgg::
62run() {
63 _data->set_coordinate_system(_coordinate_system);
64
65 FltToEggConverter converter;
66 converter.set_merge_externals(_merge_externals);
67 converter.set_egg_data(_data);
68 converter._compose_transforms = _compose_transforms;
69 converter._allow_errors = _allow_errors;
70
71 apply_parameters(converter);
72
73
74 PT(FltHeader) header = new FltHeader(_path_replace);
75
76 nout << "Reading " << _input_filename << "\n";
77 FltError result = header->read_flt(_input_filename);
78 if (result != FE_ok) {
79 nout << "Unable to read: " << result << "\n";
80 exit(1);
81 }
82
83 header->check_version();
84
85
86 if (!converter.convert_flt(header)) {
87 nout << "Errors in conversion.\n";
88 exit(1);
89 }
90
91 if (_input_units == DU_invalid) {
92 _input_units = converter.get_input_units();
93 }
94
96 nout << "\n";
97}
98
99
100int main(int argc, char *argv[]) {
101 init_libflt();
102 FltToEgg prog;
103 prog.parse_command_line(argc, argv);
104 prog.run();
105 return 0;
106}
void write_egg_file()
Writes out the egg file as the normal result of the program.
This is the first bead in the file, the top of the bead hierarchy, and the primary interface to readi...
Definition fltHeader.h:44
This class supervises the construction of an EggData structure from the data represented by the FltHe...
virtual DistanceUnit get_input_units()
This may be called after convert_file() has been called and returned true, indicating a successful co...
bool convert_flt(const FltHeader *flt_header)
Fills up the egg_data structure according to the indicated lwo structure.
A program to read a flt file and generate an egg file.
Definition fltToEgg.h:27
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_merge_externals(bool merge_externals)
Sets the merge_externals flag.
void set_egg_data(EggData *egg_data)
Sets the egg data that will be filled in when convert_file() is called.
This is the general base class for a file-converter program that reads some model file format and gen...
void init_libflt()
Initializes the library.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.