Changeset 776


Ignore:
Timestamp:
Jul 9, 2007 4:55:19 PM (17 years ago)
Author:
vrinside
Message:

Add 3D surface plot and grid rendering

Location:
trunk/vizservers/nanovis
Files:
15 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/vizservers/nanovis/Makefile.in

    r750 r776  
    3939                NvLoadFile.o NvDefaultTFData.o NvColorTableShader.o NvColorTableRenderer.o NvParticleAdvectionShader.o \
    4040                NvEventLog.o NvParticleRenderer.o NvLIC.o NvZincBlendeReconstructor.o NvStdVertexShader.o \
    41                 R2string.o R2FilePath.o R2Fonts.o R2Object.o
     41                ContourLineFilter.o HeightMap.o Grid.o \
     42                R2string.o R2FilePath.o R2Fonts.o R2Object.o R2Geometry.o R2IndexBuffer.o R2VertexBuffer.o
    4243
    4344all: nanovis
     
    9798R2Object.o: R2/src/R2Object.cpp $(R2INC)/R2/R2Object.h
    9899        $(CC) $(CFLAGS) -o $@ -c $<
    99 
    100 
     100R2Geometry.o: R2/src/R2Geometry.cpp $(R2INC)/R2/graphics/R2Geometry.h
     101        $(CC) $(CFLAGS) -o $@ -c $<
     102R2VertexBuffer.o: R2/src/R2VertexBuffer.cpp $(R2INC)/R2/graphics/R2VertexBuffer.h
     103        $(CC) $(CFLAGS) -o $@ -c $<
     104R2IndexBuffer.o: R2/src/R2IndexBuffer.cpp $(R2INC)/R2/graphics/R2IndexBuffer.h
     105        $(CC) $(CFLAGS) -o $@ -c $<
    101106
    102107NvStdVertexShader.o: NvStdVertexShader.cpp NvStdVertexShader.h
     108ContourLineFilter.o: ContourLineFilter.cpp ContourLineFilter.h
     109HeightMap.o: HeightMap.cpp HeightMap.h
     110Grid.o: Grid.cpp Grid.h
    103111NvLoadFile.o: NvLoadFile.cpp NvLoadFile.h
    104112NvParticleAdvectionShader.o: NvParticleAdvectionShader.cpp NvParticleAdvectionShader.h
  • trunk/vizservers/nanovis/Nv.cpp

    r755 r776  
    55#include "NvEventLog.h"
    66#include "VolumeRenderer.h"
     7#include "Grid.h"
    78#include <R2/R2FilePath.h>
    89#include <stdio.h>
     
    1617VolumeRenderer* g_vol_render;
    1718R2Fonts* g_fonts;
     19Grid* g_grid;
    1820
    1921//query opengl information
     
    130132
    131133    g_fonts = new R2Fonts();
    132     // INSOO
    133     //g_fonts->addFont("verdana", "verdana.fnt");
    134     //g_fonts->setFont("verdana");
     134    g_fonts->addFont("verdana", "verdana.fnt");
     135    g_fonts->setFont("verdana");
    135136
    136137    //g_color_table_renderer = new NvColorTableRenderer();
    137138    // INSOO
    138139    //g_color_table_renderer->setFonts(g_fonts);
     140
     141    g_grid = new Grid();
     142    g_grid->setFont(g_fonts);
    139143
    140144    NvInitVolumeRenderer();
  • trunk/vizservers/nanovis/NvShader.cpp

    r580 r776  
    11#include "NvShader.h"
     2#include <stdio.h>
    23
    34CGcontext g_context = 0;
     
    1718}
    1819
     20void NvShader::loadVertexProgram(const char* fileName, const char* entryPoint)
     21{
     22    resetPrograms();
     23
     24    printf("[%s] loading\n", fileName);
     25    _cgVP = cgCreateProgramFromFile(g_context, CG_SOURCE, fileName, CG_PROFILE_VP30,
     26                            entryPoint, NULL);
     27
     28    cgGLLoadProgram(_cgVP);
     29}
     30
     31void NvShader::loadFragmentProgram(const char* fileName, const char* entryPoint)
     32{
     33    printf("[%s] loading\n", fileName);
     34    _cgFP = cgCreateProgramFromFile(g_context, CG_SOURCE, fileName, CG_PROFILE_FP30,
     35                            entryPoint, NULL);
     36
     37    cgGLLoadProgram(_cgFP);
     38}
     39
     40void NvShader::resetPrograms()
     41{
     42    if (_cgVP != 0)
     43    {
     44        cgDestroyProgram(_cgVP);
     45    }
     46
     47    if (_cgFP != 0)
     48    {
     49        cgDestroyProgram(_cgFP);
     50    }
     51}
  • trunk/vizservers/nanovis/NvShader.h

    r580 r776  
    1010    CGprogram _cgFP;
    1111
    12 protected :
     12public :
    1313    NvShader();
    1414
    1515public :
    1616    virtual ~NvShader();
     17
     18protected :
     19    void resetPrograms();
     20public :
     21    /**
     22     * @brief create a Cg vertex program and load it
     23     * @param fileName the name of Cg program file
     24     * @param entryPoint a entry point of the Cg program
     25     */
     26    void loadVertexProgram(const char* fileName, const char* entryPoint);
     27
     28    /**
     29     * @brief create a Cg fragment program and load it
     30     * @param fileName the name of Cg program file
     31     * @param entryPoint a entry point of the Cg program
     32     */
     33    void loadFragmentProgram(const char* fileName, const char* entryPoint);
     34   
     35    CGparameter getNamedParameterFromFP(const char* paramName);
     36    CGparameter getNamedParameterFromVP(const char* paramName);
     37
     38    CGprogram getVP() const;
     39    CGprogram getFP() const;
    1740};
    1841
    1942extern CGcontext g_context;
    2043
     44inline CGparameter NvShader::getNamedParameterFromFP(const char* paramName)
     45{
     46    if (_cgFP)
     47    {
     48        return cgGetNamedParameter(_cgFP, paramName);
     49    }
     50
     51    return 0;
     52}
     53
     54inline CGparameter NvShader::getNamedParameterFromVP(const char* paramName)
     55{
     56    if (_cgVP)
     57    {
     58        return cgGetNamedParameter(_cgVP, paramName);
     59    }
     60
     61    return 0;
     62}
     63
     64inline CGprogram NvShader::getVP() const
     65{
     66    return _cgVP;
     67}
     68
     69inline CGprogram NvShader::getFP() const
     70{
     71    return _cgFP;
     72}
     73
    2174#endif //
    2275
  • trunk/vizservers/nanovis/TransferFunction.h

    r380 r776  
    3131  ~TransferFunction();
    3232  void update(float* data);
     33    Texture1D* getTexture();
    3334};
    3435
     36inline Texture1D* TransferFunction::getTexture()
     37{
     38    return tex;
     39}
    3540
    3641#endif
  • trunk/vizservers/nanovis/Volume.cpp

    r524 r776  
    2020Volume::Volume(float x, float y, float z,
    2121                int w, int h, int d, float s,
    22                 int n, float* data, double v0, double v1):
     22                int n, float* data, double v0, double v1, double nz_min):
    2323        width(w),
    2424        height(h),
     
    2727        n_components(n),
    2828        vmin(v0),
    29         vmax(v1),
     29        vmax(v1),
     30    nonzero_min(nz_min),
    3031        enabled(true),
    3132        n_slice(256), // default value
  • trunk/vizservers/nanovis/Volume.h

    r580 r776  
    4444
    4545class Volume{
    46        
    47 
    4846public:
    4947        int volume_type;        //cubic or zincblende
     
    5351
    5452        Texture3D* tex; //OpenGL texture storing the volume
    55         double vmin;    //minimum (unscaled) value in data
    56         double vmax;    //maximum (unscaled) value in data
     53    double vmin;    //minimum (unscaled) value in data
     54    double vmax;    //maximum (unscaled) value in data
     55    double nonzero_min;
    5756
    5857        float specular; //specular lighting parameter
     
    8988        Volume(float x, float y, float z,
    9089                        int width, int height, int depth, float size,
    91                         int n_component, float* data, double vmin, double vmax);
     90                        int n_component, float* data, double vmin, double vmax, double nonzero_min);
    9291        ~Volume();
    9392       
     
    10099        double range_min() { return vmin; }
    101100        double range_max() { return vmax; }
     101    double range_nzero_min() { return nonzero_min; }
    102102
    103103        void set_n_slice(int val); //set number of slices
  • trunk/vizservers/nanovis/ZincBlendeVolume.cpp

    r617 r776  
    2222                                        int w, int h, int d, float s, int n,
    2323                                        float* dataVolumeA, float* dataVolumeB,
    24                                         double v0, double v1, const Vector3& cellSize)
    25                 : Volume(x, y, z, w, h, d, s, n, dataVolumeA, v0, v1), cell_size(cellSize)
     24                                        double v0, double v1, double non_zeromin, const Vector3& cellSize)
     25                : Volume(x, y, z, w, h, d, s, n, dataVolumeA, v0, v1, non_zeromin), cell_size(cellSize)
    2626{
    2727  //label it as zincblende
  • trunk/vizservers/nanovis/ZincBlendeVolume.h

    r580 r776  
    3636                int width, int height, int depth, float size, int n_component,
    3737                float* dataVolumeA, float* dataVolumeB,
    38                 double vmin, double vmax, const Vector3& cellSize);
     38                double vmin, double vmax, double non_zeromin, const Vector3& cellSize);
    3939
    4040        ~ZincBlendeVolume();
  • trunk/vizservers/nanovis/nanovis.cpp

    r755 r776  
    4848#include "NvEventLog.h"
    4949#include "NvZincBlendeReconstructor.h"
     50#include "HeightMap.h"
     51#include "Grid.h"
    5052
    5153// R2 headers
     
    5759extern VolumeRenderer* g_vol_render;
    5860extern NvColorTableRenderer* g_color_table_renderer;
     61extern Grid* g_grid;
    5962PlaneRenderer* plane_render;
    6063Camera* cam;
     
    107110
    108111int render_window;              //the handle of the render window;
     112bool axis_on = true;
    109113
    110114// forward declarations
     
    112116void get_slice_vectors();
    113117Rappture::Outcome load_volume_stream(int index, std::iostream& fin);
    114 void load_volume(int index, int width, int height, int depth, int n_component, float* data, double vmin, double vmax);
     118void load_volume(int index, int width, int height, int depth, int n_component, float* data, double vmin, double vmax,
     119                double nzero_min);
    115120TransferFunction* get_transfunc(char *name);
    116121void resize_offscreen_buffer(int w, int h);
     
    140145vector<Volume*> volume;
    141146
     147vector<HeightMap*> g_heightMap;
     148
    142149// maps transfunc name to TransferFunction object
    143150Tcl_HashTable tftable;
     
    196203static int PlaneEnableCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
    197204
     205static int GridCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
     206static int AxisCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]));
     207
    198208static int GetVolumeIndices _ANSI_ARGS_((Tcl_Interp *interp, int argc, CONST84 char *argv[], vector<int>* vectorPtr));
     209static int GetIndices(Tcl_Interp *interp, int argc, CONST84 char *argv[], vector<int>* vectorPtr);
    199210static int GetAxis _ANSI_ARGS_((Tcl_Interp *interp, char *str, int *valPtr));
    200211static int GetColor _ANSI_ARGS_((Tcl_Interp *interp, char *str, float *rgbPtr));
     
    318329    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    319330
    320     // INSOO
    321     // TBD
    322     //bmp_write("nv>screenshot -bytes");
    323     bmp_write_to_file();
     331    bmp_write("nv>screenshot -bytes");
    324332   
    325333    resize_offscreen_buffer(old_win_width, old_win_height);
     
    756764            return TCL_OK;
    757765        }
     766
    758767        Tcl_AppendResult(interp, "bad option \"", argv[2],
    759768            "\": should be label", (char*)NULL);
     
    833842            if (!strcmp(header, "<HDR>"))
    834843            {
     844                printf("HDR stream is in\n");
    835845                std::stringstream fdata(std::ios_base::out|std::ios_base::in|std::ios_base::binary);
    836846                fdata.write(buf.bytes(),buf.size());
     
    11001110        volume[1]->disable_data();
    11011111        volume[1]->disable();
     1112        return TCL_OK;
     1113    }
     1114
     1115    Tcl_AppendResult(interp, "bad option \"", argv[1],
     1116        "\": should be data, outline, shading, or state", (char*)NULL);
     1117    return TCL_ERROR;
     1118}
     1119
     1120int HeightMapCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]))
     1121{
     1122    if (argc < 2)
     1123    {
     1124        {   
     1125        srand( (unsigned)time( NULL ) );
     1126        int size = 20 * 20;
     1127        float* data = (float*) malloc(sizeof(float) * size);
     1128        for (int i = 0; i < size; ++i)
     1129        {
     1130            data[i] = rand() * 1.0f / RAND_MAX;
     1131        }
     1132
     1133        HeightMap* heightMap = new HeightMap();
     1134        heightMap->setHeight(0, 0, 1, 1, 20, 20, data);
     1135        heightMap->setColorMap(get_transfunc("default"));
     1136        heightMap->setVisible(true);
     1137        heightMap->setLineContourVisible(true);
     1138        g_heightMap.push_back(heightMap);
     1139        }
     1140
     1141        return TCL_OK;
     1142    }
     1143
     1144    char c = *argv[1];
     1145    if (c == 'd' && strcmp(argv[1],"data") == 0)
     1146    {
     1147        //bytes
     1148        vector<int> indices;
     1149        if (strcmp(argv[2],"on") == 0)
     1150        {
     1151            if (GetVolumeIndices(interp, argc-2, argv+2, &indices) != TCL_OK)
     1152            {
     1153                return TCL_ERROR;
     1154            }
     1155
     1156            for (int i = 0; i < indices.size(); ++i)
     1157            {
     1158                if ((indices[i] < g_heightMap.size()) && (g_heightMap[indices[i]] != NULL))
     1159                {
     1160                    g_heightMap[indices[i]]->setVisible(true);
     1161                }
     1162            }
     1163            return TCL_OK;
     1164        }
     1165        else if (strcmp(argv[2],"off") == 0)
     1166        {
     1167            if (GetVolumeIndices(interp, argc-2, argv+2, &indices) != TCL_OK)
     1168            {
     1169                return TCL_ERROR;
     1170            }
     1171
     1172            for (int i = 0; i < indices.size(); ++i)
     1173            {
     1174                if ((indices[i] < g_heightMap.size()) && (g_heightMap[indices[i]] != NULL))
     1175                {
     1176                    g_heightMap[indices[i]]->setVisible(false);
     1177                }
     1178            }
     1179            return TCL_OK;
     1180        }
     1181       
     1182       
     1183       
     1184    }
     1185    else if (c == 'l' && (strcmp(argv[1], "linecontour") == 0))
     1186    {
     1187        //bytes
     1188        vector<int> indices;
     1189        if (strcmp(argv[2],"on") == 0)
     1190        {
     1191            if (GetVolumeIndices(interp, argc-3, argv+3, &indices) != TCL_OK)
     1192            {
     1193                return TCL_ERROR;
     1194            }
     1195
     1196            for (int i = 0; i < indices.size(); ++i)
     1197            {
     1198                if ((indices[i] < g_heightMap.size()) && (g_heightMap[indices[i]] != NULL))
     1199                {
     1200                    g_heightMap[indices[i]]->setLineContourVisible(true);
     1201                }
     1202            }
     1203            return TCL_OK;
     1204        }
     1205        else if (strcmp(argv[2],"off") == 0)
     1206        {
     1207            if (GetVolumeIndices(interp, argc-3, argv+3, &indices) != TCL_OK)
     1208            {
     1209                return TCL_ERROR;
     1210            }
     1211
     1212            for (int i = 0; i < indices.size(); ++i)
     1213            {
     1214                if ((indices[i] < g_heightMap.size()) && (g_heightMap[indices[i]] != NULL))
     1215                {
     1216                    g_heightMap[indices[i]]->setLineContourVisible(false);
     1217                }
     1218            }
     1219            return TCL_OK;
     1220        }
     1221       
     1222        return TCL_OK;
     1223    }
     1224    else if (c == 't' && (strcmp(argv[1], "transfunc") == 0))
     1225    {
     1226        TransferFunction *tf = get_transfunc((char*)argv[3]);
     1227        if (tf == NULL) {
     1228            Tcl_AppendResult(interp, "transfer function \"", argv[3],
     1229                "\" is not defined", (char*)NULL);
     1230            return TCL_ERROR;
     1231        }
     1232
     1233        vector<int> indices;
     1234        if (GetVolumeIndices(interp, argc - 3, argv + 3, &indices) != TCL_OK)
     1235        {
     1236            for (int i = 0; i < indices.size(); ++i)
     1237            {
     1238                if ((indices[i] < g_heightMap.size()) && (g_heightMap[indices[i]] != NULL))
     1239                {
     1240                    g_heightMap[indices[i]]->setColorMap(tf);
     1241                }
     1242            }
     1243        }
     1244        return TCL_OK;
     1245    }
     1246   
     1247    Tcl_AppendResult(interp, "bad option \"", argv[1],
     1248        "\": should be data, outline, shading, or state", (char*)NULL);
     1249    return TCL_ERROR;
     1250}
     1251
     1252int GridCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]))
     1253{
     1254    char c = *argv[1];
     1255    if (c == 'v' && strcmp(argv[1],"visible") == 0)
     1256    {
     1257        if (strcmp(argv[2],"on") == 0)
     1258        {
     1259            g_grid->setVisible(true);
     1260            return TCL_OK;
     1261        }
     1262        else if (strcmp(argv[2],"off") == 0)
     1263        {
     1264            g_grid->setVisible(false);
     1265            return TCL_OK;
     1266        }
     1267    }
     1268    else if (c == 'l' && strcmp(argv[1],"linecount") == 0)
     1269    {
     1270        int x, y, z;
     1271
     1272        if ((Tcl_GetInt(interp, argv[2], &x) == TCL_OK) &&
     1273            (Tcl_GetInt(interp, argv[3], &y) == TCL_OK) &&
     1274            (Tcl_GetInt(interp, argv[4], &z) == TCL_OK)) {
     1275
     1276            if (g_grid) g_grid->setGridLineCount(x, y, z);
     1277
     1278            return TCL_OK;
     1279        }
     1280    }
     1281    else if (c == 'a' && strcmp(argv[1],"axiscolor") == 0)
     1282    {
     1283        int r, g, b;
     1284        if ((Tcl_GetInt(interp, argv[2], &r) == TCL_OK) &&
     1285            (Tcl_GetInt(interp, argv[3], &g) == TCL_OK) &&
     1286            (Tcl_GetInt(interp, argv[4], &b) == TCL_OK)) {
     1287
     1288            if (g_grid) g_grid->setAxisColor(r / 255.0f, g / 255.0f, b / 255.0f);
     1289            return TCL_OK;
     1290        }
     1291    }
     1292    else if (c == 'l' && strcmp(argv[1],"linecolor") == 0)
     1293    {
     1294        int r, g, b;
     1295        if ((Tcl_GetInt(interp, argv[2], &r) == TCL_OK) &&
     1296            (Tcl_GetInt(interp, argv[3], &g) == TCL_OK) &&
     1297            (Tcl_GetInt(interp, argv[4], &b) == TCL_OK)) {
     1298
     1299            if (g_grid) g_grid->setGridLineColor(r / 255.0f, g / 255.0f, b / 255.0f);
     1300            return TCL_OK;
     1301        }
     1302    }
     1303    else if (c == 'm')
     1304    {
     1305        if (strcmp(argv[1],"minmax") == 0)
     1306        {
     1307            double x1, y1, z1, x2, y2, z2;
     1308            if ((Tcl_GetDouble(interp, argv[2], &x1) == TCL_OK) &&
     1309                (Tcl_GetDouble(interp, argv[3], &y1) == TCL_OK) &&
     1310                (Tcl_GetDouble(interp, argv[4], &z1) == TCL_OK) &&
     1311                (Tcl_GetDouble(interp, argv[5], &x2) == TCL_OK) &&
     1312                (Tcl_GetDouble(interp, argv[6], &y2) == TCL_OK) &&
     1313                (Tcl_GetDouble(interp, argv[7], &z2) == TCL_OK)) {
     1314
     1315                if (g_grid) g_grid->setMinMax(Vector3(x1, y1, z1), Vector3(x2, y2, z2));
     1316
     1317                return TCL_OK;
     1318            }
     1319        }
     1320    }
     1321    else if (c == 'a' && strcmp(argv[1],"axisname") == 0)
     1322    {
     1323        int axisID;
     1324        if ((Tcl_GetInt(interp, argv[2], &axisID) == TCL_OK))
     1325        {
     1326            if (g_grid) g_grid->setAxisName(axisID, argv[3]);
     1327            return TCL_OK;
     1328        }
     1329    }
     1330
     1331    Tcl_AppendResult(interp, "bad option \"", argv[1],
     1332        "\": should be data, outline, shading, or state", (char*)NULL);
     1333    return TCL_ERROR;
     1334}
     1335
     1336int AxisCmd _ANSI_ARGS_((ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]))
     1337{
     1338    if (argc < 2) {
     1339        Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
     1340            " option arg arg...\"", (char*)NULL);
     1341        return TCL_ERROR;
     1342    }
     1343
     1344    char c = *argv[1];
     1345    if (c == 'v' && strcmp(argv[1],"visible") == 0)
     1346    {
     1347        if (strcmp(argv[2],"on") == 0)
     1348        {
     1349            axis_on = true;
     1350        }
     1351        else if (strcmp(argv[2],"off") == 0)
     1352        {
     1353            axis_on = false;
     1354        }
     1355           
    11021356        return TCL_OK;
    11031357    }
     
    11451399                vectorPtr->push_back(ivol);
    11461400            }
     1401        }
     1402    }
     1403    return TCL_OK;
     1404}
     1405
     1406static int
     1407GetIndices(Tcl_Interp *interp, int argc, CONST84 char *argv[],
     1408    vector<int>* vectorPtr)
     1409{
     1410    int ivol;
     1411    for (int n=0; n < argc; n++)
     1412    {
     1413        if (Tcl_GetInt(interp, argv[n], &ivol) != TCL_OK) {
     1414            return TCL_ERROR;
     1415        }
     1416        if (ivol < 0 || ivol >= volume.size()) {
     1417            Tcl_AppendResult(interp, "bad volume index \"", argv[n],
     1418                    "\"", (char*)NULL);
     1419                return TCL_ERROR;
    11471420        }
    11481421    }
     
    14751748        double vmin = 0.0;
    14761749        double vmax = 0.0;
     1750        double nzero_min = 0.0;
    14771751        int ngen = 0;
    14781752        for (int iz=0; iz < nz; iz++) {
     
    14931767                    if (vm < vmin) { vmin = vm; }
    14941768                    if (vm > vmax) { vmax = vm; }
     1769                    if (vm != 0.0f && vm < nzero_min)
     1770                    {
     1771                        nzero_min = vm;
     1772                    }
    14951773
    14961774                    data[ngen++] = vx;
     
    15061784        }
    15071785
    1508         load_volume(index, nx, ny, nz, 3, data, vmin, vmax);
     1786        load_volume(index, nx, ny, nz, 3, data, vmin, vmax, nzero_min);
    15091787        delete [] data;
    15101788    } else {
     
    15651843                for (int i=0; i < nxy; i++) {
    15661844                    ftmp << xymesh.atNode(i).x() << " " << xymesh.atNode(i).y() << std::endl;
     1845               
    15671846                }
    15681847                ftmp.close();
     
    16911970            // generate the uniformly sampled data that we need for a volume
    16921971            int ngen = 0;
     1972            double nzero_min = 0.0;
    16931973            for (int iz=0; iz < nz; iz++) {
    16941974                double zval = z0 + iz*dmin;
     
    16991979                        double v = field.value(xval,yval,zval);
    17001980
     1981                        if (v != 0.0f && v < nzero_min)
     1982                        {
     1983                            nzero_min = v;
     1984                        }
     1985
    17011986                        // scale all values [0-1], -1 => out of bounds
    17021987                        v = (isnan(v)) ? -1.0 : (v - vmin)/dv;
     1988
    17031989                        data[ngen] = v;
    17041990                        ngen += 4;
     
    17462032
    17472033            load_volume(index, nx, ny, nz, 4, data,
    1748                 field.valueMin(), field.valueMax());
     2034                field.valueMin(), field.valueMax(), nzero_min);
    17492035
    17502036            delete [] data;
     
    18052091            // generate the uniformly sampled data that we need for a volume
    18062092            int ngen = 0;
     2093            double nzero_min = 0.0;
    18072094            for (iz=0; iz < nz; iz++) {
    18082095                double zval = z0 + iz*dmin;
     
    18132100                        double v = field.value(xval,yval,zval);
    18142101
     2102                        if (v != 0.0f && v < nzero_min)
     2103                        {
     2104                            nzero_min = v;
     2105                        }
    18152106                        // scale all values [0-1], -1 => out of bounds
    18162107                        v = (isnan(v)) ? -1.0 : (v - vmin)/dv;
     
    18612152
    18622153            load_volume(index, nx, ny, nz, 4, data,
    1863                 field.valueMin(), field.valueMax());
     2154                field.valueMin(), field.valueMax(), nzero_min);
    18642155
    18652156            delete [] data;
     
    18882179 */
    18892180void load_volume(int index, int width, int height, int depth,
    1890     int n_component, float* data, double vmin, double vmax)
     2181    int n_component, float* data, double vmin, double vmax, double nzero_min)
    18912182{
    18922183    while (n_volumes <= index) {
     
    19012192
    19022193    volume[index] = new Volume(0.f, 0.f, 0.f, width, height, depth, 1.,
    1903                                  n_component, data, vmin, vmax);
     2194                                 n_component, data, vmin, vmax, nzero_min);
    19042195    assert(volume[index]!=0);
    19052196}
     
    19902281  win_width = w;
    19912282  win_height = h;
     2283
     2284    if (g_fonts)
     2285    {
     2286        g_fonts->resize(w, h);
     2287    }
    19922288
    19932289  //fprintf(stderr, "screen_buffer size: %d\n", sizeof(screen_buffer));
     
    22122508        (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
    22132509
     2510    Tcl_CreateCommand(interp, "axis", AxisCmd,
     2511        (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     2512
     2513    Tcl_CreateCommand(interp, "grid", GridCmd,
     2514        (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     2515
     2516    Tcl_CreateCommand(interp, "heightmap", HeightMapCmd,
     2517        (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     2518
    22142519    // get screenshot
    22152520    Tcl_CreateCommand(interp, "screenshot", ScreenShotCmd,
     
    29753280
    29763281        //now render things in the scene
    2977         draw_3d_axis();
     3282        if (axis_on)
     3283        {
     3284            draw_3d_axis();
     3285        }
     3286
     3287        if (g_grid->isVisible())
     3288        {
     3289            g_grid->render();
     3290        }
    29783291
    29793292        //lic->render();        //display the line integral convolution result
     
    29883301        g_vol_render->render_all();
    29893302        perf->disable();
     3303
     3304        for (int ii = 0; ii < g_heightMap.size(); ++ii)
     3305        {
     3306            if (g_heightMap[ii]->isVisible())
     3307                g_heightMap[ii]->render();
     3308        }
    29903309
    29913310        glPopMatrix();
     
    32433562*/
    32443563
     3564void removeAllData()
     3565{
     3566    //
     3567}
    32453568
    32463569
     
    33083631    glutMainLoop();
    33093632
     3633    removeAllData();
     3634
    33103635    NvExit();
    33113636
  • trunk/vizservers/nanovis/shaders/one_volume.cg

    r524 r776  
    5656    float normal_dot_half = max(dot(normal, half_vector), 0);
    5757
    58     float ambient = 0.8;
     58    //float ambient = 0.8;
     59    float ambient = 0.2;
    5960    float diffuse = normal_dot_light * renderParameters.z;
    6061    float specular = pow(normal_dot_half, renderParameters.w)*(1-ambient-diffuse);
Note: See TracChangeset for help on using the changeset viewer.