Changeset 25
- Timestamp:
- 11/16/08 14:01:36 (5 years ago)
- Files:
-
- 1 modified
-
branches/pdfcube-0.0.3/src/pdfcube.cc (modified) (29 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pdfcube-0.0.3/src/pdfcube.cc
r24 r25 75 75 // depending on the values in this array 76 76 static bool *page_transition; 77 77 78 ////////////////////////////////////////////////////////////////////////// 78 79 // Forward declarations … … 126 127 perspstepsc = new double[N_FRAMES]; 127 128 } 129 130 // Dtor. 128 131 ~pdfcube() { 129 132 delete[]steps; … … 135 138 } 136 139 140 /// Current page. 137 141 int page() { 138 142 return current_page; 139 143 } 140 144 145 /// Total pages 141 146 int pages() { 142 147 return total_pages; 143 148 } 149 144 150 // Cube Normals 145 151 static GLfloat n[6][3]; 152 146 153 // Cube Faces 147 154 static GLint faces[6][4]; 155 148 156 // Cube vertex (filled in pdfcube->initialize()) 149 157 GLfloat v[8][3]; 158 150 159 // Cube texture mapping 151 160 static GLfloat mapping[6][8]; 161 152 162 // Cube Rotation Animation steps (17 frames) 153 163 // Cube rotation at each frame 154 155 164 GLfloat *steps; 156 // x camera movement165 // ... x camera movement 157 166 double *xsteps; 158 // z camera movement167 // ... z camera movement 159 168 double *zsteps; 169 170 // Other animations 160 171 double *zoomsteps; 161 172 double *perspsteps; 162 173 double *perspstepsc; 163 174 175 // Restart pdf 164 176 void restart(GtkWidget * widget) { 165 177 current_page = 0; … … 167 179 } 168 180 181 // Jump to page 169 182 void go_to(GtkWidget * widget, int page) { 170 183 if (page >= 0 && page < total_pages) { … … 174 187 } 175 188 189 // Jump to section (1..9) 176 190 void section(GtkWidget * widget, int section) { 177 191 #ifndef NDEBUG … … 195 209 } 196 210 211 // OpenGL initialization 197 212 void 198 213 initialize(GtkWidget * widget) { … … 292 307 } 293 308 309 // Redraw scene 294 310 void 295 311 redraw(GtkWidget * widget) { … … 704 720 } 705 721 722 // Prev face of the cube in [0..3] 706 723 int prev_face() { 707 724 if (current_face - 1 < 0) … … 711 728 } 712 729 730 // Next face of the cube in [0..3] 713 731 int next_face() { 714 732 if (current_face + 1 > 3) … … 718 736 } 719 737 738 // Prev document page 720 739 int prev_page() { 721 740 assert(current_page >= 0); … … 726 745 } 727 746 747 // Next document page 728 748 int next_page() { 729 749 assert(current_page < total_pages); … … 742 762 } 743 763 764 // Initialization of animation vectors 744 765 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 749 766 float step_factor = 0.2 * double(N_FRAMES); //this is little buggy 750 767 float step = (step_factor) / (double(N_FRAMES)/2.0); … … 768 785 cout << endl; 769 786 #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 };*/773 787 774 788 float xstep_ratio = 0.4; … … 793 807 cout << endl; 794 808 #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 };*/798 809 799 810 float granular = 0.07; … … 808 819 zsteps[i] = -zsteps[i - N_FRAMES / 2]; 809 820 } 810 // zsteps[N_FRAMES - 1] = 0.0;811 821 812 822 #ifndef NDEBUG … … 817 827 cout << endl; 818 828 #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 };*/822 829 823 830 float zoomstop = 0.38; … … 834 841 cout << endl; 835 842 #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 839 844 float perspstart = 44.00; 840 845 float perspstop = 21.00; … … 850 855 #endif 851 856 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 };*/855 857 float perspcstart = 44.00; 856 858 float perspcstop = 30.00; … … 859 861 } 860 862 #ifndef NDEBUG 861 // cout << "Step perspc " << perspcstep << endl;862 863 cout << "Matrix6 "; 863 864 for (i = 0; i < N_FRAMES; i++) … … 867 868 } 868 869 870 // Go to the previous page 869 871 void 870 872 backward(GtkWidget * widget) { … … 875 877 } 876 878 879 // Reset internal status and updates all textures 877 880 void 878 881 reset(GtkWidget * widget) { … … 894 897 } 895 898 899 // Reset status without updating textures 896 900 void 897 901 quick_reset(GtkWidget * widget) { … … 910 914 previous_animation = ANIM_NONE; 911 915 last_animation = ANIM_NONE; 912 // update_textures(widget);913 916 } 914 917 … … 1017 1020 static const gint tex_height = (gint) (3 * 768 / 2); 1018 1021 1022 // renders the poppler page on a pixmap 1019 1023 void 1020 1024 render_page(GdkPixbuf * pm, int i, gint iWidth, gint iHeight) { … … 1027 1031 } 1028 1032 1029 void buildLists()1030 {1033 void buildLists() 1034 { 1031 1035 int i; 1032 cube_faces=glGenLists(6);1033 1036 cube_faces=glGenLists(6); 1037 1034 1038 for (i = 0; i < 6; i++) { 1035 1039 glNewList(cube_faces+i,GL_COMPILE); 1036 1040 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); 1039 1043 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); 1043 1047 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); 1047 1051 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); 1051 1055 glVertex3fv(&v[faces[i][3]][0]); 1052 1056 glEnd(); 1053 1057 glEndList(); 1054 1058 } 1055 1056 }1059 1060 } 1057 1061 1058 1062 void … … 1089 1093 }; 1090 1094 1095 // cube normals 1091 1096 GLfloat 1092 1097 pdfcube::n[6][3] = { … … 1099 1104 , {0.0, -1.0, 0.0} 1100 1105 }; 1106 //bcube faces 1101 1107 GLint 1102 1108 pdfcube::faces[6][4] = { … … 1109 1115 , {4, 5, 1, 0} 1110 1116 }; 1117 // face mapping 1111 1118 GLfloat 1112 1119 pdfcube::mapping[6][8] = { … … 1125 1132 }; 1126 1133 1134 // the pdf-cube 1127 1135 pdfcube * 1128 1136 pc;

