Panda3D
eggToX.cxx
1 // Filename: eggToX.cxx
2 // Created by: drose (19Jun01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "eggToX.h"
16 #include "config_xfile.h"
17 #include "pystub.h"
18 
19 ////////////////////////////////////////////////////////////////////
20 // Function: EggToX::Constructor
21 // Access: Public
22 // Description:
23 ////////////////////////////////////////////////////////////////////
24 EggToX::
25 EggToX() : EggToSomething("DirectX", ".x", true, false) {
26  add_texture_options();
27  add_delod_options(0.0);
28 
29  set_program_brief("convert an .egg file into a DirectX .x file");
30  set_program_description
31  ("This program reads an Egg file and outputs an equivalent, "
32  "or nearly equivalent, DirectX-style .x file. Only simple "
33  "hierarchy and polygon meshes are supported; advanced features "
34  "like LOD's, decals, and animation or skinning are not supported.");
35 
36  add_option
37  ("m", "", 0,
38  "Convert all the objects in the egg file as one big mesh, instead of "
39  "preserving the normal egg hierarchy.",
40  &EggToX::dispatch_none, &xfile_one_mesh);
41 
42  // X files are always y-up-left.
43  remove_option("cs");
44  _got_coordinate_system = true;
45  _coordinate_system = CS_yup_left;
46 
47  // We always have -f on: force complete load. X files don't support
48  // external references.
49  remove_option("f");
50  _force_complete = true;
51 }
52 
53 
54 ////////////////////////////////////////////////////////////////////
55 // Function: EggToX::run
56 // Access: Public
57 // Description:
58 ////////////////////////////////////////////////////////////////////
59 void EggToX::
60 run() {
61  if (!do_reader_options()) {
62  exit(1);
63  }
64 
65  if (!_x.add_tree(_data)) {
66  nout << "Unable to define egg structure.\n";
67  exit(1);
68  }
69 
70  if (!_x.write(get_output_filename())) {
71  nout << "Unable to write " << get_output_filename() << ".\n";
72  exit(1);
73  }
74 }
75 
76 
77 int main(int argc, char *argv[]) {
78  // A call to pystub() to force libpystub.so to be linked in.
79  pystub();
80 
81  init_libxfile();
82  EggToX prog;
83  prog.parse_command_line(argc, argv);
84  prog.run();
85  return 0;
86 }
A program to read in a egg file and write an equivalent, or nearly equivalent, DirectX-style "x" file...
Definition: eggToX.h:34
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_...
This is the general base class for a file-converter program that reads some model file format and gen...