Panda3D
vrmlToEgg.cxx
1 // Filename: vrmlToEgg.cxx
2 // Created by: drose (01Oct04)
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 "vrmlToEgg.h"
16 
17 #include "vrmlToEggConverter.h"
18 #include "pystub.h"
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: VRMLToEgg::Constructor
22 // Access: Public
23 // Description:
24 ////////////////////////////////////////////////////////////////////
25 VRMLToEgg::
26 VRMLToEgg() :
27  SomethingToEgg("VRML", ".wrl")
28 {
29  add_units_options();
30  add_normals_options();
31  add_transform_options();
32 
33  set_program_brief("convert VRML 2.0 model files to .egg");
34  set_program_description
35  ("This program converts VRML 2.0 model files to egg. Animated files, "
36  "and VRML 1.0 files, are not supported.");
37 
38  redescribe_option
39  ("cs",
40  "Specify the coordinate system of the input " + _format_name +
41  " file. Normally, this is y-up.");
42 
43  _coordinate_system = CS_yup_right;
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: VRMLToEgg::run
48 // Access: Public
49 // Description:
50 ////////////////////////////////////////////////////////////////////
51 void VRMLToEgg::
52 run() {
53  nout << "Reading " << _input_filename << "\n";
54 
55  _data->set_coordinate_system(_coordinate_system);
56 
57  VRMLToEggConverter converter;
58  converter.set_egg_data(_data);
59  converter._allow_errors = _allow_errors;
60 
61  apply_parameters(converter);
62 
63  if (!converter.convert_file(_input_filename)) {
64  nout << "Errors in conversion.\n";
65  exit(1);
66  }
67 
68  write_egg_file();
69  nout << "\n";
70 }
71 
72 
73 int main(int argc, char *argv[]) {
74  // A call to pystub() to force libpystub.so to be linked in.
75  pystub();
76 
77  VRMLToEgg prog;
78  prog.parse_command_line(argc, argv);
79  prog.run();
80  return 0;
81 }
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_...
A program to read a VRML file and generate an egg file.
Definition: vrmlToEgg.h:28
This class supervises the construction of an EggData structure from a VRML 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...
virtual bool convert_file(const Filename &filename)
Handles the reading of the input file and converting it to egg.