Loading...
Logo
Processing Forum
I'm trying to mimic proscene's camera movements without using the mouse but it seems I'm not undestanding it quite well. I want to rotate the camera to mimic look up, down, left and right.

From this interesting thread I got this example to rotate the camera
Copy code
  1. scene.camera().frame().rotate(new Quaternion(new PVector(0,0,1), PApplet.QUARTER_PI));
It seemed intuitive that for a "look up" rotation I should rotate using the camera's upVector as axis like this

Copy code
  1. scene.camera().frame().rotate(new Quaternion(scene.camera().upVector(), radians(1)));
But it doesn´t work as I expected. What am I doing wrong?

Thanks.

Replies(2)

Let me share my $0.02.

First, it's not clear what the up vector is. Since proscene is Processing-independent it could be different things. Therefore it's probably better to just define the vector you want to use and expect yourself, like in the example above.

Second, your assumption is wrong. The direction vector you rotate around is never equal to the direction of the rotation. When you rotate around for example the y axis (which is a suitable candidate for the up vector), then you rotate LEFT and RIGHT. I think to rotate UP and DOWN you need to rotate around the x axis. You can simulate this with a translated box and the rotateX, rotateY, rotateZ calls in Processing.

Third, you rotate by radians(1), which is very small. Perhaps you want something like 45, 90 etc. so you can actually notice the rotation.

Thanks a lot amnon! I was making it more difficult that it was, 3d transformations are a pending topic to me.

Defining the vector myself was the solution , sitting in the x-y plane you need to rotate around X axis for looking up and down, and around  Y axis for left and right . Because output from camera().position() and camera().viewDirection() were already in my world coordinates I was expecting the same from upVector(). 

Rotating just one degree is OK, this rotation is done every frame in which the user performs a determined action, allowing him to move a first person camera.