I am trying to place an object in the space, facing an specific direction with an specific rotation.
I know it's position in the world, it's forward vector and it's up vector, but nothing I try works.
I tried calculating pitch and yaw and rotating it using:
Code :double pitch = asin(forward.y/sqrt(forward.x*forward.x + forward.z*forward.z)) * (180/M_PI); double yaw = atan2(forward.x,forward.z) * (180/M_PI); glRotated(pitch,1,0,0); glRotated(yaw,0,1,0);
but it didn't work. I also tried using gluLookAt
Code :gluLookAt( 0,0,0, forward.x,forward.y,forward.z, up.x,up.y,up.z);
but it didn't work too. I also tried lots of variations.
What is the correct way to do it? I am sure that the forward and up vectors are correct, since I show them on the screen. I am just drawing a line from [0,0,0] to [1,0,0] to test it.