Porting from 2.4 to 2.6. My issues.

I’m finally porting my importers/exporters to 2.6 and I have some issues from the API differences. Though I need to find the new classes and functions which replaced some old ones, I also encounter cases when old stuff exist but do stuff differently.
So I’m going to post my questions in this thread as I go along.

Before I start, is there maybe a FAQ page listing all the major differences/changes intended for people like me who are porting their existing scripts?


My first question:

In my importer, I used to create bones by assigning matrices read from the file to them. I also needed to convert the matrices from y-up space to z-up. Matrices are in armature space.

In 2.62, the bones appear in their correct position, but the rotation matrices seems to rotate the bones in their space, not in armature space. So my character is standing while its Armature is lying on the floor.

Codes:
2.4


rzUp = Blender.Mathutils.Matrix().identity() * Blender.Mathutils.RotationMatrix(90,4,'x')
mybone.matrix = matrixFromFile * rzUp

2.6


rzUp = mathutils.Matrix.Identity(4) * mathutils.Matrix.Rotation(math.radians(90.0), 4, 'X')
mybone.transform(matrixFromFile * rzUp)

And if you’re gonna suggest to look at existing importers, all formats I checked don’t support bones and the rest don’t use (store/read) bone matrices.

I’m aware of that change, thanks. Mixing columns with rows would surely mess up bone locations and in my case they are correct, simply rotations are applied in bonespace, not armaturespace.

why not post your importers/exporters for some help about the usage with newer api-verrsions?

And most important - you know the big break from blender-2.60/1/2 to current blender-2.63?
So what 2.6x version you aim at?

What should posting the tools which are only useful for our game project help with? I’ve explained the exact problem I’m having and freed you from having to go through hundreds of lines of code to spot a problem. I hate when people just throw all their code out and ask people to say “what’s wrong”. Am I wrong?

And I don’t know of any huge changes in 2.63, except “mesh.polygons” instead of “mesh.faces”. Using 2.62 because I used it when started writing the first script.

bump .

Tried matrix.bones[i].matrix_local too, that didn’t do anything at all.

yes, you are wrong in my opinion - or do you think its always a nice behaviour only to take and to share nothing?
You are shure your coding (those hundreds of lines) is senseless … why you ask for any help?
Instead you “bump” again … and you want to force an answer… that instantly solves a particular “problem”, that you cant describe with a simple code-sample (cause you obviously cannot split/deduct such part out of the so many lines of code)?

Maybe you go a step back and try to write down the problem again …

Hey, what’s with the attitude?

I asked you if you think I’m wrong for thinking it’s wrong to throw all of your code to a person and ask them to spot a problem, when you can spot the exact problem yourself and ask what’s wrong with the erroneous line(s) instead.
Not if you think it’s wrong to not share the final script. And why assume I’m not going to share it when its done? Even then I could be working on a non-open format used only by a single team for their game and have no rights to do so. And I don’t see the moral part of sharing your script to get an answer either.

If I dump the skeleton part of my 3d file to a new file and test it with just the few lines of code (posted here) and see the problem is indeed with those few lines of code, then I’m doing you a favor by simplifying my question and doing the testing myself.

You are shure your coding (those hundreds of lines) is senseless … why you ask for any help?

Wow… It’s useless for answering the question. The material, texture, mesh and property reading part of the script has nothing to do with skeleton orientation which I’m having problem with.

And if you can’t understand the problem, well maybe you just don’t know the solution? I would understand if you asked for clarification on some particular part, but if you’re asking me to rewrite the question, then sorry, I don’t know what you need. I’ve written the exact issue, goal and example code.

in your sample you posted 2 different line of codes and i can only say from the matrix-calculation i know for blender-2.61 it still works. But the different lines of codes may have different results, …— the setting of matrix-values is not the same like using the “transform-function” (that made me think you want to do something totally different …).

Well what is the usual way of creating a bone from a matrix then? I couldn’t find anything, EditBones have a “matrix” attribute, which is the matrix in armature space (what I need), but it’s read-only.

And there’s also a non-EditBone, but Bone attribute “matrix_local”, which seems what I need too, but I can’t modify it too, seems read-only too, though not mentioned.


import bpy
import mathutils
import math

rzUp = mathutils.Matrix.Identity(4) * mathutils.Matrix.Rotation(math.radians(90.0), 4, 'X')

armobj = bpy.context.object
armature = armobj.data

mybone = armature.bones['Bone'] 
mybone.matrix_local = mybone.matrix_local * rzUp

#print (mybone.matrix_local)

So I thought EditBone.transform() is fine, without multiplying each matrix with a RotationMatrix the final skeleton looks correct, except it’s lying on the floor because in the file the Matrices are in right-handed-Y-Up space.

creating new bones from a matrix only?

I dont know if there is such a solution,
i only did create new bones and setting their base, tip
like its done for example in the import_bvh.py.
At the end then the bone gets naturally a matrix from this setting.
(and roll could be used too - but i never needed it …)

but you already did say, you did check all importers and they did not use bones … …
(so i dont know what my blender-version shows … or why i can see it)

Well yeah, many (game) formats store bones as transform matrices.
The importer I wrote for Blender 2.4 creates bones from matrices too with no problem, and it’s based on someone else’s script.

but you already did say, you did check all importers and they did not use bones …)
*matrices.

The solution seems to be switching the multiplication order of the matrices. Might be caused from the changes in the 2.62 release, dunno.