Commit 7cd9bfa88e27d283a5878ad1fff9fe607401a34f
Merge branch 'master' of git.stim.ee.uh.edu:codebase/stimlib
Showing
2 changed files
with
151 additions
and
66 deletions
Show diff stats
stim/biomodels/cellset.h
... | ... | @@ -3,6 +3,7 @@ |
3 | 3 | |
4 | 4 | #include <stim/math/vec3.h> |
5 | 5 | #include <vector> |
6 | +#include <list> | |
6 | 7 | #include <unordered_map> |
7 | 8 | #include <fstream> |
8 | 9 | |
... | ... | @@ -129,4 +130,4 @@ public: |
129 | 130 | }; //end class cellset |
130 | 131 | }; //end namespace stim |
131 | 132 | |
132 | -#endif | |
133 | 133 | \ No newline at end of file |
134 | +#endif | ... | ... |
stim/gl/gl_spider.h
... | ... | @@ -68,6 +68,7 @@ class gl_spider // : public virtual gl_texture<T> |
68 | 68 | std::vector<stim::vec3<float> > dV; //A list of all the direction vectors. |
69 | 69 | std::vector<stim::vec3<float> > pV; //A list of all test positions (relative to p) |
70 | 70 | std::vector<float> mV; //A list of all the size vectors. |
71 | + std::vector<float> lV; //A list of all the size vectors. | |
71 | 72 | |
72 | 73 | stim::matrix<float, 4> cT; //current Transformation matrix (tissue)->(texture) |
73 | 74 | GLuint texID; //OpenGL ID for the texture to be traced |
... | ... | @@ -93,6 +94,9 @@ class gl_spider // : public virtual gl_texture<T> |
93 | 94 | GLuint radius_buffID; //framebuffer ID, radius templates |
94 | 95 | GLuint radius_texID; //texture ID, radius templates |
95 | 96 | |
97 | + GLuint length_buffID; //framebuffer ID, radius templates | |
98 | + GLuint length_texID; //texture ID, radius templates | |
99 | + | |
96 | 100 | GLuint cylinder_buffID; //framebuffer ID, cylinder (surrounding fiber) |
97 | 101 | GLuint cylinder_texID; //texture ID, cylinder |
98 | 102 | |
... | ... | @@ -113,6 +117,7 @@ class gl_spider // : public virtual gl_texture<T> |
113 | 117 | std::vector< stim::vec3<float> > cL; //centerline up to the current point |
114 | 118 | std::vector< stim::vec3<float> > cD; //directions up to the current point (debugging) |
115 | 119 | std::vector< float > cM; //radius up to the current point |
120 | + std::vector< float > cLen; //radius up to the current point | |
116 | 121 | |
117 | 122 | stim::glnetwork<float> nt; //network object holding the currently traced centerlines |
118 | 123 | stim::glObj<float> sk; //OBJ file storing the network (identical to above) |
... | ... | @@ -132,6 +137,7 @@ class gl_spider // : public virtual gl_texture<T> |
132 | 137 | stim::cuda::cuda_texture t_dir; //cuda_texture object used as an interface between OpenGL and cuda for direction vectors. |
133 | 138 | stim::cuda::cuda_texture t_pos; //cuda_texture object used as an interface between OpenGL and cuda for position vectors. |
134 | 139 | stim::cuda::cuda_texture t_mag; //cuda_texture object used as an interface between OpenGL and cuda for size vectors. |
140 | + stim::cuda::cuda_texture t_len; //cuda_texture object used as an interface between OpenGL and cuda for size vectors. | |
135 | 141 | |
136 | 142 | |
137 | 143 | #ifdef DEBUG |
... | ... | @@ -222,7 +228,7 @@ class gl_spider // : public virtual gl_texture<T> |
222 | 228 | /// changes the x, y, z size of the spider to minimize the cost |
223 | 229 | /// function. |
224 | 230 | void |
225 | - findOptimalScale() | |
231 | + findOptimalRadius() | |
226 | 232 | { |
227 | 233 | #ifdef TIMING |
228 | 234 | gpuStartTimer(); |
... | ... | @@ -243,6 +249,31 @@ class gl_spider // : public virtual gl_texture<T> |
243 | 249 | setMagnitude(m*mV[best]); //adjust the magnitude. |
244 | 250 | } |
245 | 251 | |
252 | + /// Method for finding the best length for the spider. | |
253 | + /// changes the x, y, z size of the spider to minimize the cost | |
254 | + /// function. | |
255 | + void | |
256 | + findOptimalLength() | |
257 | + { | |
258 | + #ifdef TIMING | |
259 | + gpuStartTimer(); | |
260 | + #endif | |
261 | + setMatrix(); //create the transformation. | |
262 | + glCallList(dList+3); //move the templates to p, d, m. | |
263 | + glFinish(); //flush the drawing pipeline. | |
264 | + #ifdef TIMING | |
265 | + size_time += gpuStopTimer(); | |
266 | + #endif | |
267 | + int best = getCost(t_len.getTexture(), t_len.getAuxArray(), numSamplesMag); //get best cost. | |
268 | + #ifdef DEBUG | |
269 | +// name.str(""); | |
270 | +// name << "Final_Cost_Size_" << iter << "_" << iter_siz << ".bmp"; | |
271 | +// test(t_mag.getTexture(), n_pixels*2.0, numSamplesMag*n_pixels, name.str()); | |
272 | +// iter_siz++; | |
273 | + #endif | |
274 | + setLength(mV[best]); //adjust the magnitude. | |
275 | + } | |
276 | + | |
246 | 277 | |
247 | 278 | |
248 | 279 | |
... | ... | @@ -485,6 +516,48 @@ class gl_spider // : public virtual gl_texture<T> |
485 | 516 | glEndList(); ///finilize the displaylist. |
486 | 517 | } |
487 | 518 | |
519 | + ///@param float delta, How much the rectangles are allowed to expand. | |
520 | + ///Method for populating the buffer with the sampled texture. | |
521 | + ///Objects created are rectangles the with the created sizes. | |
522 | + ///All points are sampled from a texture. | |
523 | + ///Stored in a display list. | |
524 | + ///uses the default m <1,1,0> | |
525 | + void | |
526 | + genLengthVectors(float delta = 0.70) | |
527 | + { | |
528 | + | |
529 | + //Set up the vectors necessary for Rectangle creation. | |
530 | + stim::vec3<float> Y(1.0, 0.0, 0.0); //orthogonal vec. | |
531 | + stim::vec3<float> pos(0.0, 0.0, 0.0); //center of the future rect. | |
532 | + float mag = 1.0; ///size of the rectangle | |
533 | + stim::vec3<float> dir(0.0, 0.0, 1.0); ///normal of the rectangle plane. | |
534 | + stim::vec<float> temp(0.0,0.0,0.0); | |
535 | + | |
536 | + //Set up the variable necessary for vector creation. | |
537 | + float min = 1.0-delta; ///smallest size | |
538 | + float max = 1.0+delta; ///largers size. | |
539 | + float step = (max-min)/(numSamplesMag-1); ///the size variation from one rect to the next. | |
540 | + float factor; | |
541 | + glNewList(dList+3, GL_COMPILE); | |
542 | + for(int i = 0; i < numSamplesMag; i++){ ///for the number of position samples | |
543 | + //Create linear index | |
544 | + factor = (min+step*i)*mag; ///scaling factor | |
545 | + lV.push_back(factor); ///save the size factor for further use. | |
546 | + temp[0] = factor; | |
547 | + temp[1] = mag; | |
548 | + hor = stim::rect<float>(temp, ///generate a rectangle with the new vector as a normal. | |
549 | + pos, dir, | |
550 | + ((Y.cross(d)).cross(d)) | |
551 | + .norm()); | |
552 | + ver = stim::rect<float>(temp, ///generate another rectangle that's perpendicular the first but parallel to the cart vector. | |
553 | + pos, dir, | |
554 | + hor.n()); | |
555 | + UpdateBuffer(0.0, 0.0+i*n_pixels); ///sample the necessary points and put them into a display list. | |
556 | + CHECK_OPENGL_ERROR | |
557 | + } | |
558 | + glEndList(); ///finilize the displaylist. | |
559 | + } | |
560 | + | |
488 | 561 | ///@param float v_x x-coordinate in buffer-space, |
489 | 562 | ///@param float v_y y-coordinate in buffer-space. |
490 | 563 | ///Samples the texture space. |
... | ... | @@ -654,21 +727,21 @@ class gl_spider // : public virtual gl_texture<T> |
654 | 727 | GL_COLOR_ATTACHMENT0, |
655 | 728 | GL_TEXTURE_2D, |
656 | 729 | direction_texID, |
657 | - 0); | |
658 | - glBindFramebuffer(GL_FRAMEBUFFER, direction_buffID); | |
659 | - GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0}; | |
660 | - glDrawBuffers(1, DrawBuffers); | |
661 | - glBindTexture(GL_TEXTURE_2D, direction_texID); | |
662 | - glClearColor(1,1,1,1); | |
663 | - glClear(GL_COLOR_BUFFER_BIT); | |
664 | - glMatrixMode(GL_PROJECTION); | |
730 | + 0); ///Bind the texture to the 0th color attachement of the framebuffer | |
731 | + glBindFramebuffer(GL_FRAMEBUFFER, direction_buffID); ///Bind the buffer again (safety operation). | |
732 | + GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0}; ///Designate the texture to be the drawbuffer of the framebuffer | |
733 | + glDrawBuffers(1, DrawBuffers); ///Set the current drawbuffer to the texture. | |
734 | + glBindTexture(GL_TEXTURE_2D, direction_texID); ///Bind the Texture | |
735 | + glClearColor(1,1,1,1); ///Set clear color to white | |
736 | + glClear(GL_COLOR_BUFFER_BIT); ///Clear the texture | |
737 | + glMatrixMode(GL_PROJECTION); | |
665 | 738 | glLoadIdentity(); |
666 | 739 | glMatrixMode(GL_MODELVIEW); |
667 | - glLoadIdentity(); | |
668 | - glViewport(0,0,2.0*n_pixels, numSamples*n_pixels); | |
740 | + glLoadIdentity(); ///Load identity matrix into the projection and modelview | |
741 | + glViewport(0,0,2.0*n_pixels, numSamples*n_pixels); ///Designate the viewport and orth | |
669 | 742 | gluOrtho2D(0.0,2.0*n_pixels,0.0,numSamples*n_pixels); |
670 | 743 | glEnable(GL_TEXTURE_3D); |
671 | - glBindTexture(GL_TEXTURE_3D, texID); | |
744 | + glBindTexture(GL_TEXTURE_3D, texID); ///Bind the larger 3D texture. | |
672 | 745 | |
673 | 746 | CHECK_OPENGL_ERROR |
674 | 747 | } |
... | ... | @@ -735,12 +808,12 @@ class gl_spider // : public virtual gl_texture<T> |
735 | 808 | getCost(cudaTextureObject_t tObj, float* result, int n) |
736 | 809 | { |
737 | 810 | #ifdef TIMING |
738 | - gpuStartTimer(); | |
811 | + gpuStartTimer(); ///Add timing variables | |
739 | 812 | #endif |
740 | 813 | stim::vec<int> cost = |
741 | 814 | stim::cuda::get_cost(tObj, result, n, 2*n_pixels, n_pixels); ///call the cuda function with the appropriate texture buffer. |
742 | 815 | #ifdef TIMING |
743 | - cost_time += gpuStopTimer(); | |
816 | + cost_time += gpuStopTimer(); | |
744 | 817 | #endif |
745 | 818 | current_cost = cost[1]; ///current cost. |
746 | 819 | return cost[0]; |
... | ... | @@ -761,9 +834,6 @@ class gl_spider // : public virtual gl_texture<T> |
761 | 834 | stim::rect<float> ver; |
762 | 835 | |
763 | 836 | //Timing variables. |
764 | - #ifdef TESTING | |
765 | - std::clock_t start; | |
766 | - #endif | |
767 | 837 | |
768 | 838 | //--------------------------------------------------------------------------// |
769 | 839 | //-----------------------------CONSTRUCTORS---------------------------------// |
... | ... | @@ -845,7 +915,7 @@ class gl_spider // : public virtual gl_texture<T> |
845 | 915 | #endif |
846 | 916 | } |
847 | 917 | |
848 | - ///destructor | |
918 | + ///destructor deletes all the texture and buffer objects. | |
849 | 919 | ~gl_spider |
850 | 920 | (void) |
851 | 921 | { |
... | ... | @@ -856,6 +926,8 @@ class gl_spider // : public virtual gl_texture<T> |
856 | 926 | glDeleteBuffers(1, &position_buffID); |
857 | 927 | glDeleteTextures(1, &radius_texID); |
858 | 928 | glDeleteBuffers(1, &radius_buffID); |
929 | + glDeleteTextures(1, &length_texID); | |
930 | + glDeleteBuffers(1, &length_buffID); | |
859 | 931 | glDeleteTextures(1, &cylinder_texID); |
860 | 932 | glDeleteBuffers(1, &cylinder_buffID); |
861 | 933 | } |
... | ... | @@ -882,7 +954,7 @@ class gl_spider // : public virtual gl_texture<T> |
882 | 954 | iter_dir = 0; |
883 | 955 | iter_siz = 0; |
884 | 956 | #endif |
885 | - stepsize = 10.0; | |
957 | + stepsize = 3.0; | |
886 | 958 | n_pixels = 16.0; |
887 | 959 | |
888 | 960 | srand(100); |
... | ... | @@ -893,6 +965,8 @@ class gl_spider // : public virtual gl_texture<T> |
893 | 965 | CHECK_OPENGL_ERROR |
894 | 966 | GenerateFBO(n_pixels*2, numSamplesMag*n_pixels, radius_texID, radius_buffID); |
895 | 967 | CHECK_OPENGL_ERROR |
968 | + GenerateFBO(n_pixels*2, numSamplesMag*n_pixels, length_texID, length_buffID); | |
969 | + CHECK_OPENGL_ERROR | |
896 | 970 | GenerateFBO(16, 216, cylinder_texID, cylinder_buffID); |
897 | 971 | CHECK_OPENGL_ERROR |
898 | 972 | t_dir.MapCudaTexture(direction_texID, GL_TEXTURE_2D); |
... | ... | @@ -901,8 +975,10 @@ class gl_spider // : public virtual gl_texture<T> |
901 | 975 | t_pos.Alloc(numSamplesPos); |
902 | 976 | t_mag.MapCudaTexture(radius_texID, GL_TEXTURE_2D); |
903 | 977 | t_mag.Alloc(numSamplesMag); |
978 | + t_len.MapCudaTexture(length_texID, GL_TEXTURE_2D); | |
979 | + t_len.Alloc(numSamplesMag); | |
904 | 980 | setMatrix(); |
905 | - dList = glGenLists(3); | |
981 | + dList = glGenLists(4); | |
906 | 982 | glListBase(dList); |
907 | 983 | Bind(direction_texID, direction_buffID, numSamples, n_pixels); |
908 | 984 | genDirectionVectors(5*stim::PI/4); |
... | ... | @@ -913,8 +989,8 @@ class gl_spider // : public virtual gl_texture<T> |
913 | 989 | Bind(radius_texID, radius_buffID, numSamplesMag, n_pixels); |
914 | 990 | genMagnitudeVectors(); |
915 | 991 | Unbind(); |
916 | - Bind(cylinder_texID, cylinder_buffID, 27); | |
917 | -// DrawCylinder(); | |
992 | + Bind(length_texID, length_buffID, numSamplesMag, n_pixels); | |
993 | + genLengthVectors(); | |
918 | 994 | Unbind(); |
919 | 995 | } |
920 | 996 | |
... | ... | @@ -984,12 +1060,20 @@ class gl_spider // : public virtual gl_texture<T> |
984 | 1060 | |
985 | 1061 | |
986 | 1062 | ///@param float mag, size of the sampled region. |
987 | - ///Sets the m vector to the input mag for both templates. | |
1063 | + ///Sets the m value to the input mag for both templates. | |
988 | 1064 | void |
989 | 1065 | setMagnitude(float mag) |
990 | 1066 | { |
991 | 1067 | m = mag; |
992 | 1068 | } |
1069 | + | |
1070 | + ///@param float len, length of the sampled region. | |
1071 | + ///Sets the length value to the input len for both templates. | |
1072 | + void | |
1073 | + setLength(float len) | |
1074 | + { | |
1075 | + length = len; | |
1076 | + } | |
993 | 1077 | |
994 | 1078 | ///@param float x, voxel size in the x direction. |
995 | 1079 | ///@param float y, voxel size in the y direction. |
... | ... | @@ -1038,32 +1122,32 @@ class gl_spider // : public virtual gl_texture<T> |
1038 | 1122 | stim::vec<float> |
1039 | 1123 | getRotation(stim::vec3<float> dir) |
1040 | 1124 | { |
1041 | - stim::vec<float> out(0.0,0.0,0.0,0.0); | |
1042 | - stim::vec3<float> from(0.0,0.0,1.0); | |
1043 | - out[0] = acos(dir.dot(from))*180/stim::PI; | |
1044 | - #ifdef DEBUG | |
1045 | - std::cout << "out is " << out << std::endl; | |
1046 | - std::cout << "when rotating from " << from << " to " << dir << std::endl; | |
1047 | - #endif | |
1048 | - if(out[0] < 0.01){ | |
1125 | + stim::vec<float> out(0.0,0.0,0.0,0.0); ///The 4D rotation matrix for GL rotation | |
1126 | + stim::vec3<float> from(0.0,0.0,1.0); ///Converting from template always involves 0,0,1 as a starting vector | |
1127 | + out[0] = acos(dir.dot(from))*180/stim::PI; ///angle of rotation | |
1128 | + if(out[0] < 1.0){ | |
1049 | 1129 | out[0] = 0.0; |
1050 | 1130 | out[1] = 0.0; |
1051 | 1131 | out[2] = 0.0; |
1052 | 1132 | out[3] = 1.0; |
1053 | - } | |
1054 | - else if(out[0] < -180.0+0.01) | |
1133 | + } ///if we rotate less what one degree don't rotate | |
1134 | + else if(out[0] < -179.0) ///if we rotate more than -179 degrees rotate 180. | |
1055 | 1135 | { |
1056 | 1136 | out[0] = 180.0; |
1057 | 1137 | out[1] = 1.0; |
1058 | 1138 | out[2] = 0.0; |
1059 | 1139 | out[3] = 0.0; |
1060 | - } else { | |
1140 | + } else { ///the rotational axis is the cross fromxdir. | |
1061 | 1141 | stim::vec3<float> temp(0.0, 0.0, 0.0);; |
1062 | 1142 | temp = (from.cross(dir)).norm(); |
1063 | 1143 | out[1] = temp[0]; |
1064 | 1144 | out[2] = temp[1]; |
1065 | 1145 | out[3] = temp[2]; |
1066 | 1146 | } |
1147 | + #ifdef DEBUG | |
1148 | + std::cout << "out is " << out << std::endl; | |
1149 | + std::cout << "when rotating from " << from << " to " << dir << std::endl; | |
1150 | + #endif | |
1067 | 1151 | return out; |
1068 | 1152 | } |
1069 | 1153 | |
... | ... | @@ -1210,13 +1294,13 @@ class gl_spider // : public virtual gl_texture<T> |
1210 | 1294 | void |
1211 | 1295 | setSeeds(std::string file) |
1212 | 1296 | { |
1213 | - std::ifstream myfile(file.c_str()); | |
1297 | + std::ifstream myfile(file.c_str()); ///open a stream | |
1214 | 1298 | string line; |
1215 | 1299 | if(myfile.is_open()) |
1216 | 1300 | { |
1217 | 1301 | while (getline(myfile, line)) |
1218 | 1302 | { |
1219 | - float x, y, z, u, v, w, m; | |
1303 | + float x, y, z, u, v, w, m; ///read the xyz uvw and m coordinates. | |
1220 | 1304 | myfile >> x >> y >> z >> u >> v >> w >> m; |
1221 | 1305 | setSeed(x, y, z); |
1222 | 1306 | setSeedVec(u, v, w); |
... | ... | @@ -1303,7 +1387,7 @@ class gl_spider // : public virtual gl_texture<T> |
1303 | 1387 | findOptimalPosition(); |
1304 | 1388 | Unbind(); |
1305 | 1389 | Bind(radius_texID, radius_buffID, numSamplesMag, n_pixels); |
1306 | - findOptimalScale(); | |
1390 | + findOptimalRadius(); | |
1307 | 1391 | Unbind(); |
1308 | 1392 | CHECK_OPENGL_ERROR |
1309 | 1393 | |
... | ... | @@ -1351,12 +1435,13 @@ class gl_spider // : public virtual gl_texture<T> |
1351 | 1435 | outFile.open("New_Pos_Vectors.txt"); |
1352 | 1436 | outFile << name.str().c_str(); |
1353 | 1437 | } |
1438 | +/* | |
1354 | 1439 | void |
1355 | 1440 | DrawCylinder() |
1356 | 1441 | { |
1357 | 1442 | glNewList(dList+3, GL_COMPILE); |
1358 | 1443 | float z0 = -0.5; float z1 = 0.5; float r0 = 0.5; |
1359 | - float x,y; | |
1444 | + float x,y; | |
1360 | 1445 | float xold = 0.5; float yold = 0.0; |
1361 | 1446 | float step = 360.0/numSamples*32; |
1362 | 1447 | //float step = 360.0/8.0; |
... | ... | @@ -1387,7 +1472,7 @@ class gl_spider // : public virtual gl_texture<T> |
1387 | 1472 | glEnd(); |
1388 | 1473 | glEndList(); |
1389 | 1474 | } |
1390 | - | |
1475 | +*/ | |
1391 | 1476 | ///need to return the cylinder. |
1392 | 1477 | ///SOMETHING MIGHT BE GOING ON HERE IN GENERATE BUFFER. |
1393 | 1478 | void |
... | ... | @@ -1455,7 +1540,7 @@ class gl_spider // : public virtual gl_texture<T> |
1455 | 1540 | // Unbind(); |
1456 | 1541 | //THIS IS EXPERIMENTAL |
1457 | 1542 | Bind(radius_texID, radius_buffID, numSamplesMag, n_pixels); |
1458 | - findOptimalScale(); | |
1543 | + findOptimalRadius(); | |
1459 | 1544 | Unbind(); |
1460 | 1545 | //THIS IS EXPERIMENTAL |
1461 | 1546 | |
... | ... | @@ -1475,31 +1560,30 @@ class gl_spider // : public virtual gl_texture<T> |
1475 | 1560 | gpuStartTimer(); |
1476 | 1561 | #endif |
1477 | 1562 | |
1478 | -// float s = 3.0; | |
1479 | - GLuint selectBuf[2048]; | |
1480 | - GLint hits; | |
1481 | - glSelectBuffer(2048, selectBuf); | |
1482 | - glDisable(GL_CULL_FACE); | |
1483 | - (void) glRenderMode(GL_SELECT); | |
1563 | + GLuint selectBuf[2048]; ///size of the selection buffer in bytes. | |
1564 | + GLint hits; ///hit fibers | |
1565 | + glSelectBuffer(2048, selectBuf); ///bind the selection mode to the selection buffer. | |
1566 | + glDisable(GL_CULL_FACE); ///Disable cullFace | |
1567 | + (void) glRenderMode(GL_SELECT); ///initialize GL select mode. | |
1484 | 1568 | //Init Names stack |
1485 | 1569 | |
1486 | - glInitNames(); | |
1487 | - glPushName(1); | |
1570 | + glInitNames(); ///Initialize the naming array. | |
1571 | + glPushName(1); ///Push a single name to the stack. | |
1488 | 1572 | |
1489 | 1573 | CHECK_OPENGL_ERROR |
1490 | 1574 | //What would that vessel see in front of it. |
1491 | - camSel.setPosition(loc); | |
1492 | - camSel.setFocalDistance(mag/stepsize); | |
1575 | + camSel.setPosition(loc); ///Set the viewing camera | |
1576 | + camSel.setFocalDistance(mag/stepsize); ///Set how far the fiber looks forward. | |
1493 | 1577 | camSel.LookAt((loc[0]+dir[0]*mag/stepsize), |
1494 | 1578 | (loc[1]+dir[1]*mag/stepsize), |
1495 | - (loc[2]+dir[2]*mag/stepsize)); | |
1496 | - ps = camSel.getPosition(); | |
1579 | + (loc[2]+dir[2]*mag/stepsize)); ///Set the look direction | |
1580 | + ps = camSel.getPosition(); ///get all the necessary rotation variable for openGL | |
1497 | 1581 | ups = camSel.getUp(); |
1498 | 1582 | ds = camSel.getLookAt(); |
1499 | - glMatrixMode(GL_PROJECTION); | |
1500 | - glPushMatrix(); | |
1583 | + glMatrixMode(GL_PROJECTION); ///Push the projection matrix. | |
1584 | + glPushMatrix(); ///Reset the current projection matrix | |
1501 | 1585 | glLoadIdentity(); |
1502 | - glOrtho(-mag/stepsize/2.0, mag/stepsize/2.0, -mag/stepsize/2.0, mag/stepsize/2.0, 0.0, mag/stepsize/2.0); | |
1586 | + glOrtho(-mag/stepsize/2.0, mag/stepsize/2.0, -mag/stepsize/2.0, mag/stepsize/2.0, 0.0, mag/stepsize/2.0); ///Finalize the look paramenters | |
1503 | 1587 | glMatrixMode(GL_MODELVIEW); |
1504 | 1588 | glPushMatrix(); |
1505 | 1589 | glLoadIdentity(); |
... | ... | @@ -1508,36 +1592,36 @@ class gl_spider // : public virtual gl_texture<T> |
1508 | 1592 | gluLookAt(ps[0], ps[1], ps[2], |
1509 | 1593 | ds[0], ds[1], ds[2], |
1510 | 1594 | ups[0], ups[1], ups[2]); |
1511 | - | |
1512 | - sk.Render(); | |
1595 | + ///Set the look at distance | |
1596 | + sk.Render(); ///Render the network | |
1513 | 1597 | // nt.Render(); |
1514 | 1598 | |
1515 | 1599 | CHECK_OPENGL_ERROR |
1516 | 1600 | |
1517 | 1601 | |
1518 | - glLoadName((int) sk.numL()); | |
1602 | + glLoadName((int) sk.numL()); ///Load all the names | |
1519 | 1603 | // glLoadName(nt.sizeE()); |
1520 | 1604 | |
1521 | - sk.RenderLine(cL); | |
1605 | + sk.RenderLine(cL); ///Render the current line. | |
1522 | 1606 | // nt.RenderLine(cL); |
1523 | 1607 | |
1524 | 1608 | // glPopName(); |
1525 | - glFlush(); | |
1609 | + glFlush(); ///Flush the buffer | |
1526 | 1610 | |
1527 | 1611 | glMatrixMode(GL_PROJECTION); |
1528 | 1612 | glPopMatrix(); |
1529 | 1613 | glMatrixMode(GL_MODELVIEW); |
1530 | 1614 | CHECK_OPENGL_ERROR |
1531 | - glPopMatrix(); | |
1615 | + glPopMatrix(); ///clear the vis matrices and pop the matrix | |
1532 | 1616 | |
1533 | 1617 | // glEnable(GL_CULL_FACE); |
1534 | - hits = glRenderMode(GL_RENDER); | |
1535 | - int found_hits = processHits(hits, selectBuf); | |
1618 | + hits = glRenderMode(GL_RENDER); ///Check for hits. | |
1619 | + int found_hits = processHits(hits, selectBuf); ///Process the hits. | |
1536 | 1620 | #ifdef TIMING |
1537 | 1621 | hit_time += gpuStopTimer(); |
1538 | 1622 | #endif |
1539 | 1623 | |
1540 | - return found_hits; | |
1624 | + return found_hits; ///return whether we hit something or not. | |
1541 | 1625 | } |
1542 | 1626 | |
1543 | 1627 | //Given a size of the array (hits) and the memory holding it (buffer) |
... | ... | @@ -1545,7 +1629,7 @@ class gl_spider // : public virtual gl_texture<T> |
1545 | 1629 | int |
1546 | 1630 | processHits(GLint hits, GLuint buffer[]) |
1547 | 1631 | { |
1548 | - GLuint *ptr; | |
1632 | + GLuint *ptr; ///pointer to the detection buffer | |
1549 | 1633 | ptr = (GLuint *) buffer; |
1550 | 1634 | ptr++; |
1551 | 1635 | ptr++; //Skip the minimum depth value. | ... | ... |