Commit 481fdd89 authored by Robert Menzel's avatar Robert Menzel

added setter/getter for bundler-style focal length

parent 28241811
......@@ -117,7 +117,7 @@ class GenericCamera
Eye getEye() const { return mCurrentEye; }
/**
* Set the horizontal field of view of the camera.
* Set the horizontal field of view of the camera in degree.
* vertical FoV will get (implicitly) changed!
* @param _fovh New horizontal field of view of the camera.
*/
......@@ -125,7 +125,7 @@ class GenericCamera
double getHorizontalFieldOfView() const { return mHorizontalFieldOfView; }
/**
* Set the vertical field of view of the camera.
* Set the vertical field of view of the camera in degree.
* Aspect ratio will get changed!
* @param _fovv New vertical field of view of the camera.
*/
......@@ -281,6 +281,17 @@ class GenericCamera
/// Sets all internal state from a string
void setStateFromString( const std::string &_state );
/// The focal length is coupled to the sensor size in real cameras. As this camera does not model a
/// sensor size, the focal length is given in pixels and is in relation to the viewports resolution.
/// This model is also used by bundler.
/// Note that this gives only useful results if the viewports aspect ratio is the same as the
/// projections aspect ratio!
float getFocalLenght();
/// Sets the focal length in pixel relative to the viewport dimension. This will change the FoV.
/// See getFocalLenght() for more information.
void setFocalLength( float _focalLengthInPixel );
private:
/// the Matrix with the camera position/orientation.
/// eyeShift is the half of the eyeDistance (can be 0 if we don't want stereo)
......
......@@ -485,6 +485,16 @@ void GenericCamera::setStateFromString( const std::string &_state )
mViewportSize = toUvec2( token[pos++] );
}
float GenericCamera::getFocalLenght()
{
return ( (float) mViewportSize.y ) / ( 2.0f * tan( calcDegToRad(0.5f * mHorizontalFieldOfView) ) );
}
void GenericCamera::setFocalLength( float _focalLengthInPixel )
{
float hFoVrad = 2.0f * atan( ( 0.5f * mViewportSize.y ) * (1.0f / _focalLengthInPixel ) );
setHorizontalFieldOfView( calcRadToDeg( hFoVrad ) );
}
/////////////// TESTS /////////////
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment