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

pandatool/src/eggcharbase/eggCharacterCollection.h

Go to the documentation of this file.
00001 // Filename: eggCharacterCollection.h
00002 // Created by:  drose (26Feb01)
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 #ifndef EGGCHARACTERCOLLECTION_H
00020 #define EGGCHARACTERCOLLECTION_H
00021 
00022 #include <pandatoolbase.h>
00023 
00024 #include "eggCharacterData.h"
00025 
00026 #include <eggData.h>
00027 #include <eggNode.h>
00028 #include <pointerTo.h>
00029 
00030 class EggTable;
00031 class EggAttributes;
00032 
00033 ////////////////////////////////////////////////////////////////////
00034 //       Class : EggCharacterCollection
00035 // Description : Represents a set of characters, as read and collected
00036 //               from possibly several model and/or animation egg
00037 //               files.
00038 ////////////////////////////////////////////////////////////////////
00039 class EggCharacterCollection {
00040 public:
00041   EggCharacterCollection();
00042   virtual ~EggCharacterCollection();
00043 
00044   int add_egg(EggData *egg);
00045 
00046   INLINE int get_num_eggs() const;
00047   INLINE EggData *get_egg(int i) const;
00048   INLINE int get_first_model_index(int egg_index) const;
00049   INLINE int get_num_models(int egg_index) const;
00050 
00051   INLINE int get_num_characters() const;
00052   INLINE EggCharacterData *get_character(int i) const;
00053   EggCharacterData *get_character_by_name(const string &character_name) const;
00054 
00055   INLINE EggCharacterData *get_character_by_model_index(int model_index) const;
00056 
00057   virtual void write(ostream &out, int indent_level = 0) const;
00058 
00059   virtual EggCharacterData *make_character_data();
00060   virtual EggJointData *make_joint_data(EggCharacterData *char_data);
00061   virtual EggSliderData *make_slider_data(EggCharacterData *char_data);
00062 
00063 public:
00064   EggCharacterData *make_character(const string &character_name);
00065 
00066   class EggInfo {
00067   public:
00068     PT(EggData) _egg;
00069     typedef pvector<PT(EggNode)> Models;
00070     Models _models;
00071     int _first_model_index;
00072   };
00073 
00074   typedef pvector<EggInfo> Eggs;
00075   Eggs _eggs;
00076 
00077   typedef pvector<EggCharacterData *> Characters;
00078   Characters _characters;
00079   Characters _characters_by_model_index;
00080 
00081 private:
00082   bool scan_hierarchy(EggNode *egg_node);
00083   void scan_for_top_joints(EggNode *egg_node, EggNode *model_root,
00084                            const string &character_name);
00085   void scan_for_top_tables(EggTable *bundle, EggNode *model_root,
00086                            const string &character_name);
00087   void scan_for_morphs(EggNode *egg_node, int model_index,
00088                        EggCharacterData *char_data);
00089   void scan_for_sliders(EggNode *egg_node, int model_index,
00090                         EggCharacterData *char_data);
00091 
00092   void add_morph_back_pointers(EggAttributes *attrib, EggObject *egg_object,
00093                                int model_index, EggCharacterData *char_data);
00094 
00095   // The _top_egg_nodes member is only used temporarily, when adding
00096   // each pre-existing egg file to the structure for the first time.
00097   typedef pvector<EggNode *> EggNodeList;
00098   typedef pmap<EggNode *, EggNodeList> TopEggNodes;
00099   typedef pmap<string, TopEggNodes> TopEggNodesByName;
00100   TopEggNodesByName _top_egg_nodes;
00101 
00102   int _next_model_index;
00103 
00104   void match_egg_nodes(EggCharacterData *char_Data, EggJointData *joint_data,
00105                        EggNodeList &egg_nodes, int egg_index, int model_index);
00106   void found_egg_match(EggCharacterData *char_data, EggJointData *joint_data,
00107                        EggNode *egg_node, int egg_index, int model_index);
00108 };
00109 
00110 #include "eggCharacterCollection.I"
00111 
00112 #endif
00113 
00114 

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