[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23554] trunk/blender/release/scripts/io: Fixed export scripts: 3DS, OBJ, X3D, FBX.

Arystanbek Dyussenov arystan.d at gmail.com
Tue Sep 29 14:16:58 CEST 2009


Revision: 23554
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23554
Author:   kazanbas
Date:     2009-09-29 14:16:58 +0200 (Tue, 29 Sep 2009)

Log Message:
-----------
Fixed export scripts: 3DS, OBJ, X3D, FBX. These need testing now.

Modified Paths:
--------------
    trunk/blender/release/scripts/io/export_3ds.py
    trunk/blender/release/scripts/io/export_fbx.py
    trunk/blender/release/scripts/io/export_obj.py
    trunk/blender/release/scripts/io/export_x3d.py

Modified: trunk/blender/release/scripts/io/export_3ds.py
===================================================================
--- trunk/blender/release/scripts/io/export_3ds.py	2009-09-29 09:48:30 UTC (rev 23553)
+++ trunk/blender/release/scripts/io/export_3ds.py	2009-09-29 12:16:58 UTC (rev 23554)
@@ -559,14 +559,15 @@
 		uf = mesh.active_uv_texture.data[i] if do_uv else None
 		
 		if do_uv:
-			f_uv =  (uf.uv1, uf.uv2, uf.uv3, uf.uv4) if face.verts[3] else (uf.uv1, uf.uv2, uf.uv3)
+			f_uv = uf.uv
+			# f_uv =  (uf.uv1, uf.uv2, uf.uv3, uf.uv4) if face.verts[3] else (uf.uv1, uf.uv2, uf.uv3)
 # 			f_uv = face.uv
 			img = uf.image if uf else None
 # 			img = face.image
 			if img: img = img.name
 
-		if f_v[3] == 0:
-		# if len(f_v)==3:
+		# if f_v[3] == 0:
+		if len(f_v)==3:
 			new_tri = tri_wrapper((f_v[0], f_v[1], f_v[2]), face.material_index, img)
 # 			new_tri = tri_wrapper((f_v[0].index, f_v[1].index, f_v[2].index), face.mat, img)
 			if (do_uv): new_tri.faceuvs= uv_key(f_uv[0]), uv_key(f_uv[1]), uv_key(f_uv[2])
@@ -1109,11 +1110,12 @@
 	# to the class instance from the operator settings before calling.
 
 	__props__ = [
-		bpy.props.StringProperty(attr="filename", name="File Name", description="File name used for exporting the 3DS file", maxlen= 1024, default= ""),
+		# bpy.props.StringProperty(attr="filename", name="File Name", description="File name used for exporting the 3DS file", maxlen= 1024, default= ""),
+		bpy.props.StringProperty(attr="path", name="File Path", description="File path used for exporting the 3DS file", maxlen= 1024, default= ""),
 	]
 	
 	def execute(self, context):
-		save_3ds(self.filename, context)
+		save_3ds(self.path, context)
 		return ('FINISHED',)
 	
 	def invoke(self, context, event):

Modified: trunk/blender/release/scripts/io/export_fbx.py
===================================================================
--- trunk/blender/release/scripts/io/export_fbx.py	2009-09-29 09:48:30 UTC (rev 23553)
+++ trunk/blender/release/scripts/io/export_fbx.py	2009-09-29 12:16:58 UTC (rev 23554)
@@ -1528,7 +1528,8 @@
 		file.write('\n\t\tPolygonVertexIndex: ')
 		i=-1
 		for f in me.faces:
-			fi = [v_index for j, v_index in enumerate(f.verts) if v_index != 0 or j != 3]
+			fi = f.verts
+			# fi = [v_index for j, v_index in enumerate(f.verts) if v_index != 0 or j != 3]
 # 			fi = [v.index for v in f]
 
 			# flip the last index, odd but it looks like
@@ -1637,10 +1638,7 @@
 		# returns a slice of data depending on number of face verts
 		# data is either a MeshTextureFace or MeshColor
 		def face_data(data, face):
-			if f.verts[3] == 0:
-				totvert = 3
-			else:
-				totvert = 4
+			totvert = len(f.verts)
 						
 			return data[:totvert]
 
@@ -1740,12 +1738,9 @@
 				i = -1
 				ii = 0 # Count how many UVs we write
 				
-				for f, uf in zip(me.faces, uvlayer.data):
+				for uf in uvlayer.data:
 # 				for f in me.faces:
