Set Up vector to a node without changijng it rotation

hello guys,
can anyone tell me how to make a node vertically aligned with a vector, the vector starts at the 0,0 of the node and goes up with a certain angle .
If I use look at , the node just looks at the up vector which I dont want to, I want it to be aligne with the UP vector.
I managed to make it work with quaternions, but the problem is that I want to rotate by a certain angle the current rotation of the spatial.

This adds to the current rotation but lol my models keeps spinning really fast, the angle is right, but the problem is taht it keeps adding the angle to my spatial, and I want the angle to be My current spatial rotaion + a certain fixed angle, and stop at that.

[java] float angle = normal.normalizeLocal().angleBetween(Vector3f.UNIT_Y);
transformationRotation.fromAngleAxis(angle, Vector3f.UNIT_Y.cross(normal));
spatial.setLocalRotation(transformationRotation.mult(spatial.getLocalRotation()));
Debug2D.setArrow2(spatial.getLocalTranslation(), spatial.getLocalTranslation().add(normal.mult(100)));
[/java]

thx

If you want to use look at, then you can attach the spatial to a node, rotate the spatial along the x axis by FastMath.Half_PI, so that the top of it, is now facing you. Then do can do look at on the node.

[java]node.lookAt (new Vector3f (0, 1, 1), Vector3f.UNIT_Y);[/java]

like normal, and it will orient the top of the spatial to be in that direction.

Edit: In that case, use lookAt (or w/e) to get the final rotation, and use Quaternion.Slerp (), to interpolate between the rotations
Edit: These edits are screwing me over. So you just want to go from 1 rotation to another instantly? Maybe you need to .clone() the transforms then if they are being used by reference somewhere

1 Like

Sorry wezrule for the dits :confused: didn’t see your post!
well since I am rotating all the spatials on screen, moving them to another node is kinda hard, i’d rather rotate them in place.
is it possible to rotate a spatial on an axis without affecting its other rotation axises??

like rotating a spatial on the normal.cross(Yaxis) only

OMG wezrule I just found out there is a method called rotateUpTo(newUp)

the normal must be normailized and it works like a charm :slight_smile:

I really love JMONKEy haha!

1 Like

your right :), there’s still many hidden methods I’ve never spotted before

Edit: the implementation of it, was pretty much the same as your solution, so you were on the right track