PDA

View Full Version : Simulating Lens Shift



André Agenor
11-12-2010, 07:58 AM
Hi,

I need help.
I am making a camera class and wish I could do using the lens shift glFrustum ().
Does anyone know how I do it?

I want add filmOffsetX and FilmOffsetY, for distorting perspective like real view camera

Today I am using the following formula.

Sorry my English.


double fW, fH;
fH = tan( fovy / 360 * M_PI ) * nearPlane;
fW = fH * aspect;


glMatrixMode(GL_PROJECTION);
glLoadIdentity();

switch (projection)
{
case PERSPECTIVE:
{
glFrustum( -fW, fW, -fH, fH, nearPlane, farPlane );
}
break;
case ORTHOGRAPHIC:
{
//glOrtho( );
}
default:
break;
}


void Camera::setFilmOffsetX(double _FilmOffsetX)
{
if (filmOffsetX != _FilmOffsetX)
{
filmOffsetX = _FilmOffsetX;
emit filmOffsetXChanged(_FilmOffsetX);
}
}

void Camera::setFilmOffsetY(double _FilmOffsetY)
{
if (filmOffsetY != _FilmOffsetY)
{
filmOffsetY = _FilmOffsetY;
emit filmOffsetYChanged(_FilmOffsetY);
}
}