22 #ifndef _HEIGHTMAP_HH_
23 #define _HEIGHTMAP_HH_
27 #include <boost/filesystem.hpp>
38 class TerrainGlobalOptions;
47 class GzTerrainMatGen;
102 public:
void LoadFromMsg(ConstVisualPtr &_msg);
109 public:
double GetHeight(
double _x,
double _y,
double _z = 1000);
121 double _outsideRadius,
double _insideRadius,
122 double _weight = 0.1);
134 double _outsideRadius,
double _insideRadius,
135 double _weight = 0.1);
147 double _outsideRadius,
double _insideRadius,
148 double _weight = 0.1);
160 double _outsideRadius,
double _insideRadius,
161 double _weight = 0.1);
166 public:
double GetAvgHeight(Ogre::Vector3 _pos,
double _brushSize);
170 public:
void SetWireframe(
bool _show);
174 public: Ogre::TerrainGroup *GetOgreTerrain()
const;
185 public: Ogre::TerrainGroup::RayResult GetMouseHit(
CameraPtr _camera,
192 public:
void SplitHeights(
const std::vector<float> &_heightmap,
int _n,
193 std::vector<std::vector<float> > &_v);
198 public:
unsigned int GetTerrainSubdivisionCount()
const;
207 private:
void ModifyTerrain(Ogre::Vector3 _pos,
double _outsideRadius,
208 double _insideRadius,
double _weight,
209 const std::string &_op);
213 private:
bool InitBlendMaps(Ogre::Terrain *_terrain);
216 private:
void ConfigureTerrainDefaults();
221 private:
void DefineTerrain(
int _x,
int _y);
225 private:
void SetupShadows(
bool _enabled);
234 private:
void UpdateTerrainHash(
const std::string &_hash,
235 const boost::filesystem::path &_terrainDir);
243 private:
bool PrepareTerrainPaging(
244 const boost::filesystem::path &_terrainDirPath);
247 private:
static const unsigned int numTerrainSubdivisions;
253 private:
static const double loadRadiusFactor;
260 private:
static const double holdRadiusFactor;
264 private:
static const boost::filesystem::path hashFilename;
268 private:
static const boost::filesystem::path pagingDirname;
273 private: boost::filesystem::path gzPagingDir;
285 private:
unsigned int dataSize;
291 private: Ogre::TerrainGlobalOptions *terrainGlobals;
294 private: Ogre::TerrainGroup *terrainGroup;
297 private:
bool terrainsImported;
300 private: std::vector<std::string> diffuseTextures;
303 private: std::vector<std::string> normalTextures;
306 private: std::vector<double> worldSizes;
309 private: std::vector<double> blendHeight;
312 private: std::vector<double> blendFade;
315 private: std::vector<float> heights;
325 private: Ogre::PageManager *pageManager;
328 private: Ogre::TerrainPaging *terrainPaging;
331 private: Ogre::PagedWorld *world;
334 private: std::vector<std::vector<float> > subTerrains;
337 private:
int terrainIdx;
340 private:
bool useTerrainPaging;
343 private:
bool terrainHashChanged;
350 :
public Ogre::TerrainMaterialGeneratorA
360 public Ogre::TerrainMaterialGeneratorA::SM2Profile
363 public:
SM2Profile(Ogre::TerrainMaterialGenerator *_parent,
364 const Ogre::String &_name,
const Ogre::String &_desc);
369 public: Ogre::MaterialPtr generate(
const Ogre::Terrain *_terrain);
371 public: Ogre::MaterialPtr generateForCompositeMap(
372 const Ogre::Terrain *_terrain);
374 public:
void UpdateParams(
const Ogre::MaterialPtr &_mat,
375 const Ogre::Terrain *_terrain);
377 public:
void UpdateParamsForCompositeMap(
const Ogre::MaterialPtr &_mat,
378 const Ogre::Terrain *_terrain);
380 protected:
virtual void addTechnique(
const Ogre::MaterialPtr &_mat,
381 const Ogre::Terrain *_terrain, TechniqueType _tt);
384 #pragma clang diagnostic push
385 #pragma clang diagnostic ignored "-Woverloaded-virtual"
386 #endif // ifdef __clang__
389 public Ogre::TerrainMaterialGeneratorA::SM2Profile::ShaderHelperGLSL
391 public:
virtual Ogre::HighLevelGpuProgramPtr generateVertexProgram(
392 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
395 public:
virtual Ogre::HighLevelGpuProgramPtr generateFragmentProgram(
396 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
399 public:
virtual void updateParams(
const SM2Profile *_prof,
400 const Ogre::MaterialPtr &_mat,
401 const Ogre::Terrain *_terrain,
bool _compositeMap);
403 protected:
virtual void generateVpHeader(
const SM2Profile *_prof,
404 const Ogre::Terrain *_terrain, TechniqueType _tt,
405 Ogre::StringUtil::StrStreamType &_outStream);
407 protected:
virtual void generateVpFooter(
const SM2Profile *_prof,
408 const Ogre::Terrain *_terrain, TechniqueType _tt,
409 Ogre::StringUtil::StrStreamType &_outStream);
411 protected:
virtual void generateVertexProgramSource(
412 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
414 Ogre::StringUtil::StrStreamType &_outStream);
416 protected:
virtual void defaultVpParams(
const SM2Profile *_prof,
417 const Ogre::Terrain *_terrain, TechniqueType _tt,
418 const Ogre::HighLevelGpuProgramPtr &_prog);
420 protected:
virtual unsigned int generateVpDynamicShadowsParams(
421 unsigned int _texCoordStart,
const SM2Profile *_prof,
422 const Ogre::Terrain *_terrain, TechniqueType _tt,
423 Ogre::StringUtil::StrStreamType &_outStream);
425 protected:
virtual void generateVpDynamicShadows(
426 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
428 Ogre::StringUtil::StrStreamType &_outStream);
430 protected:
virtual void generateFpHeader(
const SM2Profile *_prof,
431 const Ogre::Terrain *_terrain,
433 Ogre::StringUtil::StrStreamType &_outStream);
435 protected:
virtual void generateFpLayer(
const SM2Profile *_prof,
436 const Ogre::Terrain *_terrain, TechniqueType tt,
438 Ogre::StringUtil::StrStreamType &_outStream);
440 protected:
virtual void generateFpFooter(
const SM2Profile *_prof,
441 const Ogre::Terrain *_terrain,
443 Ogre::StringUtil::StrStreamType &_outStream);
445 protected:
virtual void generateFpDynamicShadowsParams(
446 Ogre::uint *_texCoord, Ogre::uint *_sampler,
447 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
449 Ogre::StringUtil::StrStreamType &_outStream);
451 protected:
virtual void generateFpDynamicShadowsHelpers(
453 const Ogre::Terrain *_terrain,
455 Ogre::StringUtil::StrStreamType &_outStream);
457 protected:
void generateFpDynamicShadows(
const SM2Profile *_prof,
458 const Ogre::Terrain *_terrain, TechniqueType _tt,
459 Ogre::StringUtil::StrStreamType &_outStream);
461 protected:
virtual void generateFragmentProgramSource(
463 const Ogre::Terrain *_terrain,
465 Ogre::StringUtil::StrStreamType &_outStream);
467 protected:
virtual void updateVpParams(
const SM2Profile *_prof,
468 const Ogre::Terrain *_terrain, TechniqueType _tt,
469 const Ogre::GpuProgramParametersSharedPtr &_params);
471 private: Ogre::String GetChannel(Ogre::uint _idx);
477 public Ogre::TerrainMaterialGeneratorA::SM2Profile::ShaderHelperCg
479 public:
virtual Ogre::HighLevelGpuProgramPtr generateFragmentProgram(
480 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
483 public:
virtual Ogre::HighLevelGpuProgramPtr generateVertexProgram(
484 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
487 protected:
virtual void generateVpHeader(
const SM2Profile *_prof,
488 const Ogre::Terrain *_terrain, TechniqueType _tt,
489 Ogre::StringUtil::StrStreamType &_outStream);
491 protected:
virtual void generateVpFooter(
const SM2Profile *_prof,
492 const Ogre::Terrain *_terrain, TechniqueType _tt,
493 Ogre::StringUtil::StrStreamType &_outStream);
495 protected:
virtual void generateVertexProgramSource(
496 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
498 Ogre::StringUtil::StrStreamType &_outStream);
500 protected:
virtual void defaultVpParams(
const SM2Profile *_prof,
501 const Ogre::Terrain *_terrain, TechniqueType _tt,
502 const Ogre::HighLevelGpuProgramPtr &_prog);
504 protected:
virtual unsigned int generateVpDynamicShadowsParams(
505 unsigned int _texCoordStart,
const SM2Profile *_prof,
506 const Ogre::Terrain *_terrain, TechniqueType _tt,
507 Ogre::StringUtil::StrStreamType &_outStream);
509 protected:
virtual void generateVpDynamicShadows(
510 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
512 Ogre::StringUtil::StrStreamType &_outStream);
515 #pragma clang diagnostic pop
516 #endif // ifdef __clang__
bool unloadProceduralPage(Ogre::Page *, Ogre::PagedWorldSection *)
Give a provider the opportunity to unload page content procedurally.
Definition: Heightmap.hh:69
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:43
Generic integer x, y vector.
Definition: Vector2i.hh:39
Shader model 2 profile target.
Definition: Heightmap.hh:359
boost::shared_ptr< Camera > CameraPtr
Definition: RenderTypes.hh:82
bool loadProceduralPage(Ogre::Page *, Ogre::PagedWorldSection *)
Give a provider the opportunity to load page content procedurally.
Definition: Heightmap.hh:62
Rendering a terrain using heightmap information.
Definition: Heightmap.hh:88
bool prepareProceduralPage(Ogre::Page *, Ogre::PagedWorldSection *)
Give a provider the opportunity to prepare page content procedurally.
Definition: Heightmap.hh:55
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:74
Utility class to help with generating shaders for GLSL.
Definition: Heightmap.hh:388
Definition: Heightmap.hh:349
Encapsulates an image.
Definition: Image.hh:68
Keeping the CG shader for reference.
Definition: Heightmap.hh:476
Pretends to provide procedural page content to avoid page loading.
Definition: Heightmap.hh:51
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48
bool unprepareProceduralPage(Ogre::Page *, Ogre::PagedWorldSection *)
Give a provider the opportunity to unprepare page content procedurally.
Definition: Heightmap.hh:77