Panda3D
eggToX.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 eggToX.cxx
10  * @author drose
11  * @date 2001-06-19
12  */
13 
14 #include "eggToX.h"
15 #include "config_xfile.h"
16 
17 /**
18  *
19  */
20 EggToX::
21 EggToX() : EggToSomething("DirectX", ".x", true, false) {
22  add_texture_options();
23  add_delod_options(0.0);
24 
25  set_program_brief("convert an .egg file into a DirectX .x file");
26  set_program_description
27  ("This program reads an Egg file and outputs an equivalent, "
28  "or nearly equivalent, DirectX-style .x file. Only simple "
29  "hierarchy and polygon meshes are supported; advanced features "
30  "like LOD's, decals, and animation or skinning are not supported.");
31 
32  add_option
33  ("m", "", 0,
34  "Convert all the objects in the egg file as one big mesh, instead of "
35  "preserving the normal egg hierarchy.",
36  &EggToX::dispatch_none, &xfile_one_mesh);
37 
38  // X files are always y-up-left.
39  remove_option("cs");
40  _got_coordinate_system = true;
41  _coordinate_system = CS_yup_left;
42 
43  // We always have -f on: force complete load. X files don't support
44  // external references.
45  remove_option("f");
46  _force_complete = true;
47 }
48 
49 
50 /**
51  *
52  */
53 void EggToX::
54 run() {
55  if (!do_reader_options()) {
56  exit(1);
57  }
58 
59  if (!_x.add_tree(_data)) {
60  nout << "Unable to define egg structure.\n";
61  exit(1);
62  }
63 
64  if (!_x.write(get_output_filename())) {
65  nout << "Unable to write " << get_output_filename() << ".\n";
66  exit(1);
67  }
68 }
69 
70 
71 int main(int argc, char *argv[]) {
72  init_libxfile();
73  EggToX prog;
74  prog.parse_command_line(argc, argv);
75  prog.run();
76  return 0;
77 }
A program to read in a egg file and write an equivalent, or nearly equivalent, DirectX-style "x" file...
Definition: eggToX.h:31
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_...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Filename get_output_filename() const
If has_output_filename() returns true, this is the filename that the user specified.
bool add_tree(EggData *egg_data)
Adds the egg tree rooted at the indicated node to the X structure.
Definition: xFileMaker.cxx:64
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void init_libxfile()
Initializes the library.
This is the general base class for a file-converter program that reads some model file format and gen...
bool write(const Filename &filename)
Writes the .x file data to the indicated filename; returns true on success, false otherwise.
Definition: xFileMaker.cxx:54