[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21799] branches/soc-2009-kazanbas: FBX exporter:
Arystanbek Dyussenov
arystan.d at gmail.com
Wed Jul 22 15:35:03 CEST 2009
Revision: 21799
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21799
Author: kazanbas
Date: 2009-07-22 15:35:02 +0200 (Wed, 22 Jul 2009)
Log Message:
-----------
FBX exporter:
- made an operator with props for UI. UI is still "raw"
- ran 2to3 on export_fbx.py to make it python 3-compatible
Next: testing/fixing.
Modified Paths:
--------------
branches/soc-2009-kazanbas/release/io/export_fbx.py
branches/soc-2009-kazanbas/release/io/export_obj.py
branches/soc-2009-kazanbas/release/io/export_ply.py
branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_object_api.c
Modified: branches/soc-2009-kazanbas/release/io/export_fbx.py
===================================================================
--- branches/soc-2009-kazanbas/release/io/export_fbx.py 2009-07-22 12:43:37 UTC (rev 21798)
+++ branches/soc-2009-kazanbas/release/io/export_fbx.py 2009-07-22 13:35:02 UTC (rev 21799)
@@ -38,6 +38,7 @@
import os
import time
+import math # math.pi
# try:
# import time
@@ -65,10 +66,10 @@
import Mathutils
# from Blender.Mathutils import Matrix, Vector, RotationMatrix
-import BPyObject
-import BPyMesh
-import BPySys
-import BPyMessages
+# import BPyObject
+# import BPyMesh
+# import BPySys
+# import BPyMessages
## This was used to make V, but faster not to do all that
##valid = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_,.()[]{}'
@@ -79,7 +80,7 @@
def cleanName(name):
for ch in invalid: name = name.replace(ch, '_')
return name
-del v, i
+# del v, i
def copy_file(source, dest):
@@ -107,14 +108,14 @@
# Make a name for the target path.
dest_image_path = dest_dir + image_path.split('\\')[-1].split('/')[-1]
if not Blender.sys.exists(dest_image_path): # Image isnt alredy there
- print '\tCopying "%s" > "%s"' % (image_path, dest_image_path)
+ print('\tCopying "%s" > "%s"' % (image_path, dest_image_path))
try:
copy_file(image_path, dest_image_path)
copyCount+=1
except:
- print '\t\tWarning, file failed to copy, skipping.'
+ print('\t\tWarning, file failed to copy, skipping.')
- print '\tCopied %d images' % copyCount
+ print('\tCopied %d images' % copyCount)
def BPyObject_getObjectArmature(ob):
'''
@@ -141,9 +142,9 @@
def eulerRadToDeg(eul):
ret = Mathutils.Euler()
- ret.x = 180 / math.pi * eul.x
- ret.y = 180 / math.pi * eul.y
- ret.z = 180 / math.pi * eul.z
+ ret.x = 180 / math.pi * eul[0]
+ ret.y = 180 / math.pi * eul[1]
+ ret.z = 180 / math.pi * eul[2]
return ret
@@ -221,7 +222,7 @@
#name = BPySys.cleanName(name)
name = cleanName(name) # use our own
- while name in dct.itervalues(): name = increment_string(name)
+ while name in iter(dct.values()): name = increment_string(name)
if use_other: # even if other is None - orig_name_other will be a string or None
dct[orig_name, orig_name_other] = name
@@ -286,9 +287,9 @@
if not len_groupNames:
# no verts? return a vert aligned empty list
- return [[] for i in xrange(len(me.verts))], []
+ return [[] for i in range(len(me.verts))], []
else:
- vWeightList= [[0.0]*len_groupNames for i in xrange(len(me.verts))]
+ vWeightList= [[0.0]*len_groupNames for i in range(len(me.verts))]
for i, v in enumerate(me.verts):
for g in v.groups:
@@ -303,7 +304,7 @@
These 2 lists can be modified and then used with dict2MeshWeight to apply the changes.
'''
- vWeightDict= [dict() for i in xrange(len(me.verts))] # Sync with vertlist.
+ vWeightDict= [dict() for i in range(len(me.verts))] # Sync with vertlist.
# Clear the vert group.
groupNames= [g.name for g in ob.vertex_groups]
@@ -368,7 +369,6 @@
ANIM_ACTION_ALL = False,
BATCH_ENABLE = False,
BATCH_GROUP = True,
- BATCH_SCENE = False,
BATCH_FILE_PREFIX = '',
BATCH_OWN_DIR = False
):
@@ -436,7 +436,7 @@
filename = new_fbxpath + newname + '.fbx'
- print '\nBatch exporting %s as...\n\t"%s"' % (data, filename)
+ print('\nBatch exporting %s as...\n\t"%s"' % (data, filename))
# XXX don't know what to do with this, probably do the same? (Arystan)
if BATCH_GROUP: #group
@@ -596,7 +596,8 @@
self.fbxGroupNames = []
self.fbxParent = None # set later on IF the parent is in the selection.
if matrixWorld: self.matrixWorld = matrixWorld * GLOBAL_MATRIX
- else: self.matrixWorld = ob.matrixWorld * GLOBAL_MATRIX
+ else: self.matrixWorld = ob.matrix * GLOBAL_MATRIX
+# else: self.matrixWorld = ob.matrixWorld * GLOBAL_MATRIX
self.__anim_poselist = {} # we should only access this
def parRelMatrix(self):
@@ -606,7 +607,8 @@
return self.matrixWorld
def setPoseFrame(self, f):
- self.__anim_poselist[f] = self.blenObject.matrixWorld.copy()
+ self.__anim_poselist[f] = self.blenObject.matrix.copy()
+# self.__anim_poselist[f] = self.blenObject.matrixWorld.copy()
def getAnimParRelMatrix(self, frame):
if self.fbxParent:
@@ -638,7 +640,7 @@
- print '\nFBX export starting...', filename
+ print('\nFBX export starting...', filename)
start_time = bpy.sys.time()
# start_time = Blender.sys.time()
try:
@@ -713,7 +715,7 @@
else:
# This is bad because we need the parent relative matrix from the fbx parent (if we have one), dont use anymore
#if ob and not matrix: matrix = ob.matrixWorld * GLOBAL_MATRIX
- if ob and not matrix: raise "error: this should never happen!"
+ if ob and not matrix: raise Exception("error: this should never happen!")
matrix_rot = matrix
#if matrix:
@@ -751,7 +753,7 @@
loc, rot, scale, matrix, matrix_rot = object_tx(ob, loc, matrix, matrix_mod)
file.write('\n\t\t\tProperty: "Lcl Translation", "Lcl Translation", "A+",%.15f,%.15f,%.15f' % loc)
- file.write('\n\t\t\tProperty: "Lcl Rotation", "Lcl Rotation", "A+",%.15f,%.15f,%.15f' % eulerRadToDeg(rot))
+ file.write('\n\t\t\tProperty: "Lcl Rotation", "Lcl Rotation", "A+",%.15f,%.15f,%.15f' % tuple(eulerRadToDeg(rot)))
# file.write('\n\t\t\tProperty: "Lcl Rotation", "Lcl Rotation", "A+",%.15f,%.15f,%.15f' % rot)
file.write('\n\t\t\tProperty: "Lcl Scaling", "Lcl Scaling", "A+",%.15f,%.15f,%.15f' % scale)
return loc, rot, scale, matrix, matrix_rot
@@ -1453,7 +1455,7 @@
# TODO - this is a bit lazy, we could have a simple write loop
# for this case because all weights are 1.0 but for now this is ok
# Parent Bones arent used all that much anyway.
- vgroup_data = [(j, 1.0) for j in xrange(len(my_mesh.blenData.verts))]
+ vgroup_data = [(j, 1.0) for j in range(len(my_mesh.blenData.verts))]
else:
# This bone is not a parent of this mesh object, no weights
vgroup_data = []
@@ -1728,7 +1730,7 @@
file.write('\n\t\t\tColorIndex: ')
i = -1
- for j in xrange(ii):
+ for j in range(ii):
if i == -1:
file.write('%i' % j)
i=0
@@ -1786,7 +1788,7 @@
file.write('\n\t\t\tUVIndex: ')
i = -1
- for j in xrange(ii):
+ for j in range(ii):
if i == -1:
file.write('%i' % j)
i=0
@@ -1890,7 +1892,7 @@
uv_faces = [None] * len(me.faces)
i=-1
- for f, uf in zip(me.faces, uv_faces)
+ for f, uf in zip(me.faces, uv_faces):
# for f in me.faces:
try: mat = mats[f.material_index]
# try: mat = mats[f.mat]
@@ -1955,7 +1957,7 @@
file.write('\n\t\t}')
if len(uvlayers) > 1:
- for i in xrange(1, len(uvlayers)):
+ for i in range(1, len(uvlayers)):
file.write('\n\t\tLayer: %i {' % i)
file.write('\n\t\t\tVersion: 100')
@@ -1983,7 +1985,7 @@
layer_offset = 0
if uvlayers: layer_offset = len(uvlayers)-1
- for i in xrange(layer_offset, len(collayers)+layer_offset):
+ for i in range(layer_offset, len(collayers)+layer_offset):
file.write('\n\t\tLayer: %i {' % i)
file.write('\n\t\t\tVersion: 100')
@@ -2033,7 +2035,8 @@
# if EXP_OBS_SELECTED is false, use sceens objects
if not batch_objects:
- if EXP_OBS_SELECTED: tmp_objects = sce.objects.context
+ if EXP_OBS_SELECTED: tmp_objects = context.selected_objects
+# if EXP_OBS_SELECTED: tmp_objects = sce.objects.context
else: tmp_objects = sce.objects
else:
tmp_objects = batch_objects
@@ -2201,9 +2204,9 @@
my_mesh = my_object_generic(ob, mtx)
my_mesh.blenData = me
my_mesh.origData = origData
- my_mesh.blenMaterials = material_mapping_local.keys()
+ my_mesh.blenMaterials = list(material_mapping_local.keys())
my_mesh.blenMaterialList = mats
- my_mesh.blenTextures = texture_mapping_local.keys()
+ my_mesh.blenTextures = list(texture_mapping_local.keys())
# if only 1 null texture then empty the list
if len(my_mesh.blenTextures) == 1 and my_mesh.blenTextures[0] == None:
@@ -2336,8 +2339,8 @@
# Finished finding groups we use
- materials = [(sane_matname(mat_tex_pair), mat_tex_pair) for mat_tex_pair in materials.iterkeys()]
- textures = [(sane_texname(tex), tex) for tex in textures.iterkeys() if tex]
+ materials = [(sane_matname(mat_tex_pair), mat_tex_pair) for mat_tex_pair in materials.keys()]
+ textures = [(sane_texname(tex), tex) for tex in textures.keys() if tex]
materials.sort() # sort by name
textures.sort()
@@ -2497,7 +2500,7 @@
#for bonename, bone, obname, bone_mesh, armob in ob_bones:
for my_bone in ob_bones:
- if me in my_bone.blenMeshes.itervalues():
+ if me in iter(my_bone.blenMeshes.values()):
write_sub_deformer_skin(my_mesh, my_bone, weights)
# Write pose's really weired, only needed when an armature and mesh are used together
@@ -2784,9 +2787,9 @@
# we have tagged all actious that are used be selected armatures
if blenAction:
if blenAction.tag:
- print '\taction: "%s" exporting...' % blenAction.name
+ print('\taction: "%s" exporting...' % blenAction.name)
else:
- print '\taction: "%s" has no armature using it, skipping' % blenAction.name
+ print('\taction: "%s" has no armature using it, skipping' % blenAction.name)
continue
if blenAction == None:
@@ -2866,7 +2869,7 @@
file.write('\n\t\t\tVersion: 1.1')
file.write('\n\t\t\tChannel: "Transform" {')
- context_bone_anim_mats = [ (my_ob.getAnimParRelMatrix(frame), my_ob.getAnimParRelMatrixRot(frame)) for frame in xrange(act_start, act_end+1) ]
+ context_bone_anim_mats = [ (my_ob.getAnimParRelMatrix(frame), my_ob.getAnimParRelMatrixRot(frame)) for frame in range(act_start, act_end+1) ]
# ----------------
# ----------------
@@ -2889,7 +2892,7 @@
file.write('\n\t\t\t\tChannel: "%s" {' % TX_CHAN) # translation
- for i in xrange(3):
+ for i in range(3):
# Loop on each axis of the bone
file.write('\n\t\t\t\t\tChannel: "%s" {'% ('XYZ'[i])) # translation
file.write('\n\t\t\t\t\t\tDefault: %.15f' % context_bone_anim_vecs[0][i] )
@@ -3064,7 +3067,7 @@
# copy_images( basepath, [ tex[1] for tex in textures if tex[1] != None ])
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list