⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 teheightmap.h

📁 海量地形数据漫游系统,对于OPENGL开发人员具有一定的参考
💻 H
字号:
//##################################################//# $Id: TeHeightMap.h 28 2005-08-28 10:37:47Z peciva $#ifndef TE_HEIGHT_MAP_H#define TE_HEIGHT_MAP_H/*****************************************************************************\ * * TeHeightMap.h * * TeHeightMap - height map class * * Author: Martin Havl龛ek (xhavli15 AT stud.fit.vutbr.cz) * Contributors: PCJohn (peciva AT fit.vutbr.cz) * * ---------------------------------------------------------------------------- * * THIS SOFTWARE IS NOT COPYRIGHTED * * This source code is offered for use in the public domain. * You may use, modify or distribute it freely. * * This source code is distributed in the hope that it will be useful but * WITHOUT ANY WARRANTY.  ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY * DISCLAIMED.  This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * If you find the source code useful, authors will kindly welcome * if you give them credit and keep their names with their source code. *\*****************************************************************************//** * TeHeightMap class header file. * * \file TeHeightMap.h * \author Martin Havl龛ek (martyn AT seznam.cz) * \author PCJohn (peciva AT fit.vutbr.cz) */#include <Inventor/SbLinear.h>/** * Height map representation. * * This class provides many methods that cover all relevant operations * that can be done with heightmap values. * * The methods can be devided into several categories: * \li Set of constructors - these provide variety of ways how to initialize *     the heightmap object. * \li Size management - change resolution of the map without loosing values. * \li Setting, getting and copying values. * \li Statistics gathering - minimal, maximal and average height. * \li Vertical shifts. * \li Algebraic operations. * \li Generating values and their filtering. */class TeHeightMap {  friend class TeFaultFormation;  friend class TeLinearFilter;private:  /** Heightmap x size. \sa getResolution(), setResolution() */  int resx;  /** Heightmap y size. \sa getResolution(), setResolution() */  int resy;  /** Array to store heightmap values. \sa getValues(), startEditing() */  float *values;  /** Minimal height storage \sa getMinValue(), getStats() */  float minValue;  /** Maximal height storage \sa getMaxValue(), getStats() */  float maxValue;  /** Average height storage \sa getAverageValue(), getStats() */  float averageValue;  /** Bitfield to store flags that indicates which statistics are valid. \sa resetFlags(), minValue, maxValue, averageValue */  struct {    unsigned int     minUpdated : 1; // bit 0    unsigned int     maxUpdated : 1; // bit 1    unsigned int averageUpdated : 1; // bit 2    // free                          // ...    // free                          // bit 31  } flags;  void resetFlags();public:  // Constructors  TeHeightMap();  TeHeightMap(const SbVec2s resolution);  TeHeightMap(const int resx, const int resy);  TeHeightMap(const TeHeightMap &hmap);  TeHeightMap(const TeHeightMap *hmap, const SbVec2s origin, const SbVec2s size);  // Destructor  ~TeHeightMap();  // Operators  TeHeightMap& operator= (const TeHeightMap &hmap);  // Heightmap size management  SbVec2s getResolution() const;  void getResolution(int &x, int &y) const;  void setResolution(const SbVec2s &newRes);  // Setting values  void setValue(const int x, const int y, const float value);  void setAllValues(const float value);  // Getting values  float getValue(const int x, const int y) const;  const float* getValues() const;  const float* operator[] (int i) const;  float* startEditing();  void finishEditing();  // Statistics  void getStats(float *min, float *max, float *average); // 1 pass  float getMinValue();  float getMaxValue();  float getAverageValue();  // Shifts  void shift(const float delta);  void shiftMinValue(const float value);  void shiftMinValue(const float value, const float old);  void shiftMaxValue(const float value);  void shiftMaxValue(const float value, const float old);  void shiftAverageValue(const float value);  void shiftAverageValue(const float value, const float old);  // Copying  void copyFrom(const TeHeightMap *hmap);  void copyFrom(const TeHeightMap *hmap, const SbVec2s &sorigin,                const SbVec2s &size, const SbVec2s &dorigin = SbVec2s(0,0));  // Adding (with rate, 1.0==100%)  void addFrom(const TeHeightMap *hmap, const float rate);  void addFrom(const TeHeightMap *hmap, const SbVec2s &sorigin,               const SbVec2s &size, const SbVec2s &dorigin,               const float rate);  void addAll(const float value);  // Subtracting (with rate, 1.0==100%)  void subtractFrom(const TeHeightMap *hmap, const float rate);  void subtractFrom(const TeHeightMap *hmap, const SbVec2s &sorigin,                    const SbVec2s &size, const SbVec2s &dorigin,                    const float rate);  void subtractAll(const float value);  // Multiplying (with rate, 1.0==100%)  void multiplyFrom(const TeHeightMap *hmap, const float rate);  void multiplyFrom(const TeHeightMap *hmap, const SbVec2s &sorigin,                    const SbVec2s &size, const SbVec2s &dorigin,                    const float rate);  void multiplyAll(const float value);  // Filtering  void filter_Linear(const float coef, const int times);  // ... more to come ...  // Generating  void generate_FaultFormation(const unsigned int seed, const int num_faults,                               const float min_delta, const float max_delta);  void generate_4HMOverlap_Mask();  // ... more to come ...  // FOR DEBUGGING ONLY  void dump();};#endif /* TE_HEIGHT_MAP_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -