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

pandatool/src/eggcharbase/eggCharacterFilter.cxx

Go to the documentation of this file.
00001 // Filename: eggCharacterFilter.cxx
00002 // Created by:  drose (23Feb01)
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 "eggCharacterFilter.h"
00020 #include "eggCharacterCollection.h"
00021 #include "eggCharacterData.h"
00022 
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //     Function: EggCharacterFilter::Constructor
00026 //       Access: Public
00027 //  Description:
00028 ////////////////////////////////////////////////////////////////////
00029 EggCharacterFilter::
00030 EggCharacterFilter() : EggMultiFilter(false) {
00031   _collection = (EggCharacterCollection *)NULL;
00032 }
00033 
00034 ////////////////////////////////////////////////////////////////////
00035 //     Function: EggCharacterFilter::Destructor
00036 //       Access: Public, Virtual
00037 //  Description:
00038 ////////////////////////////////////////////////////////////////////
00039 EggCharacterFilter::
00040 ~EggCharacterFilter() {
00041   if (_collection != (EggCharacterCollection *)NULL) {
00042     delete _collection;
00043   }
00044 }
00045 
00046 
00047 ////////////////////////////////////////////////////////////////////
00048 //     Function: EggCharacterFilter::post_command_line
00049 //       Access: Protected, Virtual
00050 //  Description:
00051 ////////////////////////////////////////////////////////////////////
00052 bool EggCharacterFilter::
00053 post_command_line() {
00054   if (_collection == (EggCharacterCollection *)NULL) {
00055     _collection = make_collection();
00056   }
00057 
00058   if (!EggMultiFilter::post_command_line()) {
00059     return false;
00060   }
00061 
00062   Eggs::iterator ei;
00063   for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
00064     EggData *data = (*ei);
00065 
00066     if (_collection->add_egg(data) < 0) {
00067       nout << data->get_egg_filename().get_basename()
00068            << " does not contain a character model or animation channel.\n";
00069       return false;
00070     }
00071   }
00072 
00073   return true;
00074 }
00075 
00076 ////////////////////////////////////////////////////////////////////
00077 //     Function: EggCharacterFilter::write_eggs
00078 //       Access: Protected, Virtual
00079 //  Description: Writes out all of the egg files in the _eggs vector,
00080 //               to the output directory if one is specified, or over
00081 //               the input files if -inplace was specified.
00082 ////////////////////////////////////////////////////////////////////
00083 void EggCharacterFilter::
00084 write_eggs() {
00085   // Optimize (that is, collapse redudant nodes) in all of the
00086   // characters' joint tables before writing them out.
00087   int num_characters = _collection->get_num_characters();
00088   for (int i = 0; i < num_characters; i++) {
00089     EggCharacterData *char_data = _collection->get_character(i);
00090     char_data->get_root_joint()->optimize();
00091   }
00092 
00093   EggMultiFilter::write_eggs();
00094 }
00095 
00096 ////////////////////////////////////////////////////////////////////
00097 //     Function: EggCharacterFilter::make_collection
00098 //       Access: Protected, Virtual
00099 //  Description: Allocates and returns a new EggCharacterCollection
00100 //               structure.  This is primarily intended as a hook so
00101 //               derived classes can customize the type of
00102 //               EggCharacterCollection object used to represent the
00103 //               character information.
00104 ////////////////////////////////////////////////////////////////////
00105 EggCharacterCollection *EggCharacterFilter::
00106 make_collection() {
00107   return new EggCharacterCollection;
00108 }

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