Commit: 279c8f18d0f1f448caa7b994e80dfee1bcdae106
Author: Gaia Clary
Date:   Sun Oct 23 16:07:23 2016 +0200
Branches: collada-2
https://developer.blender.org/rB279c8f18d0f1f448caa7b994e80dfee1bcdae106

new:Collada 2 initial setup (added new subfolder, changed CMakelists, added 
collada version switcher to SPACE Menu

===================================================================

M       source/blender/collada/CMakeLists.txt
A       source/blender/collada/v2/collada_version_switcher.cpp
A       source/blender/collada/v2/collada_version_switcher.h
M       source/blender/editors/io/io_collada.c
M       source/blender/editors/io/io_collada.h
M       source/blender/editors/io/io_ops.c

===================================================================

diff --git a/source/blender/collada/CMakeLists.txt 
b/source/blender/collada/CMakeLists.txt
index 293049a..002d078 100644
--- a/source/blender/collada/CMakeLists.txt
+++ b/source/blender/collada/CMakeLists.txt
@@ -101,6 +101,9 @@ set(SRC
        collada.h
        collada_internal.h
        collada_utils.h
+
+       v2/collada_version_switcher.cpp
+       v2/collada_version_switcher.h
 )
 
 if(WITH_BUILDINFO)
diff --git a/source/blender/collada/v2/collada_version_switcher.cpp 
b/source/blender/collada/v2/collada_version_switcher.cpp
new file mode 100644
index 0000000..ed6bf5b
--- /dev/null
+++ b/source/blender/collada/v2/collada_version_switcher.cpp
@@ -0,0 +1,55 @@
+/*
+ * ***** 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 *****
+ */
+
+#include <string>
+
+extern "C" {
+       #include "BKE_context.h"
+       #include "WM_api.h"
+       #include "WM_types.h"
+       #include "BLI_string.h"
+
+int collada_version = 0; // Can be 0 (default, version 1) or 1 (new and 
experimental, version 2)
+
+static char *get_op_switchto_string()
+{
+       int to = (collada_version + 1) % 2;
+       char *result = BLI_sprintfN("Switch to Blender COLLADA Version %d", 
to+1);
+       return result;
+}
+
+static int wm_collada_versionswitch_exec(bContext *C, wmOperator *op)
+{
+       collada_version = (collada_version + 1) % 2;
+       op->type->name = get_op_switchto_string();
+       return OPERATOR_FINISHED;
+}
+
+void WM_OT_collada_versionswitch(wmOperatorType *ot)
+{
+       ot->name        = get_op_switchto_string();
+       ot->description = "Switch Collada version between original 
implementation and new implementation (for testing)";
+       ot->idname      = "WM_OT_collada_version";
+       ot->exec        = wm_collada_versionswitch_exec;
+
+}
+}
\ No newline at end of file
diff --git a/source/blender/editors/io/io_collada.h 
b/source/blender/collada/v2/collada_version_switcher.h
similarity index 62%
copy from source/blender/editors/io/io_collada.h
copy to source/blender/collada/v2/collada_version_switcher.h
index 4bb1475..73ca455 100644
--- a/source/blender/editors/io/io_collada.h
+++ b/source/blender/collada/v2/collada_version_switcher.h
@@ -4,7 +4,7 @@
  * 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. 
+ * 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
@@ -15,25 +15,8 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * The Original Code is Copyright (C) 2007 Blender Foundation.
- * All rights reserved.
- *
- * 
- * Contributor(s): Blender Foundation
+ * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov.
  *
  * ***** END GPL LICENSE BLOCK *****
  */
 
-/** \file blender/editors/io/io_collada.h
- *  \ingroup editor/io
- */
-
-#ifndef __IO_COLLADA_H__
-#define __IO_COLLADA_H__
-
-struct wmOperatorType;
-
-void WM_OT_collada_export(struct wmOperatorType *ot);
-void WM_OT_collada_import(struct wmOperatorType *ot);
-
-#endif
diff --git a/source/blender/editors/io/io_collada.c 
b/source/blender/editors/io/io_collada.c
index 8659100..24aa385 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -75,6 +75,8 @@ static int wm_collada_export_invoke(bContext *C, wmOperator 
*op, const wmEvent *
        return OPERATOR_RUNNING_MODAL;
 }
 
