Panda3D
 All Classes Functions Variables Enumerations
xFileToEggConverter.h
00001 // Filename: xFileToEggConverter.h
00002 // Created by:  drose (21Jun01)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef XFILETOEGGCONVERTER_H
00016 #define XFILETOEGGCONVERTER_H
00017 
00018 #include "pandatoolbase.h"
00019 #include "xFileAnimationSet.h"
00020 #include "xFile.h"
00021 #include "somethingToEggConverter.h"
00022 #include "eggTextureCollection.h"
00023 #include "eggMaterialCollection.h"
00024 #include "pvector.h"
00025 #include "pmap.h"
00026 #include "luse.h"
00027 #include "pointerTo.h"
00028 
00029 class Datagram;
00030 class XFileMesh;
00031 class XFileMaterial;
00032 class EggGroup;
00033 class EggGroupNode;
00034 class EggTexture;
00035 class EggMaterial;
00036 class XFileDataObject;
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //       Class : XFileToEggConverter
00040 // Description : 
00041 ////////////////////////////////////////////////////////////////////
00042 class XFileToEggConverter : public SomethingToEggConverter {
00043 public:
00044   XFileToEggConverter();
00045   XFileToEggConverter(const XFileToEggConverter &copy);
00046   ~XFileToEggConverter();
00047 
00048   virtual SomethingToEggConverter *make_copy();
00049 
00050   virtual string get_name() const;
00051   virtual string get_extension() const;
00052   virtual bool supports_compressed() const;
00053 
00054   virtual bool convert_file(const Filename &filename);
00055   void close();
00056 
00057   EggGroup *get_dart_node() const;
00058 
00059   EggTexture *create_unique_texture(const EggTexture &copy);
00060   EggMaterial *create_unique_material(const EggMaterial &copy);
00061   EggGroup *find_joint(const string &joint_name);
00062   void strip_nodes(TypeHandle t);
00063 
00064 public:
00065   bool _make_char;
00066   string _char_name;
00067   double _frame_rate;
00068   bool _keep_model;
00069   bool _keep_animation;
00070 
00071 private:
00072   typedef XFileAnimationSet::FrameData FrameData;
00073   
00074   bool get_toplevel();
00075   bool convert_toplevel_object(XFileDataNode *obj, EggGroupNode *egg_parent);
00076   bool convert_object(XFileDataNode *obj, EggGroupNode *egg_parent);
00077   bool convert_frame(XFileDataNode *obj, EggGroupNode *egg_parent);
00078   bool convert_transform(XFileDataNode *obj, EggGroupNode *egg_parent);
00079   bool convert_animation_set(XFileDataNode *obj);
00080   bool convert_animation_set_object(XFileDataNode *obj, 
00081                                     XFileAnimationSet &animation_set);
00082   bool convert_animation(XFileDataNode *obj, 
00083                          XFileAnimationSet &animation_set);
00084   bool convert_animation_object(XFileDataNode *obj, 
00085                                 const string &joint_name, FrameData &table);
00086   bool convert_animation_key(XFileDataNode *obj, const string &joint_name,
00087                              FrameData &table);
00088   bool set_animation_frame(const string &joint_name, FrameData &table, 
00089                            int frame, int key_type,
00090                            const XFileDataObject &values); 
00091   bool convert_mesh(XFileDataNode *obj, EggGroupNode *egg_parent);
00092 
00093   bool create_polygons();
00094   bool create_hierarchy();
00095 
00096   PT(XFile) _x_file;
00097 
00098   bool _any_frames;
00099   bool _any_animation;
00100   int _ticks_per_second;
00101   int _total_tick_deltas;
00102   int _num_ticks;
00103 
00104   typedef pvector<XFileMesh *> Meshes;
00105   Meshes _meshes;
00106 
00107   typedef pvector<XFileAnimationSet *> AnimationSets;
00108   AnimationSets _animation_sets;
00109     
00110   typedef pmap<string, EggGroup *> Joints;
00111   Joints _joints;
00112 
00113   EggGroup *_dart_node;
00114 
00115   EggTextureCollection _textures;
00116   EggMaterialCollection _materials;
00117 };
00118 
00119 #endif
 All Classes Functions Variables Enumerations