Implementação de Stereo na
Biblioteca VGL
Marcos Machado
Métodos de Stereo da Câmera do
VGL
// Set parallax min and max (in degrees)
void SetParallax (float pmin, float pmax);
// Set screen
void SetPhysicalScreen (float w, float d);
// Set zero parallax setting (from 0.0 to 1.0)
void SetZeroParallax (float zps);
ComputeStereo do VGL:
parâmetros
pmin
pmax
Parâmetros:
pmin
pmax
w
d
w
d
physical screen
view volume
y'
yc
zc
xc
x'
view frustum
Controle do paralaxe
/2
P/2
tg (/2 ) = P / 2d
/2
P/2
d
Desktop: d = 60 cm, max = 1,5o
 Pmax  1,57 cm
Sala RV: d = 3 m, max = 1,5o
 Pmax  7,85 cm
ComputeStereo do VGL (1)
P/2 = d * tg (/2 )
float phy_pmin = - m_distance*(float)tan(m_pmin*VGL_PI/360.0f);
float phy_pmax = m_distance*(float)tan(m_pmax*VGL_PI/360.0f);
float pmin = phy_pmin/m_width*(m_vmax.x-m_vmin.x)*m_znear/m_vmin.z;
float pmax = phy_pmax/m_width*(m_vmax.x-m_vmin.x)*m_znear/m_vmin.z;
Escolhe Pmin e Pmax, calcula tc e ZZPS
Pmax/2
Zfar
Zzps
Znear
tc/2
tc/2
Pmin/2
Escolhe Pmin e Pmax, calcula tc e ZZPS
Zfar
ZZP
Pmin
Pma
x
S
Znea
r
tc
Escolhe Pmin e Pmax, calcula tc e ZZPS
Zfar
tc / Zfar = (Pmin + Pmax) / (Zfar - Znear)
ZZP
Pmin
Pma
x
S
Znea
r
tc
tc = Zfar . (Pmin + Pmax) / (Zfar - Znear)
Escolhe Pmin e Pmax, calcula tc e ZZPS
Zfar
tc = Zfar . (Pmin + Pmax) / (Zfar - Znear)
ZZP
Pmin
Pma
x
S
Znea
r
tc / ZZPS = Pmin / (ZZPS - Znear)
tc
ZZPS = Znear . tc / (tc - Pmin)
ComputeStereo do VGL (2)
tc = m_zfar*(pmin+pmax)/(m_zfar-m_znear);
zps = tc*m_znear/(tc-pmin);
Dados Pmin e ZZPS, calcula tc
Pmax/2
Zfar
Pmim
t c1 
Z zps
Z zps  Z near
Zzps
Znear
tc/2
tc/2
Pmin/2
Dados Pmin e tc, calcula Pmax
Pmax/2
Zfar
Pmax 
Z far  Z near
Z far
Zzps
tc  Pmim
Znear
tc/2
tc/2
Pmin/2
ComputeStereo do VGL (3)
if (m_zps>=0.0f) // if explicitly given
{
zps = m_znear + m_zps*(m_zfar-m_znear);
...
tc = (zps*pmin)/(zps-m_znear);
float p = tc*(m_zfar-m_znear)/m_zfar - pmin;
if (p > pmax)
{
// use pmax and find pmin
p = pmax / (zps/m_zfar*(m_zfar-m_znear)/(zps-m_znear) - 1.0f);
tc = (zps*p)/(zps-m_znear);
pmin = tc*(zps-m_znear)/zps; // pmin based on pmax value
} else
{
pmax = p; // pmax based on pmin value
Pmim
t c1 
Z zps
Z zps  Z near
Pmax
t c2 
Z far
Z far  Z near
tc  min{tc1 , tc2 }
HIT (Horizontal Image Translation)

Em OpenGL, projeção é feita no plano Znear
Zzps
Znea
r
HIT
tc
HIT
tc
HIT (Horizontal Image Translation)
Zfar
Zzps
HIT
tc
Znear
HIT (Horizontal Image Translation)
Zfar
tc
HIT
tc
Zzps
Znear
HIT (Horizontal Image Translation)
Zfar
tc
HIT
Znear
HIT = tc . Znear / Zzps
tc
Zzps
ComputeStereo do VGL (4)
m_hit = m_tc * m_znear / zps * m_vmin.z / m_znear;
GetProjection( )
// current eye (-1=stereo left, 0=mono, 1=stereo right)
// compute stereo params
if (!m_updated)
ComputeStereo();
m.Identity();
m.Frustum(
m_vmin.x-m_curreye*m_hit, m_vmax.x-m_curreye*m_hit,
m_vmin.y,m_vmax.y,
m_vmin.z,m_vmax.z);
GetModelView( )
...
if (m_curreye != 0)
m.Translate(-m_curreye*m_tc,0.0f,0.0f);
...
Download

vgl-stereo - PUC-Rio