www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Windmiller on April 17, 2020, 12:01:52 am

Title: Rotate object according to forward and downward vectors
Post by: Windmiller on April 17, 2020, 12:01:52 am
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..

Code: [Select]
cube.setRotationMatrix(forwardVector.getRotationMatrix());
But How do I combine this with the downward vector??


Regads, M

Title: Re: Rotate object according to forward and downward vectors
Post by: MichaelJPCT on April 17, 2020, 07:09:54 pm
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.
Title: Re: Rotate object according to forward and downward vectors
Post by: Windmiller on April 18, 2020, 12:02:59 am
Thank you! I didn't see that function, thanks a million  :)