Commit 8b30eb84e3bec987dd1da9f5c285598e2a1291c2

Authored by Jiaming Guo
1 parent 86a4e373

add SPACE keyboard to render the transparant T close to GT

Showing 1 changed file with 38 additions and 3 deletions   Show diff stats
@@ -77,6 +77,7 @@ GLuint cmap_tex = 0; //texture name for the color map @@ -77,6 +77,7 @@ GLuint cmap_tex = 0; //texture name for the color map
77 float delta; 77 float delta;
78 float sigma = 3; //default sigma 78 float sigma = 3; //default sigma
79 float radius = 3; //equals to radius 79 float radius = 3; //equals to radius
  80 +int transparancy_fac = 0;
80 81
81 //sets an OpenGL viewport taking up the entire window 82 //sets an OpenGL viewport taking up the entire window
82 void glut_render_single_projection(){ 83 void glut_render_single_projection(){
@@ -149,6 +150,15 @@ void glut_render(void) { @@ -149,6 +150,15 @@ void glut_render(void) {
149 glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map 150 glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map
150 151
151 GT.glCylinder(sigma, radius); //render the GT network 152 GT.glCylinder(sigma, radius); //render the GT network
  153 + if (transparancy_fac == 1) {
  154 + glEnable(GL_BLEND); //enable color blend
  155 + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //set blend function
  156 + glDisable(GL_DEPTH_TEST); //should disable depth
  157 + glColor4f(1.0f, 1.0f, 1.0f, 0.2f);
  158 + T.glCylinder(sigma, radius);
  159 + glDisable(GL_BLEND);
  160 + glEnable(GL_DEPTH_TEST);
  161 + }
152 162
153 glut_render_right_projection(); //set up a projection for the right half of the window 163 glut_render_right_projection(); //set up a projection for the right half of the window
154 glut_render_modelview(); //set up the modelview matrix using camera details 164 glut_render_modelview(); //set up the modelview matrix using camera details
@@ -175,6 +185,15 @@ void glut_render(void) { @@ -175,6 +185,15 @@ void glut_render(void) {
175 glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map 185 glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map
176 186
177 _GT.glCylinder(sigma, radius); //render the GT network 187 _GT.glCylinder(sigma, radius); //render the GT network
  188 + if (transparancy_fac == 1) {
  189 + glEnable(GL_BLEND); //enable color blend
  190 + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //set blend function
  191 + glDisable(GL_DEPTH_TEST); //should disable depth
  192 + glColor4f(1.0f, 1.0f, 1.0f, 0.2f);
  193 + _T.glCylinder(sigma, radius);
  194 + glDisable(GL_BLEND);
  195 + glEnable(GL_DEPTH_TEST);
  196 + }
178 197
179 glut_render_right_projection(); //set up a projection for the right half of the window 198 glut_render_right_projection(); //set up a projection for the right half of the window
180 glut_render_modelview(); //set up the modelview matrix using camera details 199 glut_render_modelview(); //set up the modelview matrix using camera details
@@ -186,13 +205,21 @@ void glut_render(void) { @@ -186,13 +205,21 @@ void glut_render(void) {
186 glut_render_left_projection(); //set up a projection for the left half of the window 205 glut_render_left_projection(); //set up a projection for the left half of the window
187 glut_render_modelview(); //set up the modelview matrix using camera details 206 glut_render_modelview(); //set up the modelview matrix using camera details
188 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen 207 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen
189 -  
190 - //_GT.glRandColorCenterlineGT(dlist1, _gt_t, colormap); 208 +
191 _GT.glRandColorCylinder1(dlist1, _gt_t, colormap, sigma, radius); 209 _GT.glRandColorCylinder1(dlist1, _gt_t, colormap, sigma, radius);
  210 + if (transparancy_fac == 1) {
  211 + glEnable(GL_BLEND); //enable color blend
  212 + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //set blend function
  213 + glDisable(GL_DEPTH_TEST); //should disable depth
  214 + glColor4f(1.0f, 1.0f, 1.0f, 0.2f);
  215 + _T.glRandColorCylinder2(dlist2, _t_gt, colormap, sigma, radius);
  216 + glDisable(GL_BLEND);
  217 + glEnable(GL_DEPTH_TEST);
  218 + }
192 219
193 glut_render_right_projection(); //set up a projection for the right half of the window 220 glut_render_right_projection(); //set up a projection for the right half of the window
194 glut_render_modelview(); //set up the modelview matrix using camera details 221 glut_render_modelview(); //set up the modelview matrix using camera details
195 - //_T.glRandColorCenterlineT(dlist2, _t_gt, colormap); 222 +
196 _T.glRandColorCylinder2(dlist2, _t_gt, colormap, sigma, radius); 223 _T.glRandColorCylinder2(dlist2, _t_gt, colormap, sigma, radius);
197 sigma = radius; //set sigma equal to radius 224 sigma = radius; //set sigma equal to radius
198 } 225 }
@@ -362,6 +389,14 @@ void glut_keyboard(unsigned char key, int x, int y){ @@ -362,6 +389,14 @@ void glut_keyboard(unsigned char key, int x, int y){
362 if (radius < 0.001f) 389 if (radius < 0.001f)
363 radius = 0.2; 390 radius = 0.2;
364 break; 391 break;
  392 +
  393 + // render a transparant T very close to GT
  394 + case 32: // if keyboard 'SPACE' is pressed, then change the transparancy_fac
  395 + if (compareMode && !mappingMode && !transparancy_fac)
  396 + transparancy_fac = 1;
  397 + else
  398 + transparancy_fac = 0;
  399 + break;
365 400
366 // close window and exit application 401 // close window and exit application
367 case 27: // if keyboard 'ESC' is pressed, then exit 402 case 27: // if keyboard 'ESC' is pressed, then exit