Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov. 00019 * 00020 * ***** END GPL LICENSE BLOCK ***** 00021 */ 00022 00027 #ifndef __DOCUMENTIMPORTER_H__ 00028 #define __DOCUMENTIMPORTER_H__ 00029 00030 #include "COLLADAFWIWriter.h" 00031 #include "COLLADAFWMaterial.h" 00032 #include "COLLADAFWEffect.h" 00033 #include "COLLADAFWColor.h" 00034 #include "COLLADAFWImage.h" 00035 #include "COLLADAFWInstanceGeometry.h" 00036 #include "COLLADAFWController.h" 00037 #include "COLLADAFWMorphController.h" 00038 #include "COLLADAFWSkinController.h" 00039 #include "COLLADAFWEffectCommon.h" 00040 00041 00042 #include "BKE_object.h" 00043 00044 #include "TransformReader.h" 00045 #include "AnimationImporter.h" 00046 #include "ArmatureImporter.h" 00047 #include "MeshImporter.h" 00048 00049 00050 00051 struct Main; 00052 struct bContext; 00053 00055 class DocumentImporter : COLLADAFW::IWriter 00056 { 00057 public: 00059 enum ImportStage { 00060 General, 00061 Controller, 00062 }; 00064 DocumentImporter(bContext *C, const char *filename); 00065 00067 ~DocumentImporter(); 00068 00070 bool import(); 00071 00073 Object* create_camera_object(COLLADAFW::InstanceCamera*, Scene*); 00074 Object* create_lamp_object(COLLADAFW::InstanceLight*, Scene*); 00075 Object* create_instance_node(Object*, COLLADAFW::Node*, COLLADAFW::Node*, Scene*, Object*, bool); 00076 void write_node(COLLADAFW::Node*, COLLADAFW::Node*, Scene*, Object*, bool); 00077 MTex* create_texture(COLLADAFW::EffectCommon*, COLLADAFW::Texture&, Material*, int, TexIndexTextureArrayMap&); 00078 void write_profile_COMMON(COLLADAFW::EffectCommon*, Material*); 00079 void translate_anim_recursive(COLLADAFW::Node*, COLLADAFW::Node*, Object*); 00080 00085 void cancel(const COLLADAFW::String& errorMessage); 00086 00088 void start(); 00089 00091 void finish(); 00092 00093 bool writeGlobalAsset(const COLLADAFW::FileInfo*); 00094 00095 bool writeScene(const COLLADAFW::Scene*); 00096 00097 bool writeVisualScene(const COLLADAFW::VisualScene*); 00098 00099 bool writeLibraryNodes(const COLLADAFW::LibraryNodes*); 00100 00101 bool writeAnimation(const COLLADAFW::Animation*); 00102 00103 bool writeAnimationList(const COLLADAFW::AnimationList*); 00104 00105 bool writeGeometry(const COLLADAFW::Geometry*); 00106 00107 bool writeMaterial(const COLLADAFW::Material*); 00108 00109 bool writeEffect(const COLLADAFW::Effect*); 00110 00111 bool writeCamera(const COLLADAFW::Camera*); 00112 00113 bool writeImage(const COLLADAFW::Image*); 00114 00115 bool writeLight(const COLLADAFW::Light*); 00116 00117 bool writeSkinControllerData(const COLLADAFW::SkinControllerData*); 00118 00119 bool writeController(const COLLADAFW::Controller*); 00120 00121 bool writeFormulas(const COLLADAFW::Formulas*); 00122 00123 bool writeKinematicsScene(const COLLADAFW::KinematicsScene*); 00124 00126 bool addExtraTags(const COLLADAFW::UniqueId &uid, ExtraTags *extra_tags); 00128 ExtraTags* getExtraTags(const COLLADAFW::UniqueId &uid); 00129 00130 private: 00131 00133 ImportStage mImportStage; 00134 std::string mFilename; 00135 00136 bContext *mContext; 00137 00138 UnitConverter unit_converter; 00139 ArmatureImporter armature_importer; 00140 MeshImporter mesh_importer; 00141 AnimationImporter anim_importer; 00142 00144 typedef std::map<std::string, ExtraTags*> TagsMap; 00146 TagsMap uid_tags_map; 00147 00148 std::map<COLLADAFW::UniqueId, Image*> uid_image_map; 00149 std::map<COLLADAFW::UniqueId, Material*> uid_material_map; 00150 std::map<COLLADAFW::UniqueId, Material*> uid_effect_map; 00151 std::map<COLLADAFW::UniqueId, Camera*> uid_camera_map; 00152 std::map<COLLADAFW::UniqueId, Lamp*> uid_lamp_map; 00153 std::map<Material*, TexIndexTextureArrayMap> material_texture_mapping_map; 00154 std::map<COLLADAFW::UniqueId, Object*> object_map; 00155 std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> node_map; 00156 std::vector<const COLLADAFW::VisualScene*> vscenes; 00157 std::vector<Object*> libnode_ob; 00158 00159 std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> root_map; // find root joint by child joint uid, for bone tree evaluation during resampling 00160 std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map; 00161 00162 }; 00163 00164 #endif