We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi all, Does anybody know how to extract rotation angles from a Matrix, like for position with the functions modelX, Y, Z()? I think I already know about getMatrix(), setMatrix() or applyMatrix(), but I need to get individually translation and rotation informations after several cumulative Matrix transformations. Especially because both set/applyMatrix() have no effect with OBJexport (for after boolean operations in Blender in my case..), but I also believe it could be very usefull and interesting. I don't well understand Matrix inside informations... Hope someone can help, thanks!
Answers
Hi step, I referred to this Stack Overflow discussion, then tried this:
Euclidean Spaces also has an explanation of this and other conversions. I've not tested the following, but I wonder if you'll want to check that the rotation mode of an object (XYZ in the above example) is the same in Processing as in Blender.
That works perfectly! Thank you so much!
Checking rotation modes between Processing and Blender, XYZ axes are for me all the sames (hope I don't make any mistake..). With this precision : importing an .obj file exported from processing with OBJexport in Blender, applies a 90° rotation on X axis in the transform panel. That can be erased.
But I really feel unsure with my previous answer cause, comparing visually axes orientations between Processing and Blender, X & Y axes have permuted (90° X rotation canceled)... Do we have to consider separately Processing & OBJexport in comparison with Blender, for rotation mode?
Well, I guess I'd start by giving myself some diagnostic tools. First, I'd draw the transform in Processing...
Then, I'd take a screen shot every time I saved an obj file.
This is so I can compare the screenshot against my result in Blender.
Link
Link
The world coordinates in Blender and Processing are very different. In Processing the y-axis which describes up is flipped, so (0.0, 1.0, 0.0) moves down and (0.0, -1.0, 0.0) moves up; in Blender the y-axis describes forward while the z-axis describes up.
Furthermore, in Blender there's a distinction between translating, rotating and scaling an object while in Object Mode and doing the same to vertices, edges and faces in Edit Mode.
In Processing, that distinction is less clear and harder to control, but I imagine the difference in world coordinates would impact both your object's orientation and that of its vertices. Another wrinkle is how you export the boxes, in the above example, I've exported all three boxes as one object. In Blender I could enter edit mode, select the desired faces, then create separate objects.
Hi behreajj,
Thank you for your answer, all these precisions and references. It has required some time to me for understanding, doing some tests, and finally it's still a work in progress :)
Well, I first compare axes between Processing/OBJexport and Blender using your drawTransform function :
In Processing :
In Blender :
Boxes lengths increase from X to Z, and as I can retrieve same axes I believe (and hope so) it doesn't a matter for me, except that Z is inverted...
Your first code example gave me the idea that storing all matrix transformations in a list was probably the only solution that could finally solve my problem :
Transformations history must be restored as needed. I probably was afraid to play with different matrix like in your example, because that's really so hot sometimes with just only one! I don't know yet if there are any solution that way.
Finally, here is a full code example :
After many tests (and bugs...), it appears to me that it now works.
In Blender :
Different matrix transformations can than be reproduced, a position with right axes rotations can be restored. That way multiple files can be exported separately, and boolean operations can than be applied between them in Blender.
I hope it is not a dream (!), and that this method will work ALL the time!
Feel really free to give me frankly your opinion! And many thanks again for your help!