Panda3D
|
00001 // Filename: softToEggConverter.h 00002 // Created by: masad (25Sep03) 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 SOFTTOEGGCONVERTER_H 00016 #define SOFTTOEGGCONVERTER_H 00017 00018 #include "pandatoolbase.h" 00019 #include "somethingToEggConverter.h" 00020 #include "softNodeTree.h" 00021 00022 #include "eggTextureCollection.h" 00023 #include "distanceUnit.h" 00024 #include "coordinateSystem.h" 00025 00026 #ifdef _MIN 00027 #undef _MIN 00028 #endif 00029 #ifdef _MAX 00030 #undef _MAX 00031 #endif 00032 00033 #include <SAA.h> 00034 #include <SI_macros.h> 00035 00036 class EggData; 00037 class EggGroup; 00038 class EggTable; 00039 class EggVertexPool; 00040 class EggNurbsCurve; 00041 class EggPrimitive; 00042 class EggXfmSAnim; 00043 class EggSAnimData; 00044 00045 00046 //////////////////////////////////////////////////////////////////// 00047 // Class : SoftToEggConverter 00048 // Description : This class supervises the construction of an EggData 00049 // structure from a single Softimage file, or from the data 00050 // already in th cout << "egg name = " << eggFilename << endl;e global Softimage model space. 00051 // 00052 //////////////////////////////////////////////////////////////////// 00053 class SoftToEggConverter : public SomethingToEggConverter { 00054 public: 00055 SoftToEggConverter(const string &program_name = ""); 00056 SoftToEggConverter(const SoftToEggConverter ©); 00057 virtual ~SoftToEggConverter(); 00058 00059 void Help(); 00060 void Usage(); 00061 void ShowOpts(); 00062 00063 bool HandleGetopts(int &idx, int argc, char **argv); 00064 bool DoGetopts(int &argc, char **&argv); 00065 00066 SoftNodeDesc *find_node(string name); 00067 int *FindClosestTriVert( EggVertexPool *vpool, SAA_DVector *vertices, int numVert ); 00068 00069 virtual SomethingToEggConverter *make_copy(); 00070 virtual string get_name() const; 00071 virtual string get_extension() const; 00072 00073 virtual bool convert_file(const Filename &filename); 00074 bool convert_soft(bool from_selection); 00075 bool open_api(); 00076 void close_api(); 00077 00078 private: 00079 bool convert_flip(double start_frame, double end_frame, 00080 double frame_inc, double output_frame_rate); 00081 00082 bool make_soft_skin(); 00083 bool cleanup_soft_skin(); 00084 bool convert_char_chan(); 00085 bool convert_char_model(); 00086 bool convert_hierarchy(EggGroupNode *egg_root); 00087 bool process_model_node(SoftNodeDesc *node_desc); 00088 00089 void make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type); 00090 void make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type); 00091 void add_knots( vector <double> &eggKnots, double *knots, int numKnots, SAA_Boolean closed, int degree ); 00092 00093 void set_shader_attributes(SoftNodeDesc *node_desc, EggPrimitive &primitive, int idx); 00094 void apply_texture_properties(EggTexture &tex, int uRepeat, int vRepeat); 00095 00096 bool reparent_decals(EggGroupNode *egg_parent); 00097 00098 string _program_name; 00099 bool _from_selection; 00100 00101 SI_Error result; 00102 SAA_Elem model; 00103 SAA_Database database; 00104 00105 public: 00106 00107 SoftNodeTree _tree; 00108 00109 SAA_Scene scene; 00110 00111 char *_getopts; 00112 00113 // This is argv[0]. 00114 const char *_commandName; 00115 00116 // This is the entire command line. 00117 char _commandLine[4096]; 00118 00119 char *rsrc_path; 00120 char *database_name; 00121 char *scene_name; 00122 char *model_name; 00123 char *eggFileName; 00124 char *animFileName; 00125 char *eggGroupName; 00126 char *tex_path; 00127 char *tex_filename; 00128 char *search_prefix; 00129 00130 int nurbs_step; 00131 int anim_start; 00132 int anim_end; 00133 int anim_rate; 00134 int pose_frame; 00135 int verbose; 00136 int flatten; 00137 int shift_textures; 00138 int ignore_tex_offsets; 00139 int use_prefix; 00140 00141 bool foundRoot; 00142 bool geom_as_joint; 00143 bool make_anim; 00144 bool make_nurbs; 00145 bool make_poly; 00146 bool make_soft; 00147 bool make_morph; 00148 bool make_duv; 00149 bool make_dart; 00150 bool has_morph; 00151 bool make_pose; 00152 00153 00154 char *GetTextureName( SAA_Scene *scene, SAA_Elem *texture ); 00155 00156 EggTextureCollection _textures; 00157 00158 bool _polygon_output; 00159 double _polygon_tolerance; 00160 00161 enum TransformType { 00162 TT_invalid, 00163 TT_all, 00164 TT_model, 00165 TT_dcs, 00166 TT_none, 00167 }; 00168 TransformType _transform_type; 00169 00170 static TransformType string_transform_type(const string &arg); 00171 00172 typedef pvector<EggSAnimData *> MorphTable; 00173 MorphTable _morph_table; 00174 00175 EggTable *morph_node; 00176 EggSAnimData *find_morph_table(char *name); 00177 }; 00178 00179 extern const int TEX_PER_MAT; 00180 00181 #endif