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

pandatool/src/eggcharbase/eggCharacterData.cxx

Go to the documentation of this file.
00001 // Filename: eggCharacterData.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 "eggCharacterData.h"
00020 #include "eggCharacterCollection.h"
00021 #include "eggJointData.h"
00022 #include "eggSliderData.h"
00023 
00024 #include "indent.h"
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //     Function: EggCharacterData::Constructor
00028 //       Access: Public
00029 //  Description:
00030 ////////////////////////////////////////////////////////////////////
00031 EggCharacterData::
00032 EggCharacterData(EggCharacterCollection *collection) {
00033   _collection = collection;
00034   _root_joint = _collection->make_joint_data(this);
00035 }
00036 
00037 ////////////////////////////////////////////////////////////////////
00038 //     Function: EggCharacterData::Destructor
00039 //       Access: Public, Virtual
00040 //  Description:
00041 ////////////////////////////////////////////////////////////////////
00042 EggCharacterData::
00043 ~EggCharacterData() {
00044   delete _root_joint;
00045 
00046   Sliders::iterator si;
00047   for (si = _sliders.begin(); si != _sliders.end(); ++si) {
00048     EggSliderData *slider = (*si).second;
00049     delete slider;
00050   }
00051 }
00052 
00053 ////////////////////////////////////////////////////////////////////
00054 //     Function: EggCharacterData::add_model
00055 //       Access: Public
00056 //  Description: Indicates that the given model_index (with the
00057 //               indicated model_root) is associated with this
00058 //               character.  This is normally called by the
00059 //               EggCharacterCollection class as new models are
00060 //               discovered.
00061 //
00062 //               A "model" here is either a character model (or one
00063 //               LOD of a character model), or a character animation
00064 //               file: in either case, a hierarchy of joints.
00065 ////////////////////////////////////////////////////////////////////
00066 void EggCharacterData::
00067 add_model(int model_index, EggNode *model_root) {
00068   Model m;
00069   m._model_index = model_index;
00070   m._model_root = model_root;
00071   _models.push_back(m);
00072 }
00073 
00074 ////////////////////////////////////////////////////////////////////
00075 //     Function: EggCharacterData::make_slider
00076 //       Access: Public
00077 //  Description: Returns the slider matching the indicated name.  If
00078 //               no such slider exists already, creates a new one.
00079 ////////////////////////////////////////////////////////////////////
00080 EggSliderData *EggCharacterData::
00081 make_slider(const string &name) {
00082   Sliders::iterator si;
00083   si = _sliders.find(name);
00084   if (si != _sliders.end()) {
00085     return (*si).second;
00086   }
00087 
00088   EggSliderData *slider = _collection->make_slider_data(this);
00089   slider->set_name(name);
00090   _sliders.insert(Sliders::value_type(name, slider));
00091   return slider;
00092 }
00093 
00094 ////////////////////////////////////////////////////////////////////
00095 //     Function: EggCharacterData::write
00096 //       Access: Public, Virtual
00097 //  Description:
00098 ////////////////////////////////////////////////////////////////////
00099 void EggCharacterData::
00100 write(ostream &out, int indent_level) const {
00101   indent(out, indent_level)
00102     << "Character " << get_name() << ":\n";
00103   get_root_joint()->write(out, indent_level + 2);
00104 
00105   Sliders::const_iterator si;
00106   for (si = _sliders.begin(); si != _sliders.end(); ++si) {
00107     EggSliderData *slider = (*si).second;
00108     slider->write(out, indent_level + 2);
00109   }
00110 }

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