AGXDynamics  2.35.0.3
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 
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 
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*/
agxModel::GaussianFunctionSettings::maxHeight
agx::Real maxHeight
Definition: HeightMapGenerator.h:101
Referenced.h
agx::Real
double Real
Definition: Real.h:42
agxModel::GaussianFunctionSettings::areaSize
agx::Vec2 areaSize
Definition: HeightMapGenerator.h:95
agxModel::HeightMapGenerator::m_width
size_t m_width
Definition: HeightMapGenerator.h:78
Vector.h
agxModel
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:36
agxModel::MeshModifierUtils::bumpCylindricalMeshAroundAnAxisFromHeightData
AGXMODEL_EXPORT agxCollide::Trimesh * bumpCylindricalMeshAroundAnAxisFromHeightData(agxCollide::Trimesh *trimesh, agx::RealMatrix *heightData, agx::Vec3 axis, agx::Vec3 perpendicularBaseVector, agx::Real cylinderLength, agx::Vec3 cylinderCenter)
agx::Vector
Templated vector class.
Definition: Vector.h:52
agxModel::GaussianHeightMapGenerator::setSeed
void setSeed(agx::UInt seed)
Sets the seed that it used by the random number generator when creating a bump texture.
Definition: HeightMapGenerator.h:170
agxModel::GaussianHeightMapGenerator::m_seed
agx::UInt m_seed
Definition: HeightMapGenerator.h:155
export.h
agxModel::HeightMapGenerator::getWidth
size_t getWidth()
Gets the width in pixels of the produced texture.
Definition: HeightMapGenerator.h:160
agx::RealMatrix
agx::Vector< agx::RealVector > RealMatrix
Definition: HeightMapGenerator.h:31
agx::VectorPOD< Real >
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
agxModel::GaussianHeightMapGenerator::m_settings
GaussianFunctionSettings m_settings
Definition: HeightMapGenerator.h:154
agxModel::HeightMapGenerator
A base class used for generating textures.
Definition: HeightMapGenerator.h:45
Image.h
agx::Vec2T
Definition: Vec2Template.h:30
agxModel::GaussianFunctionSettings::widthInterval
agx::Vec2 widthInterval
Definition: HeightMapGenerator.h:96
agxModel::GaussianFunctionSettings::periodic_X
bool periodic_X
Definition: HeightMapGenerator.h:99
Serializable.h
agxModel::HeightMapGenerator::m_height
size_t m_height
Definition: HeightMapGenerator.h:79
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:113
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
agx::UInt
uint32_t UInt
Definition: Integer.h:34
agxCollide
This namespace consists of a set of classes for handling geometric intersection tests including boole...
Definition: ContactForceFilterParticipant.h:22
agxModel::HeightMapGenerator::getHeight
size_t getHeight()
Gets the height in pixels of the produced texture.
Definition: HeightMapGenerator.h:165
agxModel::GaussianFunctionSettings::numDimples
size_t numDimples
Definition: HeightMapGenerator.h:98
agxModel::GaussianHeightMapGenerator
A height map generator using a Gaussian function.
Definition: HeightMapGenerator.h:105
AGXMODEL_EXPORT
#define AGXMODEL_EXPORT
Definition: agxModel/export.h:42
agx::init
void AGXPHYSICS_EXPORT init()
Initialize agx.
agxModel::GaussianFunctionSettings
This struct holds parameters for the creation of a height texture that is a composite bump created by...
Definition: HeightMapGenerator.h:87
agx::Vec3T< Real >
agxCollide::Trimesh
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:42
Real.h
agx_vector_types.h
agxModel::GaussianFunctionSettings::periodic_Y
bool periodic_Y
Definition: HeightMapGenerator.h:100
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
agxModel::GaussianFunctionSettings::heightInterval
agx::Vec2 heightInterval
Definition: HeightMapGenerator.h:97