Panda3D
daeToEgg.cxx
1 // Filename: daeToEgg.cxx
2 // Created by: pro-rsoft (08May08)
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 "daeToEgg.h"
16 
17 #include "daeToEggConverter.h"
18 #include "pystub.h"
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: DAEToEgg::Constructor
22 // Access: Public
23 // Description:
24 ////////////////////////////////////////////////////////////////////
25 DAEToEgg::
26 DAEToEgg():
27  SomethingToEgg("COLLADA", ".dae")
28 {
29  add_animation_options();
30  add_units_options();
31  add_normals_options();
32  add_transform_options();
33 
34  add_option
35  ("invtrans", "", false,
36  "Import the .dae file using inverted transparency. "
37  "This is useful when importing COLLADA files from some authoring tools "
38  "that export models with inverted transparency, such as Google SketchUp.",
39  &SomethingToEgg::dispatch_none, &_invert_transparency);
40 
41  set_program_brief("convert COLLADA assets into .egg files");
42  set_program_description
43  ("This program converts .dae files (COLLADA Digital Asset Exchange) to .egg.");
44 
45  _coordinate_system = CS_yup_right;
46  _animation_convert = AC_both;
47 }
48 
49 ////////////////////////////////////////////////////////////////////
50 // Function: DAEToEgg::run
51 // Access: Public
52 // Description:
53 ////////////////////////////////////////////////////////////////////
54 void DAEToEgg::
55 run() {
56  if (_animation_convert != AC_both && _animation_convert != AC_none &&
57  _animation_convert != AC_chan && _animation_convert != AC_model) {
58  cerr << "Unsupported animation convert option.\n";
59  exit(1);
60  }
61 
62  nout << "Reading " << _input_filename << "\n";
63 
64  _data->set_coordinate_system(_coordinate_system);
65 
66  DAEToEggConverter converter;
67  converter.set_egg_data(_data);
68  converter._allow_errors = _allow_errors;
69  converter._invert_transparency = _invert_transparency;
70 
71  apply_parameters(converter);
72 
73  if (!converter.convert_file(_input_filename)) {
74  nout << "Errors in conversion.\n";
75  exit(1);
76  }
77 
78  write_egg_file();
79  nout << "\n";
80 }
81 
82 
83 int main(int argc, char *argv[]) {
84  // A call to pystub() to force libpystub.so to be linked in.
85  pystub();
86 
87  DAEToEgg prog;
88  prog.parse_command_line(argc, argv);
89  prog.run();
90  return 0;
91 }
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_...
virtual bool convert_file(const Filename &filename)
Handles the reading of the input file and converting it to egg.
This class supervises the construction of an EggData structure from a DAE file.
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...
A program to read a DAE file and generate an egg file.
Definition: daeToEgg.h:28