[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16323] trunk/blender/release/scripts/ bpymodules/colladaImEx: collada 1.4 importer/exporter - some improvements:
Remigiusz Fiedler
migius at 4d-vectors.de
Mon Sep 1 01:31:18 CEST 2008
Revision: 16323
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16323
Author: migius
Date: 2008-09-01 01:30:42 +0200 (Mon, 01 Sep 2008)
Log Message:
-----------
collada 1.4 importer/exporter - some improvements:
- added support for import IPOs interpolation type: LINEAR,BEZIER
- include patch jointVertexWeight from Dmitri: http://projects.blender.org/tracker/index.php?func=detail&aid=17427
- non-armature-animation export/import seams to work
- still buggy: armature-position and armature-animation export&import
Modified Paths:
--------------
trunk/blender/release/scripts/bpymodules/colladaImEx/collada.py
trunk/blender/release/scripts/bpymodules/colladaImEx/helperObjects.py
trunk/blender/release/scripts/bpymodules/colladaImEx/translator.py
Modified: trunk/blender/release/scripts/bpymodules/colladaImEx/collada.py
===================================================================
--- trunk/blender/release/scripts/bpymodules/colladaImEx/collada.py 2008-08-31 21:53:39 UTC (rev 16322)
+++ trunk/blender/release/scripts/bpymodules/colladaImEx/collada.py 2008-08-31 23:30:42 UTC (rev 16323)
@@ -28,6 +28,8 @@
from cutils import *
from datetime import *
+debprn = 0 #False #--- print debug "print 'deb: ..."
+
# The number of decimals to export floats to
ROUND = 5
@@ -483,11 +485,11 @@
self.target = xmlUtils.ReadAttribute(xmlNode, DaeSyntax.TARGET)
def SaveToXml(self, daeDocument):
-# if debprn: print 'deb:DaeChannel() self.source=', self.source #-------
-# if debprn: print 'deb:DaeChannel() self.target=', self.target #-------
+ if debprn: print 'deb:DaeChannel() self.source=', self.source #-------
+ if debprn: print 'deb:DaeChannel() self.target=', self.target #-------
node = super(DaeChannel, self).SaveToXml(daeDocument)
-#org SetAttribute(node, DaeSyntax.SOURCE, StripString('#'+self.source.id))
- SetAttribute(node, DaeSyntax.SOURCE, StripString('#'+self.source))
+ SetAttribute(node, DaeSyntax.SOURCE, StripString('#'+self.source.id))
+ ##SetAttribute(node, DaeSyntax.SOURCE, StripString('#'+self.source))
SetAttribute(node, DaeSyntax.TARGET, self.target)
return node
@@ -3503,4 +3505,4 @@
for daeTechnique in daeExtra.techniques:
if daeTechnique.profile == 'Blender':
return daeTechnique
- return None
+ return None
\ No newline at end of file
Modified: trunk/blender/release/scripts/bpymodules/colladaImEx/helperObjects.py
===================================================================
--- trunk/blender/release/scripts/bpymodules/colladaImEx/helperObjects.py 2008-08-31 21:53:39 UTC (rev 16322)
+++ trunk/blender/release/scripts/bpymodules/colladaImEx/helperObjects.py 2008-08-31 23:30:42 UTC (rev 16323)
@@ -26,7 +26,7 @@
import collada
from Blender.Mathutils import *
-debprn = False #--- print debug "print 'deb: ..."
+debprn = 0 #False #--- print debug "print 'deb: ..."
class Armature(object):
# static vars
@@ -219,6 +219,9 @@
types.append(Blender.Object.Pose.LOC)
elif ta[0] == collada.DaeSyntax.ROTATE and not Blender.Object.Pose.ROT in types:
types.append(Blender.Object.Pose.ROT)
+ #TODO: check if scale correct implemented
+ elif ta[0] == collada.DaeSyntax.SCALE and not Blender.Object.Pose.SCALE in types:
+ types.append(Blender.Object.Pose.SCALE)
return types
def GetType(self, daeNode, target):
@@ -237,11 +240,16 @@
targetId = targetArray[1]
# Get the animationInfo object for this node (or create a new one)
animation = cls._animations.setdefault(nodeId, AnimationInfo(nodeId))
+ #if debprn: print 'deb:helperObj.py:class AnimationInfo CreateAnimations() dir(animation)', dir(animation) #----------
# loop trough all samplers
sampler = None
+ if debprn: print 'deb:helperObj.py:class AnimationInfo CreateAnimations() \ndeb: channel.source= ', channel.source #----------
for s in daeAnimation.samplers:
- if s.id == channel.source[1:]:
+ #if debprn: print 'deb: sampler.id = ', s.id #----------
+ #if debprn: print 'deb: channel.source[1:]= ', channel.source[1:] #----------
+#org if s.id == channel.source[1:]:
+ if s.id == channel.source:
sampler = s
# Get the values for all the inputs
@@ -249,18 +257,41 @@
input = sampler.GetInput("INPUT")
inputSource = daeAnimation.GetSource(input.source)
if inputSource.techniqueCommon.accessor.HasParam("TIME") and len(inputSource.techniqueCommon.accessor.params) == 1:
+ if debprn: print 'deb: DDDDD getting target' #----------
output = sampler.GetInput("OUTPUT")
outputSource = daeAnimation.GetSource(output.source)
outputAccessor = outputSource.techniqueCommon.accessor
accessorCount = outputAccessor.count
accessorStride = outputAccessor.stride
+ interpolations = sampler.GetInput("INTERPOLATION")
+ interpolationsSource = daeAnimation.GetSource(interpolations.source)
+ if 0: #because probably interpolationsAccessor is identical to outputAccessor
+ interpolationsAccessor = interpolationsSource.techniqueCommon.accessor
+ accessorCount = interpolationsAccessor.count
+ accessorStride = interpolationsAccessor.stride
+
+ if debprn: print 'deb: outputSource.source.data: ', outputSource.source.data #----------
+ #if debprn: print 'deb: dir(outputAccessor.params): ', dir(outputAccessor.params) #----------
+ #if debprn: print 'deb: dir(outputAccessor.params[0]): ', str(outputAccessor.params[0]) #----------
times = [x*fps for x in inputSource.source.data]
-
+ if debprn: print 'deb: times=', times #---------
for timeIndex in range(len(times)):
time = animation.times.setdefault(times[timeIndex], dict())
target = time.setdefault(targetId, dict())
+ #interp = time.setdefault(targetId, dict())
+ #if debprn: print 'deb: accessorStride=', accessorStride #---------
+ value = []
for j in range(accessorStride):
- target[outputAccessor.params[j]] = outputSource.source.data[timeIndex*accessorStride + j]
+ #if debprn: print 'deb: timeIndex,j,data=',timeIndex, j, outputSource.source.data[timeIndex*accessorStride + j] #---------
+ #if debprn: print 'deb: outputAccessor.params[j]=',outputAccessor.params[j] #---------
+ #target[outputAccessor.params[j]] = outputSource.source.data[timeIndex*accessorStride + j]
+ value.append(outputSource.source.data[timeIndex*accessorStride + j])
+ if debprn: print 'deb: value=', value #---------
+ target[outputAccessor.params[0]] = value
+ #interp[outputAccessor.params[j]] = interpolationsSource.source.data[timeIndex*accessorStride + j]
+ if debprn: print 'deb: time=', time #---------
+ if debprn: print 'deb: target=', target #---------
+ #if debprn: print 'deb:helperObj.py: X X X X X X X X X class AnimationInfo CreateAnimations() animation=', animation #----------
CreateAnimations = classmethod(CreateAnimations)
Modified: trunk/blender/release/scripts/bpymodules/colladaImEx/translator.py
===================================================================
--- trunk/blender/release/scripts/bpymodules/colladaImEx/translator.py 2008-08-31 21:53:39 UTC (rev 16322)
+++ trunk/blender/release/scripts/bpymodules/colladaImEx/translator.py 2008-08-31 23:30:42 UTC (rev 16323)
@@ -24,6 +24,11 @@
# --------------------------------------------------------------------------
# History
+# 2008.08.31 by migius:
+# - added support for import IPOs interpolation type: LINEAR,BEZIER
+# - include patch jointVertexWeight from Dmitri: http://projects.blender.org/tracker/index.php?func=detail&aid=17427
+# - non-armature-animation export/import seams to work
+# - still buggy: armatures-position and armature-animation export&import
# 2008.08.04 by migius:
# - bugfix/refactor localTransformMatrix usage in hierarchies:
# it preserves local orientation for each child, so imported IPOs are correct working
@@ -37,7 +42,8 @@
import datetime
from helperObjects import *
-debprn = False #--- print debug "print 'deb: ..."
+debprn = 0 #--- print debug "print 'deb: ..."
+dmitri = 0 #switch for testing patch from Dmitri
class Translator(object):
isImporter = False
@@ -102,44 +108,6 @@
scenesLibrary = None
fps = 25
- def CreateID(self, name, typeName=None):
- if len(name) > 0 and not name[0].isalpha():
- name = "i"+name
-
- if not (name in self.ids):
- self.ids.append(name)
- return name
- else:
- tempName = name
- if not(typeName is None) and name.rfind(typeName) >= 0:
- # Check for existing number at the end?
- return self.IncrementString(tempName, True)
- else:
- # First check if no Blender Object exists with the name 'tempName + typeName'
- if (tempName + typeName) in self.allBlenderNames:
- return self.IncrementString(tempName + typeName, True)
- else:
- return self.CreateID(tempName+typeName, typeName)
-
- def IncrementString(self, name, checkName):
- tempName = name
- if name.rfind('.') >= 0:
- while tempName[-1:].isdigit():
- tempName = tempName[:-1]
- digitStr = name[-(len(name)-len(tempName)):]
- digit = 1
- if len(digitStr) > 0 and len(digitStr) != len(name):
- digit = int(digitStr)+1
- newName = tempName+str(digit).zfill(3)
- else:
- newName = name+'.001'
-
- if not (newName in self.ids) and (not checkName or not (newName in self.allBlenderNames)):
- self.ids.append(newName)
- return newName
- else:
- return self.IncrementString(newName, checkName)
-
def __init__(self, fileName):
global waitingControllers, armatures
# Keep track of the controller that are waiting to be applied
@@ -182,7 +150,45 @@
self.inverseAxisTransformMatrix = Matrix()
self.orgAxiss = ["X","Y","Z"]
+ def CreateID(self, name, typeName=None):
+ if len(name) > 0 and not name[0].isalpha():
+ name = "i"+name
+ if not (name in self.ids):
+ self.ids.append(name)
+ return name
+ else:
+ tempName = name
+ if not(typeName is None) and name.rfind(typeName) >= 0:
+ # Check for existing number at the end?
+ return self.IncrementString(tempName, True)
+ else:
+ # First check if no Blender Object exists with the name 'tempName + typeName'
+ if (tempName + typeName) in self.allBlenderNames:
+ return self.IncrementString(tempName + typeName, True)
+ else:
+ return self.CreateID(tempName+typeName, typeName)
+
+ def IncrementString(self, name, checkName):
+ tempName = name
+ if name.rfind('.') >= 0:
+ while tempName[-1:].isdigit():
+ tempName = tempName[:-1]
+ digitStr = name[-(len(name)-len(tempName)):]
+ digit = 1
+ if len(digitStr) > 0 and len(digitStr) != len(name):
+ digit = int(digitStr)+1
+ newName = tempName+str(digit).zfill(3)
+ else:
+ newName = name+'.001'
+
+ if not (newName in self.ids) and (not checkName or not (newName in self.allBlenderNames)):
+ self.ids.append(newName)
+ return newName
+ else:
+ return self.IncrementString(newName, checkName)
+
+
def CreateNameForObject(self, name, replace, myType):
if not replace:
return name
@@ -274,12 +280,11 @@
self.inverseAxisTransformMatrix = Matrix(self.axisTransformMatrix).invert()
-
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list