22 #ifndef _HEIGHTMAP_HH_
23 #define _HEIGHTMAP_HH_
27 #include <boost/filesystem.hpp>
37 class TerrainGlobalOptions;
46 class GzTerrainMatGen;
108 public:
double GetHeight(
double _x,
double _y,
double _z = 1000);
120 double _outsideRadius,
double _insideRadius,
121 double _weight = 0.1);
133 double _outsideRadius,
double _insideRadius,
134 double _weight = 0.1);
146 double _outsideRadius,
double _insideRadius,
147 double _weight = 0.1);
159 double _outsideRadius,
double _insideRadius,
160 double _weight = 0.1);
165 public:
double GetAvgHeight(Ogre::Vector3 _pos,
double _brushSize);
191 public:
void SplitHeights(
const std::vector<float> &_heightmap,
int _n,
192 std::vector<std::vector<float> > &_v);
206 private:
void ModifyTerrain(Ogre::Vector3 _pos,
double _outsideRadius,
207 double _insideRadius,
double _weight,
208 const std::string &_op);
212 private:
bool InitBlendMaps(Ogre::Terrain *_terrain);
215 private:
void ConfigureTerrainDefaults();
220 private:
void DefineTerrain(
int _x,
int _y);
224 private:
void SetupShadows(
bool _enabled);
233 private:
void UpdateTerrainHash(
const std::string &_hash,
234 const boost::filesystem::path &_terrainDir);
242 private:
bool PrepareTerrainPaging(
243 const boost::filesystem::path &_terrainDirPath);
250 private:
static const unsigned int numTerrainSubdivisions;
256 private:
static const double loadRadiusFactor;
263 private:
static const double holdRadiusFactor;
267 private:
static const boost::filesystem::path hashFilename;
271 private:
static const boost::filesystem::path pagingDirname;
276 private: boost::filesystem::path gzPagingDir;
288 private:
unsigned int dataSize;
294 private: Ogre::TerrainGlobalOptions *terrainGlobals;
297 private: Ogre::TerrainGroup *terrainGroup;
300 private:
bool terrainsImported;
303 private: std::vector<std::string> diffuseTextures;
306 private: std::vector<std::string> normalTextures;
309 private: std::vector<double> worldSizes;
312 private: std::vector<double> blendHeight;
315 private: std::vector<double> blendFade;
318 private: std::vector<float> heights;
328 private: Ogre::PageManager *pageManager;
331 private: Ogre::TerrainPaging *terrainPaging;
334 private: Ogre::PagedWorld *world;
337 private: std::vector<std::vector<float> > subTerrains;
340 private:
int terrainIdx;
343 private:
bool useTerrainPaging;
346 private:
bool terrainHashChanged;
362 public Ogre::TerrainMaterialGeneratorA::SM2Profile
365 public:
SM2Profile(Ogre::TerrainMaterialGenerator *_parent,
366 const Ogre::String &_name,
const Ogre::String &_desc);
371 public: Ogre::MaterialPtr
generate(
const Ogre::Terrain *_terrain);
374 const Ogre::Terrain *_terrain);
376 public:
void UpdateParams(
const Ogre::MaterialPtr &_mat,
377 const Ogre::Terrain *_terrain);
380 const Ogre::Terrain *_terrain);
382 protected:
virtual void addTechnique(
const Ogre::MaterialPtr &_mat,
383 const Ogre::Terrain *_terrain, TechniqueType _tt);
387 public Ogre::TerrainMaterialGeneratorA::SM2Profile::ShaderHelperGLSL
390 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
394 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
398 const Ogre::MaterialPtr &_mat,
399 const Ogre::Terrain *_terrain,
bool _compositeMap);
402 const Ogre::Terrain *_terrain, TechniqueType _tt,
403 Ogre::StringUtil::StrStreamType &_outStream);
406 const Ogre::Terrain *_terrain, TechniqueType _tt,
407 Ogre::StringUtil::StrStreamType &_outStream);
410 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
412 Ogre::StringUtil::StrStreamType &_outStream);
415 const Ogre::Terrain *_terrain, TechniqueType _tt,
416 const Ogre::HighLevelGpuProgramPtr &_prog);
419 unsigned int _texCoordStart,
const SM2Profile *_prof,
420 const Ogre::Terrain *_terrain, TechniqueType _tt,
421 Ogre::StringUtil::StrStreamType &_outStream);
424 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
426 Ogre::StringUtil::StrStreamType &_outStream);
429 const Ogre::Terrain *_terrain,
431 Ogre::StringUtil::StrStreamType &_outStream);
434 const Ogre::Terrain *_terrain, TechniqueType tt,
436 Ogre::StringUtil::StrStreamType &_outStream);
439 const Ogre::Terrain *_terrain,
441 Ogre::StringUtil::StrStreamType &_outStream);
444 Ogre::uint *_texCoord, Ogre::uint *_sampler,
445 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
447 Ogre::StringUtil::StrStreamType &_outStream);
451 const Ogre::Terrain *_terrain,
453 Ogre::StringUtil::StrStreamType &_outStream);
456 const Ogre::Terrain *_terrain, TechniqueType _tt,
457 Ogre::StringUtil::StrStreamType &_outStream);
461 const Ogre::Terrain *_terrain,
463 Ogre::StringUtil::StrStreamType &_outStream);
466 const Ogre::Terrain *_terrain, TechniqueType _tt,
467 const Ogre::GpuProgramParametersSharedPtr &_params);
469 private: Ogre::String GetChannel(Ogre::uint _idx);
475 public Ogre::TerrainMaterialGeneratorA::SM2Profile::ShaderHelperCg
478 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
482 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
486 const Ogre::Terrain *_terrain, TechniqueType _tt,
487 Ogre::StringUtil::StrStreamType &_outStream);
490 const Ogre::Terrain *_terrain, TechniqueType _tt,
491 Ogre::StringUtil::StrStreamType &_outStream);
494 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
496 Ogre::StringUtil::StrStreamType &_outStream);
499 const Ogre::Terrain *_terrain, TechniqueType _tt,
500 const Ogre::HighLevelGpuProgramPtr &_prog);
503 unsigned int _texCoordStart,
const SM2Profile *_prof,
504 const Ogre::Terrain *_terrain, TechniqueType _tt,
505 Ogre::StringUtil::StrStreamType &_outStream);
508 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
510 Ogre::StringUtil::StrStreamType &_outStream);