Changeset 25

Show
Ignore:
Timestamp:
11/16/08 14:01:36 (5 years ago)
Author:
mirko
Message:

some cleaning and some comments.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/pdfcube-0.0.3/src/pdfcube.cc

    r24 r25  
    7575// depending on the values in this array 
    7676static bool *page_transition; 
     77 
    7778////////////////////////////////////////////////////////////////////////// 
    7879// Forward declarations 
     
    126127    perspstepsc = new double[N_FRAMES]; 
    127128  } 
     129 
     130  // Dtor. 
    128131  ~pdfcube() { 
    129132    delete[]steps; 
     
    135138  } 
    136139 
     140  /// Current page. 
    137141  int page() { 
    138142    return current_page; 
    139143  } 
    140144 
     145  /// Total pages 
    141146  int pages() { 
    142147    return total_pages; 
    143148  } 
     149 
    144150  // Cube Normals 
    145151  static GLfloat n[6][3]; 
     152 
    146153  // Cube Faces 
    147154  static GLint faces[6][4]; 
     155 
    148156  // Cube vertex (filled in pdfcube->initialize()) 
    149157  GLfloat v[8][3]; 
     158 
    150159  // Cube texture mapping 
    151160  static GLfloat mapping[6][8]; 
     161 
    152162  // Cube Rotation Animation steps (17 frames) 
    153163  // Cube rotation at each frame 
    154  
    155164  GLfloat *steps; 
    156   // x camera movement  
     165  //  ... x camera movement  
    157166  double *xsteps; 
    158   // z camera movement 
     167  //  ... z camera movement 
    159168  double *zsteps; 
     169 
     170  // Other animations 
    160171  double *zoomsteps; 
    161172  double *perspsteps; 
    162173  double *perspstepsc; 
    163174 
     175  // Restart pdf 
    164176  void restart(GtkWidget * widget) { 
    165177    current_page = 0; 
     
    167179  } 
    168180 
     181  // Jump to page 
    169182  void go_to(GtkWidget * widget, int page) { 
    170183    if (page >= 0 && page < total_pages) { 
     
    174187  } 
    175188 
     189  // Jump to section (1..9) 
    176190  void section(GtkWidget * widget, int section) { 
    177191#ifndef NDEBUG 
     
    195209  } 
    196210 
     211  // OpenGL initialization 
    197212  void 
    198213  initialize(GtkWidget * widget) { 
     
    292307  } 
    293308 
     309  // Redraw scene 
    294310  void 
    295311  redraw(GtkWidget * widget) { 
     
    704720  } 
    705721 
     722  // Prev face of the cube in [0..3] 
    706723  int prev_face() { 
    707724    if (current_face - 1 < 0) 
     
    711728  } 
    712729 
     730  // Next face of the cube in [0..3] 
    713731  int next_face() { 
    714732    if (current_face + 1 > 3) 
     
    718736  } 
    719737 
     738  // Prev document page 
    720739  int prev_page() { 
    721740    assert(current_page >= 0); 
     
    726745  } 
    727746 
     747  // Next document page 
    728748  int next_page() { 
    729749    assert(current_page < total_pages); 
     
    742762  } 
    743763 
     764  // Initialization of animation vectors 
    744765  void matrix_setup() { 
    745     /*GLfloat pdfcube::steps[N_FRAMES] =  
    746       {  2.0,   2.5,   3,     4,     5,     6,     8,     10,    
    747       14,   10,   8,    6,    4,    3,    2.5,   2.0, 0.0  };*/ 
    748  
    749766    float step_factor = 0.2 * double(N_FRAMES);        //this is little buggy 
    750767    float step = (step_factor) / (double(N_FRAMES)/2.0); 
     
    768785    cout << endl; 
    769786#endif 
    770     /*double pdfcube::xsteps[N_FRAMES] =  
    771       {  0.01,  0.03,  0.07,  0.12,  0.16,  0.18,  0.20,  0.21,  
    772       0.21, 0.20, 0.18, 0.16, 0.12, 0.07, 0.03, 0.01, 0.00 };*/ 
    773787 
    774788    float xstep_ratio = 0.4; 
     
    793807    cout << endl; 
    794808#endif 
    795     /*double pdfcube::zsteps[N_FRAMES] =  
    796       { -0.01, -0.02, -0.04, -0.05, -0.04, -0.02, -0.02, -0.01,  
    797       0.01, 0.02, 0.02, 0.04, 0.05, 0.04, 0.02, 0.01, 0.00 };*/ 
    798809 
    799810    float granular = 0.07; 
     
    808819      zsteps[i] = -zsteps[i - N_FRAMES / 2]; 
    809820    } 
    810     // zsteps[N_FRAMES - 1] = 0.0; 
    811821 
    812822#ifndef NDEBUG 
     
    817827    cout << endl; 
    818828#endif 
    819     /*double pdfcube::zoomsteps[N_FRAMES] = 
    820       { 0.00, 0.01, 0.02, 0.03, 0.05, 0.07, 0.10, 0.13, 0.17,  
    821       0.21, 0.25, 0.29, 0.32, 0.35, 0.37, 0.38, 0.38 };*/ 
    822829 
    823830    float zoomstop = 0.38; 
     
    834841    cout << endl; 
    835842#endif 
    836     /*double pdfcube::perspsteps[N_FRAMES] = 
    837       { 44.0, 44.0, 44.0, 44.00, 44.00, 43.00, 42.00, 40.00,  
    838       38.00, 36.00, 33.00, 30.00, 27.00, 24.00, 22.00, 21.00, 21.00 };*/ 
     843 
    839844    float perspstart = 44.00; 
    840845    float perspstop = 21.00; 
     
    850855#endif 
    851856 
    852     /*double pdfcube::perspstepsc[N_FRAMES] = 
    853       { 44.0, 44.0, 44.0, 44.00, 44.00, 43.00, 42.00, 40.00,  
    854       38.00, 36.00, 34.00, 32.00, 31.00, 30.00, 30.00, 30.00, 30.00 };*/ 
    855857    float perspcstart = 44.00; 
    856858    float perspcstop = 30.00; 
     
    859861    } 
    860862#ifndef NDEBUG 
    861     // cout << "Step perspc " << perspcstep << endl; 
    862863    cout << "Matrix6 "; 
    863864    for (i = 0; i < N_FRAMES; i++) 
     
    867868  } 
    868869 
     870  // Go to the previous page 
    869871  void 
    870872  backward(GtkWidget * widget) { 
     
    875877  } 
    876878 
     879  // Reset internal status and updates all textures 
    877880  void 
    878881  reset(GtkWidget * widget) { 
     
    894897  } 
    895898 
     899  // Reset status without updating textures 
    896900  void 
    897901  quick_reset(GtkWidget * widget) { 
     
    910914    previous_animation = ANIM_NONE; 
    911915    last_animation = ANIM_NONE; 
    912     //    update_textures(widget); 
    913916  } 
    914917 
     
    10171020  static const gint tex_height = (gint) (3 * 768 / 2); 
    10181021 
     1022  // renders the poppler page on a pixmap 
    10191023  void 
    10201024  render_page(GdkPixbuf * pm, int i, gint iWidth, gint iHeight) { 
     
    10271031  } 
    10281032 
    1029 void buildLists() 
    1030 { 
     1033  void buildLists() 
     1034  { 
    10311035    int i; 
    1032   cube_faces=glGenLists(6); 
    1033  
     1036    cube_faces=glGenLists(6); 
     1037     
    10341038    for (i = 0; i < 6; i++) { 
    10351039      glNewList(cube_faces+i,GL_COMPILE); 
    10361040      glBegin(GL_QUADS); 
    1037      glMultiTexCoord2f(GL_TEXTURE0_ARB,(1.0 - mapping[i][4]) * tex_width, 
    1038                    mapping[i][5] * tex_height); 
     1041      glMultiTexCoord2f(GL_TEXTURE0_ARB,(1.0 - mapping[i][4]) * tex_width, 
     1042                        mapping[i][5] * tex_height); 
    10391043      glVertex3fv(&v[faces[i][0]][0]); 
    1040  
    1041      glMultiTexCoord2f(GL_TEXTURE0_ARB,(1.0 - mapping[i][6]) * tex_width, 
    1042                    mapping[i][7] * tex_height); 
     1044       
     1045      glMultiTexCoord2f(GL_TEXTURE0_ARB,(1.0 - mapping[i][6]) * tex_width, 
     1046                        mapping[i][7] * tex_height); 
    10431047      glVertex3fv(&v[faces[i][1]][0]); 
    1044  
    1045   glMultiTexCoord2f(GL_TEXTURE0_ARB,(1.0 - mapping[i][0]) * tex_width, 
    1046                    mapping[i][1] * tex_height); 
     1048       
     1049      glMultiTexCoord2f(GL_TEXTURE0_ARB,(1.0 - mapping[i][0]) * tex_width, 
     1050                        mapping[i][1] * tex_height); 
    10471051      glVertex3fv(&v[faces[i][2]][0]); 
    1048  
    1049     glMultiTexCoord2f(GL_TEXTURE0_ARB,(1.0 - mapping[i][2]) * tex_width, 
    1050                    mapping[i][3] * tex_height); 
     1052       
     1053      glMultiTexCoord2f(GL_TEXTURE0_ARB,(1.0 - mapping[i][2]) * tex_width, 
     1054                        mapping[i][3] * tex_height); 
    10511055      glVertex3fv(&v[faces[i][3]][0]); 
    10521056      glEnd(); 
    10531057      glEndList(); 
    10541058    } 
    1055    
    1056 } 
     1059     
     1060  } 
    10571061 
    10581062  void 
     
    10891093}; 
    10901094 
     1095// cube normals 
    10911096GLfloat 
    10921097pdfcube::n[6][3] = { 
     
    10991104  , {0.0, -1.0, 0.0} 
    11001105}; 
     1106//bcube faces 
    11011107GLint 
    11021108pdfcube::faces[6][4] = { 
     
    11091115  , {4, 5, 1, 0} 
    11101116}; 
     1117// face mapping 
    11111118GLfloat 
    11121119pdfcube::mapping[6][8] = { 
     
    11251132}; 
    11261133 
     1134// the pdf-cube 
    11271135pdfcube * 
    11281136pc;