Is there an easy way to create an ofCamera object that matches the default view/projection of openFrameworks?
I see there is a function called ofCamera::setupPerspective(vFlip, fov, nearDist, farDist, lensOffset) but I’m not sure how to grab those settings from the “default camera” in openFrameworks.
Basically, I want to use the default settings most of the time and every now and then trigger an animation where the camera jerkily dollies before coming back to rest at the default settings.
Here’s what I tried so far, I’m trying to recreate what I see in ofGLProgrammableRenderer::setupScreenPerspective():
float fov = 60.0; float eyeY = ofGetHeight()/2; float eyeX = ofGetWidth()/2; float halfFov = PI * fov / 360.0; float theTan = tanf(halfFov); float dist = eyeY / theTan; float aspect = ofGetWidth() / ofGetHeight(); float nearDist = dist / 10.0; float farDist = dist * 10.0; camera_.setupPerspective(true, fov, nearDist, farDist, ofVec2f(0.0, 0.0)); camera_.move(eyeX, eyeY, dist); camera_.setAspectRatio(aspect);
And the results:
And here is the same scene without using an ofCamera:
Did I screw up some of the camera math? Is there a simpler way to copy over the default perspective settings?