Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

pandatool/src/eggprogs/eggTrans.cxx

Go to the documentation of this file.
00001 // Filename: eggTrans.cxx
00002 // Created by:  drose (14Feb00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "eggTrans.h"
00020 #include "eggGroupUniquifier.h"
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //     Function: EggTrans::Constructor
00024 //       Access: Public
00025 //  Description:
00026 ////////////////////////////////////////////////////////////////////
00027 EggTrans::
00028 EggTrans() {
00029   add_path_replace_options();
00030   add_path_store_options();
00031   add_normals_options();
00032   add_transform_options();
00033   add_texture_options();
00034   add_delod_options();
00035 
00036   set_program_description
00037     ("egg-trans reads an egg file and writes an essentially equivalent "
00038      "egg file to the standard output, or to the file specified with -o.  "
00039      "Some simple operations on the egg file are supported.");
00040 
00041   add_option
00042     ("F", "", 0,
00043      "Flatten out transforms.",
00044      &EggTrans::dispatch_none, &_flatten_transforms);
00045 
00046   add_option
00047     ("t", "", 0,
00048      "Apply texture matrices to UV's.",
00049      &EggTrans::dispatch_none, &_apply_texmats);
00050 
00051   add_option
00052     ("T", "", 0,
00053      "Collapse equivalent texture references.",
00054      &EggTrans::dispatch_none, &_collapse_equivalent_textures);
00055 
00056   add_option
00057     ("c", "", 0,
00058      "Clean out degenerate polygons and unused vertices.",
00059      &EggTrans::dispatch_none, &_remove_invalid_primitives);
00060 
00061   add_option
00062     ("C", "", 0,
00063      "Clean out higher-order polygons by subdividing into triangles.",
00064      &EggTrans::dispatch_none, &_triangulate_polygons);
00065 
00066   add_option
00067     ("N", "", 0,
00068      "Standardize and uniquify group names.",
00069      &EggTrans::dispatch_none, &_standardize_names);
00070 
00071 }
00072 
00073 ////////////////////////////////////////////////////////////////////
00074 //     Function: EggTrans::run
00075 //       Access: Public
00076 //  Description:
00077 ////////////////////////////////////////////////////////////////////
00078 void EggTrans::
00079 run() {
00080   if (_remove_invalid_primitives) {
00081     nout << "Removing invalid primitives.\n";
00082     int num_removed = _data.remove_invalid_primitives();
00083     nout << "  (" << num_removed << " removed.)\n";
00084     _data.remove_unused_vertices();
00085   }
00086 
00087   if (_triangulate_polygons) {
00088     nout << "Triangulating polygons.\n";
00089     int num_produced = _data.triangulate_polygons(true);
00090     nout << "  (" << num_produced << " triangles produced.)\n";
00091   }
00092 
00093   if (_apply_texmats) {
00094     nout << "Applying texture matrices.\n";
00095     _data.apply_texmats();
00096     _data.remove_unused_vertices();
00097   }
00098 
00099   if (_collapse_equivalent_textures) {
00100     nout << "Collapsing equivalent textures.\n";
00101     int num_removed = _data.collapse_equivalent_textures();
00102     nout << "  (" << num_removed << " removed.)\n";
00103   }
00104 
00105   if (_flatten_transforms) {
00106     nout << "Flattening transforms.\n";
00107     _data.flatten_transforms();
00108     _data.remove_unused_vertices();
00109   }
00110 
00111   if (_standardize_names) {
00112     nout << "Standardizing group names.\n";
00113     EggGroupUniquifier uniquifier;
00114     uniquifier.uniquify(&_data);
00115   }
00116 
00117   if (!do_reader_options()) {
00118     exit(1);
00119   }
00120 
00121   write_egg_file();
00122 }
00123 
00124 
00125 int main(int argc, char *argv[]) {
00126   EggTrans prog;
00127   prog.parse_command_line(argc, argv);
00128   prog.run();
00129   return 0;
00130 }

Generated on Fri May 2 03:18:54 2003 for Panda-Tool by doxygen1.3