Changeset 458 for trunk


Ignore:
Timestamp:
Jun 3, 2006, 8:01:33 PM (18 years ago)
Author:
mmc
Message:

Added "up" command to set the orientation of all volumes with
respect to the camera.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/vizservers/nanovis/nanovis.cpp

    r457 r458  
    124124Texture2D* plane[10];
    125125
     126// value indicates "up" axis:  x=1, y=2, z=3, -x=-1, -y=-2, -z=-3
     127int updir = 2;
     128
    126129PerfQuery* perf;                        //perfromance counter
    127130
     
    157160static int ScreenCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    158161static int TransfuncCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
     162static int UpCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    159163static int VolumeCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
     164
    160165static int PlaneNewCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    161166static int PlaneLinkCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
     
    582587        "\": should be define", (char*)NULL);
    583588    return TCL_ERROR;
     589}
     590
     591/*
     592 * ----------------------------------------------------------------------
     593 * CLIENT COMMAND:
     594 *   up axis
     595 *
     596 * Clients use this to set the "up" direction for all volumes.  Volumes
     597 * are oriented such that this direction points upward.
     598 * ----------------------------------------------------------------------
     599 */
     600static int
     601UpCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[])
     602{
     603    if (argc != 2) {
     604        Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
     605            " x|y|z|-x|-y|-z\"", (char*)NULL);
     606        return TCL_ERROR;
     607    }
     608
     609    int sign = 1;
     610    char *axisName = argv[1];
     611    if (*axisName == '-') {
     612        sign = -1;
     613        axisName++;
     614    }
     615
     616    int axis;
     617    if (GetAxis(interp, axisName, &axis) != TCL_OK) {
     618        return TCL_ERROR;
     619    }
     620
     621    updir = (axis+1)*sign;
     622
     623    return TCL_OK;
    584624}
    585625
     
    21112151        (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
    21122152
     2153    // set the "up" direction for volumes
     2154    Tcl_CreateCommand(interp, "up", UpCmd,
     2155        (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     2156
    21132157    // manipulate volume data
    21142158    Tcl_CreateCommand(interp, "volume", VolumeCmd,
     
    27282772   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen
    27292773
    2730    if(volume_mode){ //3D rendering mode
     2774   if (volume_mode) {
     2775     //3D rendering mode
    27312776     glEnable(GL_TEXTURE_2D);
    27322777     glEnable(GL_DEPTH_TEST);
     
    27352780     cam->activate();
    27362781
    2737      //now render things in the scene
    2738      //
    2739      draw_3d_axis();
    2740    
    2741      //lic->render();   //display the line integral convolution result
    2742      //soft_display_verts();
    2743      //perf->enable();
    2744      //  psys->render();
    2745      //perf->disable();
    2746      //fprintf(stderr, "particle pixels: %d\n", perf->get_pixel_count());
    2747      //perf->reset();
    2748    
    2749      perf->enable();
    2750        vol_render->render_all();
    2751        //fprintf(stderr, "%lf\n", get_time_interval());
    2752      perf->disable();
     2782     //set up the orientation of items in the scene.
     2783     glPushMatrix();
     2784       switch (updir) {
     2785         case 1:  // x
     2786               glRotatef(90, 0, 0, 1);
     2787               glRotatef(90, 1, 0, 0);
     2788           break;
     2789
     2790         case 2:  // y
     2791           // this is the default
     2792           break;
     2793
     2794         case 3:  // z
     2795               glRotatef(-90, 1, 0, 0);
     2796               glRotatef(-90, 0, 0, 1);
     2797           break;
     2798
     2799         case -1:  // -x
     2800               glRotatef(-90, 0, 0, 1);
     2801           break;
     2802
     2803         case -2:  // -y
     2804               glRotatef(180, 0, 0, 1);
     2805               glRotatef(-90, 0, 1, 0);
     2806           break;
     2807
     2808         case -3:  // -z
     2809               glRotatef(90, 1, 0, 0);
     2810           break;
     2811       }
     2812
     2813       //now render things in the scene
     2814       draw_3d_axis();
     2815
     2816       //lic->render();         //display the line integral convolution result
     2817       //soft_display_verts();
     2818       //perf->enable();
     2819       //  psys->render();
     2820       //perf->disable();
     2821       //fprintf(stderr, "particle pixels: %d\n", perf->get_pixel_count());
     2822       //perf->reset();
     2823
     2824       perf->enable();
     2825         vol_render->render_all();
     2826       perf->disable();
     2827
     2828     glPopMatrix();
    27532829   }
    2754    else{ //2D rendering mode
    2755 
     2830   else{
     2831     //2D rendering mode
    27562832     perf->enable();
    27572833       plane_render->render();
Note: See TracChangeset for help on using the changeset viewer.