-					uvs = [uf.uv1, uf.uv2, uf.uv3, uf.uv4]
-					uvs = face_data(uvs, f)
-					
-					for uv in uvs:
+					for uv in uf.uv:
 # 					for uv in f.uv:
 						if i==-1:
 							file.write('%.6f,%.6f' % tuple(uv))
@@ -3356,7 +3351,8 @@
 	# to the class instance from the operator settings before calling.
 	
 	__props__ = [
-		bpy.props.StringProperty(attr="filename", name="File Name", description="File name used for exporting the PLY file", maxlen= 1024, default=""),
+		bpy.props.StringProperty(attr="path", name="File Path", description="File path used for exporting the FBX file", maxlen= 1024, default= ""),
+		
 		bpy.props.BoolProperty(attr="EXP_OBS_SELECTED", name="Selected Objects", description="Export selected objects on visible layers", default=True),
 # 		bpy.props.BoolProperty(attr="EXP_OBS_SCENE", name="Scene Objects", description="Export all objects in this scene", default=True),
 		bpy.props.FloatProperty(attr="_SCALE", name="Scale", description="Scale all data, (Note! some imports dont support scaled armatures)", min=0.01, max=1000.0, soft_min=0.01, soft_max=1000.0, default=1.0),
@@ -3389,8 +3385,8 @@
 		return context.active_object != None
 	
 	def execute(self, context):
-		if not self.filename:
-			raise Exception("filename not set")
+		if not self.path:
+			raise Exception("path not set")
 
 		GLOBAL_MATRIX = mtx4_identity
 		GLOBAL_MATRIX[0][0] = GLOBAL_MATRIX[1][1] = GLOBAL_MATRIX[2][2] = self._SCALE
@@ -3398,7 +3394,7 @@
 		if self._YROT90: GLOBAL_MATRIX = GLOBAL_MATRIX * mtx4_y90n
 		if self._ZROT90: GLOBAL_MATRIX = GLOBAL_MATRIX * mtx4_z90n
 			
-		write(self.filename,
+		write(self.path,
 			  None, # XXX
 			  context,
 			  self.EXP_OBS_SELECTED,

Modified: trunk/blender/release/scripts/io/export_obj.py
===================================================================
--- trunk/blender/release/scripts/io/export_obj.py	2009-09-29 09:48:30 UTC (rev 23553)
+++ trunk/blender/release/scripts/io/export_obj.py	2009-09-29 12:16:58 UTC (rev 23554)
@@ -153,7 +153,7 @@
 		
 		elif mat: # No face image. if we havea material search for MTex image.
 			for mtex in mat.textures:
-				if mtex and mtex.texure.type == 'IMAGE':
+				if mtex and mtex.texture.type == 'IMAGE':
 					try:
 						filename = copy_image(mtex.texture.image)
 # 						filename = mtex.texture.image.filename.split('\\')[-1].split('/')[-1]
@@ -330,7 +330,8 @@
 		return round(v.x, 6), round(v.y, 6), round(v.z, 6)
 		
 	def veckey2d(v):
-		return round(v.x, 6), round(v.y, 6)
+		return round(v[0], 6), round(v[1], 6)
+		# return round(v.x, 6), round(v.y, 6)
 	
 	def findVertexGroupName(face, vWeightMap):
 		"""
@@ -376,7 +377,7 @@
 #	scn = Scene.GetCurrent()
 
 	file = open(filename, "w")
-	
+
 	# Write Header
 	version = "2.5"
 	file.write('# Blender3D v%s OBJ File: %s\n' % (version, bpy.data.filename.split('/')[-1].split('\\')[-1] ))
@@ -593,11 +594,12 @@
 
 					tface = uv_layer.data[f_index]
 
-					uvs = [tface.uv1, tface.uv2, tface.uv3]
+					uvs = tface.uv
+					# uvs = [tface.uv1, tface.uv2, tface.uv3]
 
-					# add another UV if it's a quad
-					if f.verts[3] != 0:
-						uvs.append(tface.uv4)
+					# # add another UV if it's a quad
+					# if len(f.verts) == 4:
+					# 	uvs.append(tface.uv4)
 
 					for uv_index, uv in enumerate(uvs):
 						uvkey = veckey2d(uv)
@@ -661,8 +663,8 @@
 			for f_index, f in enumerate(faces):
 				f_v = [{"index": index, "vertex": me.verts[index]} for index in f.verts]
 
-				if f.verts[3] == 0:
-					f_v.pop()
+				# if f.verts[3] == 0:
+				# 	f_v.pop()
 
 #				f_v= f.v
 				f_smooth= f.smooth
@@ -673,9 +675,10 @@
 					tface = me.active_uv_texture.data[face_index_pairs[f_index][1]]
 
 					f_image = tface.image
-					f_uv= [tface.uv1, tface.uv2, tface.uv3]
-					if f.verts[3] != 0:
-						f_uv.append(tface.uv4)
+					f_uv = tface.uv
+					# f_uv= [tface.uv1, tface.uv2, tface.uv3]
+					# if len(f.verts) == 4:
+					# 	f_uv.append(tface.uv4)
 #					f_image = f.image
 #					f_uv= f.uv
 				
@@ -918,7 +921,7 @@
 	# to the class instance from the operator settings before calling.
 
 	__props__ = [
-		bpy.props.StringProperty(attr="filename", name="File Name", description="File name used for exporting the OBJ file", maxlen= 1024, default= ""),
+		bpy.props.StringProperty(attr="path", name="File Path", description="File path used for exporting the OBJ file", maxlen= 1024, default= ""),
 
 		# context group
 		bpy.props.BoolProperty(attr="use_selection", name="Selection Only", description="", default= False),
@@ -949,7 +952,7 @@
 	
 	def execute(self, context):
 
-		do_export(self.filename, context,
+		do_export(self.path, context,
 				  EXPORT_TRI=self.use_triangles,
 				  EXPORT_EDGES=self.use_edges,
 				  EXPORT_NORMALS=self.use_normals,

Modified: trunk/blender/release/scripts/io/export_x3d.py
===================================================================
--- trunk/blender/release/scripts/io/export_x3d.py	2009-09-29 09:48:30 UTC (rev 23553)
+++ trunk/blender/release/scripts/io/export_x3d.py	2009-09-29 12:16:58 UTC (rev 23554)
@@ -604,7 +604,8 @@
 
 		for face in mesh.active_uv_texture.data:
 		# for face in mesh.faces:
-			uvs = [face.uv1, face.uv2, face.uv3, face.uv4] if face.verts[3] else [face.uv1, face.uv2, face.uv3]
+			uvs = face.uv
+			# uvs = [face.uv1, face.uv2, face.uv3, face.uv4] if face.verts[3] else [face.uv1, face.uv2, face.uv3]
 
 			for uv in uvs:
 			# for uv in face.uv:
@@ -676,11 +677,11 @@
 
 		shininess = mat.specular_hardness/512.0
 		# shininess = mat.hard/512.0
-		specR = (mat.specular_color[0]+0.001)/(1.25/(mat.specular_reflection+0.001))
+		specR = (mat.specular_color[0]+0.001)/(1.25/(mat.specular_intensity+0.001))
 		# specR = (mat.specCol[0]+0.001)/(1.25/(mat.spec+0.001))
-		specG = (mat.specular_color[1]+0.001)/(1.25/(mat.specular_reflection+0.001))
+		specG = (mat.specular_color[1]+0.001)/(1.25/(mat.specular_intensity+0.001))
 		# specG = (mat.specCol[1]+0.001)/(1.25/(mat.spec+0.001))
-		specB = (mat.specular_color[2]+0.001)/(1.25/(mat.specular_reflection+0.001))
+		specB = (mat.specular_color[2]+0.001)/(1.25/(mat.specular_intensity+0.001))
 		# specB = (mat.specCol[2]+0.001)/(1.25/(mat.spec+0.001))
 		transp = 1-mat.alpha
 		# matFlags = mat.getMode()
@@ -1213,7 +1214,7 @@
 	# to the class instance from the operator settings before calling.
 
 	__props__ = [
-		bpy.props.StringProperty(attr="filename", name="File Name", description="File name used for exporting the X3D file", maxlen=1024, default=""),
+		bpy.props.StringProperty(attr="path", name="File Path", description="File path used for exporting the X3D file", maxlen= 1024, default= ""),
 
 		bpy.props.BoolProperty(attr="apply_modifiers", name="Apply Modifiers", description="Use transformed mesh data from each object.", default=True),
 		bpy.props.BoolProperty(attr="triangulate", name="Triangulate", description="Triangulate quads.", default=False),
@@ -1221,7 +1222,7 @@
 	]
 	
 	def execute(self, context):
-		x3d_export(self.filename, context, self.apply_modifiers, self.triangulate, self.compress)
+		x3d_export(self.path, context, self.apply_modifiers, self.triangulate, self.compress)
 		return ('FINISHED',)
 	
 	def invoke(self, context, event):





More information about the Bf-blender-cvs mailing list