Ignore:
Timestamp:
Jan 2, 2008 11:00:15 AM (17 years ago)
Author:
vrinside
Message:

Modified scaling grids and heightmaps in order to match the grid and the heightmap. It is still needed to rendering axis.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/vizservers/nanovis/HeightMap.cpp

    r835 r837  
    1515
    1616HeightMap::HeightMap()
    17 : _contour(0), _colorMap(0), _indexBuffer(0), _vertexBufferObjectID(0), _vertexCount(0), _textureBufferObjectID(0),
    18   _contourVisible(true), _scale(1.0f, 1.0f, 1.0f), _contourColor(1.0f, 0.0f, 0.0f)
     17: _contour(0), _colorMap(0), _indexBuffer(0), _indexCount(0), _vertexBufferObjectID(0), _vertexCount(0),
     18    _textureBufferObjectID(0), _contourVisible(true), _scale(1.0f, 1.0f, 1.0f), _contourColor(1.0f, 0.0f, 0.0f), _visible(false),
     19    _vmin(0.0f), _vmax(0.0f), _centerPoint(0.0f, 0.0f, 0.0f)
    1920{
    2021        _shader = new NvShader();
     
    4243{
    4344    glPushMatrix();
    44     glScalef(_scale.x, _scale.y, _scale.z);
    45     glTranslatef(-0.5f, -0.5f, -0.5f);
     45
     46    if (_scale.x != 0)
     47    {
     48        glScalef(1 / _scale.x, 1 / _scale.x , 1 / _scale.x);
     49    }
     50
     51    glTranslatef(-_centerPoint.x, - _centerPoint.y, - _centerPoint.z);
     52
    4653        if (_contour)
    4754        {
     
    208215            if (_vmin > heights[i].y) {
    209216                _vmin = heights[i].y;
    210             } else if (_vmax < heights[i].y) {
     217            }
     218        if (_vmax < heights[i].y) {
    211219                _vmax = heights[i].y;
    212220            }
    213221        }
     222
     223    _scale.x = 1.0f;
     224    _scale.z = _vmax - _vmin;
     225    _scale.y = 1.0f;
     226
     227    _centerPoint.set(_scale.x * 0.5, _scale.z * 0.5 + _vmin, _scale.y * 0.5);
    214228
    215229        Vector3* texcoord = (Vector3*) malloc(count * sizeof(Vector3));
     
    259273{
    260274        _vertexCount = xCount * yCount;
     275
    261276        reset();
    262277
     
    266281            if (_vmin > heights[i]) {
    267282                _vmin = heights[i];
    268             } else if (_vmax < heights[i]) {
     283            }
     284
     285        if (_vmax < heights[i]) {
    269286                _vmax = heights[i];
    270287            }
    271288        }
    272     //_scale.x = endX - startX;
    273     //_scale.y = (endY - startY) / _scale.x;
    274     //_scale.z = max / _scale.z;
     289
     290    _scale.x = endX - startX;
     291    _scale.y = _vmax - _vmin;
     292    _scale.z = endY - startY;
     293
     294    _centerPoint.set(_scale.x * 0.5 + startX, _scale.y * 0.5 + _vmin, _scale.z * 0.5 + startY);
    275295
    276296        Vector3* texcoord = (Vector3*) malloc(count * sizeof(Vector3));
    277         for (int i = 0; i < count; ++i) {
     297        for (int i = 0; i < count; ++i)
     298    {
    278299            texcoord[i].set(0, 0, heights[i]);
    279300        }
Note: See TracChangeset for help on using the changeset viewer.