diff --git a/openglcanvas.cpp b/openglcanvas.cpp
index af7298eba66988292feb68e5a8c377b171ca11f4..2288d04e1fe79fae958e94a6449a127a1bc7e172 100644
--- a/openglcanvas.cpp
+++ b/openglcanvas.cpp
@@ -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);
diff --git a/openglcanvas.h b/openglcanvas.h
index e614574031b7152c3caa03d457fe29cd92e1e78e..064ba3b1a65a0255401d5b7acbc7cbed515a5f72 100644
--- a/openglcanvas.h
+++ b/openglcanvas.h
@@ -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;
diff --git a/pano_interface_1.pro b/pano_interface_1.pro
index d229edd9d9f5f6f6e840136c100d2b3f38a13f51..be14f9fff9d9697aef37d8d771556121b52852ec 100644
--- a/pano_interface_1.pro
+++ b/pano_interface_1.pro
@@ -76,3 +76,7 @@ HEADERS += panowindow1.h \
files.h
FORMS += panowindow1.ui
+
+OTHER_FILES += \
+ shaders/fragment_shader.frag \
+ shaders/test_vertex_shader.vert
diff --git a/panowindow1.ui b/panowindow1.ui
index f6880c370006d6ffac897a1355f5b70f0652cf78..aec84ac8e473a00cf9c4c928b66c149b38976d56 100644
--- a/panowindow1.ui
+++ b/panowindow1.ui
@@ -202,6 +202,11 @@
Mercator
+ -
+
+ Zorin-Barr
+
+
-
diff --git a/shaders/test_vertex_shader.vert b/shaders/test_vertex_shader.vert
index 7107ae727b048c2d0bd695451ed4fc55bcbc33dc..b5f5399dce77b8fe3af5eb909a4f85581671cabc 100644
--- a/shaders/test_vertex_shader.vert
+++ b/shaders/test_vertex_shader.vert
@@ -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);