AGX Dynamics  2.35.0.1
HeightMapGenerator.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. 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 
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 
128 
132  void setSeed(agx::UInt seed);
133 
138 
139  protected:
140 
141  void init();
142 
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 
161  {
162  return m_width;
163  }
164 
166  {
167  return m_height;
168  }
169 
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*/
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXMODEL_EXPORT
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:43
This struct holds parameters for the creation of a height texture that is a composite bump created by...
GaussianFunctionSettings(const agx::Vec2 &size, const agx::Vec2 &widthInter, const agx::Vec2 &heightInter, size_t num, bool periodic_x=false, bool periodic_y=false, agx::Real max_Height=0)
A height map generator using a Gaussian function.
virtual ~GaussianHeightMapGenerator()
Default destructor.
GaussianFunctionSettings getSettings()
Gets the settings used in the simulation.
GaussianHeightMapGenerator()
Default constructor.
agx::RealMatrix generateHeightData()
Generates and returns height data in matrix form.
agx::RealMatrix createGaussianHeightMatrix(agx::Vec2 X_bounds, size_t X_resolution, agx::Vec2 Y_bounds, size_t Y_resolution, const agx::RealMatrix &pos, const agx::RealMatrix &spread, const agx::RealVector &amplitude, bool limitToMaxHeight=false, agx::Real maxHeight=0)
Creates a matrix that holds the heights of the Gaussian dimples.
void setSettings(const GaussianFunctionSettings &settings)
Sets the settings that will be used when creating the Gaussian texture.
GaussianHeightMapGenerator(const size_t &width, const size_t &height, const GaussianFunctionSettings &settings)
Constructor that takes the image width, image hegiht and settings as arguments.
void setSeed(agx::UInt seed)
Sets the seed that it used by the random number generator when creating a bump texture.
A base class used for generating textures.
virtual ~HeightMapGenerator()
Default destructor.
void setWidth(const size_t &width)
Sets the height in pixels of the produced texture.
void setHeigth(const size_t &height)
Sets the height in pixels of the produced texture.
HeightMapGenerator(const size_t &width, const size_t &height)
size_t getHeight()
Gets the height in pixels of the produced texture.
size_t getWidth()
Gets the width in pixels of the produced texture.
Base class providing referencing counted objects.
Definition: Referenced.h:114
Templated vector class.
Definition: agx/Vector.h:53
#define AGX_FORCE_INLINE
Definition: macros.h:58
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)
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:37
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t UInt
Definition: Integer.h:34
double Real
Definition: Real.h:42
agx::Vector< agx::RealVector > RealMatrix