Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Finding camera up with yaw, pitch and roll?

$
0
0

Hey!

I am trying to do object picking with rays in Processing. Everything works fine, except I cannot find the right 'up' vector of the camera. I am using Peasy library.

I could get the cameraUp vector by:

right = PVector.cross(view,new PVector(0,0,1)); then

cameraUp = PVector.cross(view, right);

However the problem is that when I am orbiting with the camera the up vector (0,0,1) gets rotated. I would like to find the up vector of the rotated coordinate system. Peasy lets you access the pitch, yaw and roll.

I tried doing it with:

    up.x = cos(cam.getRotations()[0])*sin(cam.getRotations()[1]);
    up.y = -cos(cam.getRotations()[1]);
    up.z = sin(cam.getRotations()[0])*sin(cam.getRotations()[1]);

and a few similar versions, but I just can't get it to work. it might be due to peasy defining the axis differently.

Any hint on how I could solve this?

Any answer would be much appreciated:)


Viewing all articles
Browse latest Browse all 2896

Trending Articles