Commit 2aeab3e5 authored by Luis Penaranda's avatar Luis Penaranda
Browse files

Show in the extended interface the Pannini method.

parent 5653a6a6
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -19,17 +19,24 @@ To build in GNU/Linux and Mac, simply run qmake and make. In Windows, it
would be easier to go through QtCreator (of course, you can also use
QtCreator on GNU/Linux and Mac).

By default, the interface lets the user choose, beyond our method, between
common projection methods. The compilation flag PANO_EXTENDED_CONTROLS can
be added to show controls for other state-of-the-art projection methods.

To configure, you can set in the file ~/.panorc the following options.
        shader_dir=<path to directory containing the shader files>
        image_file=<full path to the desired input file>
        image_dir=<path to directory containing the input files>
        fov=<starting value of fov, in degrees>
        max_fov=<starting value of max_fov, in degrees>
If the program is compiled with the PANO_EXTENDED_CONTROLS flag, these
options are also available.
        pd=<Pannini d parameter>
        zblambda=<Zorin-Barr lambda parameter>
        zbR=<Zorin-Barr R parameter>
Lines in the file must start with option names, and no spaces should go
between option names, equal signs and values. If no shader path is set, the
default is ./shaders/. If no input file is set, or the file is missing, a
file chooser will be shown at startup. The default value of max_fov and fov
are 60 degrees. zblambda and zbR are specified in floating-point, following
machine locales.
are 60 degrees. pd, zblambda and zbR are specified in floating-point,
following machine locales.
+44 −2
Original line number Diff line number Diff line
@@ -96,6 +96,11 @@
          <string>Mercator</string>
         </property>
        </item>
        <item>
         <property name="text">
          <string>Pannini</string>
         </property>
        </item>
        <item>
         <property name="text">
          <string>Zorin-Barr</string>
@@ -154,6 +159,9 @@
    </item>
    <item>
     <layout class="QFormLayout" name="formLayout">
      <property name="fieldGrowthPolicy">
       <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
      </property>
      <item row="0" column="0">
       <widget class="QSlider" name="changezblambda">
        <property name="sizePolicy">
@@ -180,7 +188,7 @@
       </widget>
      </item>
      <item row="0" column="1">
       <widget class="QLabel" name="label_2">
       <widget class="QLabel" name="label_lambda">
        <property name="text">
         <string>lambda</string>
        </property>
@@ -212,12 +220,29 @@
       </widget>
      </item>
      <item row="1" column="1">
       <widget class="QLabel" name="label_4">
       <widget class="QLabel" name="label_R">
        <property name="text">
         <string>R</string>
        </property>
       </widget>
      </item>
      <item row="2" column="0">
       <widget class="QSlider" name="changepd">
        <property name="maximum">
         <number>400</number>
        </property>
        <property name="orientation">
         <enum>Qt::Horizontal</enum>
        </property>
       </widget>
      </item>
      <item row="2" column="1">
       <widget class="QLabel" name="label_d">
        <property name="text">
         <string>d</string>
        </property>
       </widget>
      </item>
     </layout>
    </item>
    <item>
@@ -381,6 +406,7 @@
    <slot>shrinkallbutton(bool)</slot>
    <slot>change_zb_lambda(int)</slot>
    <slot>change_zb_R(int)</slot>
    <slot>change_p_d(int)</slot>
   </slots>
  </customwidget>
 </customwidgets>
@@ -658,5 +684,21 @@
    </hint>
   </hints>
  </connection>
  <connection>
   <sender>changepd</sender>
   <signal>sliderMoved(int)</signal>
   <receiver>GLCanvas</receiver>
   <slot>change_p_d(int)</slot>
   <hints>
    <hint type="sourcelabel">
     <x>1166</x>
     <y>209</y>
    </hint>
    <hint type="destinationlabel">
     <x>563</x>
     <y>345</y>
    </hint>
   </hints>
  </connection>
 </connections>
</ui>
+60 −14
Original line number Diff line number Diff line
@@ -28,14 +28,17 @@
//#define CONST_PI_F      (0x1.921fb6p+1f)
//#define CONST_PI_2_F    (0x1.921fb6p+0f)

#ifdef PANO_EXTENDED_CONTROLS
// These definitions specify which attributes should be used to store some
// parameters passed to the vertex shader. Nvidia hardware
// only leaves attributes 1 and 7 unreserved; attributes 8 to 15 are
// reserved for textures.
// TODO: we use attributes 14 and 15, which work for Nvidia; we need to
// test with other hardware.
#define PD_ATTR 13
#define ZBL_ATTR 14
#define ZBR_ATTR 15
#endif // PANO_EXTENDED_CONTROLS

