Moving and rotating ofEasyCam messed up scene navigation?

Hi everybody,

In my scene, I have a Box bbox - which is instantiated from a custom struct -, and an ofEasyCam cam.

    // Set camera to isometric-like perspective view
    cam.rotateDeg(135, cam.getZAxis());
    glm::vec3 center = bbox->getCenter();   // center point of a box
    double radius = 125.0;  // distance between camera and box center
    cam.setPosition(center.x, center.y, center.z + radius);
    cam.rotateAroundDeg(75, cam.getXAxis(), center);
    cam.rotateDeg(75, cam.getXAxis());

I rotate and move the camera so that it creates an orthographic-like view, which totally works! However, the mouse interactions now feel unnatural and weird when dragging the mouse from left to right or vis versa.

When I drag the mouse cursor to right the box gets tilted to the left?

2021-03-18 08_38_49

The small object that you can see at one of the bottom corners of the box is a plane that has the origin (0, 0, 0), a x-axis (1, 0, 0) and a y-axis(0, 1, 0). It represents the origin and direction of the box in the first place, if that makes sense. bbox is defined by a plane a width, height, and depth.

try calling cam.setRelativeYAxis(true); in the setup. That should fix that behavior

1 Like

Ha, amazing, that finally fixed it! Thank you very much, Roy. :slight_smile:

Am I right in the assumption that this sets the world y-axis for the camera to orbit around?
Does “relative” refer to world coordinates, whereas the camera y-axis would be local?

Thanks again! Your reply is much appreciated.

It is a bit more convoluted than that. when not using relative Y axis, it will use a fixed Y axis set by default to 0, 1, 0. You can set this axis with setUpAxis. This was set as the default mode because it allowed the easy cam to behave in a similar way as how several CAD software cameras work.
When relative axis is set to true, the up axis becomes the cameras local y axis, which changes continuously as the camera moves.

1 Like

Hm, that’s interesting, because that’s exactly what I was after, meaning CG or CAD software like viewport behaviour, and which now seems to work with your fix. The default y-axis felt weird to me. I’m using CAD a lot. :wink:

1 Like

I wouldn’t have guessed this with your avatar. :slight_smile:

Really? How so? And you must be a Tool and/or Alex Grey fan? :slight_smile:

Well I love architecture and your image has a lot of curves, thicknesses and lines, plus some angles.

My avatar yes, those two plus any symbolism passed the human part.

I was just being sociable, I guess.

1 Like