+extern int collada_version;
+
 /* function used for WM_OT_save_mainfile too */
 static int wm_collada_export_exec(bContext *C, wmOperator *op)
 {
@@ -151,28 +153,35 @@ static int wm_collada_export_exec(bContext *C, wmOperator 
*op)
        /* get editmode results */
        ED_object_editmode_load(CTX_data_edit_object(C));
 
-
-       export_count = collada_export(CTX_data_scene(C),
-               filepath,
-               apply_modifiers,
-               export_mesh_type,
-               selected,
-               include_children,
-               include_armatures,
-               include_shapekeys,
-               deform_bones_only,
-
-               active_uv_only,
-               include_uv_textures,
-               include_material_textures,
-               use_texture_copies,
-
-               triangulate,
-               use_object_instantiation,
-               use_blender_profile,
-               sort_by_name,
-               export_transformation_type,
-               open_sim);
+       if (collada_version == 1)
+       {
+               BKE_report(op->reports, RPT_ERROR, "Collada Version 2 Exporter 
not yet implemented");
+               return OPERATOR_CANCELLED;
+       }
+       else
+       {
+               export_count = collada_export(CTX_data_scene(C),
+                       filepath,
+                       apply_modifiers,
+                       export_mesh_type,
+                       selected,
+                       include_children,
+                       include_armatures,
+                       include_shapekeys,
+                       deform_bones_only,
+
+                       active_uv_only,
+                       include_uv_textures,
+                       include_material_textures,
+                       use_texture_copies,
+
+                       triangulate,
+                       use_object_instantiation,
+                       use_blender_profile,
+                       sort_by_name,
+                       export_transformation_type,
+                       open_sim);
+       }
 
        if (export_count == 0) {
                BKE_report(op->reports, RPT_WARNING, "No objects selected -- 
Created empty export file");
@@ -411,20 +420,28 @@ static int wm_collada_import_exec(bContext *C, wmOperator 
*op)
        min_chain_length = RNA_int_get(op->ptr, "min_chain_length");
 
        RNA_string_get(op->ptr, "filepath", filename);
-       if (collada_import(
-               C, filename,
-               import_units,
-               find_chains,
-               auto_connect,
-               fix_orientation,
-               min_chain_length))
+
+       if (collada_version == 1)
        {
-               return OPERATOR_FINISHED;
+               BKE_report(op->reports, RPT_ERROR, "Collada Version 2 Importer 
not yet implemented");
        }
-       else {
-               BKE_report(op->reports, RPT_ERROR, "Errors found during parsing 
COLLADA document (see console for details)");
-               return OPERATOR_CANCELLED;
+       else
+       {
+               if (collada_import(
+                       C, filename,
+                       import_units,
+                       find_chains,
+                       auto_connect,
+                       fix_orientation,
+                       min_chain_length))
+               {
+                       return OPERATOR_FINISHED;
+               }
+               else {
+                       BKE_report(op->reports, RPT_ERROR, "Errors found during 
parsing COLLADA document (see console for details)");
+               }
        }
+       return OPERATOR_CANCELLED;
 }
 
 static void uiCollada_importSettings(uiLayout *layout, PointerRNA *imfptr)
diff --git a/source/blender/editors/io/io_collada.h 
b/source/blender/editors/io/io_collada.h
index 4bb1475..d57e23c 100644
--- a/source/blender/editors/io/io_collada.h
+++ b/source/blender/editors/io/io_collada.h
@@ -35,5 +35,6 @@ struct wmOperatorType;
 
 void WM_OT_collada_export(struct wmOperatorType *ot);
 void WM_OT_collada_import(struct wmOperatorType *ot);
+void WM_OT_collada_versionswitch(struct wmOperatorType *ot);
 
 #endif
diff --git a/source/blender/editors/io/io_ops.c 
b/source/blender/editors/io/io_ops.c
index d1e9335..c40355f 100644
--- a/source/blender/editors/io/io_ops.c
+++ b/source/blender/editors/io/io_ops.c
@@ -48,6 +48,9 @@ void ED_operatortypes_io(void)
        /* Collada operators: */
        WM_operatortype_append(WM_OT_collada_export);
        WM_operatortype_append(WM_OT_collada_import);
+
+       /* Collada Switch to new implementation */
+       WM_operatortype_append(WM_OT_collada_versionswitch);
 #endif
 #ifdef WITH_ALEMBIC
        WM_operatortype_append(WM_OT_alembic_import);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to