i have a node with some Geometry objects attached and i want to rotate the node on user input on the x, y, or z, each time by 90°
E.g. i want to rotate first on the x-Axis by 90° and after that on the y-Axis by 90°. But if i use the localRotation of the node, it rotates around the parent (or global) z-Axis.
I didn´t find a easy solution for that and i also don´t know how to solve it.
i´m afraid that i need a complex math calculation or maybe i it to easy and i´m only thinking to complex
i mean
if i look from the Z-axis to the node (Cam), and i hit rotateOnZAxis(). i will that the node is rotating on the z-axis im looking from
and not the z-axis from node
Vector3f rotate = node.getParent().getLocalRotation().mult(axis);
quad = new Quaternion().fromAngleAxis(FastMath.PI/2, rotate);
node.rotate(quad);
axis is a given Vector3f for X,Y or Z Axis
Have there is the same problem, if i rotate only on one of these Axis, its working, but wen i rotate on a second axis then it rotating again arround the nodes local axis
Do note that this is a cumulative effect meaning that the passed ‘quad’ rotation will be multiplied against the existing rotation. This may or may not be what you want… and it may be exactly backwards (ie: you really want the existing rotation post-multiplied with your new one).
I have trouble wrapping my head around the effect you are trying to achieve so I can’t be sure.
See, this is almost certainly wrong… first you get the axis relative to the Current rotation… then you make a rotation about that axis… then you multiply that axis by the current rotation… so it seems like you double-apply the rotation basically.
What is the actual effect you are trying to achieve? Can you describe it in terms of another game we might know?
no not around the camera´s axes, it should rotate on a fixed axes that has nothing to do with the block/node i want rotate
so if i want rotate around the Vector3f.UNIT_Z the local rotate of the block can be X,Y or Z Axis
the getParent() give be back the root node
Oh. In this case just calling the rotate(float, float, float) method of the Node should do the trick (and you don’t even have to worry about Quaternions):
node.rotate(FastMath.HALF_PI, 0, 0); // 90° rotation around x-axis
Since this changes the node’s local rotation, the effect in the game world is as if it had been rotated around it’s parent’s axes