OpenGLCanvas::OpenGLCanvas(QWidget *parent) :
    QGLWidget(parent)
@@ -50,8 +53,11 @@ OpenGLCanvas::OpenGLCanvas(QWidget *parent) :
    visualization = "Moebius";
    auto_fov_max=false;
    shrink_for_all=false;
#ifdef PANO_EXTENDED_CONTROLS
    pd=0.f; // Pannini projection d
    zblambda=.1f; // Zorin-Barr transformation lambda
    zbR=1.f; // Zorin-Barr transformation R
#endif // PANO_EXTENDED_CONTROLS

    time_frames = 0;
    time_timer.setInterval(0);
@@ -105,6 +111,14 @@ void OpenGLCanvas::change_fov_max(int new_fov_max){
    updateGL();
}

#ifdef PANO_EXTENDED_CONTROLS
void OpenGLCanvas::change_p_d(int new_p_d){
    pd=(float)new_p_d/10;
    fprintf(stderr,"p_d=%f\n",pd);
    glVertexAttrib1f(PD_ATTR,pd);
    updateGL();
}

void OpenGLCanvas::change_zb_lambda(int new_zb_lambda){
    zblambda=(float)new_zb_lambda/1000;
    fprintf(stderr,"zb_lambda=%f\n",zblambda);
@@ -118,6 +132,7 @@ void OpenGLCanvas::change_zb_R(int new_zb_R){
    glVertexAttrib1f(ZBR_ATTR,zbR);
    updateGL();
}
#endif // PANO_EXTENDED_CONTROLS

//void OpenGLCanvas::change_scale(double s){

@@ -244,6 +259,14 @@ void OpenGLCanvas::read_config_file(){
                auto_fov_max=atof(read_line);
                fprintf(stderr,"auto_max_fov=%d\n",auto_fov_max);
            }
#ifdef PANO_EXTENDED_CONTROLS
            // check for the Pannini parameter, d
            if(!strncmp(line,"pd=",3)){
                strcpy(read_line,line+3);
                read_line[strlen(line)-4]='\0';
                pd=atof(read_line);
                fprintf(stderr,"pd=%f\n",pd);
            }
            // check for the Zorin-Barr transformation parameters, lambda and R
            if(!strncmp(line,"zblambda=",9)){
                strcpy(read_line,line+9);
@@ -257,6 +280,7 @@ void OpenGLCanvas::read_config_file(){
                zbR=atof(read_line);
                fprintf(stderr,"zbR=%f\n",zbR);
            }
#endif // PANO_EXTENDED_CONTROLS
        }
        fclose(rcfile);
    }
@@ -480,6 +504,21 @@ void OpenGLCanvas::vertex_transformation(float *positions, int m, int n, float c
                positions[3*(j+i*n)+1] = v/extent;
                positions[3*(j+i*n)+2] = z;
            }
            else if (visualization=="Orthographic"){
                u=x;
                v=y;
                positions[3*(j+i*n)]=x/extent;
                positions[3*(j+i*n)+1]=y/extent;
                positions[3*(j+i*n)+2]=z;
            }
#ifdef PANO_EXTENDED_CONTROLS
            else if (visualization=="Pannini"){
                u = 2*x/(-z+pd);
                v = 2*y/(-z+pd);
                positions[3*(j+i*n)] = u/extent;
                positions[3*(j+i*n)+1] = v/extent;
                positions[3*(j+i*n)+2] = z;
            }
            else if (visualization=="Zorin-Barr"){
                // perspective
                u = x/(-z);
@@ -497,13 +536,7 @@ void OpenGLCanvas::vertex_transformation(float *positions, int m, int n, float c
                positions[3*(j+i*n)+1] = v/extent;
                positions[3*(j+i*n)+2] = z;
            }
            else if (visualization=="Orthographic"){
                u=x;
                v=y;
                positions[3*(j+i*n)]=x/extent;
                positions[3*(j+i*n)+1]=y/extent;
                positions[3*(j+i*n)+2]=z;
            }
#endif // PANO_EXTENDED_CONTROLS
        }
    }
}
@@ -573,11 +606,6 @@ float OpenGLCanvas::calculate_extent(float fov_rads){
        // Write now it's olny showing the entire panorama intead of
        // the corresponging FOV.
    }
    else if (visualization=="Zorin-Barr"){
        // TODO: check whether this is correct
        u=x/(-z);
        v=y/(-z);
    }
    else if (visualization=="Orthographic"){
        if(z<0.f){
            u=x;
@@ -586,6 +614,17 @@ float OpenGLCanvas::calculate_extent(float fov_rads){
            u=v=1.f;
        }
    }
#ifdef PANO_EXTENDED_CONTROLS
    else if (visualization=="Pannini"){
        u=2.f*x/(pd-z);
        v=2.f*y/(pd-z);
    }
    else if (visualization=="Zorin-Barr"){
        // TODO: check whether this is correct
        u=x/(-z);
        v=y/(-z);
    }
#endif // PANO_EXTENDED_CONTROLS
    return u;
}

