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

Added Stereographic and Mercator to the interface

parent cdb7b3c7
Loading
Loading
Loading
Loading
+33 −4
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ OpenGLCanvas::OpenGLCanvas(QWidget *parent) :
    center_lambda = 0.f;
    center_phi = 0.f;
    fov_scale_relation = "Naive";
    visualization = "Perspective";
    visualization = "Moebius";
    auto_fov_max=false;

    time_frames = 0;
@@ -439,10 +439,9 @@ void OpenGLCanvas::vertex_transformation(float *positions, int m, int n, float c
            lambda = atan2(x,-z)/CONST_PI_F;
            phi = asin(y)/CONST_PI_2_F;

            if (visualization=="Moebius"){
                u = x/(-z);
                v = y/(-z);

            if (visualization=="Perspective"){
                positions[3*(j+i*n)] = u/extent;
                positions[3*(j+i*n)+1] = v/extent;
                positions[3*(j+i*n)+2] = z;
@@ -460,6 +459,22 @@ void OpenGLCanvas::vertex_transformation(float *positions, int m, int n, float c
                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){
    x = (4.*u)/(u*u+v*v+4.);
    y = (4.*v)/(u*u+v*v+4.);
    z = (u*u+v*v-4.)/(u*u+v*v+4.);
    if (visualization=="Moebius"){
        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;
}

@@ -692,9 +719,11 @@ void OpenGLCanvas::paintGL(){
    // defining transformation parameters (that will be passed to the vertex shader)
    float extent = calculate_extent(fov_rads);
    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=="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);
    glLoadIdentity();
    glOrtho(0.0, 2.0/extent, 0.0, 2.0/scale, 0.0, -2.0/vis_mode);
+11 −1
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@
    <widget class="QComboBox" name="comboBox_2">
     <item>
      <property name="text">
       <string>Perspective</string>
       <string>Moebius</string>
      </property>
     </item>
     <item>
@@ -192,6 +192,16 @@
       <string>Equi-Rectangular</string>
      </property>
     </item>
     <item>
      <property name="text">
       <string>Stereographic</string>
      </property>
     </item>
     <item>
      <property name="text">
       <string>Mercator</string>
      </property>
     </item>
    </widget>
   </item>
   <item row="12" column="1">
+14 −4
Original line number Diff line number Diff line
@@ -57,14 +57,24 @@ void main(void){
    lambda = atan(x,-z)/3.1415;
    phi = asin(y)/1.5708;

    // perspective projection
    // Visualize using specified visualization (remove for timings in the paper! Use only "Perspective" in the paper!)
    if (vis_mode==1.0) {
        u = x/(-z);
        v = y/(-z);

    // 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);
        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) {
        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);