implementação de stereo na biblioteca vgl marcos machado
TRANSCRIPT
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
Parâmetros:pminpmaxwd
view volume
dw
xc
yc
zc
y'
x'
view frustumphysical screen
pminpmax
Controle do paralaxe
P/2
/2
d
P/2
/2
tg (/2 ) = P / 2d
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
tc/2 tc/2
Pmax/2
Pmin/2
Zfar
Zzps
Znear
Escolhe Pmin e Pmax, calcula tc e ZZPS
Pmin
tc
Znear
Zfar
ZZPS
Pmax
Escolhe Pmin e Pmax, calcula tc e ZZPS
tc
Znear
Zfar
ZZPS
Pmin Pmax
tc / Zfar = (Pmin + Pmax) / (Zfar - Znear)
tc = Zfar . (Pmin + Pmax) / (Zfar - Znear)
Escolhe Pmin e Pmax, calcula tc e ZZPS
tc
Znear
Zfar
ZZPS
Pmin Pmax
tc / ZZPS = Pmin / (ZZPS - Znear)
ZZPS = Znear . tc / (tc - Pmin)
tc = Zfar . (Pmin + Pmax) / (Zfar - Znear)
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
tc/2 tc/2
Pmax/2
Pmin/2
Zfar
Zzps
Znear
zpsnearzps
mimc Z
ZZ
Pt
1
Dados Pmin e tc, calcula Pmax
tc/2 tc/2
Pmax/2
Pmin/2
Zfar
Zzps
Znear
mimcfar
nearfar PtZ
ZZP
max
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
} }
zpsnearzps
mimc Z
ZZ
Pt
1
farnearfar
c ZZZ
Pt
max
2
},min{21 ccc ttt
tc
HIT (Horizontal Image Translation)
HITHIT
Em OpenGL, projeção é feita no plano Znear
Znear
tc
Zzps
HIT (Horizontal Image Translation)
Znear
Zzps
Zfar
tc
HIT
HIT (Horizontal Image Translation)
Znear
Zzps
Zfar
tc
HIT
tc
HIT (Horizontal Image Translation)
Znear
Zzps
Zfar
tc
HIT = tc . Znear / Zzps
HIT
tc
ComputeStereo do VGL (4)
m_hit = m_tc * m_znear / zps * m_vmin.z / m_znear;
GetProjection( )
// 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);
// current eye (-1=stereo left, 0=mono, 1=stereo right)
GetModelView( )
...
if (m_curreye != 0)
m.Translate(-m_curreye*m_tc,0.0f,0.0f);
...