AGX Dynamics  2.37.2.0
HeightMapGenerator.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXMODEL_HEIGHT_MAP_GENERATOR_H
18 #define AGXMODEL_HEIGHT_MAP_GENERATOR_H
19 
20 #include <agxModel/export.h>
21 #include <agx/Referenced.h>
22 #include <agx/Real.h>
23 #include <agx/Vector.h>
24 #include <agx/agx_vector_types.h>
25 #include <agxIO/Image.h>
26 #include <agxStream/Serializable.h>
27 
28 
29 namespace agx
30 {
32 }
33 
34 
35 namespace agxCollide
36 {
37  class Trimesh;
38 }
39 
40 namespace agxModel
41 {
46  {
47  public:
48 
50  HeightMapGenerator(const size_t& width, const size_t& height);
51 
55  size_t getWidth();
56 
60  void setWidth(const size_t& width);
61 
65  size_t getHeight();
66 
70  void setHeigth(const size_t& height);
71 
72  protected:
73 
75  virtual ~HeightMapGenerator();
76 
77  protected:
78  size_t m_width;
79  size_t m_height;
80  };
81 
83 
88  {
89  public:
90  GaussianFunctionSettings(const agx::Vec2& size, const agx::Vec2& widthInter,
91  const agx::Vec2& heightInter, size_t num, bool periodic_x = false, bool periodic_y = false, agx::Real max_Height = 0);
92 
94 
95  agx::Vec2 areaSize; // Specifying the area size that will be mapped to the height texture
96  agx::Vec2 widthInterval; // Specifying the width interval where bumps will be present
97  agx::Vec2 heightInterval; // Specifying the height interval where bumps will be present
98  size_t numDimples; // Specifying the number of Gaussian bumps that is used in the texture
99  bool periodic_X; // True if the bumps should be periodic along the x-axis
100  bool periodic_Y; // True if the bumps should be periodic along the Y-axis
101  agx::Real maxHeight; // Max height of any point in the height texture
102  };
103 
106  {
107 
108  public:
109 
112 
116  GaussianHeightMapGenerator(const size_t& width, const size_t& height,
117  const GaussianFunctionSettings& settings);
118 
122  void setSettings(const GaussianFunctionSettings& settings);
123 
127  GaussianFunctionSettings getSettings();
128 
132  void setSeed(agx::UInt seed);
133 
137  agx::RealMatrix generateHeightData();
138 
139  protected:
140 
141  void init();
142 
144  virtual ~GaussianHeightMapGenerator();
145 
147  agx::RealMatrix createGaussianHeightMatrix(agx::Vec2 X_bounds, size_t X_resolution,
148  agx::Vec2 Y_bounds, size_t Y_resolution,
149  const agx::RealMatrix& pos, const agx::RealMatrix& spread, const agx::RealVector& amplitude,
150  bool limitToMaxHeight=false, agx::Real maxHeight=0);
151 
152  protected:
153 
156  };
157 
158  /*Implementation*/
159 
160  AGX_FORCE_INLINE size_t HeightMapGenerator::getWidth()
161  {
162  return m_width;
163  }
164 
165  AGX_FORCE_INLINE size_t HeightMapGenerator::getHeight()
166  {
167  return m_height;
168  }
169 
170  AGX_FORCE_INLINE void GaussianHeightMapGenerator::setSeed(agx::UInt seed)
171  {
172  m_seed = seed;
173  }
174 
178  namespace MeshModifierUtils
179  {
181  agxCollide::Trimesh *trimesh,
182  agx::RealMatrix *heightData,
183  agx::Vec3 axis,
184  agx::Vec3 perpendicularBaseVector,
185  agx::Real cylinderLength,
186  agx::Vec3 cylinderCenter);
187  }
188 }
189 
190 #endif /*AGXMODEL_HEIGHT_MAP_GENERATOR_H*/
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API...
This namespace consists of a set of classes for handling geometric intersection tests including boole...
AGXMODEL_EXPORT agxCollide::Trimesh * bumpCylindricalMeshAroundAnAxisFromHeightData(agxCollide::Trimesh *trimesh, agx::RealMatrix *heightData, agx::Vec3 axis, agx::Vec3 perpendicularBaseVector, agx::Real cylinderLength, agx::Vec3 cylinderCenter)
This struct holds parameters for the creation of a height texture that is a composite bump created by...
A height map generator using a Gaussian function.
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGX_FORCE_INLINE
Definition: Object.h:59
Base class providing referencing counted objects.
Definition: Referenced.h:119
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:36
Templated vector class.
Definition: Vector.h:52
agx::Vector< agx::RealVector > RealMatrix
uint32_t UInt
Definition: Integer.h:34
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
#define AGXMODEL_EXPORT
double Real
Definition: Real.h:42
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:42
A base class used for generating textures.