I am at a loss here. I was busy rewriting my Titan Quest script when I ran into some weirdness with the bones. Instead of harassing MrAdults with about a dozen pm's a day I'll put it here incase someone else might be able to help.
Old code:
Code: Select all
def Bones(self):
self.data.seek(4,1)
numBones = self.data.readUInt()
self.bones = []
for i in range( numBones):
bone = {'name' : noeStrFromBytes(self.data.readBytes(32))}
bone['index'] = i
bone['child'] = self.data.readUInt()
bone['numChild'] = self.data.readUInt()
boneBuff=self.data.readBytes(48)
(a1,a2,a3),(a4,a5,a6),(a7,a8,a9),(x,y,z) = NoeMat43.fromBytes(boneBuff)
tupl=(a1,a2,a3,0),(a4,a5,a6,0),(a7,a8,a9,0),(x,y,z,1)
bone['matrix'] = NoeMat44(tupl)
self.bones.append(bone)
for bone in self.bones:
for i in range( bone['numChild']):
child = bone['child'] + i
self.bones[child]['parent'] = bone['index']
for bone in self.bones:
if not 'parent' in bone:
bone['parent'] = -1
else:
matrix = bone['matrix']
parent = self.bones[ bone['parent']]['matrix']
bone['matrix'] = matrix.__mul__(parent)
m = bone['matrix'].mat44
for bone in self.bones:
m = bone['matrix'].mat44
k=[0,0,0,0]
for t in range(len(m)):
k[t] = NoeVec3(m[t][:-1])
bone['matrix'] = NoeMat43(list(k))
self.boneList.append(NoeBone(bone['index'],
bone['name'],
bone['matrix'],
None,
bone['parent']))
return
new code:
Code: Select all
def Bones(self):
self.data.seek(4,1)
numBones = self.data.readUInt()
self.bones = []
for i in range( numBones):
bone = {'name' : noeStrFromBytes(self.data.readBytes(32))}
bone['index'] = i
bone['child'] = self.data.readUInt()
bone['numChild'] = self.data.readUInt()
bone['matrix'] = NoeMat43.fromBytes(self.data.readBytes(48))
self.bones.append(bone)
for bone in self.bones:
for i in range( bone['numChild']):
child = bone['child'] + i
self.bones[child]['parent'] = bone['index']
for bone in self.bones:
if not 'parent' in bone:
bone['parent'] = -1
else:
matrix = bone['matrix']
parent = self.bones[ bone['parent']]['matrix']
bone['matrix'] = matrix.__mul__(parent)
#bone['matrix'] = bone['matrix'].transpose()
m = bone['matrix'].mat43
self.boneList.append(NoeBone(bone['index'],
bone['name'],
bone['matrix'],
None,
bone['parent']))
#self.boneList = rapi.multiplyBones(self.boneList)
Old code:
new code:
According to me I'm basically doing the same, but I must be missing some detail.
Edit: updated old code to more readable version