18 #ifndef _GAZEBO_RENDERING_HEIGHTMAP_HH_
19 #define _GAZEBO_RENDERING_HEIGHTMAP_HH_
23 #include <boost/filesystem.hpp>
34 class TerrainGlobalOptions;
43 class GzTerrainMatGen;
98 public:
void LoadFromMsg(ConstVisualPtr &_msg);
105 public:
double GetHeight(
double _x,
double _y,
double _z = 1000);
117 double _outsideRadius,
double _insideRadius,
118 double _weight = 0.1);
130 double _outsideRadius,
double _insideRadius,
131 double _weight = 0.1);
143 double _outsideRadius,
double _insideRadius,
144 double _weight = 0.1);
156 double _outsideRadius,
double _insideRadius,
157 double _weight = 0.1);
162 public:
double GetAvgHeight(Ogre::Vector3 _pos,
double _brushSize);
166 public:
void SetWireframe(
bool _show);
170 public: Ogre::TerrainGroup *GetOgreTerrain()
const;
181 public: Ogre::TerrainGroup::RayResult GetMouseHit(
CameraPtr _camera,
188 public:
void SplitHeights(
const std::vector<float> &_heightmap,
int _n,
189 std::vector<std::vector<float> > &_v);
194 public:
unsigned int GetTerrainSubdivisionCount()
const;
203 private:
void ModifyTerrain(Ogre::Vector3 _pos,
double _outsideRadius,
204 double _insideRadius,
double _weight,
205 const std::string &_op);
209 private:
bool InitBlendMaps(Ogre::Terrain *_terrain);
212 private:
void ConfigureTerrainDefaults();
217 private:
void DefineTerrain(
int _x,
int _y);
221 private:
void SetupShadows(
bool _enabled);
230 private:
void UpdateTerrainHash(
const std::string &_hash,
231 const boost::filesystem::path &_terrainDir);
239 private:
bool PrepareTerrainPaging(
240 const boost::filesystem::path &_terrainDirPath);
243 private:
static const unsigned int numTerrainSubdivisions;
249 private:
static const double loadRadiusFactor;
256 private:
static const double holdRadiusFactor;
260 private:
static const boost::filesystem::path hashFilename;
264 private:
static const boost::filesystem::path pagingDirname;
269 private: boost::filesystem::path gzPagingDir;
281 private:
unsigned int dataSize;
287 private: Ogre::TerrainGlobalOptions *terrainGlobals;
290 private: Ogre::TerrainGroup *terrainGroup;
293 private:
bool terrainsImported;
296 private: std::vector<std::string> diffuseTextures;
299 private: std::vector<std::string> normalTextures;
302 private: std::vector<double> worldSizes;
305 private: std::vector<double> blendHeight;
308 private: std::vector<double> blendFade;
311 private: std::vector<float> heights;
321 private: Ogre::PageManager *pageManager;
324 private: Ogre::TerrainPaging *terrainPaging;
327 private: Ogre::PagedWorld *world;
330 private: std::vector<std::vector<float> > subTerrains;
333 private:
int terrainIdx;
336 private:
bool useTerrainPaging;
339 private:
bool terrainHashChanged;
346 :
public Ogre::TerrainMaterialGeneratorA
356 public Ogre::TerrainMaterialGeneratorA::SM2Profile
359 public:
SM2Profile(Ogre::TerrainMaterialGenerator *_parent,
360 const Ogre::String &_name,
const Ogre::String &_desc);
365 public: Ogre::MaterialPtr generate(
const Ogre::Terrain *_terrain);
367 public: Ogre::MaterialPtr generateForCompositeMap(
368 const Ogre::Terrain *_terrain);
370 public:
void UpdateParams(
const Ogre::MaterialPtr &_mat,
371 const Ogre::Terrain *_terrain);
373 public:
void UpdateParamsForCompositeMap(
const Ogre::MaterialPtr &_mat,
374 const Ogre::Terrain *_terrain);
376 protected:
virtual void addTechnique(
const Ogre::MaterialPtr &_mat,
377 const Ogre::Terrain *_terrain, TechniqueType _tt);
380 #pragma clang diagnostic push
381 #pragma clang diagnostic ignored "-Woverloaded-virtual"
382 #endif // ifdef __clang__
385 public Ogre::TerrainMaterialGeneratorA::SM2Profile::ShaderHelperGLSL
387 public:
virtual Ogre::HighLevelGpuProgramPtr generateVertexProgram(
388 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
391 public:
virtual Ogre::HighLevelGpuProgramPtr generateFragmentProgram(
392 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
395 public:
virtual void updateParams(
const SM2Profile *_prof,
396 const Ogre::MaterialPtr &_mat,
397 const Ogre::Terrain *_terrain,
bool _compositeMap);
399 protected:
virtual void generateVpHeader(
const SM2Profile *_prof,
400 const Ogre::Terrain *_terrain, TechniqueType _tt,
401 Ogre::StringStream &_outStream);
403 protected:
virtual void generateVpFooter(
const SM2Profile *_prof,
404 const Ogre::Terrain *_terrain, TechniqueType _tt,
405 Ogre::StringStream &_outStream);
407 protected:
virtual void generateVertexProgramSource(
408 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
410 Ogre::StringStream &_outStream);
412 protected:
virtual void defaultVpParams(
const SM2Profile *_prof,
413 const Ogre::Terrain *_terrain, TechniqueType _tt,
414 const Ogre::HighLevelGpuProgramPtr &_prog);
416 protected:
virtual unsigned int generateVpDynamicShadowsParams(
417 unsigned int _texCoordStart,
const SM2Profile *_prof,
418 const Ogre::Terrain *_terrain, TechniqueType _tt,
419 Ogre::StringStream &_outStream);
421 protected:
virtual void generateVpDynamicShadows(
422 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
424 Ogre::StringStream &_outStream);
426 protected:
virtual void generateFpHeader(
const SM2Profile *_prof,
427 const Ogre::Terrain *_terrain,
429 Ogre::StringStream &_outStream);
431 protected:
virtual void generateFpLayer(
const SM2Profile *_prof,
432 const Ogre::Terrain *_terrain, TechniqueType tt,
434 Ogre::StringStream &_outStream);
436 protected:
virtual void generateFpFooter(
const SM2Profile *_prof,
437 const Ogre::Terrain *_terrain,
439 Ogre::StringStream &_outStream);
441 protected:
virtual void generateFpDynamicShadowsParams(
442 Ogre::uint *_texCoord, Ogre::uint *_sampler,
443 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
445 Ogre::StringStream &_outStream);
447 protected:
virtual void generateFpDynamicShadowsHelpers(
449 const Ogre::Terrain *_terrain,
451 Ogre::StringStream &_outStream);
453 protected:
void generateFpDynamicShadows(
const SM2Profile *_prof,
454 const Ogre::Terrain *_terrain, TechniqueType _tt,
455 Ogre::StringStream &_outStream);
457 protected:
virtual void generateFragmentProgramSource(
459 const Ogre::Terrain *_terrain,
461 Ogre::StringStream &_outStream);
463 protected:
virtual void updateVpParams(
const SM2Profile *_prof,
464 const Ogre::Terrain *_terrain, TechniqueType _tt,
465 const Ogre::GpuProgramParametersSharedPtr &_params);
467 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::StringStream &_outStream);
491 protected:
virtual void generateVpFooter(
const SM2Profile *_prof,
492 const Ogre::Terrain *_terrain, TechniqueType _tt,
493 Ogre::StringStream &_outStream);
495 protected:
virtual void generateVertexProgramSource(
496 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
498 Ogre::StringStream &_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::StringStream &_outStream);
509 protected:
virtual void generateVpDynamicShadows(
510 const SM2Profile *_prof,
const Ogre::Terrain *_terrain,
512 Ogre::StringStream &_outStream);
520 #pragma clang diagnostic pop
521 #endif // ifdef __clang__
bool unloadProceduralPage(Ogre::Page *, Ogre::PagedWorldSection *)
Give a provider the opportunity to unload page content procedurally.
Definition: Heightmap.hh:65
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
Generic integer x, y vector.
Definition: Vector2i.hh:36
Shader model 2 profile target.
Definition: Heightmap.hh:355
boost::shared_ptr< Camera > CameraPtr
Definition: RenderTypes.hh:87
friend ShaderHelperGLSL
Definition: Heightmap.hh:472
bool loadProceduralPage(Ogre::Page *, Ogre::PagedWorldSection *)
Give a provider the opportunity to load page content procedurally.
Definition: Heightmap.hh:58
#define GZ_RENDERING_VISIBLE
Definition: system.hh:241
Rendering a terrain using heightmap information.
Definition: Heightmap.hh:84
bool prepareProceduralPage(Ogre::Page *, Ogre::PagedWorldSection *)
Give a provider the opportunity to prepare page content procedurally.
Definition: Heightmap.hh:51
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:79
friend ShaderHelperCg
Definition: Heightmap.hh:517
Utility class to help with generating shaders for GLSL.
Definition: Heightmap.hh:384
Definition: Heightmap.hh:345
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:47
bool unprepareProceduralPage(Ogre::Page *, Ogre::PagedWorldSection *)
Give a provider the opportunity to unprepare page content procedurally.
Definition: Heightmap.hh:73