@@ -739,11 +778,15 @@ void OpenGLCanvas::setShaders() {

    GLuint p = glCreateProgram();

    // Bind attributes zblambda and zbR to the vertex shader.
#ifdef PANO_EXTENDED_CONTROLS
    // Bind attributes pd, zblambda and zbR to the vertex shader.
    glVertexAttrib1f(PD_ATTR,pd);
    glBindAttribLocation(p,PD_ATTR,"pd");
    glVertexAttrib1f(ZBL_ATTR,zblambda);
    glBindAttribLocation(p,ZBL_ATTR,"zblambda");
    glVertexAttrib1f(ZBR_ATTR,zbR);
    glBindAttribLocation(p,ZBR_ATTR,"zbR");
#endif // PANO_EXTENDED_CONTROLS

    glAttachShader(p,v);
    glAttachShader(p,f);
@@ -796,9 +839,12 @@ void OpenGLCanvas::paintGL(){
    else if (visualization=="3D Sphere") vis_mode=2.f;
    else if (visualization=="Equi-Rectangular") vis_mode=3.f;
    else if (visualization=="Stereographic") vis_mode=4.f;
    else if (visualization=="Orthographic") vis_mode=4.5f;
    else if (visualization=="Mercator") vis_mode=5.f;
    else if (visualization=="Orthographic") vis_mode=4.5f;
#ifdef PANO_EXTENDED_CONTROLS
    else if (visualization=="Pannini") vis_mode=4.25f;
    else if (visualization=="Zorin-Barr") vis_mode=6.f;
#endif // PANO_EXTENDED_CONTROLS
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.0, 2.0/extent, 0.0, 2.0/scale, 0.0, -2.0/vis_mode);
+6 −0
Original line number Diff line number Diff line
@@ -53,8 +53,11 @@ public slots:
    void change_fov(double f);
    void change_fov(int new_fov);
    void change_fov_max(int new_fov_max);
#ifdef PANO_EXTENDED_CONTROLS
    void change_p_d(int new_p_d);
    void change_zb_lambda(int new_zb_lambda);
    void change_zb_R(int new_zb_R);
#endif // PANO_EXTENDED_CONTROLS
//    void change_scale(double s);
    void change_center_lambda(double lambda);
    void change_center_phi(double phi);
@@ -76,7 +79,10 @@ private:
    QString visualization;
    bool auto_fov_max;
    bool shrink_for_all;
#ifdef PANO_EXTENDED_CONTROLS
    float pd; // parameter of the Pannini projection
    float zblambda,zbR; // parameters of the Zorin-Barr transformation
#endif // PANO_EXTENDED_CONTROLS

    Chronos time_time;
    QTimer time_timer;
+8 −3
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ float u, v, x, y, z;
varying float r, theta, s;
float lambda, phi;
float extent, scale, vis_mode, center_lambda, center_phi;
attribute float zblambda,zbR;
attribute float zblambda,zbR,pd;

void main(void){

@@ -71,8 +71,13 @@ void main(void){
    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.0*x/(-z+1.0);
        v = 2.0*y/(-z+1.0);
        u = 2.0*x/(1.0-z);
        v = 2.0*y/(1.0-z);
        gl_Position = vec4(u/extent,v/extent,z,1.0);
    }
    else if (vis_mode==4.25) { // Pannini
        u = 2.0*x/(pd-z);
        v = 2.0*y/(pd-z);
        gl_Position = vec4(u/extent,v/extent,z,1.0);
    }
    else if (vis_mode==4.5){ // Orthographic