Changeset 1188


Ignore:
Timestamp:
Oct 16, 2008 1:30:45 PM (16 years ago)
Author:
vrinside
Message:
 
Location:
trunk/packages/vizservers/nanovis
Files:
8 edited

Legend:

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

    r1163 r1188  
    4040
    4141#include <tcl.h>
     42#include <stdlib.h>
    4243#include "Trace.h"
    4344#include "Command.h"
     
    13141315    //
    13151316    if (NanoVis::volume[n] != NULL) {
     1317        //NanoVis::volume[n]->set_n_slice(512-n);
    13161318        NanoVis::volume[n]->set_n_slice(256-n);
    13171319        NanoVis::volume[n]->disable_cutplane(0);
     
    18971899            //
    18981900            if (volPtr != NULL) {
    1899                 volPtr->set_n_slice(256-n);
     1901                //volPtr->set_n_slice(256-n);
     1902                volPtr->set_n_slice(512-n);
    19001903                volPtr->disable_cutplane(0);
    19011904                volPtr->disable_cutplane(1);
     
    21292132    // GEORGE
    21302133
    2131 
    21322134    NanoVis::render_2d_contour(heightmap, image_width, image_height);
    21332135   
     
    21412143    srand((unsigned)time(NULL));
    21422144
    2143     int size = 20 * 200;
     2145    int size = 20 * 20;
    21442146    double sigma = 5.0;
    21452147    double mean = exp(0.0) / (sigma * sqrt(2.0));
    21462148    float* data = (float*) malloc(sizeof(float) * size);
    21472149
    2148     float x;
     2150    float x, y;
    21492151    for (int i = 0; i < size; ++i) {
    21502152        x = - 10 + i%20;
    2151         data[i] = exp(- (x * x)/(2 * sigma * sigma)) /
     2153        y = - 10 + (i/20);
     2154        data[i] = exp(- (x * y)/(2 * sigma * sigma)) /
    21522155            (sigma * sqrt(2.0)) / mean * 2 + 1000;
     2156        //data[i] = ((float)rand()) / RAND_MAX * 1.0;
    21532157    }
    21542158
     
    21582162    float miny = 0.5f;
    21592163    float maxy = 3.5f;
    2160     hmPtr->setHeight(minx, miny, maxx, maxy, 20, 200, data);
     2164    hmPtr->setHeight(minx, miny, maxx, maxy, 20, 20, data);
    21612165    hmPtr->setColorMap(NanoVis::get_transfunc("default"));
    21622166    hmPtr->setVisible(true);
     
    21642168    NanoVis::grid->setVisible(true);
    21652169    NanoVis::heightMap.push_back(hmPtr);
     2170
     2171    int image_width = 512;
     2172    int image_height = 512;
     2173
     2174    NanoVis::render_2d_contour(hmPtr, image_width, image_height);
     2175
    21662176    return TCL_OK;
    21672177}
     
    22052215    // HELP ME
    22062216    // GOERGE
    2207     {"topview",      1, HeightMapTopView,     3, 3, "model",},
     2217    {"topview",      2, HeightMapTopView,     2, 2, "",},
    22082218};
    22092219static int nHeightMapOps = NumCmdSpecs(heightMapOps);
  • trunk/packages/vizservers/nanovis/HeightMap.cpp

    r1161 r1188  
    2323
    2424#define TOPCONTOUR      0
     25//#define TOPCONTOUR    1
    2526HeightMap::HeightMap() :
    2627    _vertexBufferObjectID(0),
     
    512513}
    513514
     515void HeightMap::render_topview(graphics::RenderContext* renderContext, int render_width, int render_height)
     516{
     517   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     518    glPushAttrib(GL_VIEWPORT_BIT);
     519    glViewport(0, 0, render_width, render_height);
     520    glMatrixMode(GL_PROJECTION);
     521    glPushMatrix();
     522    glLoadIdentity();
     523    //gluOrtho2D(0, render_width, 0, render_height);
     524    glOrtho(-.5, .5, -.5, .5, -50, 50);
     525    glMatrixMode(GL_MODELVIEW);
     526    glPushMatrix();
     527    glLoadIdentity();
     528
     529    glTranslatef(0.0, 0.0, -10.0);
     530
     531    // put camera rotation and traslation
     532    //glScalef(1 / _scale.x, 1 / _scale.y , 1 / _scale.z);
     533
     534    if (renderContext->getCullMode() == graphics::RenderContext::NO_CULL) {
     535        glDisable(GL_CULL_FACE);
     536    } else {
     537        glEnable(GL_CULL_FACE);
     538        glCullFace((GLuint) renderContext->getCullMode());
     539    }
     540
     541    glPolygonMode(GL_FRONT_AND_BACK, (GLuint) renderContext->getPolygonMode());
     542    glShadeModel((GLuint) renderContext->getShadingModel());
     543
     544    glPushMatrix();
     545
     546    //glTranslatef(-_centerPoint.x, -_centerPoint.y, -_centerPoint.z);
     547
     548    //glScalef(0.01, 0.01, 0.01f);
     549    glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
     550    glTranslatef(-_centerPoint.x, -_centerPoint.y, -_centerPoint.z);
     551    if (_contour != NULL) {
     552        glDepthRange (0.001, 1.0);
     553    }
     554       
     555    glEnable(GL_DEPTH_TEST);
     556
     557    glEnable(GL_BLEND);
     558    glEnable(GL_TEXTURE_2D);
     559    if (_vertexBufferObjectID)
     560    {
     561        printf("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\n");
     562        glColor3f(1.0f, 1.0f, 1.0f);
     563        glShadeModel(GL_SMOOTH);
     564        glEnable(GL_BLEND);
     565        glEnableClientState(GL_VERTEX_ARRAY);
     566        glDisableClientState(GL_COLOR_ARRAY);
     567        glDisableClientState(GL_INDEX_ARRAY);
     568        glDisableClientState(GL_NORMAL_ARRAY);
     569       
     570        if (_colorMap) {
     571            cgGLBindProgram(_shader->getFP());
     572            cgGLEnableProfile(CG_PROFILE_FP30);
     573           
     574            cgGLSetTextureParameter(_tf, _colorMap->id);
     575            cgGLEnableTextureParameter(_tf);
     576           
     577            glEnable(GL_TEXTURE_1D);
     578            _colorMap->getTexture()->activate();
     579           
     580            glEnableClientState(GL_TEXTURE_COORD_ARRAY);
     581        }
     582        else {
     583            glDisableClientState(GL_TEXTURE_COORD_ARRAY);
     584        }
     585       
     586        glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferObjectID);
     587        glVertexPointer(3, GL_FLOAT, 12, 0);
     588       
     589        glBindBuffer(GL_ARRAY_BUFFER, _textureBufferObjectID);
     590        ::glTexCoordPointer(3, GL_FLOAT, 12, 0);
     591       
     592#define _TRIANGLES_
     593#ifdef _TRIANGLES_
     594        glDrawElements(GL_TRIANGLES, _indexCount, GL_UNSIGNED_INT,
     595                       _indexBuffer);
     596#else                   
     597        glDrawElements(GL_QUADS, _indexCount, GL_UNSIGNED_INT,
     598                       _indexBuffer);
     599#endif
     600
     601        glBindBuffer(GL_ARRAY_BUFFER, 0);
     602       
     603        glDisableClientState(GL_VERTEX_ARRAY);
     604        if (_colorMap) {
     605            _colorMap->getTexture()->deactivate();
     606            glDisableClientState(GL_TEXTURE_COORD_ARRAY);
     607           
     608            cgGLDisableProfile(CG_PROFILE_FP30);
     609        }
     610    }
     611   
     612    glShadeModel(GL_FLAT);
     613    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
     614   
     615    if (_contour != NULL) {
     616        if (_contourVisible) {
     617            glDisable(GL_BLEND);
     618            glDisable(GL_TEXTURE_2D);
     619            glColor4f(_contourColor.x, _contourColor.y, _contourColor.z, 1.0f);
     620            glDepthRange (0.0, 0.999);
     621            _contour->render();
     622            glDepthRange (0.0, 1.0);
     623        }
     624
     625#if TOPCONTOUR
     626        if (_topContourVisible) {
     627            glDisable(GL_BLEND);
     628            glDisable(GL_TEXTURE_2D);
     629            glColor4f(_contourColor.x, _contourColor.y, _contourColor.z, 1.0f);
     630            //glDepthRange (0.0, 0.999);
     631            _topContour->render();
     632            //glDepthRange (0.0, 1.0);
     633        }
     634#endif
     635    }
     636   
     637    glPopMatrix();
     638    glPopMatrix();
     639
     640    glMatrixMode(GL_PROJECTION);
     641    glPushMatrix();
     642    glMatrixMode(GL_MODELVIEW);
     643
     644    glPopAttrib();
     645}
     646
  • trunk/packages/vizservers/nanovis/HeightMap.h

    r1112 r1188  
    6565public :
    6666    void render(graphics::RenderContext* renderContext);
     67    void render_topview(graphics::RenderContext* renderContext, int render_width, int render_height);
    6768    /**
    6869     *@brief Create a height map with heigh values
  • trunk/packages/vizservers/nanovis/RpDX.cpp

    r1181 r1188  
    4747
    4848    if (filename == NULL) {
    49         resultPtr->AddError("filename is NULL");
     49        //resultPtr->AddError("filename is NULL");
    5050        return;
    5151    }
     
    5656    _dxobj = DXImportDX((char*)filename,NULL,NULL,NULL,NULL);
    5757    if (_dxobj == NULL) {
    58         resultPtr->AddError("can't import DX file \"%s\"", filename);
     58        //resultPtr->AddError("can't import DX file \"%s\"", filename);
    5959        return;
    6060    }
     
    6767    dxpos = (Array) DXGetComponentValue((Field) _dxobj, (char *)"positions");
    6868    if (dxpos == NULL) {
    69         resultPtr->AddError("can't get component value of \"positions\"");
     69        //resultPtr->AddError("can't get component value of \"positions\"");
    7070        return;
    7171    }
     
    7474    fprintf(stdout, "_n = %d\n",_n);
    7575    if (type != TYPE_FLOAT) {
    76         resultPtr->AddError("\"positions\" is not type float (type=%d)\n", type);
     76        //resultPtr->AddError("\"positions\" is not type float (type=%d)\n", type);
    7777        return;
    7878    }
     
    8383    pos = (float*) DXGetArrayData(dxpos);
    8484    if (pos == NULL) {
    85         resultPtr->AddError("DXGetArrayData failed to return positions array");
     85        //resultPtr->AddError("DXGetArrayData failed to return positions array");
    8686        return;
    8787    }
     
    9191    if (DXQueryGridConnections(dxgrid, &_numAxis, NULL) == NULL) {
    9292        // raise error, data is not a regular grid and we cannot handle it
    93         resultPtr->AddError("DX says our grid is not regular, we cannot handle this data");
     93        //resultPtr->AddError("DX says our grid is not regular, we cannot handle this data");
    9494        return;
    9595    }
     
    9898    if (_positions == NULL) {
    9999        // malloc failed, raise error
    100         resultPtr->AddError("malloc of _positions array failed");
     100        //resultPtr->AddError("malloc of _positions array failed");
    101101        return;
    102102    }
     
    106106    if (_axisLen == NULL) {
    107107        // malloc failed, raise error
    108         resultPtr->AddError("malloc of _axisLen array failed");
     108        //resultPtr->AddError("malloc of _axisLen array failed");
    109109        return;
    110110    }
     
    113113    _delta = new float[_numAxis*_numAxis];
    114114    if (_delta == NULL) {
    115         resultPtr->AddError("malloc of _delta array failed");
     115        //resultPtr->AddError("malloc of _delta array failed");
    116116        return;
    117117    }
     
    120120    _origin = new float[_numAxis];
    121121    if (_origin == NULL) {
    122         resultPtr->AddError("malloc of _origin array failed");
     122        //resultPtr->AddError("malloc of _origin array failed");
    123123        return;
    124124    }
     
    127127    _max = new float[_numAxis];
    128128    if (_max == NULL) {
    129         resultPtr->AddError("malloc of _max array failed");
     129        //resultPtr->AddError("malloc of _max array failed");
    130130        return;
    131131    }
     
    151151    _data = new float[_n];
    152152    if (_data == NULL) {
    153         resultPtr->AddError("malloc of _data array failed");
     153        //resultPtr->AddError("malloc of _data array failed");
    154154        return;
    155155    }
     
    172172
    173173    default:
    174         resultPtr->AddError("don't know how to handle data of type %d\n", type);
     174        //resultPtr->AddError("don't know how to handle data of type %d\n", type);
    175175        return;
    176176    }
  • trunk/packages/vizservers/nanovis/Volume.cpp

    r1053 r1188  
    3434    pointsetIndex(-1),
    3535    enabled(true),
    36     n_slice(256),               // default value
     36    //n_slice(256),             // default value
     37    n_slice(512),               // default value
    3738    specular(6.),               // default value
    3839    diffuse(3.),                // default value
  • trunk/packages/vizservers/nanovis/define.h

    r434 r1188  
    6060void debug(char *message, double v1, double v2, double v3);
    6161
     62#define __NANOVIS_DEBUG__ 0
     63//#define __NANOVIS_DEBUG__ 1
     64
    6265#endif
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r1182 r1188  
    879879
    880880   glClearColor(0,0,0,1);
     881   //glClearColor(0.7,0.7,0.7,1);
    881882   glClear(GL_COLOR_BUFFER_BIT);
    882883
     
    24032404    //ppm_write(prefix);
    24042405    //write(0, "\n", 1);
    2405    
    2406 
    2407 
    2408 
    24092406    //plane_render->remove_plane(index);
     2407
     2408    // CURRENT
     2409    offscreen_buffer_capture();
     2410    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen
     2411        //glEnable(GL_TEXTURE_2D);
     2412        //glEnable(GL_DEPTH_TEST);
     2413    //heightmap->render_topview(renderContext, width, height);
     2414    //NanoVis::display();
     2415    if (HeightMap::update_pending) {
     2416        SetHeightmapRanges();
     2417    }
     2418
     2419    //cam->activate();
     2420
     2421    heightmap->render_topview(renderContext, width, height);
     2422
     2423    NanoVis::read_screen();
     2424    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
     2425
     2426    // INSOO TEST CODE
     2427    bmp_write_to_file(1, "/tmp");
    24102428   
    24112429    resize_offscreen_buffer(old_width, old_height);
  • trunk/packages/vizservers/nanovis/shaders/one_volume.cg

    r1000 r1188  
    6464    //float normal_dot_half = abs(dot(normal, half_vector));
    6565
    66 
    6766    float ambient = 0.8;
    6867
     
    8786  return OUT;
    8887}
     88
Note: See TracChangeset for help on using the changeset viewer.