Could you make it so we can do just

[java]cam.setRotation(x, y, z)[/java]

like we can do for objects (spatials and geometries)? That would make it easier to use, because we won’t have to play with quaterions and this way it’ll be more intuitive and straightforward.

You cannot just set an x,y,z Euler rotation on a spatial, you need to use a quaternion or a Matrix3f. Euler rotations are not used for several reasons. This is worth a read.

1 Like

Well, I don’t care how it will work internally. It can convert x,y,z degrees to quaternions and rotate appropriately. I’d like just easy function that will save me a hassle with figuring out how to use quaternions.

[java]new Quaternion().fromAngles(x, y, z);[/java]

You don’t even have to know what a Quaternion is…

2 Likes

Well you better figure them out. And read the link I posted:

...[Euler rotations]...There are problems however. One is that the order of operations is important. If you pitch an object 90 degrees, then yaw it 90 you get a different result than if yaw is done before pitch. Try it.

Another big problem is known as gimbal lock(external link). A gimbal is an axis of rotation. This problem occurs when mathematically two axes of rotation become aligned and one gets canceled out.

@sbook said:

[java]new Quaternion().fromAngles(x, y, z);[/java]

You don't even have to know what a Quaternion is..

Thanks! I didn't know about this method!

//edit: And yes, I've read article, but it's a matter of just avoiding gimbal lock and follows always same rotation step order.

You don’t want to mess with rotations at all due to several reasons, best use direction vectors: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies

@dariuszg-jagielski said:

Well, I don't care how it will work internally. It can convert x,y,z degrees to quaternions and rotate appropriately. I'd like just easy function that will save me a hassle with figuring out how to use quaternions.

It's exactly why you don't care that you don't get it. If you'd care for a bit you'd know that to get a proper rotation you can't simply say:

Take X, Y, Z and make a quaternion out of it.

A quaternion is made of:

X component (composed of X, Y, Z, W)

Y component (composed of X, Y, Z, W)

Z component (composed of X, Y, Z, W)

W component (composed of X, Y, Z, W)

So, tell me; how the hell are we supposed to code a rotation quaternion from a basic vector3f? I'd love to know. We've only have 13 missing variables. Hey, we could make them up. Oh wait. We can't 'cause then you'd come whine here saying it doesn't work.