[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35775] trunk/blender/source/blender/ collada: Mostly formatting commit, small elaboration in extra handling API (take pointer to importer).
Nathan Letwory
nathan at letworyinteractive.com
Fri Mar 25 10:52:37 CET 2011
Revision: 35775
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35775
Author: jesterking
Date: 2011-03-25 09:52:36 +0000 (Fri, 25 Mar 2011)
Log Message:
-----------
Mostly formatting commit, small elaboration in extra handling API (take pointer to importer).
Modified Paths:
--------------
trunk/blender/source/blender/collada/DocumentImporter.cpp
trunk/blender/source/blender/collada/DocumentImporter.h
trunk/blender/source/blender/collada/ExtraHandler.cpp
trunk/blender/source/blender/collada/ExtraHandler.h
Modified: trunk/blender/source/blender/collada/DocumentImporter.cpp
===================================================================
--- trunk/blender/source/blender/collada/DocumentImporter.cpp 2011-03-25 08:47:41 UTC (rev 35774)
+++ trunk/blender/source/blender/collada/DocumentImporter.cpp 2011-03-25 09:52:36 UTC (rev 35775)
@@ -92,617 +92,579 @@
// creates empties for each imported bone on layer 2, for debugging
// #define ARMATURE_TEST
-/** Class that needs to be implemented by a writer.
- IMPORTANT: The write functions are called in arbitrary order.*/
-/*
-private:
- std::string mFilename;
-
- bContext *mContext;
+DocumentImporter::DocumentImporter(bContext *C, const char *filename) :
+ mImportStage(General),
+ mFilename(filename),
+ mContext(C),
+ armature_importer(&unit_converter, &mesh_importer, &anim_importer, CTX_data_scene(C)),
+ mesh_importer(&unit_converter, &armature_importer, CTX_data_scene(C)),
+ anim_importer(&unit_converter, &armature_importer, CTX_data_scene(C))
+{}
- UnitConverter unit_converter;
- ArmatureImporter armature_importer;
- MeshImporter mesh_importer;
- AnimationImporter anim_importer;
+DocumentImporter::~DocumentImporter() {}
- 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;
+bool DocumentImporter::import()
+{
+ /** TODO Add error handler (implement COLLADASaxFWL::IErrorHandler */
+ COLLADASaxFWL::Loader loader;
+ COLLADAFW::Root root(&loader, this);
+ ExtraHandler *ehandler = new ExtraHandler(this);
+
+ loader.registerExtraDataCallbackHandler(ehandler);
+
- std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> root_map;
- */
- // find root joint by child joint uid, for bone tree evaluation during resampling
+ if (!root.loadDocument(mFilename))
+ return false;
+
+ /** TODO set up scene graph and such here */
+
+ mImportStage = Controller;
+
+ COLLADASaxFWL::Loader loader2;
+ COLLADAFW::Root root2(&loader2, this);
+
+ if (!root2.loadDocument(mFilename))
+ return false;
+
+
+ delete ehandler;
- // animation
- // std::map<COLLADAFW::UniqueId, std::vector<FCurve*> > uid_fcurve_map;
- // Nodes don't share AnimationLists (Arystan)
- // std::map<COLLADAFW::UniqueId, Animation> uid_animated_map; // AnimationList->uniqueId to AnimatedObject map
+ return true;
+}
-//public:
+void DocumentImporter::cancel(const COLLADAFW::String& errorMessage)
+{
+ // TODO: if possible show error info
+ //
+ // Should we get rid of invisible Meshes that were created so far
+ // or maybe create objects at coordinate space origin?
+ //
+ // The latter sounds better.
+}
- /** Constructor. */
- DocumentImporter::DocumentImporter(bContext *C, const char *filename) :
- mImportStage(General),
- mFilename(filename),
- mContext(C),
- armature_importer(&unit_converter, &mesh_importer, &anim_importer, CTX_data_scene(C)),
- mesh_importer(&unit_converter, &armature_importer, CTX_data_scene(C)),
- anim_importer(&unit_converter, &armature_importer, CTX_data_scene(C))
- {}
+void DocumentImporter::start(){}
- /** Destructor. */
- DocumentImporter::~DocumentImporter() {}
-
- bool DocumentImporter::import()
- {
- /** TODO Add error handler (implement COLLADASaxFWL::IErrorHandler */
- COLLADASaxFWL::Loader loader;
- COLLADAFW::Root root(&loader, this);
- ExtraHandler *ehandler = new ExtraHandler();
+void DocumentImporter::finish()
+{
+ if(mImportStage!=General)
+ return;
- loader.registerExtraDataCallbackHandler(ehandler);
+ /** TODO Break up and put into 2-pass parsing of DAE */
+ std::vector<const COLLADAFW::VisualScene*>::iterator it;
+ for (it = vscenes.begin(); it != vscenes.end(); it++) {
+ PointerRNA sceneptr, unit_settings;
+ PropertyRNA *system, *scale;
+ // TODO: create a new scene except the selected <visual_scene> - use current blender scene for it
+ Scene *sce = CTX_data_scene(mContext);
-
- if (!root.loadDocument(mFilename))
- return false;
+ // for scene unit settings: system, scale_length
+ RNA_id_pointer_create(&sce->id, &sceneptr);
+ unit_settings = RNA_pointer_get(&sceneptr, "unit_settings");
+ system = RNA_struct_find_property(&unit_settings, "system");
+ scale = RNA_struct_find_property(&unit_settings, "scale_length");
- /** TODO set up scene graph and such here */
+ switch(unit_converter.isMetricSystem()) {
+ case UnitConverter::Metric:
+ RNA_property_enum_set(&unit_settings, system, USER_UNIT_METRIC);
+ break;
+ case UnitConverter::Imperial:
+ RNA_property_enum_set(&unit_settings, system, USER_UNIT_IMPERIAL);
+ break;
+ default:
+ RNA_property_enum_set(&unit_settings, system, USER_UNIT_NONE);
+ break;
+ }
+ RNA_property_float_set(&unit_settings, scale, unit_converter.getLinearMeter());
- mImportStage = Controller;
-
- COLLADASaxFWL::Loader loader2;
- COLLADAFW::Root root2(&loader2, this);
-
- if (!root2.loadDocument(mFilename))
- return false;
-
-
- delete ehandler;
+ const COLLADAFW::NodePointerArray& roots = (*it)->getRootNodes();
- return true;
+ for (unsigned int i = 0; i < roots.getCount(); i++) {
+ write_node(roots[i], NULL, sce, NULL, false);
+ }
}
-
- void DocumentImporter::cancel(const COLLADAFW::String& errorMessage)
- {
- // TODO: if possible show error info
- //
- // Should we get rid of invisible Meshes that were created so far
- // or maybe create objects at coordinate space origin?
- //
- // The latter sounds better.
- }
- void DocumentImporter::start(){}
+ armature_importer.make_armatures(mContext);
- /** This method is called after the last write* method. No other methods will be called after this.*/
- void DocumentImporter::finish()
- {
- if(mImportStage!=General)
- return;
-
- /** TODO Break up and put into 2-pass parsing of DAE */
- std::vector<const COLLADAFW::VisualScene*>::iterator it;
- for (it = vscenes.begin(); it != vscenes.end(); it++) {
- PointerRNA sceneptr, unit_settings;
- PropertyRNA *system, *scale;
- // TODO: create a new scene except the selected <visual_scene> - use current blender scene for it
- Scene *sce = CTX_data_scene(mContext);
-
- // for scene unit settings: system, scale_length
- RNA_id_pointer_create(&sce->id, &sceneptr);
- unit_settings = RNA_pointer_get(&sceneptr, "unit_settings");
- system = RNA_struct_find_property(&unit_settings, "system");
- scale = RNA_struct_find_property(&unit_settings, "scale_length");
-
- switch(unit_converter.isMetricSystem()) {
- case UnitConverter::Metric:
- RNA_property_enum_set(&unit_settings, system, USER_UNIT_METRIC);
- break;
- case UnitConverter::Imperial:
- RNA_property_enum_set(&unit_settings, system, USER_UNIT_IMPERIAL);
- break;
- default:
- RNA_property_enum_set(&unit_settings, system, USER_UNIT_NONE);
- break;
- }
- RNA_property_float_set(&unit_settings, scale, unit_converter.getLinearMeter());
-
- const COLLADAFW::NodePointerArray& roots = (*it)->getRootNodes();
-
- for (unsigned int i = 0; i < roots.getCount(); i++) {
- write_node(roots[i], NULL, sce, NULL, false);
- }
- }
-
- armature_importer.make_armatures(mContext);
-
#if 0
- armature_importer.fix_animation();
+ armature_importer.fix_animation();
#endif
- for (std::vector<const COLLADAFW::VisualScene*>::iterator it = vscenes.begin(); it != vscenes.end(); it++) {
- const COLLADAFW::NodePointerArray& roots = (*it)->getRootNodes();
+ for (std::vector<const COLLADAFW::VisualScene*>::iterator it = vscenes.begin(); it != vscenes.end(); it++) {
+ const COLLADAFW::NodePointerArray& roots = (*it)->getRootNodes();
- for (unsigned int i = 0; i < roots.getCount(); i++)
- translate_anim_recursive(roots[i],NULL,NULL);
- }
+ for (unsigned int i = 0; i < roots.getCount(); i++)
+ translate_anim_recursive(roots[i],NULL,NULL);
+ }
- if (libnode_ob.size()) {
- Scene *sce = CTX_data_scene(mContext);
+ if (libnode_ob.size()) {
+ Scene *sce = CTX_data_scene(mContext);
- fprintf(stderr, "got %d library nodes to free\n", (int)libnode_ob.size());
- // free all library_nodes
- std::vector<Object*>::iterator it;
- for (it = libnode_ob.begin(); it != libnode_ob.end(); it++) {
- Object *ob = *it;
+ fprintf(stderr, "got %d library nodes to free\n", (int)libnode_ob.size());
+ // free all library_nodes
+ std::vector<Object*>::iterator it;
+ for (it = libnode_ob.begin(); it != libnode_ob.end(); it++) {
+ Object *ob = *it;
- Base *base = object_in_scene(ob, sce);
- if (base) {
- BLI_remlink(&sce->base, base);
- free_libblock_us(&G.main->object, base->object);
- if (sce->basact==base)
- sce->basact= NULL;
- MEM_freeN(base);
- }
+ Base *base = object_in_scene(ob, sce);
+ if (base) {
+ BLI_remlink(&sce->base, base);
+ free_libblock_us(&G.main->object, base->object);
+ if (sce->basact==base)
+ sce->basact= NULL;
+ MEM_freeN(base);
}
- libnode_ob.clear();
-
- DAG_scene_sort(CTX_data_main(mContext), sce);
- DAG_ids_flush_update(CTX_data_main(mContext), 0);
}
+ libnode_ob.clear();
+
+ DAG_scene_sort(CTX_data_main(mContext), sce);
+ DAG_ids_flush_update(CTX_data_main(mContext), 0);
}
+}
- void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW::Node *par = NULL, Object *parob = NULL)
- {
- if (par && par->getType() == COLLADAFW::Node::JOINT) {
- // par is root if there's no corresp. key in root_map
- if (root_map.find(par->getUniqueId()) == root_map.end())
- root_map[node->getUniqueId()] = par;
- else
- root_map[node->getUniqueId()] = root_map[par->getUniqueId()];
- }
+void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW::Node *par = NULL, Object *parob = NULL)
+{
+ if (par && par->getType() == COLLADAFW::Node::JOINT) {
+ // par is root if there's no corresp. key in root_map
+ if (root_map.find(par->getUniqueId()) == root_map.end())
+ root_map[node->getUniqueId()] = par;
+ else
+ root_map[node->getUniqueId()] = root_map[par->getUniqueId()];
+ }
- COLLADAFW::Transformation::TransformationType types[] = {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list