I wrote this VERY simple code. Using the BGE and the default cube, it prints the rotation of the cube initially and after I assign new values, it prints the new matrix with the new value, but the cube itself doesn’t rotate to the new position. I was expecting to see the cube rotate on the Z axis but nothing happens. I’m calling it with an ‘always’ sensor and a python controller. Any ideas?
I would suggest learning how orientation matrices work. It’s much more complicated than you seem to think. Each value is not, in fact, the rotation in degrees on each axis, it is a point relative to the object center that the axis points to, which always has a distance of ‘1’ away. I believe you can convert this matrix to something more user-friendly with a built in function.
Mokazon,
Thanks. It works. But this is an example of what I was trying to find out in this and my other post about documentation. I’ve read all that I could find about the BGE, and all the links that all of you here have provided. But I have never seen anything that would tell me about what you have used here. I had seen the own.rotation for example, but where did you find out about using the syntax ‘own.orientation.to_euler()’ and ‘own.orientation=own.rot.to_matrix()’ ? I am looking specifically at the to_euler() and to_matrix(). I have never seen this in any documentation, but you obviously know what you’re doing. Are these and other things listed somewhere where I can find them for reference?
I have printed some directories, including ‘math’ and ‘mathutils’ but I didn’t see ‘to_euler’ or ‘to_matrix’. I will do what you said. Thank you. Everyone here has been very helpful.
Also, when printing directories, you have to print them at the level of what you are interested in knowing. Printing a directory for mathutils in general is not going to return the functions specific to mathutils.Matrix. To get what you wanted, you should have done as mokazon said:
Thanks Blendenzo! Going further into the directories will definitely help me. The other part I have been missing is exactly how to read the API. When I saw ‘type’ under all the modules, I had no idea what that meant as far as returning a value, etc. I could never find a tutorial on how to understand the API exactly. Now at least I have an idea.