Ignore:
Timestamp:
Mar 27, 2006, 9:54:02 PM (18 years ago)
Author:
qiaow
Message:

Transfer function widget is working!!

Location:
trunk/gui/vizservers/nanovis
Files:
6 edited

Legend:

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

    r379 r380  
    2121TransferFunction::TransferFunction(int _size, float* data){
    2222
    23   tex = new Texture1D(size, GL_UNSIGNED_BYTE);
    24   id = tex->id;
     23  tex = new Texture1D(_size, GL_FLOAT);
    2524
    2625  tex->initialize_float_rgba(data);
     26  id = tex->id;
    2727}
    2828
     
    3030TransferFunction::~TransferFunction(){ delete tex; }
    3131
     32void TransferFunction::update(float* data){
     33  tex->update_float_rgba(data);
     34}
    3235
    3336
  • trunk/gui/vizservers/nanovis/TransferFunction.h

    r379 r380  
    2626  Texture1D* tex; //the texture storing the colors
    2727
     28public:
    2829  GLuint id;    //OpenGL's texture identifier
    29 
    30 
    31 public:
    3230  TransferFunction(int _size, float* data);
    3331  ~TransferFunction();
     32  void update(float* data);
    3433};
    3534
  • trunk/gui/vizservers/nanovis/config.h

    r261 r380  
    1515
    1616
    17 //#define NV40  //Uncomment if using 6 series card. By default we assume older card the 5xxx series
     17#define NV40    //Uncomment if using 6 series card. By default we assume older card the 5xxx series
  • trunk/gui/vizservers/nanovis/nanovis.cpp

    r379 r380  
    2424#include "RpFieldPrism3D.h"
    2525
     26//transfer function headers
    2627#include "transfer-function/TransferFunctionMain.h"
    2728#include "transfer-function/ControlPoint.h"
     
    3132#include "transfer-function/MainWindow.h"
    3233
    33 float color_table[256][4];
    34 
     34float color_table[256][4];     
     35
     36int render_window;              //the handle of the render window;
    3537// forward declarations
    3638void init_particles();
     
    7577CGprogram m_one_volume_fprog;
    7678CGparameter m_vol_one_volume_param;
     79CGparameter m_tf_one_volume_param;
    7780CGparameter m_mvi_one_volume_param;
    7881CGparameter m_render_param_one_volume_param;
     
    528531
    529532
     533//load value from the gui, only one transfer function
     534extern void update_tf_texture(){
     535  glutSetWindow(render_window);
     536
     537  fprintf(stderr, "tf update\n");
     538  if(tf[0]==0) return;
     539
     540  float data[256*4];
     541  for(int i=0; i<256; i++){
     542    data[4*i+0] = color_table[i][0];
     543    data[4*i+1] = color_table[i][1];
     544    data[4*i+2] = color_table[i][2];
     545    data[4*i+3] = color_table[i][3];
     546    fprintf(stderr, "(%f,%f,%f,%f) ", data[4*i+0], data[4*i+1], data[4*i+2], data[4*i+3]);
     547  }
     548
     549  tf[0]->update(data);
     550}
     551
     552
     553
    530554//initialize frame buffer objects for offscreen rendering
    531555void init_fbo(){
     
    689713      m_vol_one_volume_param = cgGetNamedParameter(m_one_volume_fprog, "volume");
    690714      cgGLSetTextureParameter(m_vol_one_volume_param, volume[0]->id);
     715      m_tf_one_volume_param = cgGetNamedParameter(m_one_volume_fprog, "tf");
     716      cgGLSetTextureParameter(m_tf_one_volume_param, tf[0]->id);
    691717      m_mvi_one_volume_param = cgGetNamedParameter(m_one_volume_fprog, "modelViewInv");
    692718      m_render_param_one_volume_param = cgGetNamedParameter(m_one_volume_fprog, "renderParameters");
     
    738764
    739765
    740 
     766void init_tf(){
     767  float data[256*4];
     768  memset(data, 0, 4*256*sizeof(float));
     769
     770  tf[0] = new TransferFunction(256, data);
     771}
    741772
    742773
     
    792823   load_vector_file(0, "./data/J-wire-vec.dx");
    793824   load_volume_file(1, "./data/mu-wire-3d.dx");
     825
     826   init_tf();   //initialize transfer function
    794827
    795828   init_fbo();  //frame buffer objects
     
    952985/*----------------------------------------------------*/
    953986void idle(){
     987  glutSetWindow(render_window);
     988
    954989  struct timespec ts;
    955990  ts.tv_sec = 0;
     
    13521387  cgGLSetTextureParameter(m_vol_one_volume_param, volume[volume_index]->id);
    13531388  cgGLEnableTextureParameter(m_vol_one_volume_param);
     1389  cgGLEnableTextureParameter(m_tf_one_volume_param);
    13541390
    13551391  //hack!
     
    13691405  cgGLDisableProfile(CG_PROFILE_FP30);
    13701406
    1371   cgGLEnableTextureParameter(m_vol_one_volume_param);
    1372   //cgGLDisableTextureParameter(m_vel_tex_param);
    1373   //cgGLDisableTextureParameter(m_pos_tex_param);
     1407  cgGLDisableTextureParameter(m_vol_one_volume_param);
     1408  cgGLDisableTextureParameter(m_tf_one_volume_param);
    13741409}
    13751410
     
    19281963   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
    19291964
    1930    MainTransferFunctionWindow * mainWin;
    1931    mainWin = new MainTransferFunctionWindow();
    1932    mainWin->mainInit();
     1965   MainTransferFunctionWindow * tf_window;
     1966   tf_window = new MainTransferFunctionWindow();
     1967   tf_window->mainInit();
    19331968   
    19341969   glutInitWindowSize(NPIX, NPIX);
    19351970   glutInitWindowPosition(10, 10);
    1936    glutCreateWindow(argv[0]);
     1971   render_window = glutCreateWindow(argv[0]);
    19371972
    19381973   glutDisplayFunc(display);
  • trunk/gui/vizservers/nanovis/shaders/one_volume.cg

    r378 r380  
    1717PixelOut main(v2f IN, /* uniform sampler1D tf,*/
    1818                uniform sampler3D volume,
    19                 //uniform sampler1D map,
     19                uniform sampler1D tf,
    2020                uniform float4x4 modelViewInv,
    2121                uniform float4 renderParameters)
     
    3434    else{
    3535      //shades of red //more opaque
    36       OUT.Color = float4(sample, 0, 0, 7*sample/renderParameters.x);
     36      OUT.Color = tex1D(tf, sample);
     37      OUT.Color.w = 10*OUT.Color.w/renderParameters.x;
    3738
    38       if(sample<0.6 && sample>0.4){
    39         OUT.Color = float4(0, 0, 1, 10*sample/renderParameters.x);
    40       }
     39      //OUT.Color = float4(sample, 0, 0, 7*sample/renderParameters.x);
     40
     41      //if(sample<0.6 && sample>0.4){
     42        //OUT.Color = float4(0, 0, 1, 10*sample/renderParameters.x);
     43      //}
    4144    }
    4245  }
  • trunk/gui/vizservers/nanovis/transfer-function/ColorPaletteWindow.cpp

    r379 r380  
    106106
    107107
    108 void update_tf_texture(){};
     108void update_tf_texture();
    109109
    110110void ColorPalette::cmdHandler(int arg){
Note: See TracChangeset for help on using the changeset viewer.