- Timestamp:
- May 5, 2006, 12:04:13 PM (18 years ago)
- Location:
- trunk/gui/vizservers/nanovis
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/vizservers/nanovis/PlaneRenderer.cpp
r431 r432 20 20 g_context(_context), 21 21 render_width(_width), 22 render_height(_height) 22 render_height(_height), 23 active_plane(-1) 23 24 { 24 25 plane.clear(); … … 72 73 //glColor3f(1.,1.,1.); //MUST HAVE THIS LINE!!! 73 74 75 //if no active plane 76 if(active_plane == -1) 77 return; 78 74 79 activate_shader(active_plane); 75 80 glBegin(GL_QUADS); … … 104 109 105 110 void PlaneRenderer::set_active_plane(int index) { active_plane = index; } 111 void PlaneRenderer::set_screen_size(int w, int h) { render_width = w; render_height = h;} 106 112 -
trunk/gui/vizservers/nanovis/PlaneRenderer.h
r431 r432 64 64 //plane is added. 65 65 void set_active_plane(int index); //set the active plane to be rendered 66 void set_screen_size(int w, int h); //change the rendering size 66 67 void render(); 67 68 }; -
trunk/gui/vizservers/nanovis/Texture2D.cpp
r431 r432 132 132 fprintf(stderr, "max texture units: %d.\n", max); 133 133 } 134 -
trunk/gui/vizservers/nanovis/Texture2D.h
r431 r432 36 36 void activate(); 37 37 void deactivate(); 38 void enable(); 39 void disable(); 38 40 GLuint initialize(float* data); 39 41 static void check_max_size(); -
trunk/gui/vizservers/nanovis/VolumeRenderer.cpp
r431 r432 168 168 float z_step = fabs(zNear-zFar)/n_slices; 169 169 int n_actual_slices = (int)(fabs(zNear-zFar)/z_step + 1); 170 171 //if no cloud 172 //n_actual_slices = 0; 173 170 174 actual_slices[cur_vol] = n_actual_slices; 171 175 polys[cur_vol] = new ConvexPolygon*[n_actual_slices]; 176 177 //if no cloud 178 //polys[cur_vol] = NULL; 172 179 173 180 float slice_z; … … 259 266 260 267 int counter = 0; 268 261 269 //transform slices and store them 262 270 for (int i=0; i<n_actual_slices; i++){ … … 291 299 total_rendered_slices++; 292 300 } 301 293 302 } //iterate all volumes 294 303 //fprintf(stderr, "total slices: %d\n", total_rendered_slices); … … 705 714 void VolumeRenderer::switch_volume_mode() { volume_mode = (!volume_mode); } 706 715 716 void VolumeRenderer::enable_volume(int index){ 717 volume[index]->enable(); 718 } 719 720 void VolumeRenderer::disable_volume(int index){ 721 volume[index]->disable(); 722 } -
trunk/gui/vizservers/nanovis/VolumeRenderer.h
r423 r432 86 86 void switch_slice_mode(); //switch_cutplane_mode 87 87 void switch_volume_mode(); 88 void enable_volume(int index); //enable a volume 89 void disable_volume(int index); //disable a volume 88 90 }; 89 91 -
trunk/gui/vizservers/nanovis/nanovis.cpp
r431 r432 129 129 static int OutlineCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[])); 130 130 static int RefreshCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[])); 131 static int Switch2D3DCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[])); 132 static int PlaneNewCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[])); 133 static int PlaneLinkCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[])); 134 static int PlaneEnableCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[])); 131 135 132 136 static int DecodeAxis _ANSI_ARGS_((Tcl_Interp *interp, char *str, int *valPtr)); … … 516 520 } 517 521 522 //Enable a volume. 523 //Can enable a volume that is not yet added to the volume renderer. 524 //But it won't be rendered until it's added to the volume renderer using VolumeLinkCmd 525 //volume_index: the index maintained in the volume renderer. 518 526 static int 519 527 VolumeEnableCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]) 520 528 { 521 fprintf(stderr, " link volumecommand\n");529 fprintf(stderr, "enabled a volume to render command\n"); 522 530 523 531 double volume_index, mode; … … 525 533 if (argc != 3) { 526 534 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 527 " volume_index tf_index\"", (char*)NULL);535 " volume_index mode \"", (char*)NULL); 528 536 return TCL_ERROR; 529 537 } … … 536 544 537 545 if(mode==0) 538 vol ume[(int)volume_index]->disable();546 vol_render->disable_volume((int)volume_index); 539 547 else 540 vol ume[(int)volume_index]->enable();548 vol_render->enable_volume((int)volume_index); 541 549 542 550 return TCL_OK; … … 617 625 return TCL_OK; 618 626 } 627 628 629 //Switch: 630 //arg[1] = 0 : 3D rendering 631 //arg[1] !=0 : 2D rendering 632 static int 633 Switch2D3DCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]) 634 { 635 fprintf(stderr, "switch 2D 3D rendering modes cmd\n"); 636 637 double mode; 638 639 if (argc != 2) { 640 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 641 " mode\"", (char*)NULL); 642 return TCL_ERROR; 643 } 644 if (Tcl_GetDouble(interp, argv[1], &mode) != TCL_OK) { 645 return TCL_ERROR; 646 } 647 648 if(mode==0) 649 volume_mode = true; 650 else 651 volume_mode = false; 652 653 return TCL_OK; 654 } 655 656 657 static int 658 PlaneNewCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[])){ 659 fprintf(stderr, "load plane for 2D visualization command\n"); 660 661 double index, w, h; 662 663 if (argc != 4) { 664 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 665 " plane_index w h \"", (char*)NULL); 666 return TCL_ERROR; 667 } 668 if (Tcl_GetDouble(interp, argv[1], &index) != TCL_OK) { 669 return TCL_ERROR; 670 } 671 if (Tcl_GetDouble(interp, argv[2], &w) != TCL_OK) { 672 return TCL_ERROR; 673 } 674 if (Tcl_GetDouble(interp, argv[3], &h) != TCL_OK) { 675 return TCL_ERROR; 676 } 677 678 //Now read w*h*4 bytes. The server expects the plane to be a stream of floats 679 char* tmp = new char[int(w*h*sizeof(float))]; 680 bzero(tmp, w*h*4); 681 int status = read(0, tmp, w*h*sizeof(float)); 682 if (status <= 0){ 683 exit(0); 684 } 685 686 plane[(int)index] = new Texture2D(w, h, GL_FLOAT, GL_LINEAR, 1, (float*)tmp); 687 688 delete[] tmp; 689 return TCL_OK; 690 } 691 692 693 static 694 int PlaneLinkCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[])){ 695 fprintf(stderr, "link the plane to the 2D renderer command\n"); 696 697 double plane_index, tf_index; 698 699 if (argc != 3) { 700 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 701 " plane_index tf_index \"", (char*)NULL); 702 return TCL_ERROR; 703 } 704 if (Tcl_GetDouble(interp, argv[1], &plane_index) != TCL_OK) { 705 return TCL_ERROR; 706 } 707 if (Tcl_GetDouble(interp, argv[2], &tf_index) != TCL_OK) { 708 return TCL_ERROR; 709 } 710 711 plane_render->add_plane(plane[(int)plane_index], tf[(int)tf_index]); 712 713 return TCL_OK; 714 } 715 716 717 //Enable a 2D plane for render 718 //The plane_index is the index mantained in the 2D plane renderer 719 static 720 int PlaneEnableCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[])){ 721 fprintf(stderr, "enable a plane so the 2D renderer can render it command\n"); 722 723 double plane_index, mode; 724 725 if (argc != 3) { 726 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 727 " plane_index mode \"", (char*)NULL); 728 return TCL_ERROR; 729 } 730 if (Tcl_GetDouble(interp, argv[1], &plane_index) != TCL_OK) { 731 return TCL_ERROR; 732 } 733 if (Tcl_GetDouble(interp, argv[2], &mode) != TCL_OK) { 734 return TCL_ERROR; 735 } 736 737 if(mode==0) 738 plane_render->set_active_plane(-1); 739 else 740 plane_render->set_active_plane(plane_index); 741 742 return TCL_OK; 743 } 744 745 619 746 620 747 //report errors related to CG shaders … … 1176 1303 screen_buffer = 0; 1177 1304 } 1178 screen_buffer = new unsigned char[ 5*win_width*win_height];1305 screen_buffer = new unsigned char[4*win_width*win_height]; 1179 1306 assert(screen_buffer!=0); 1180 1307 … … 1190 1317 //change the camera setting 1191 1318 cam->set_screen_size(win_width, win_height); 1319 plane_render->set_screen_size(win_width, win_height); 1192 1320 1193 1321 //Reinitialize final fbo for final display … … 1349 1477 screen_buffer = 0; 1350 1478 } 1351 screen_buffer = new unsigned char[ 5*win_width*win_height];1479 screen_buffer = new unsigned char[4*win_width*win_height]; 1352 1480 assert(screen_buffer!=0); 1353 1481 … … 1473 1601 1474 1602 //debug: set magic number 1475 memset(screen_buffer, 253, 5*win_width*win_height);1476 1477 glReadPixels(0, 0, win_width, win_height, GL_RGBA, GL_UNSIGNED_BYTE, screen_buffer);1478 //glReadPixels(0, 0, win_width, win_height, GL_RGB, GL_UNSIGNED_BYTE, screen_buffer);1603 //memset(screen_buffer, 253, 5*win_width*win_height); 1604 //glReadPixels(0, 0, win_width, win_height, GL_RGBA, GL_UNSIGNED_BYTE, screen_buffer); 1605 1606 glReadPixels(0, 0, win_width, win_height, GL_RGB, GL_UNSIGNED_BYTE, screen_buffer); 1479 1607 assert(glGetError()==0); 1480 1608 1609 /* 1610 //debug: check from the back of screen_buffer to see how far ReadPixel went 1481 1611 fprintf(stderr, "%d %d:", win_width, win_height); 1482 1612 for(int i=5*win_width*win_height-1; i>=0; i--){ … … 1484 1614 fprintf(stderr, "%d\n", i); 1485 1615 i=0; 1486 //fprintf(stderr, "%d ", screen_buffer[i]);1487 1488 }1616 } 1617 } 1618 */ 1489 1619 1490 1620 /* … … 2029 2159 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen 2030 2160 2031 if( 2161 if(volume_mode){ //3D rendering mode 2032 2162 glEnable(GL_TEXTURE_2D); 2033 2163 glEnable(GL_DEPTH_TEST); … … 2072 2202 read_screen(); 2073 2203 #else 2074 read_screen();2204 //read_screen(); 2075 2205 #endif 2076 2206
Note: See TracChangeset
for help on using the changeset viewer.