Commit 8e1fbd14 by Luis Penaranda

added the Zorin-Barr transformation

1 parent a5318a15
......@@ -40,6 +40,8 @@ OpenGLCanvas::OpenGLCanvas(QWidget *parent) :
fov_scale_relation = "Naive";
visualization = "Moebius";
auto_fov_max=false;
zblambda=.1f; // Zorin-Barr transformation lambda
zbR=1.f; // Zorin-Barr transformation R
time_frames = 0;
time_timer.setInterval(0);
......@@ -248,6 +250,19 @@ void OpenGLCanvas::read_config_file(){
auto_fov_max=atof(read_line);
fprintf(stderr,"auto_max_fov=%d\n",auto_fov_max);
}
// check for the Zorin-Barr transformation parameters, lambda and R
if(!strncmp(line,"zblambda=",9)){
strcpy(read_line,line+9);
read_line[strlen(line)-10]='\0';
zblambda=atof(read_line);
fprintf(stderr,"zblambda=%f\n",zblambda);
}
if(!strncmp(line,"zbR=",4)){
strcpy(read_line,line+4);
read_line[strlen(line)-5]='\0';
zbR=atof(read_line);
fprintf(stderr,"zbR=%f\n",zbR);
}
}
fclose(rcfile);
}
......@@ -475,6 +490,24 @@ void OpenGLCanvas::vertex_transformation(float *positions, int m, int n, float c
positions[3*(j+i*n)+2] = z;
}
// perspective
if (visualization=="Zorin-Barr"){
// perspective
u = x/(-z);
v = y/(-z);
// apply Z-B transformation to (u,v)
float lambda=.1f;
float R=1.f;
float alpha=atanf(v/u);
float r=hypotf(u,v);
float rhoprime=(lambda*r/R)+(1.f-lambda)*(R*(sqrtf(r*r+1.f)-1.f))/(r*(sqrtf(R*R+1.f)-1.f));
u=rhoprime*cosf(alpha);
v=rhoprime*sinf(alpha);
//
positions[3*(j+i*n)] = u/extent;
positions[3*(j+i*n)+1] = v/extent;
positions[3*(j+i*n)+2] = z;
}
}
}
......@@ -546,6 +579,11 @@ float OpenGLCanvas::calculate_extent(float fov_rads){
// Write now it's olny showing the entire panorama intead of
// the corresponging FOV.
}
if (visualization=="Zorin-Barr"){
// TODO: check whether this is correct
u = x/(-z);
v = y/(-z);
}
return u;
}
......@@ -724,6 +762,7 @@ void OpenGLCanvas::paintGL(){
else if (visualization=="Equi-Rectangular") vis_mode=3.0;
else if (visualization=="Stereographic") vis_mode=4.0;
else if (visualization=="Mercator") vis_mode=5.0;
else if (visualization=="Zorin-Barr") vis_mode=6.0;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 2.0/extent, 0.0, 2.0/scale, 0.0, -2.0/vis_mode);
......
......@@ -71,6 +71,7 @@ private:
QString fov_scale_relation;
QString visualization;
bool auto_fov_max;
float zblambda,zbR; // parameters of the Zorin-Barr transformation
Chronos time_time;
QTimer time_timer;
......
......@@ -76,3 +76,7 @@ HEADERS += panowindow1.h \
files.h
FORMS += panowindow1.ui
OTHER_FILES += \
shaders/fragment_shader.frag \
shaders/test_vertex_shader.vert
......@@ -202,6 +202,11 @@
<string>Mercator</string>
</property>
</item>
<item>
<property name="text">
<string>Zorin-Barr</string>
</property>
</item>
</widget>
</item>
<item row="12" column="1">
......
......@@ -4,6 +4,7 @@ float u, v, x, y, z;
varying float r, theta, s;
float lambda, phi;
float extent, scale, vis_mode, center_lambda, center_phi;
varying float zbu,zbv,zblambda,zbr,zbR,zbalpha,zbrho;
void main(void){
......@@ -58,23 +59,39 @@ void main(void){
phi = asin(y)/1.5708;
// Visualize using specified visualization (remove for timings in the paper! Use only "Perspective" in the paper!)
if (vis_mode==1.0) {
if (vis_mode==1.0) { // Moebius
u = x/(-z);
v = y/(-z);
gl_Position = vec4(u/extent,v/extent,z,1.0);
}
else if (vis_mode==2.0) gl_Position = vec4(0.9*x,0.9*y,z,1.0);
else if (vis_mode==3.0) gl_Position = vec4(lambda,phi,z,1.0);
else if (vis_mode==4.0) {
else if (vis_mode==2.0) // 3D Sphere
gl_Position = vec4(0.9*x,0.9*y,z,1.0);
else if (vis_mode==3.0) // Equi-Rectangular
gl_Position = vec4(lambda,phi,z,1.0);
else if (vis_mode==4.0) { // Stereographic
u = 2.f*x/(-z+1);
v = 2.f*y/(-z+1);
gl_Position = vec4(u/extent,v/extent,z,1.0);
}
else if (vis_mode==5.0) {
else if (vis_mode==5.0) { // Mercator
u = lambda;
v = log((1.0/cos(phi)) + tan(phi));
gl_Position = vec4(u,v,z,1.0);
}
else if (vis_mode==6.0) { // Zorin-Barr
// perspective projection
zbu = x/(-z);
zbv = y/(-z);
// Z-B transformation
zblambda=0.1;
zbR=1.0;
zbalpha=atan(zbv,zbu);
zbr=sqrt(zbu*zbu+zbv*zbv);
zbrho=(zblambda*zbr/zbR)+(1.0-zblambda)*(zbR*(sqrt(zbr*zbr+1.0)-1.0))/(zbr*(sqrt(zbR*zbR+1.0)-1.0));
u=zbrho*cos(zbalpha);
v=zbrho*sin(zbalpha);
gl_Position = vec4(u/extent,v/extent,z,1.0);
}
// gl_Position = vec4(u/2.0,v/2.0,z,1.0);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!