Author Topic: Rotate object according to forward and downward vectors  (Read 142 times)

Offline Windmiller

  • byte
  • *
  • Posts: 6
    • View Profile
Rotate object according to forward and downward vectors
« 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, Morgan

« Last Edit: April 17, 2020, 01:39:02 am by Windmiller »

Offline MichaelJPCT

  • long
  • ***
  • Posts: 200
    • View Profile
Re: Rotate object according to forward and downward vectors
« Reply #1 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.

Offline Windmiller

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Rotate object according to forward and downward vectors
« Reply #2 on: April 18, 2020, 12:02:59 am »
Thank you! I didn't see that function, thanks a million  :)