Rotate object according to forward and downward vectors

Started by Windmiller, April 17, 2020, 12:01:52 AM

Previous topic - Next topic

Windmiller

Hello

I'm trying to rotate a cube in object's space (local) based on a forward and a downward vector.
I want one of the object's side faces to point in a forward vector, while the cube's down face is pointing in the downward vector's direction.

How can this be done with Jpct-AE? I now how to do it in Monogame, but I can't make it happen with Jpct

I can make one of the directions with the following code, here the forward as an example..

cube.setRotationMatrix(forwardVector.getRotationMatrix());

But How do I combine this with the downward vector??


Regads, M


MichaelJPCT

i always use object3d.setOrientation(forward vec, up vec) .
up vec is negative of downward vec.
only 6 float values (two vec3) are needed.
you need vectors in world space.

Windmiller

Thank you! I didn't see that function, thanks a million  :)