2011-01-28 12:56:30 +00:00
|
|
|
/*
|
2010-06-03 17:41:33 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
2010-10-05 00:05:14 +00:00
|
|
|
|
2011-02-21 08:38:53 +00:00
|
|
|
/** \file DocumentImporter.h
|
|
|
|
* \ingroup collada
|
|
|
|
*/
|
|
|
|
|
2010-10-05 00:05:14 +00:00
|
|
|
#ifndef __DOCUMENTIMPORTER_H__
|
|
|
|
#define __DOCUMENTIMPORTER_H__
|
2010-12-14 21:46:03 +00:00
|
|
|
|
|
|
|
#include "COLLADAFWIWriter.h"
|
|
|
|
#include "COLLADAFWMaterial.h"
|
|
|
|
#include "COLLADAFWEffect.h"
|
|
|
|
#include "COLLADAFWColor.h"
|
|
|
|
#include "COLLADAFWImage.h"
|
|
|
|
#include "COLLADAFWInstanceGeometry.h"
|
|
|
|
#include "COLLADAFWController.h"
|
|
|
|
#include "COLLADAFWMorphController.h"
|
|
|
|
#include "COLLADAFWSkinController.h"
|
2011-07-23 20:49:26 +00:00
|
|
|
#include "COLLADAFWEffectCommon.h"
|
|
|
|
|
2010-12-14 21:46:03 +00:00
|
|
|
|
|
|
|
#include "BKE_object.h"
|
|
|
|
|
|
|
|
#include "TransformReader.h"
|
|
|
|
#include "AnimationImporter.h"
|
|
|
|
#include "ArmatureImporter.h"
|
|
|
|
#include "MeshImporter.h"
|
2011-07-26 18:28:07 +00:00
|
|
|
|
2010-12-14 21:46:03 +00:00
|
|
|
|
|
|
|
|
Merge of the COLLADA GSoC branch into trunk.
COLLADA code is disabled by default (it has dependencies requiring manual install).
SCons and CMake builds are supported on Windows and Linux, no Mac building yet. More on building COLLADA code: http://wiki.blender.org/index.php/User:Kazanbas/Building_Collada_Branch.
The detailed command log of the merge (can be useful for educational purposes):
branch=https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-chingachgook
# collada code
svn copy $branch/source/blender/collada source/blender/collada
# operator
svn merge -c 20401,20955,21077,24077,24079 $branch/source/blender/windowmanager/intern/wm_operators.c source/blender/windowmanager/intern/wm_operators.c
# menu
svn merge -c 24079 $branch/release/scripts/ui/space_info.py release/scripts/ui/space_info.py
# scons
svn merge -c 20398 $branch/source/blender/SConscript source/blender/SConscript
svn merge -c 20398,20691,20955,22726 $branch/tools/btools.py tools/btools.py
svn merge -c 20691,20955,22726 $branch/tools/Blender.py tools/Blender.py
svn merge -c 20398,20692,20955 $branch/config/linux2-config.py config/linux2-config.py
svn merge -c 22726 $branch/config/win64-vc-config.py config/win64-vc-config.py
svn merge -c 22726 $branch/config/win32-vc-config.py config/win32-vc-config.py
svn merge -c 24077 $branch/source/blender/windowmanager/SConscript source/blender/windowmanager/SConscript
# cmake
svn merge -c 23319,23905,24077,24158 $branch/CMakeLists.txt CMakeLists.txt
svn merge -c 23319 $branch/source/blender/CMakeLists.txt source/blender/CMakeLists.txt
svn merge -c 23319 $branch/source/creator/CMakeLists.txt source/creator/CMakeLists.txt
svn merge -c 23319 $branch/CMake/macros.cmake CMake/macros.cmake
svn merge -c 24077 $branch/source/blender/windowmanager/CMakeLists.txt source/blender/windowmanager/CMakeLists.txt
2009-10-30 15:35:50 +00:00
|
|
|
struct Main;
|
|
|
|
struct bContext;
|
|
|
|
|
2011-01-28 12:56:30 +00:00
|
|
|
/** Importer class. */
|
2010-12-14 21:46:03 +00:00
|
|
|
class DocumentImporter : COLLADAFW::IWriter
|
Merge of the COLLADA GSoC branch into trunk.
COLLADA code is disabled by default (it has dependencies requiring manual install).
SCons and CMake builds are supported on Windows and Linux, no Mac building yet. More on building COLLADA code: http://wiki.blender.org/index.php/User:Kazanbas/Building_Collada_Branch.
The detailed command log of the merge (can be useful for educational purposes):
branch=https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-chingachgook
# collada code
svn copy $branch/source/blender/collada source/blender/collada
# operator
svn merge -c 20401,20955,21077,24077,24079 $branch/source/blender/windowmanager/intern/wm_operators.c source/blender/windowmanager/intern/wm_operators.c
# menu
svn merge -c 24079 $branch/release/scripts/ui/space_info.py release/scripts/ui/space_info.py
# scons
svn merge -c 20398 $branch/source/blender/SConscript source/blender/SConscript
svn merge -c 20398,20691,20955,22726 $branch/tools/btools.py tools/btools.py
svn merge -c 20691,20955,22726 $branch/tools/Blender.py tools/Blender.py
svn merge -c 20398,20692,20955 $branch/config/linux2-config.py config/linux2-config.py
svn merge -c 22726 $branch/config/win64-vc-config.py config/win64-vc-config.py
svn merge -c 22726 $branch/config/win32-vc-config.py config/win32-vc-config.py
svn merge -c 24077 $branch/source/blender/windowmanager/SConscript source/blender/windowmanager/SConscript
# cmake
svn merge -c 23319,23905,24077,24158 $branch/CMakeLists.txt CMakeLists.txt
svn merge -c 23319 $branch/source/blender/CMakeLists.txt source/blender/CMakeLists.txt
svn merge -c 23319 $branch/source/creator/CMakeLists.txt source/creator/CMakeLists.txt
svn merge -c 23319 $branch/CMake/macros.cmake CMake/macros.cmake
svn merge -c 24077 $branch/source/blender/windowmanager/CMakeLists.txt source/blender/windowmanager/CMakeLists.txt
2009-10-30 15:35:50 +00:00
|
|
|
{
|
2011-03-25 09:52:36 +00:00
|
|
|
public:
|
2011-02-04 13:18:44 +00:00
|
|
|
//! Enumeration to denote the stage of import
|
2011-01-28 12:56:30 +00:00
|
|
|
enum ImportStage {
|
|
|
|
General, //!< First pass to collect all data except controller
|
|
|
|
Controller, //!< Second pass to collect controller data
|
|
|
|
};
|
2010-12-14 21:46:03 +00:00
|
|
|
/** Constructor */
|
|
|
|
DocumentImporter(bContext *C, const char *filename);
|
|
|
|
|
|
|
|
/** Destructor */
|
|
|
|
~DocumentImporter();
|
|
|
|
|
|
|
|
/** Function called by blender UI */
|
|
|
|
bool import();
|
|
|
|
|
|
|
|
/** these should not be here */
|
|
|
|
Object* create_camera_object(COLLADAFW::InstanceCamera*, Scene*);
|
|
|
|
Object* create_lamp_object(COLLADAFW::InstanceLight*, Scene*);
|
2011-06-20 10:50:17 +00:00
|
|
|
Object* create_instance_node(Object*, COLLADAFW::Node*, COLLADAFW::Node*, Scene*, Object*, bool);
|
2010-12-14 21:46:03 +00:00
|
|
|
void write_node(COLLADAFW::Node*, COLLADAFW::Node*, Scene*, Object*, bool);
|
|
|
|
MTex* create_texture(COLLADAFW::EffectCommon*, COLLADAFW::Texture&, Material*, int, TexIndexTextureArrayMap&);
|
|
|
|
void write_profile_COMMON(COLLADAFW::EffectCommon*, Material*);
|
|
|
|
void translate_anim_recursive(COLLADAFW::Node*, COLLADAFW::Node*, Object*);
|
|
|
|
|
|
|
|
/** This method will be called if an error in the loading process occurred and the loader cannot
|
2011-03-25 09:52:36 +00:00
|
|
|
continue to load. The writer should undo all operations that have been performed.
|
|
|
|
@param errorMessage A message containing informations about the error that occurred.
|
2010-12-14 21:46:03 +00:00
|
|
|
*/
|
|
|
|
void cancel(const COLLADAFW::String& errorMessage);
|
|
|
|
|
|
|
|
/** This is the method called. The writer hast to prepare to receive data.*/
|
|
|
|
void start();
|
|
|
|
|
|
|
|
/** This method is called after the last write* method. No other methods will be called after this.*/
|
|
|
|
void finish();
|
2011-03-25 09:52:36 +00:00
|
|
|
|
2010-12-14 21:46:03 +00:00
|
|
|
bool writeGlobalAsset(const COLLADAFW::FileInfo*);
|
|
|
|
|
|
|
|
bool writeScene(const COLLADAFW::Scene*);
|
|
|
|
|
|
|
|
bool writeVisualScene(const COLLADAFW::VisualScene*);
|
|
|
|
|
|
|
|
bool writeLibraryNodes(const COLLADAFW::LibraryNodes*);
|
|
|
|
|
|
|
|
bool writeAnimation(const COLLADAFW::Animation*);
|
|
|
|
|
|
|
|
bool writeAnimationList(const COLLADAFW::AnimationList*);
|
|
|
|
|
|
|
|
bool writeGeometry(const COLLADAFW::Geometry*);
|
|
|
|
|
|
|
|
bool writeMaterial(const COLLADAFW::Material*);
|
|
|
|
|
|
|
|
bool writeEffect(const COLLADAFW::Effect*);
|
|
|
|
|
|
|
|
bool writeCamera(const COLLADAFW::Camera*);
|
|
|
|
|
|
|
|
bool writeImage(const COLLADAFW::Image*);
|
|
|
|
|
|
|
|
bool writeLight(const COLLADAFW::Light*);
|
|
|
|
|
|
|
|
bool writeSkinControllerData(const COLLADAFW::SkinControllerData*);
|
|
|
|
|
|
|
|
bool writeController(const COLLADAFW::Controller*);
|
|
|
|
|
|
|
|
bool writeFormulas(const COLLADAFW::Formulas*);
|
|
|
|
|
|
|
|
bool writeKinematicsScene(const COLLADAFW::KinematicsScene*);
|
|
|
|
|
2011-03-25 09:52:36 +00:00
|
|
|
/** Add element and data for UniqueId */
|
2011-03-25 11:07:57 +00:00
|
|
|
bool addExtraTags(const COLLADAFW::UniqueId &uid, ExtraTags *extra_tags);
|
|
|
|
/** Get an extisting ExtraTags for uid */
|
|
|
|
ExtraTags* getExtraTags(const COLLADAFW::UniqueId &uid);
|
2011-03-25 09:52:36 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2011-01-28 12:56:30 +00:00
|
|
|
/** Current import stage we're in. */
|
|
|
|
ImportStage mImportStage;
|
|
|
|
std::string mFilename;
|
|
|
|
|
2011-03-25 09:52:36 +00:00
|
|
|
bContext *mContext;
|
|
|
|
|
|
|
|
UnitConverter unit_converter;
|
|
|
|
ArmatureImporter armature_importer;
|
|
|
|
MeshImporter mesh_importer;
|
|
|
|
AnimationImporter anim_importer;
|
2011-03-28 09:31:44 +00:00
|
|
|
|
|
|
|
/** TagsMap typedef for uid_tags_map. */
|
|
|
|
typedef std::map<std::string, ExtraTags*> TagsMap;
|
|
|
|
/** Tags map of unique id as a string and ExtraTags instance. */
|
|
|
|
TagsMap uid_tags_map;
|
2011-03-25 09:52:36 +00:00
|
|
|
|
|
|
|
std::map<COLLADAFW::UniqueId, Image*> uid_image_map;
|
|
|
|
std::map<COLLADAFW::UniqueId, Material*> uid_material_map;
|
|
|
|
std::map<COLLADAFW::UniqueId, Material*> uid_effect_map;
|
|
|
|
std::map<COLLADAFW::UniqueId, Camera*> uid_camera_map;
|
|
|
|
std::map<COLLADAFW::UniqueId, Lamp*> uid_lamp_map;
|
|
|
|
std::map<Material*, TexIndexTextureArrayMap> material_texture_mapping_map;
|
|
|
|
std::map<COLLADAFW::UniqueId, Object*> object_map;
|
|
|
|
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> node_map;
|
|
|
|
std::vector<const COLLADAFW::VisualScene*> vscenes;
|
|
|
|
std::vector<Object*> libnode_ob;
|
2011-07-23 20:49:26 +00:00
|
|
|
|
2011-03-25 09:52:36 +00:00
|
|
|
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> root_map; // find root joint by child joint uid, for bone tree evaluation during resampling
|
2011-07-03 11:07:34 +00:00
|
|
|
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map;
|
2011-07-23 20:49:26 +00:00
|
|
|
|
Merge of the COLLADA GSoC branch into trunk.
COLLADA code is disabled by default (it has dependencies requiring manual install).
SCons and CMake builds are supported on Windows and Linux, no Mac building yet. More on building COLLADA code: http://wiki.blender.org/index.php/User:Kazanbas/Building_Collada_Branch.
The detailed command log of the merge (can be useful for educational purposes):
branch=https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-chingachgook
# collada code
svn copy $branch/source/blender/collada source/blender/collada
# operator
svn merge -c 20401,20955,21077,24077,24079 $branch/source/blender/windowmanager/intern/wm_operators.c source/blender/windowmanager/intern/wm_operators.c
# menu
svn merge -c 24079 $branch/release/scripts/ui/space_info.py release/scripts/ui/space_info.py
# scons
svn merge -c 20398 $branch/source/blender/SConscript source/blender/SConscript
svn merge -c 20398,20691,20955,22726 $branch/tools/btools.py tools/btools.py
svn merge -c 20691,20955,22726 $branch/tools/Blender.py tools/Blender.py
svn merge -c 20398,20692,20955 $branch/config/linux2-config.py config/linux2-config.py
svn merge -c 22726 $branch/config/win64-vc-config.py config/win64-vc-config.py
svn merge -c 22726 $branch/config/win32-vc-config.py config/win32-vc-config.py
svn merge -c 24077 $branch/source/blender/windowmanager/SConscript source/blender/windowmanager/SConscript
# cmake
svn merge -c 23319,23905,24077,24158 $branch/CMakeLists.txt CMakeLists.txt
svn merge -c 23319 $branch/source/blender/CMakeLists.txt source/blender/CMakeLists.txt
svn merge -c 23319 $branch/source/creator/CMakeLists.txt source/creator/CMakeLists.txt
svn merge -c 23319 $branch/CMake/macros.cmake CMake/macros.cmake
svn merge -c 24077 $branch/source/blender/windowmanager/CMakeLists.txt source/blender/windowmanager/CMakeLists.txt
2009-10-30 15:35:50 +00:00
|
|
|
};
|
2010-10-05 00:05:14 +00:00
|
|
|
|
|
|
|
#endif
|