Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ACGL
acgl
Commits
481fdd89
Commit
481fdd89
authored
Mar 27, 2013
by
Robert Menzel
Browse files
added setter/getter for bundler-style focal length
parent
28241811
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/ACGL/Scene/GenericCamera.hh
View file @
481fdd89
...
...
@@ -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)
...
...
src/ACGL/Scene/GenericCamera.cc
View file @
481fdd89
...
...
@@ -485,6 +485,16 @@ void GenericCamera::setStateFromString( const std::string &_state )
mViewportSize
=
toUvec2
(
token
[
pos
++
]
);
}
float
GenericCamera
::
getFocalLenght
()
{
return
(
(
float
)
mViewportSize
.
y
)
/
(
2.0
f
*
tan
(
calcDegToRad
(
0.5
f
*
mHorizontalFieldOfView
)
)
);
}
void
GenericCamera
::
setFocalLength
(
float
_focalLengthInPixel
)
{
float
hFoVrad
=
2.0
f
*
atan
(
(
0.5
f
*
mViewportSize
.
y
)
*
(
1.0
f
/
_focalLengthInPixel
)
);
setHorizontalFieldOfView
(
calcRadToDeg
(
hFoVrad
)
);
}
/////////////// TESTS /////////////
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment