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

pandatool/src/mayaegg/mayaToEggConverter.h

Go to the documentation of this file.
00001 // Filename: mayaToEggConverter.h
00002 // Created by:  drose (10Nov99)
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 MAYATOEGGCONVERTER_H
00020 #define MAYATOEGGCONVERTER_H
00021 
00022 #include "pandatoolbase.h"
00023 #include "somethingToEggConverter.h"
00024 
00025 #include "mayaApi.h"
00026 #include "mayaShaders.h"
00027 #include "eggTextureCollection.h"
00028 #include "distanceUnit.h"
00029 #include "coordinateSystem.h"
00030 
00031 #include "pre_maya_include.h"
00032 #include <maya/MDagPath.h>
00033 #include "post_maya_include.h"
00034 
00035 class EggData;
00036 class EggGroup;
00037 class EggTable;
00038 class EggVertexPool;
00039 class EggNurbsCurve;
00040 class EggPrimitive;
00041 class EggXfmSAnim;
00042 class MayaShaderColorDef;
00043 
00044 class MDagPath;
00045 class MFnDagNode;
00046 class MFnNurbsSurface;
00047 class MFnNurbsCurve;
00048 class MFnMesh;
00049 class MPointArray;
00050 class MFloatArray;
00051 
00052 ////////////////////////////////////////////////////////////////////
00053 //       Class : MayaToEggConverter
00054 // Description : This class supervises the construction of an EggData
00055 //               structure from a single Maya file, or from the data
00056 //               already in the global Maya model space.
00057 //
00058 //               Note that since the Maya API presents just one global
00059 //               model space, it is not possible to simultaneously
00060 //               load two distinct Maya files.
00061 ////////////////////////////////////////////////////////////////////
00062 class MayaToEggConverter : public SomethingToEggConverter {
00063 public:
00064   MayaToEggConverter(const string &program_name = "");
00065   MayaToEggConverter(const MayaToEggConverter &copy);
00066   virtual ~MayaToEggConverter();
00067 
00068   virtual SomethingToEggConverter *make_copy();
00069 
00070   virtual string get_name() const;
00071   virtual string get_extension() const;
00072 
00073   virtual bool convert_file(const Filename &filename);
00074   bool convert_maya(bool from_selection);
00075 
00076   bool open_api();
00077   void close_api();
00078 
00079 private:
00080   bool convert_flip(double start_frame, double end_frame, 
00081                     double frame_inc, double output_frame_rate);
00082   bool convert_char_model();
00083   bool convert_char_chan(double start_frame, double end_frame, 
00084                          double frame_inc, double output_frame_rate);
00085   bool convert_hierarchy(EggGroupNode *egg_root);
00086   bool process_model_node(const MDagPath &dag_path, EggGroupNode *egg_root);
00087   bool process_chan_node(const MDagPath &dag_path, EggGroupNode *egg_root);
00088   void get_transform(const MDagPath &dag_path, EggGroup *egg_group);
00089 
00090   // I ran into core dumps trying to pass around a MFnMesh object by
00091   // value.  From now on, all MFn* objects will be passed around by
00092   // reference.
00093   void make_nurbs_surface(const MDagPath &dag_path, 
00094                           MFnNurbsSurface &surface,
00095                           EggGroup *group, EggGroupNode *egg_root);
00096   EggNurbsCurve *make_trim_curve(const MFnNurbsCurve &curve,
00097                                  const string &nurbs_name,
00098                                  EggGroupNode *egg_group,
00099                                  int trim_curve_index);
00100   void make_nurbs_curve(const MDagPath &dag_path, 
00101                         const MFnNurbsCurve &curve,
00102                         EggGroup *group, EggGroupNode *egg_root);
00103   void make_polyset(const MDagPath &dag_path,
00104                     const MFnMesh &mesh,
00105                     EggGroup *egg_group, EggGroupNode *egg_root,
00106                     MayaShader *default_shader = NULL);
00107   void make_locator(const MDagPath &dag_path, const MFnDagNode &dag_node,
00108                     EggGroup *egg_group, EggGroupNode *egg_root);
00109   bool get_vertex_weights(const MDagPath &dag_path, const MFnMesh &mesh,
00110                           EggGroupNode *egg_root,
00111                           pvector<EggGroup *> &joints, MFloatArray &weights);
00112   class JointAnim {
00113   public:
00114     MDagPath _dag_path;
00115     EggTable *_table;
00116     EggXfmSAnim *_anim;
00117   };
00118 
00119   EggGroup *get_egg_group(const MDagPath &dag_path, EggGroupNode *egg_root);
00120   EggGroup *r_get_egg_group(const string &name, const MDagPath &dag_path,
00121                             EggGroupNode *egg_root);
00122   JointAnim *get_egg_table(const MDagPath &dag_path, EggGroupNode *egg_root);
00123   JointAnim *get_egg_table(const string &name, EggGroupNode *egg_root);
00124   void set_shader_attributes(EggPrimitive &primitive,
00125                              const MayaShader &shader);
00126   void apply_texture_properties(EggTexture &tex, 
00127                                 const MayaShaderColorDef &color_def);
00128   bool compare_texture_properties(EggTexture &tex, 
00129                                   const MayaShaderColorDef &color_def);
00130 
00131   bool reparent_decals(EggGroupNode *egg_parent);
00132 
00133   typedef pmap<string, EggGroup *> Groups;
00134   Groups _groups;
00135 
00136   typedef pmap<string, JointAnim *> Tables;
00137   Tables _tables;
00138 
00139   string _program_name;
00140   bool _from_selection;
00141 
00142 public:
00143   MayaShaders _shaders;
00144   EggTextureCollection _textures;
00145   PT(MayaApi) _maya;
00146 
00147   bool _polygon_output;
00148   double _polygon_tolerance;
00149 
00150   enum TransformType {
00151     TT_invalid,
00152     TT_all,
00153     TT_model,
00154     TT_dcs,
00155     TT_none,
00156   };
00157   TransformType _transform_type;
00158 
00159   static TransformType string_transform_type(const string &arg);
00160 };
00161 
00162 
00163 #endif

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