Changeset 1299


Ignore:
Timestamp:
Mar 7, 2009 2:46:49 PM (12 years ago)
Author:
vrinside
Message:

modified lic

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

Legend:

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

    r1298 r1299  
    17621762        float dz0 = -0.5*volPtr->depth/volPtr->width;
    17631763        volPtr->move(Vector3(dx0, dy0, dz0));
     1764
     1765        //
     1766        volPtr->disable();
    17641767    }
    17651768
     
    18801883        return TCL_ERROR;
    18811884    }
     1885
    18821886    NanoVis::particle_on = state;
    18831887    return TCL_OK;
     
    20072011    if (NanoVis::licRenderer != NULL) {
    20082012        NanoVis::licRenderer->setVectorField(volPtr->id,
     2013            *(volPtr->get_location()),
    20092014            1.0f / volPtr->aspect_ratio_width,
    20102015            1.0f / volPtr->aspect_ratio_height,
  • trunk/packages/vizservers/nanovis/NvLIC.cpp

    r1111 r1299  
    4646    slice_vector = new float[size*size*4];
    4747    memset(slice_vector, 0, sizeof(float) * size * size * 4);
     48
     49    origin.set(0, 0, 0);
    4850
    4951    //initialize the pattern texture
     
    392394    //glScalef(scale.x, scale.y, scale.z);
    393395    float w = 1.0f / scale.x;
     396    glTranslatef(origin.x, origin.y, origin.z);
    394397    glScalef(1.0f, 1.0f / scale.y / w, 1.0f / scale.z / w);
    395398   
     
    445448
    446449void
    447 NvLIC::setVectorField(unsigned int texID, float scaleX, float scaleY,
     450NvLIC::setVectorField(unsigned int texID, const Vector3& ori, float scaleX, float scaleY,
    448451                      float scaleZ, float max)
    449452{
    450453    Trace("NvLIC: vector field is assigned [%d]\n", texID);
    451454    vectorFieldID = texID;
     455    origin = ori;
    452456    scale = Vector3(scaleX, scaleY, scaleZ);
    453457    this->max = max;
  • trunk/packages/vizservers/nanovis/NvLIC.h

    r851 r1299  
    4444  float* slice_vector;  //storage for the per slice vectors driving the follow
    4545  Vector3 scale;        //scaling factor stretching the lic plane to fit the actual dimensions
     46  Vector3 origin;
    4647  float offset;         //[0,1] offset could be x, y, or z direction
    4748
     
    9596    bool isActivated() const;
    9697
    97     void setVectorField(unsigned int texID, float scaleX, float scaleY, float scaleZ, float max);
     98    void setVectorField(unsigned int texID, const Vector3& ori, float scaleX, float scaleY, float scaleZ, float max);
    9899};
    99100
  • trunk/packages/vizservers/nanovis/NvParticleAdvectionShader.cpp

    r1111 r1299  
    2828}
    2929
     30void NvParticleAdvectionShader::bind(unsigned int texID)
     31{
     32    cgGLBindProgram(_cgFP);
     33
     34    cgGLSetParameter1f(_posTimestepParam, _timeStep);
     35    cgGLSetParameter1f(_maxParam, _max);
     36    cgGLSetParameter3f(_scaleParam, _scale.x, _scale.y, _scale.z);
     37    cgGLSetTextureParameter(_velTexParam, _velocityVolumeID);
     38    cgGLEnableTextureParameter(_velTexParam);
     39    cgGLSetTextureParameter(_posTexParam, texID);
     40    cgGLEnableTextureParameter(_posTexParam);
     41
     42    cgGLEnableProfile(CG_PROFILE_FP30);
     43}
  • trunk/packages/vizservers/nanovis/NvParticleAdvectionShader.h

    r850 r1299  
    3535}
    3636
    37 inline void NvParticleAdvectionShader::bind(unsigned int texID)
    38 {
    39     cgGLBindProgram(_cgFP);
    40 
    41     cgGLSetParameter1f(_posTimestepParam, _timeStep);
    42     cgGLSetParameter1f(_maxParam, _max);
    43     cgGLSetParameter3f(_scaleParam, _scale.x, _scale.y, _scale.z);
    44     cgGLSetTextureParameter(_velTexParam, _velocityVolumeID);
    45     cgGLEnableTextureParameter(_velTexParam);
    46     cgGLSetTextureParameter(_posTexParam, texID);
    47     cgGLEnableTextureParameter(_posTexParam);
    48 
    49     cgGLEnableProfile(CG_PROFILE_FP30);
    50 }
    51 
    5237inline void NvParticleAdvectionShader::unbind()
    5338{
  • trunk/packages/vizservers/nanovis/NvShader.cpp

    r1111 r1299  
    4747void NvShader::setErrorCallback(NvCgCallbackFunction callback)
    4848{
     49        printf("NvShader callback\n");
    4950    cgSetErrorCallback(callback);
    5051}
  • trunk/packages/vizservers/nanovis/config.h

    r1028 r1299  
    2828 * we'll rely on developers to set this in their respective sandboxes.
    2929 */
    30 #define PROTOTYPE               0
     30//#define PROTOTYPE             0
     31#define PROTOTYPE               1
    3132
    3233/*
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r1295 r1299  
    153153// in Command.cpp
    154154extern Tcl_Interp *initTcl();
     155
     156// in dxReader.cpp
     157extern void load_vector_stream(int index, std::istream& fin);
    155158
    156159float vert[NMESH*NMESH*3];              //particle positions in main memory
     
    399402        assert(path != NULL);
    400403    }
     404    printf("cg program compiling: %s\n", path);
     405    fflush(stdout);
    401406    CGprogram program;
    402407    program = cgCreateProgramFromFile(context, CG_SOURCE, path, profile,
    403408        entryPoint, NULL);
     409    cgGLLoadProgram(program);
     410
     411    CGerror LastError = cgGetError();
     412    if (LastError)
     413    {
     414       printf("Error message: %s\n", cgGetLastListing(context));
     415    }
     416
    404417    delete [] path;
    405     cgGLLoadProgram(program);
     418
    406419    return program;
    407420}
     
    18641877        }
    18651878        //3D rendering mode
    1866         glEnable(GL_TEXTURE_2D);
     1879        // TBD..
     1880        //glEnable(GL_TEXTURE_2D);
    18671881        glEnable(GL_DEPTH_TEST);
    18681882
     
    19912005
    19922006    angle = cam->rotate();
    1993     angle.x += delta.x;
    1994     angle.y += delta.y;
     2007    angle.x += delta_x;
     2008    angle.y += delta_y;
    19952009
    19962010    if (angle.x > 360.0) {
     
    20182032NanoVis::keyboard(unsigned char key, int x, int y)
    20192033{
     2034/*
    20202035   bool log = false;
    20212036
     
    20262041   case '+':
    20272042       lic_slice_z+=0.05;
    2028        lic->set_offset(lic_slice_z);
     2043       licRenderer->set_offset(lic_slice_z);
    20292044       break;
    20302045   case '-':
    20312046       lic_slice_z-=0.05;
    2032        lic->set_offset(lic_slice_z);
     2047       licRenderer->set_offset(lic_slice_z);
    20332048       break;
    20342049   case ',':
     
    20832098       break;
    20842099   }
     2100*/
    20852101#ifdef EVENTLOG
    20862102   if(log){
     
    21972213#endif
    21982214
     2215void
     2216NanoVis::render()
     2217{
     2218      if (NanoVis::licRenderer && NanoVis::licRenderer->isActivated())
     2219      {
     2220      NanoVis::licRenderer->convolve();
     2221      }
     2222
     2223      if (NanoVis::particleRenderer && NanoVis::particleRenderer->isActivated())
     2224      {
     2225      NanoVis::particleRenderer->advect();
     2226      }
     2227
     2228      NanoVis::update();
     2229
     2230        display();
     2231        glutSwapBuffers();
     2232
     2233}
     2234
     2235void
     2236NanoVis::resize(int x, int y)
     2237{
     2238        glViewport(0, 0, x, y);
     2239}
    21992240
    22002241void
     
    23612402    glutInitWindowPosition(10, 10);
    23622403    NanoVis::render_window = glutCreateWindow("nanovis");
    2363     glutDisplayFunc(NanoVis::display);
    23642404    glutIdleFunc(NanoVis::idle);
    2365     glutReshapeFunc(NanoVis::resize_offscreen_buffer);
    23662405
    23672406#ifndef XINETD
     
    23692408    glutMotionFunc(NanoVis::motion);
    23702409    glutKeyboardFunc(NanoVis::keyboard);
    2371 #endif
    2372 
     2410    glutReshapeFunc(NanoVis::resize);
     2411    glutDisplayFunc(NanoVis::render);
     2412#else
     2413    glutDisplayFunc(NanoVis::display);
     2414    glutReshapeFunc(NanoVis::resize_offscreen_buffer);
     2415#endif
    23732416
    23742417    while (1) {
     
    24502493        // Assume program is in the form <path>/bin/nanovis.
    24512494
     2495#ifdef XINETD
    24522496        path = argv[0];
    24532497        p = strrchr(path, '/');
     
    24642508        sprintf(newPath, "%s/lib/shaders:%s/lib/resources", path, path);
    24652509        path = newPath;
     2510#else
     2511        char buff[256];
     2512        getcwd(buff, 255);
     2513        p = strrchr(buff, '/');
     2514        if (p != NULL) {
     2515            *p = '\0';
     2516        }
     2517        newPath = new char[(strlen(buff) + 15) * 2 + 1];
     2518        sprintf(newPath, "%s/lib/shaders:%s/lib/resources", buff, buff);
     2519        path = newPath;
     2520#endif
    24662521    }
    24672522    R2FilePath::getInstance()->setWorkingDirectory(argc, (const char**) argv);
     
    24832538    NanoVis::interp = initTcl();
    24842539    NanoVis::resize_offscreen_buffer(NanoVis::win_width, NanoVis::win_height);
     2540
     2541#ifndef XINETD
     2542/*
     2543    CGprofile newProfile;
     2544    newProfile = cgGetProfile("fp30");
     2545    if (newProfile == CG_PROFILE_UNKNOWN)
     2546        printf("unknown profile\n");
     2547    else printf("fp30 know profile\n");
     2548
     2549    int n = NanoVis::n_volumes;
     2550    std::ifstream fdata;
     2551    fdata.open("flow2d.dx", std::ios::in);
     2552    load_vector_stream(n, fdata);
     2553    Volume *volPtr = NanoVis::volume[n];
     2554
     2555    if (volPtr != NULL) {
     2556        //volPtr->set_n_slice(256-n);
     2557        volPtr->set_n_slice(512-n);
     2558        volPtr->disable_cutplane(0);
     2559        volPtr->disable_cutplane(1);
     2560        volPtr->disable_cutplane(2);
     2561
     2562        NanoVis::vol_renderer->add_volume(volPtr,
     2563                NanoVis::get_transfunc("default"));
     2564    }
     2565
     2566
     2567    if (NanoVis::particleRenderer != NULL) {
     2568        NanoVis::particleRenderer->setVectorField(volPtr->id, 1.0f,
     2569            volPtr->height / (float)volPtr->width,
     2570            volPtr->depth  / (float)volPtr->width,
     2571            volPtr->wAxis.max());
     2572        NanoVis::initParticle();
     2573    }
     2574    if (NanoVis::licRenderer != NULL) {
     2575        NanoVis::licRenderer->setVectorField(volPtr->id,
     2576            1.0f / volPtr->aspect_ratio_width,
     2577            1.0f / volPtr->aspect_ratio_height,
     2578            1.0f / volPtr->aspect_ratio_depth,
     2579            volPtr->wAxis.max());
     2580        NanoVis::licRenderer->set_offset(NanoVis::lic_slice_z);
     2581        }
     2582*/
     2583#endif
    24852584    glutMainLoop();
    24862585
  • trunk/packages/vizservers/nanovis/nanovis.h

    r1295 r1299  
    156156    static void initParticle();
    157157    static void resize_offscreen_buffer(int w, int h);
     158
     159    // For development
     160    static void resize(int w, int h);
     161    static void render();
     162
    158163    static void ppm_write(const char *prefix);
    159164    static void sendDataToClient(const char *command, const char *data,
Note: See TracChangeset for help on using the changeset viewer.