I'm playing around with the 3D support in Gideros, and there seems to be a lack of rotation control, unless I'm missing something. A mesh has methods setRotationX() and setRotationY(), which both rotate the mesh around the world's axis, not the axis of the mesh itself. There's no setRotationZ() for a mesh, which means some orientations of the mesh relative to the world are impossible, unless there's some other method of rotation.
Using the 3D horse example, which shows a stationary horse mesh, as the camera moves around to view it from various angles. Suppose you make these changes:
In main.lua, replace this line:
That will leave the camera in a fixed position instead of orbiting around the horse. If you run the program, you'll see the horse facing you.
Now at the end of main.lua add:
That method rotates the mesh around the world's X axis, so the part of the mesh closest to the viewer rises up. Since it's facing you, that means the horse is now rearing up on its hind legs.
Now remove that line, so you're back to the horse standing normally and facing you. Now add this line:
That rotates the horse around the world's vertical axis, so now the horse is facing to the right.
Now here's the issue: Try to pose the horse so it's up on its hind legs, and facing to the right. Suppose you use both of those lines:
Since the rotations are done around world axis, and the Y rotation happens to be done first, the horse first turns towards the right, then rotates such that the part of the mesh nearest the viewer (the two right legs) lift off the ground, rather than the front legs. That is, the horse tips to its left.
Note that if the order of operations were reversed (rotating on the X axis, then Y axis), and the horse first raised up its front legs, then rotated to face right, we'd have the pose we were after, but then we'd lose the ability to make the horse face right and lean to its left or right.
Without a setRotationZ() method, it's impossible to rotate the horse so that it will be facing right with its front legs raised.
I've experimented with trying to manipulate the matrix of the mesh, with this:
m = mesh:getMatrix()
That has the effect of lowering the horse's two right legs, again, rotating on the world's X axis. Setting the X rotation of the matrix also rotates the mesh on the world's X axis. So manipulating the matrix rather than the mesh doesn't seem to offer a solution.
It is possible to generate a view of the horse facing right with its front legs raised by rotating it -60 degrees on the X axis, and then positioning the viewport to the left of the horse. That is, get the view you want by changing the position of the viewer rather than the orientation of the model. But that's not an effective workaround if you want a scene with more than one mesh that can be rotated independently. For example, you couldn't have two horses in the same view, one facing towards you and one to your right, both with front legs raised.
Am I missing something, or do we really need a mesh:setRotationZ()?
For context, I'm early in the process of building a new game using 3D models from a Windows game I developed years ago. I'm trying to decide whether to pose and pre-render those models in Blender, to make textures for 2D sprites, or to use the models directly in Gideros. I assume using pre-rendered sprites would have a performance advantage, and the advantage of being able to use more detailed models and render with anti-aliasing, etc. But using the models as meshes in Gideros has the advantage of freedom of perspective, and freedom to position objects at any angle without needing a huge number of textures. That assumes they can be rotated on 3 axis, though.