Commit a5318a15 authored by Leonardo Koller Sacht's avatar Leonardo Koller Sacht

Added Stereographic and Mercator to the interface

parent cdb7b3c7
...@@ -38,7 +38,7 @@ OpenGLCanvas::OpenGLCanvas(QWidget *parent) : ...@@ -38,7 +38,7 @@ OpenGLCanvas::OpenGLCanvas(QWidget *parent) :
center_lambda = 0.f; center_lambda = 0.f;
center_phi = 0.f; center_phi = 0.f;
fov_scale_relation = "Naive"; fov_scale_relation = "Naive";
visualization = "Perspective"; visualization = "Moebius";
auto_fov_max=false; auto_fov_max=false;
time_frames = 0; time_frames = 0;
...@@ -439,10 +439,9 @@ void OpenGLCanvas::vertex_transformation(float *positions, int m, int n, float c ...@@ -439,10 +439,9 @@ void OpenGLCanvas::vertex_transformation(float *positions, int m, int n, float c
lambda = atan2(x,-z)/CONST_PI_F; lambda = atan2(x,-z)/CONST_PI_F;
phi = asin(y)/CONST_PI_2_F; phi = asin(y)/CONST_PI_2_F;
u = x/(-z); if (visualization=="Moebius"){
v = y/(-z); u = x/(-z);
v = y/(-z);
if (visualization=="Perspective"){
positions[3*(j+i*n)] = u/extent; positions[3*(j+i*n)] = u/extent;
positions[3*(j+i*n)+1] = v/extent; positions[3*(j+i*n)+1] = v/extent;
positions[3*(j+i*n)+2] = z; positions[3*(j+i*n)+2] = z;
...@@ -460,6 +459,22 @@ void OpenGLCanvas::vertex_transformation(float *positions, int m, int n, float c ...@@ -460,6 +459,22 @@ void OpenGLCanvas::vertex_transformation(float *positions, int m, int n, float c
positions[3*(j+i*n)+2] = z; positions[3*(j+i*n)+2] = z;
} }
if (visualization=="Stereographic"){
u = 2*x/(-z+1);
v = 2*y/(-z+1);
positions[3*(j+i*n)] = u/extent;
positions[3*(j+i*n)+1] = v/extent;
positions[3*(j+i*n)+2] = z;
}
if (visualization=="Mercator"){
u = lambda;
v = log((1.0/cos(phi)) + tan(phi));
positions[3*(j+i*n)] = u/extent;
positions[3*(j+i*n)+1] = v/extent;
positions[3*(j+i*n)+2] = z;
}
} }
} }
...@@ -517,8 +532,20 @@ float OpenGLCanvas::calculate_extent(float fov_rads){ ...@@ -517,8 +532,20 @@ float OpenGLCanvas::calculate_extent(float fov_rads){
x = (4.*u)/(u*u+v*v+4.); x = (4.*u)/(u*u+v*v+4.);
y = (4.*v)/(u*u+v*v+4.); y = (4.*v)/(u*u+v*v+4.);
z = (u*u+v*v-4.)/(u*u+v*v+4.); z = (u*u+v*v-4.)/(u*u+v*v+4.);
u = x/(-z); if (visualization=="Moebius"){
v = y/(-z); u = x/(-z);
v = y/(-z);
}
else if (visualization=="Stereographic"){
u = 2*x/(-z+1);
v = 2*y/(-z+1);
}
else if (visualization=="Mercator"){
u = fov_rads;
// Warning: this extent calculation is wrong.
// Write now it's olny showing the entire panorama intead of
// the corresponging FOV.
}
return u; return u;
} }
...@@ -692,9 +719,11 @@ void OpenGLCanvas::paintGL(){ ...@@ -692,9 +719,11 @@ void OpenGLCanvas::paintGL(){
// defining transformation parameters (that will be passed to the vertex shader) // defining transformation parameters (that will be passed to the vertex shader)
float extent = calculate_extent(fov_rads); float extent = calculate_extent(fov_rads);
float vis_mode=.0; float vis_mode=.0;
if (visualization=="Perspective") vis_mode=1.0; if (visualization=="Moebius") vis_mode=1.0;
else if (visualization=="3D Sphere") vis_mode=2.0; else if (visualization=="3D Sphere") vis_mode=2.0;
else if (visualization=="Equi-Rectangular") vis_mode=3.0; 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;
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
glOrtho(0.0, 2.0/extent, 0.0, 2.0/scale, 0.0, -2.0/vis_mode); glOrtho(0.0, 2.0/extent, 0.0, 2.0/scale, 0.0, -2.0/vis_mode);
......
...@@ -179,7 +179,7 @@ ...@@ -179,7 +179,7 @@
<widget class="QComboBox" name="comboBox_2"> <widget class="QComboBox" name="comboBox_2">
<item> <item>
<property name="text"> <property name="text">
<string>Perspective</string> <string>Moebius</string>
</property> </property>
</item> </item>
<item> <item>
...@@ -192,6 +192,16 @@ ...@@ -192,6 +192,16 @@
<string>Equi-Rectangular</string> <string>Equi-Rectangular</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Stereographic</string>
</property>
</item>
<item>
<property name="text">
<string>Mercator</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="12" column="1"> <item row="12" column="1">
......
...@@ -57,14 +57,24 @@ void main(void){ ...@@ -57,14 +57,24 @@ void main(void){
lambda = atan(x,-z)/3.1415; lambda = atan(x,-z)/3.1415;
phi = asin(y)/1.5708; phi = asin(y)/1.5708;
// perspective projection
u = x/(-z);
v = y/(-z);
// Visualize using specified visualization (remove for timings in the paper! Use only "Perspective" in the paper!) // Visualize using specified visualization (remove for timings in the paper! Use only "Perspective" in the paper!)
if (vis_mode==1.0) gl_Position = vec4(u/extent,v/extent,z,1.0); if (vis_mode==1.0) {
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==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==3.0) gl_Position = vec4(lambda,phi,z,1.0);
else if (vis_mode==4.0) {
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) {
u = lambda;
v = log((1.0/cos(phi)) + tan(phi));
gl_Position = vec4(u,v,z,1.0);
}
// gl_Position = vec4(u/2.0,v/2.0,z,1.0); // gl_Position = vec4(u/2.0,v/2.0,z,1.0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment