[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47928] branches/soc-2012-bratwurst/source /blender/assimp: - bf_assimp: set MTEx::uvname

Alexander Gessler alexander.gessler at gmx.net
Fri Jun 15 02:45:31 CEST 2012


Revision: 47928
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47928
Author:   aramis_acg
Date:     2012-06-15 00:45:13 +0000 (Fri, 15 Jun 2012)
Log Message:
-----------
- bf_assimp: set MTEx::uvname

Modified Paths:
--------------
    branches/soc-2012-bratwurst/source/blender/assimp/MaterialImporter.cpp
    branches/soc-2012-bratwurst/source/blender/assimp/MeshImporter.cpp
    branches/soc-2012-bratwurst/source/blender/assimp/SceneImporter.h
    branches/soc-2012-bratwurst/source/blender/assimp/bassimp_internal.cpp
    branches/soc-2012-bratwurst/source/blender/assimp/bassimp_internal.h

Modified: branches/soc-2012-bratwurst/source/blender/assimp/MaterialImporter.cpp
===================================================================
--- branches/soc-2012-bratwurst/source/blender/assimp/MaterialImporter.cpp	2012-06-14 23:41:07 UTC (rev 47927)
+++ branches/soc-2012-bratwurst/source/blender/assimp/MaterialImporter.cpp	2012-06-15 00:45:13 UTC (rev 47928)
@@ -198,6 +198,12 @@
 	mtex->tex->imaflag &= ~TEX_USEALPHA;
 	mtex->tex->ima = convert_image(path);
 
+	std::string s = get_default_uv_channel_name(index);
+	if (s.length() >= sizeof(mtex->uvname)) {
+		error("UV channel name to long, ignoring");
+	}
+	strcpy(mtex->uvname,s.c_str());
+
 	// XXX convert further material properties
 }
 

Modified: branches/soc-2012-bratwurst/source/blender/assimp/MeshImporter.cpp
===================================================================
--- branches/soc-2012-bratwurst/source/blender/assimp/MeshImporter.cpp	2012-06-14 23:41:07 UTC (rev 47927)
+++ branches/soc-2012-bratwurst/source/blender/assimp/MeshImporter.cpp	2012-06-15 00:45:13 UTC (rev 47928)
@@ -306,10 +306,9 @@
 		}
 	}	
 
-	for (unsigned int i = 0; i < uv_count; i++) {
-		std::stringstream ss; 
-		ss << "UVChannel-" << i;
-		CustomData_add_layer_named(&mesh->fdata, CD_MTFACE, CD_CALLOC, NULL, mesh->totface, ss.str().c_str());
+	for (unsigned int i = 0; i < uv_count; i++) {		
+		const std::string& s = get_default_uv_channel_name(i);
+		CustomData_add_layer_named(&mesh->fdata, CD_MTFACE, CD_CALLOC, NULL, mesh->totface, s.c_str());
 	}
 
 	// activate the first uv map

Modified: branches/soc-2012-bratwurst/source/blender/assimp/SceneImporter.h
===================================================================
--- branches/soc-2012-bratwurst/source/blender/assimp/SceneImporter.h	2012-06-14 23:41:07 UTC (rev 47927)
+++ branches/soc-2012-bratwurst/source/blender/assimp/SceneImporter.h	2012-06-15 00:45:13 UTC (rev 47928)
@@ -60,6 +60,7 @@
 	void handle_scale();
 	void handle_coordinate_space();
 
+
 public:
 
 	SceneImporter(const char* path, bContext *C);
@@ -76,6 +77,7 @@
 
 	const MaterialImporter& get_material(unsigned int idx) const;
 	unsigned int resolve_matid(unsigned int src) const;
+
 };
 
 }

Modified: branches/soc-2012-bratwurst/source/blender/assimp/bassimp_internal.cpp
===================================================================
--- branches/soc-2012-bratwurst/source/blender/assimp/bassimp_internal.cpp	2012-06-14 23:41:07 UTC (rev 47927)
+++ branches/soc-2012-bratwurst/source/blender/assimp/bassimp_internal.cpp	2012-06-15 00:45:13 UTC (rev 47928)
@@ -26,6 +26,7 @@
 
 
 #include "bassimp_internal.h"
+#include "sstream" 
 
 #include "BKE_object.h"
 #include "BKE_scene.h"
@@ -36,11 +37,19 @@
 #include "WM_api.h" // XXX hrm, see if we can do without this
 #include "WM_types.h"
 
-// note: these are currently copy&paste from collada
 
+
 namespace bassimp {
 
 
+std::string get_default_uv_channel_name(unsigned int index)
+{
+	std::stringstream ss; 
+	ss << "UVChannel-" << index;
+	return ss.str();
+}
+
+
 // copied from /editors/object/object_relations.c
 int util_test_parent_loop(Object *par, Object *ob)
 {
@@ -52,6 +61,10 @@
 	return util_test_parent_loop(par->parent, ob);
 }
 
+
+// note: these are currently copy&paste from collada:
+
+
 // a shortened version of parent_set_exec()
 // if is_parent_space is true then ob->obmat will be multiplied by par->obmat before parenting
 int util_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)

Modified: branches/soc-2012-bratwurst/source/blender/assimp/bassimp_internal.h
===================================================================
--- branches/soc-2012-bratwurst/source/blender/assimp/bassimp_internal.h	2012-06-14 23:41:07 UTC (rev 47927)
+++ branches/soc-2012-bratwurst/source/blender/assimp/bassimp_internal.h	2012-06-15 00:45:13 UTC (rev 47928)
@@ -51,6 +51,8 @@
 {
 	int util_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space);
 	Object* util_add_object(Scene *scene, int type, const char *name);
+
+	std::string get_default_uv_channel_name(unsigned int index);
 }
 
 




More information about the Bf-blender-cvs mailing list