Ignore:
Timestamp:
Mar 9, 2012 10:12:14 AM (9 years ago)
Author:
ldelgass
Message:

Refactor texture classes, misc. cleanups, cut down on header pollution -- still
need to fix header deps in Makefile.in

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/HeightMap.h

    r2798 r2831  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #ifndef _HEIGHT_MAP_H_
    3 #define _HEIGHT_MAP_H_
     2#ifndef HEIGHTMAP_H
     3#define HEIGHTMAP_H
    44
    55#include <Cg/cgGL.h>
    66#include <Cg/cg.h>
     7
    78#include <R2/graphics/R2Geometry.h>
     9
    810#include "TransferFunction.h"
    911#include "NvShader.h"
    1012#include "Vector3.h"
    11 #include <RenderContext.h>
     13#include "RenderContext.h"
    1214#include "AxisRange.h"
    1315
     
    2224 *@brief Create a surface from height map and line contour of the generated surface
    2325 */
     26class HeightMap
     27{
     28public:
     29    HeightMap();
    2430
    25 class HeightMap {
     31    ~HeightMap();
     32
     33    void render(graphics::RenderContext *renderContext);
     34
     35    void render_topview(graphics::RenderContext *renderContext,
     36                        int render_width, int render_height);
     37
     38    /**
     39     *@brief Create a height map with heigh values
     40     *@param startX a x position of the first height value
     41     *@param startY a y position of the first height value
     42     *@param endX a x position of the last height value
     43     *@param endY a y position of the last height value
     44     *@param xCount the number of columns of height values
     45     *@param yCount the number of rows of height values
     46     *@param height a pointer value adrressing xCount * yCount values of heights
     47     */
     48    void setHeight(float startX, float startY, float endX, float endY,
     49                   int xCount, int yCount, float *height);
     50
     51    /**
     52     *@brief Create a height map with a set of points
     53     *@param xCount the number of columns of height values
     54     *@param yCount the number of rows of height values
     55     */
     56    void setHeight(int xCount, int yCount, Vector3 *heights);
     57
     58    void MapToGrid(Grid *gridPtr);
     59
     60    /**
     61     *@brief Define a color map for color shading of heightmap
     62     */
     63    void transferFunction(TransferFunction *tfPtr)
     64    {
     65        _tfPtr = tfPtr;
     66    }
     67
     68    /**
     69     *@brief Get the color map defined for shading of this heightmap
     70     */
     71    TransferFunction *transferFunction()
     72    {
     73        return _tfPtr;
     74    }
     75
     76    /**
     77     *@brief Set the visibility of the height map
     78     */
     79    void setVisible(bool visible)
     80    {
     81        _visible = visible;
     82    }
     83
     84    /**
     85     *@brief Return the status of the visibility
     86     */
     87    bool isVisible() const
     88    {
     89        return _visible;
     90    }
     91
     92    /**
     93     *@brief Set the visibility of the line contour
     94     */
     95    void setLineContourVisible(bool visible)
     96    {
     97        _contourVisible = visible;
     98    }
     99
     100    void setTopLineContourVisible(bool visible)
     101    {
     102        _topContourVisible = visible;
     103    }
     104
     105    void opacity(float opacity)
     106    {
     107        _opacity = opacity;
     108    }
     109
     110    float opacity()
     111    {
     112        return _opacity;
     113    }
     114
     115    /**
     116     *@brief Defind the color of the line contour
     117     */
     118    void setLineContourColor(float *rgb)
     119    {
     120        _contourColor.x = rgb[0];
     121        _contourColor.y = rgb[1];
     122        _contourColor.z = rgb[2];
     123    }
     124
     125    AxisRange xAxis, yAxis, zAxis, wAxis;
     126    static bool update_pending;
     127    static double valueMin, valueMax;
     128
     129private:
     130    void createIndexBuffer(int xCount, int zCount, float* heights);
     131    Vector3 *createHeightVertices(float startX, float startY,
     132                                  float endX, float endY,
     133                                  int xCount, int yCount, float  *height);
     134    void reset();
     135
    26136    unsigned int _vertexBufferObjectID;
    27137    unsigned int _textureBufferObjectID;
     
    29139    CGparameter _tfParam;
    30140    CGparameter _opacityParam;
    31     R2Geometry* _contour;
    32     R2Geometry* _topContour;
    33     TransferFunction* _tfPtr;
     141    R2Geometry *_contour;
     142    R2Geometry *_topContour;
     143    TransferFunction *_tfPtr;
    34144    float _opacity;
    35     NvShader* _shader;
     145    NvShader *_shader;
    36146    int *_indexBuffer;
    37147    int _indexCount;
     
    47157    float *_heights;            // Array of original (unscaled) heights
    48158                                // (y-values)
    49 public :
    50     AxisRange xAxis, yAxis, zAxis, wAxis;
    51     static bool update_pending;
    52     static double valueMin, valueMax;
    53 
    54     /**
    55      *@brief Constructor
    56      */
    57     HeightMap();
    58     /**
    59      *@brief Destructor
    60      */
    61     ~HeightMap();
    62 
    63 private :
    64     void createIndexBuffer(int xCount, int zCount, float* heights);
    65         Vector3* createHeightVertices(float startX, float startY, float endX, float endY, int xCount, int yCount, float* height);
    66         void reset();
    67 public :
    68     void render(graphics::RenderContext* renderContext);
    69     void render_topview(graphics::RenderContext* renderContext, int render_width, int render_height);
    70     /**
    71      *@brief Create a height map with heigh values
    72      *@param startX a x position of the first height value
    73      *@param startY a y position of the first height value
    74      *@param endX a x position of the last height value
    75      *@param endY a y position of the last height value
    76      *@param xCount the number of columns of height values
    77      *@param yCount the number of rows of height values
    78      *@param height a pointer value adrressing xCount * yCount values of heights
    79      */
    80     void setHeight(float startX, float startY, float endX, float endY,
    81                    int xCount, int yCount, float* height);
    82 
    83     /**
    84      *@brief Create a height map with a set of points
    85      *@param xCount the number of columns of height values
    86      *@param yCount the number of rows of height values
    87      */
    88     void setHeight(int xCount, int yCount, Vector3* heights);
    89 
    90     void MapToGrid(Grid *gridPtr);
    91     /**
    92      *@brief Define a color map for color shading of heightmap
    93      */
    94     void transferFunction(TransferFunction* tfPtr) {
    95         _tfPtr = tfPtr;
    96     }
    97     /**
    98      *@brief Get the color map defined for shading of this heightmap
    99      */
    100     TransferFunction *transferFunction(void) {
    101         return _tfPtr;
    102     }
    103     /**
    104      *@brief Set the visibility of the height map
    105      */
    106     void setVisible(bool visible) {
    107         _visible = visible;
    108     }
    109 
    110     /**
    111      *@brief Return the status of the visibility
    112      */
    113     bool isVisible() const {
    114         return _visible;
    115     }
    116     /**
    117      *@brief Set the visibility of the line contour
    118      */
    119     void setLineContourVisible(bool visible) {
    120         _contourVisible = visible;
    121     }
    122 
    123     void setTopLineContourVisible(bool visible) {
    124             _topContourVisible = visible;
    125     }
    126 
    127     void opacity(float opacity) {
    128         _opacity = opacity;
    129     }
    130     float opacity(void) {
    131         return _opacity;
    132     }
    133     /**
    134      *@brief Defind the color of the line contour
    135      */
    136     void setLineContourColor(float *rgb) {
    137         _contourColor.x = rgb[0];
    138         _contourColor.y = rgb[1];
    139         _contourColor.z = rgb[2];
    140     }
    141159};
    142160
Note: See TracChangeset for help on using the changeset viewer.