Changeset 5550


Ignore:
Timestamp:
May 18, 2015, 10:42:02 PM (4 years ago)
Author:
ldelgass
Message:

whitespace

Location:
nanovis/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • nanovis/trunk/HeightMap.cpp

    r5478 r5550  
    2424double HeightMap::valueMax = 1.0;
    2525
    26 HeightMap::HeightMap() : 
     26HeightMap::HeightMap() :
    2727    _vertexBufferObjectID(0),
    2828    _texcoordBufferObjectID(0),
     
    5252    }
    5353    if (_heights != NULL) {
    54         delete [] _heights;
    55     }
    56 }
    57 
    58 void 
     54        delete [] _heights;
     55    }
     56}
     57
     58void
    5959HeightMap::render(RenderContext *renderContext)
    6060{
     
    8686        glDepthRange(0.001, 1.0);
    8787    }
    88        
     88
    8989    glEnable(GL_DEPTH_TEST);
    9090
     
    108108            glEnable(GL_TEXTURE_1D);
    109109            _transferFunc->getTexture()->activate();
    110  
     110
    111111            glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    112112        }
     
    120120#define _TRIANGLES_
    121121#ifdef _TRIANGLES_
    122         glDrawElements(GL_TRIANGLES, _indexCount, GL_UNSIGNED_INT, 
     122        glDrawElements(GL_TRIANGLES, _indexCount, GL_UNSIGNED_INT,
    123123                       _indexBuffer);
    124124#else
    125         glDrawElements(GL_QUADS, _indexCount, GL_UNSIGNED_INT, 
     125        glDrawElements(GL_QUADS, _indexCount, GL_UNSIGNED_INT,
    126126                       _indexBuffer);
    127127#endif
     
    145145            glDisable(GL_BLEND);
    146146            glDisable(GL_TEXTURE_2D);
    147             glColor4f(_contourColor.x, _contourColor.y, _contourColor.z, 
     147            glColor4f(_contourColor.x, _contourColor.y, _contourColor.z,
    148148                      _opacity /*1.0f*/);
    149149            glDepthRange (0.0, 0.999);
     
    158158}
    159159
    160 void 
     160void
    161161HeightMap::createIndexBuffer(int xCount, int zCount, float* heights)
    162162{
    163163    if (_indexBuffer != NULL) {
    164164        delete [] _indexBuffer;
    165         _indexBuffer = NULL;
     165        _indexBuffer = NULL;
    166166    }
    167167    _indexCount = (xCount - 1) * (zCount - 1) * 6;
    168168    _indexBuffer = new int[_indexCount];
    169    
     169
    170170    int i, j;
    171171    int boundaryWidth = xCount - 1;
     
    188188                index4 = i * xCount + j + 1;
    189189                if (isnan(heights[index4])) index4Valid = false;
    190            
     190
    191191#ifdef _TRIANGLES_
    192192                if (index1Valid && index2Valid && index3Valid) {
     
    227227}
    228228
    229 void 
     229void
    230230HeightMap::reset()
    231231{
    232232    if (_vertexBufferObjectID) {
    233233        glDeleteBuffers(1, &_vertexBufferObjectID);
    234         _vertexBufferObjectID = 0;
     234        _vertexBufferObjectID = 0;
    235235    }
    236236    if (_texcoordBufferObjectID) {
    237237        glDeleteBuffers(1, &_texcoordBufferObjectID);
    238         _texcoordBufferObjectID = 0;
     238        _texcoordBufferObjectID = 0;
    239239    }
    240240    if (_contour != NULL) {
    241241        delete _contour;
    242         _contour = NULL;
     242        _contour = NULL;
    243243    }
    244244    if (_indexBuffer != NULL) {
    245245        delete [] _indexBuffer;
    246         _indexBuffer = NULL;
     246        _indexBuffer = NULL;
    247247    }
    248248}
    249249#if 0
    250 void 
     250void
    251251HeightMap::setHeight(int xCount, int yCount, Vector3f *heights)
    252252{
     
    262262        if (min > heights[i].y) {
    263263            min = heights[i].y;
    264         } 
     264        }
    265265        if (max < heights[i].y) {
    266266            max = heights[i].y;
     
    284284        texcoord[i].set(0, 0, heights[i].y);
    285285    }
    286    
     286
    287287    glGenBuffers(1, &_vertexBufferObjectID);
    288288    glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferObjectID);
    289     glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof( Vector3f ), heights, 
    290         GL_STATIC_DRAW);
     289    glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof( Vector3f ), heights,
     290        GL_STATIC_DRAW);
    291291    glGenBuffers(1, &_texcoordBufferObjectID);
    292292    glBindBuffer(GL_ARRAY_BUFFER, _texcoordBufferObjectID);
    293     glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(float) * 3, texcoord, 
    294         GL_STATIC_DRAW);
     293    glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(float) * 3, texcoord,
     294        GL_STATIC_DRAW);
    295295    glBindBuffer(GL_ARRAY_BUFFER, 0);
    296    
     296
    297297    delete [] texcoord;
    298    
     298
    299299    if (_contour != NULL) {
    300300        delete _contour;
    301         _contour = NULL;
     301        _contour = NULL;
    302302    }
    303303    ContourLineFilter lineFilter;
     
    315315}
    316316#endif
    317 void 
    318 HeightMap::setHeight(float xMin, float yMin, float xMax, float yMax, 
     317void
     318HeightMap::setHeight(float xMin, float yMin, float xMax, float yMax,
    319319                     int xNum, int yNum, float *heights)
    320320{
    321321    _vertexCount = xNum * yNum;
    322322    _xNum = xNum, _yNum = yNum;
    323     _heights = heights; 
     323    _heights = heights;
    324324    reset();
    325    
     325
    326326    // Get the min/max of the heights. */
    327327    float min, max;
     
    336336#ifdef notdef
    337337    if (retainScale_) {
    338         // Check the units of each axis.  If they are the same, we want to
    339         // retain the surface's aspect ratio when transforming coordinates to
    340         // the grid. Use the range of the longest axis when the units are the
    341         // same. 
    342         if (xAxis.units() != NULL) && (xAxis.units() == yAxis.units()) {
    343         }
    344         if (yAxis.units() != NULL) && (yAxis.units() == zAxis.units()) {
    345         }
     338        // Check the units of each axis.  If they are the same, we want to
     339        // retain the surface's aspect ratio when transforming coordinates to
     340        // the grid. Use the range of the longest axis when the units are the
     341        // same.
     342        if (xAxis.units() != NULL) && (xAxis.units() == yAxis.units()) {
     343        }
     344        if (yAxis.units() != NULL) && (yAxis.units() == zAxis.units()) {
     345        }
    346346    }
    347347#endif
     
    353353
    354354    min = 0.0, max = 1.0;
    355     xMin = yMin = min = 0.0; 
     355    xMin = yMin = min = 0.0;
    356356    xMax = yMax = max = 1.0;
    357357    // Save the scales.
     
    361361
    362362    _centerPoint.set(0.5, 0.5, 0.5);
    363    
     363
    364364#ifndef notdef
    365365    Vector3f* texcoord = new Vector3f[_vertexCount];
     
    367367        texcoord[i].set(0, 0, heights[i]);
    368368    }
    369    
    370     Vector3f* map = createHeightVertices(xMin, yMin, xMax, yMax, xNum, yNum, 
    371                                         heights);
    372    
     369
     370    Vector3f* map = createHeightVertices(xMin, yMin, xMax, yMax, xNum, yNum,
     371                                        heights);
     372
    373373    glGenBuffers(1, &_vertexBufferObjectID);
    374374    glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferObjectID);
    375     glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(Vector3f), map, 
     375    glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(Vector3f), map,
    376376        GL_STATIC_DRAW);
    377377    glGenBuffers(1, &_texcoordBufferObjectID);
    378378    glBindBuffer(GL_ARRAY_BUFFER, _texcoordBufferObjectID);
    379     glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(float) * 3, texcoord, 
     379    glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(float) * 3, texcoord,
    380380        GL_STATIC_DRAW);
    381381    glBindBuffer(GL_ARRAY_BUFFER, 0);
    382    
     382
    383383    delete [] texcoord;
    384    
    385    
     384
     385
    386386    if (_contour != NULL) {
    387387        delete _contour;
    388         _contour = NULL;
     388        _contour = NULL;
    389389    }
    390390    ContourLineFilter lineFilter;
     
    398398
    399399Vector3f *
    400 HeightMap::createHeightVertices(float xMin, float yMin, float xMax, 
    401                                 float yMax, int xNum, int yNum, float *height)
     400HeightMap::createHeightVertices(float xMin, float yMin, float xMax,
     401                                float yMax, int xNum, int yNum, float *height)
    402402{
    403403    Vector3f* vertices = new Vector3f[xNum * yNum];
     
    405405    Vector3f* dstData = vertices;
    406406    float* srcData = height;
    407    
     407
    408408    for (int y = 0; y < yNum; ++y) {
    409409        float yCoord;
    410410
    411         yCoord = yMin + ((yMax - yMin) * y) / (yNum - 1); 
     411        yCoord = yMin + ((yMax - yMin) * y) / (yNum - 1);
    412412        for (int x = 0; x < xNum; ++x) {
    413413            float xCoord;
    414414
    415             xCoord = xMin + ((xMax - xMin) * x) / (xNum - 1); 
     415            xCoord = xMin + ((xMax - xMin) * x) / (xNum - 1);
    416416            dstData->set(xCoord, *srcData, yCoord);
    417417
     
    426426 * \brief Maps the data coordinates of the surface into the grid's axes.
    427427 */
    428 void 
     428void
    429429HeightMap::mapToGrid(Grid *grid)
    430430{
     
    447447    float *normHeights = new float[count];
    448448    for (p = _heights, pend = p + count, q = normHeights; p < pend; p++, q++) {
    449         *q = (*p - bbox.min.y) * yScale;
     449        *q = (*p - bbox.min.y) * yScale;
    450450    }
    451451    Vector3f *t, *texcoord;
     
    465465
    466466    Vector3f* vertices;
    467     vertices = createHeightVertices(xMin, zMin, xMax, zMax, _xNum, _yNum, 
    468         normHeights);
    469    
     467    vertices = createHeightVertices(xMin, zMin, xMax, zMax, _xNum, _yNum,
     468        normHeights);
     469
    470470    glGenBuffers(1, &_vertexBufferObjectID);
    471471    glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferObjectID);
    472     glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(Vector3f), vertices, 
     472    glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(Vector3f), vertices,
    473473        GL_STATIC_DRAW);
    474474    glGenBuffers(1, &_texcoordBufferObjectID);
    475475    glBindBuffer(GL_ARRAY_BUFFER, _texcoordBufferObjectID);
    476     glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(float) * 3, texcoord, 
     476    glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(float) * 3, texcoord,
    477477        GL_STATIC_DRAW);
    478478    glBindBuffer(GL_ARRAY_BUFFER, 0);
     
    481481    if (_contour != NULL) {
    482482        delete _contour;
    483         _contour = NULL;
     483        _contour = NULL;
    484484    }
    485485    ContourLineFilter lineFilter;
    486486    //lineFilter.transferFunction(_transferFunc);
    487487    _contour = lineFilter.create(0.0f, 1.0f, 10, vertices, _xNum, _yNum);
    488    
     488
    489489    this->createIndexBuffer(_xNum, _yNum, normHeights);
    490490    delete [] normHeights;
  • nanovis/trunk/HeightMap.h

    r3630 r5550  
    4141     *@param height a pointer value adrressing xCount * yCount values of heights
    4242     */
    43     void setHeight(float startX, float startY, float endX, float endY, 
    44                    int xCount, int yCount, float *height);
     43    void setHeight(float startX, float startY, float endX, float endY,
     44                   int xCount, int yCount, float *height);
    4545#if 0
    4646    /**
     
    100100    float opacity()
    101101    {
    102         return _opacity;
     102        return _opacity;
    103103    }
    104104
     
    108108    void setLineContourColor(float *rgb)
    109109    {
    110         _contourColor.x = rgb[0];
    111         _contourColor.y = rgb[1];
    112         _contourColor.z = rgb[2];
     110        _contourColor.x = rgb[0];
     111        _contourColor.y = rgb[1];
     112        _contourColor.z = rgb[2];
    113113    }
    114114
     
    142142    vrmath::Vector3f _scale;
    143143    vrmath::Vector3f _centerPoint;
    144     int _xNum, _yNum;           // Number of elements x and y axes in grid.
    145     float *_heights;            // Array of original (unscaled) heights
    146                                 // (y-values)
     144    int _xNum, _yNum;          // Number of elements x and y axes in grid.
     145    float *_heights;           // Array of original (unscaled) heights
     146                               // (y-values)
    147147};
    148148
Note: See TracChangeset for help on using the changeset viewer.