Ignore:
Timestamp:
Mar 6, 2009, 9:27:24 PM (16 years ago)
Author:
dkearney
Message:

adding flowvisviewer widget and flowvis-test program for exercising flow
commands. most stuff works in the flowvis-test gui, there are not transfer
functions or legends. play/pause, stop and record work, record download's or
saves the video file to users's desktop. adding iconc for pause, record and
stop.

added "flow play" command to nanovis. the goal of this command is to send back
the next frame to the client. the play functionality allows users to see
frames as if they were a movie, and also send command nanovis server. this
makes the experience more interactive than waiting for a movie to be made and
downloading it. also the play functionality can be used as a cheap preview to
get the best angle and settings before recording the movie.

added sendDataToClient function to nanovis server so i could send back movie
files. we create the movie on the render server and send back the mpeg binary
for the user to download. the function is pretty general so it can be used to
send any blob of data.

Location:
trunk/packages/vizservers/nanovis
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/Command.cpp

    r1291 r1295  
    18481848    }
    18491849    NanoVis::initParticle();
     1850
     1851    // send the movie back to the client
     1852    // FIXME: find a way to get the data from the movie object as a char*
     1853    Rappture::Buffer data;
     1854    data.load(fileName);
     1855    char command[512];
     1856    sprintf(command,"nv>file -bytes %lu\n",data.size());
     1857    NanoVis::sendDataToClient(command,data.bytes(),data.size());
     1858
    18501859    return TCL_OK;
    18511860}
     
    19361945
    19371946static int
     1947FlowPlayOp(ClientData cdata, Tcl_Interp *interp, int objc,
     1948             Tcl_Obj *const *objv)
     1949{
     1950    if (NanoVis::licRenderer &&
     1951        !NanoVis::licRenderer->isActivated()) {
     1952        NanoVis::licRenderer->activate();
     1953    }
     1954    if (NanoVis::particleRenderer &&
     1955        !NanoVis::particleRenderer->isActivated()) {
     1956        NanoVis::particleRenderer->activate();
     1957    }
     1958
     1959    Trace("sending flow playback frame\n");
     1960
     1961    // Generate the latest frame and send it back to the client
     1962    if (NanoVis::licRenderer &&
     1963        NanoVis::licRenderer->isActivated()) {
     1964        NanoVis::licRenderer->convolve();
     1965    }
     1966    if (NanoVis::particleRenderer &&
     1967        NanoVis::particleRenderer->isActivated()) {
     1968        NanoVis::particleRenderer->advect();
     1969    }
     1970    NanoVis::offscreen_buffer_capture();  //enable offscreen render
     1971    NanoVis::display();
     1972
     1973    NanoVis::read_screen();
     1974    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
     1975
     1976    // NanoVis::bmp_write_to_file(frame_count, fileName);
     1977
     1978    Trace("FLOW end\n");
     1979    return TCL_OK;
     1980}
     1981
     1982static int
    19381983FlowResetOp(ClientData cdata, Tcl_Interp *interp, int objc,
    19391984             Tcl_Obj *const *objv)
     
    19732018    {"data",      1, FlowDataOp,          3, 0, "oper ?args?",},
    19742019    {"lic",       1, FlowLicOp,           3, 3, "on|off",},
    1975     {"particle",  1, FlowParticleOp,      3, 0, "oper ?args?",},
     2020    {"particle",  2, FlowParticleOp,      3, 0, "oper ?args?",},
     2021    {"play",      2, FlowPlayOp,          2, 2, "",},
    19762022    {"reset",     1, FlowResetOp,         2, 2, "",},
    19772023    {"vectorid",  1, FlowVectorIdOp,      3, 3, "index",},
     
    19832029 * CLIENT COMMAND:
    19842030 *   flow data follows <value>
    1985  *   flow capture
     2031 *   flow capture frames filename
    19862032 *   flow lic on|off
    19872033 *   flow particle visible on|off
    19882034 *   flow particle slice <volumeId>
    19892035 *   flow particle slicepos <value>
     2036 *   flow play
    19902037 *   flow reset
    19912038 *   flow vectorid <volumeId>
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r1282 r1295  
    12431243    stats.nFrames++;
    12441244    stats.nBytes += (bytesPerRow * win_height);
     1245}
     1246
     1247void
     1248NanoVis::sendDataToClient(const char *command, const char *data, size_t dlen)
     1249{
     1250/*
     1251    char header[200];
     1252
     1253    // Generate the PPM binary file header
     1254    sprintf(header, "P6 %d %d %d\n", win_width, win_height, PPM_MAXVAL);
     1255
     1256    size_t header_length = strlen(header);
     1257    size_t data_length = win_width * win_height * 3;
     1258
     1259    char command[200];
     1260    sprintf(command, "%s %lu\n", prefix,
     1261            (unsigned long)header_length + data_length);
     1262*/
     1263
     1264//    size_t wordsPerRow = (win_width * 24 + 31) / 32;
     1265//    size_t bytesPerRow = wordsPerRow * 4;
     1266//    size_t rowLength = win_width * 3;
     1267    size_t nRecs = 2;
     1268
     1269    struct iovec *iov;
     1270    iov = (struct iovec *)malloc(sizeof(struct iovec) * nRecs);
     1271
     1272    // Write the nanovisviewer command, then the image header and data.
     1273    // Command
     1274// FIXME: shouldn't have to cast this
     1275    iov[0].iov_base = (char *)command;
     1276    iov[0].iov_len = strlen(command);
     1277    // Data
     1278// FIXME: shouldn't have to cast this
     1279    iov[1].iov_base = (char *)data;
     1280    iov[1].iov_len = dlen;
     1281    writev(0, iov, nRecs);
     1282    free(iov);
     1283    // stats.nFrames++;
     1284    // stats.nBytes += (bytesPerRow * win_height);
    12451285}
    12461286
  • trunk/packages/vizservers/nanovis/nanovis.h

    r1238 r1295  
    147147    static TransferFunction* get_transfunc(const char *name);
    148148    static TransferFunction* DefineTransferFunction(const char *name,
    149         size_t n, float *data);
     149        size_t n, float *data);
    150150    static void SetVolumeRanges(void);
    151151    static void SetHeightmapRanges(void);
     
    157157    static void resize_offscreen_buffer(int w, int h);
    158158    static void ppm_write(const char *prefix);
     159    static void sendDataToClient(const char *command, const char *data,
     160        size_t dlen);
    159161    static void bmp_write(const char *prefix);
    160162    static void bmp_write_to_file(int frame_number, const char* directory_name);
     
    164166    static void display_offscreen_buffer();
    165167    static int render_legend(TransferFunction *tf, double min, double max,
    166         int width, int height, const char* volArg);
     168        int width, int height, const char* volArg);
    167169    static Volume *load_volume(int index, int width, int height, int depth,
    168         int n, float* data, double vmin, double vmax, double nzero_min);
     170        int n, float* data, double vmin, double vmax, double nzero_min);
    169171    static void xinetd_listen(void);
    170172    static int render_2d_contour(HeightMap* heightmap, int width, int height);
     
    182184
    183185    static void read_screen(void) {
    184         glReadPixels(0, 0, win_width, win_height, GL_RGB, GL_UNSIGNED_BYTE,
    185                      screen_buffer);
     186        glReadPixels(0, 0, win_width, win_height, GL_RGB, GL_UNSIGNED_BYTE,
     187                screen_buffer);
    186188    }
    187189    static void offscreen_buffer_capture(void) {
    188         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, final_fbo);
     190        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, final_fbo);
    189191    }
    190192};
Note: See TracChangeset for help on using the changeset viewer.