AGX Dynamics 2.37.3.4
Loading...
Searching...
No Matches
TileSpecification.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or
9having been advised so by Algoryx Simulation AB for a time limited evaluation,
10or having purchased a valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
20#include <agxTerrain/export.h>
21
22#include <agx/Integer.h>
23#include <agx/Vec3.h>
24#include <agx/Quat.h>
25#include <agx/AffineMatrix4x4.h>
26#include <agx/HashFunction.h>
27
29
30#include <utility>
31
32namespace agx {
33
34 typedef std::pair< Real, Real > RealPair;
35
36}
37
38namespace agxTerrain
39{
40 class Terrain;
41
42
49
50
55 {
56 public:
59 float height;
60 };
61
63
64
70 {
71 public:
72
82 TileSpecification( agx::Vec3 refPoint, agx::Quat refRotation,
83 agx::Real tileSize, size_t marginSize,
84 size_t resolution, agx::Real maxDepth );
85
87
91 agx::Vec3 getReferencePoint() const;
92
96 agx::Quat getReferenceRotation() const;
97
102 agx::Real getTileSize() const;
103
107 size_t getTileMarginSize() const;
108
109
113 size_t getTileResolution() const;
114
118 agx::Real getMaximumDepth() const;
119
120
121
125 agx::Vec3 convertWorldCoordinateToTilePosition( agx::Vec3 worldPos ) const;
126
131
138 agx::Vec3 convertTilePositionToWorld( agxTerrain::TileId id, agx::Vec2 tilePos ) const;
139
140
148
149
153 agx::AffineMatrix4x4 getTileTransform( agxTerrain::TileId id, agx::Real zPos = 0 ) const;
154
158 agx::AffineMatrix4x4 getTileTransform( agxTerrain::TileId id, agx::Vec3 localOffset ) const;
159
164
165 public:
167 void store(agxStream::OutputArchive& out) const;
168 void restore(agxStream::InputArchive& in);
170
171 private:
172 agx::Vec3 m_referencePoint;
173 agx::Quat m_referenceRotation;
174
175 agx::Real m_tileSize;
176 size_t m_tileMarginSize;
177 size_t m_tileResolution;
178
179 agx::Real m_maximumDepth;
180
181 agx::AffineMatrix4x4 m_gridToWorld;
182 agx::AffineMatrix4x4 m_worldToGrid;
183 };
184
185
186
187
188 AGX_FORCE_INLINE agx::Vec3 TileSpecification::getReferencePoint() const
189 {
190 return m_referencePoint;
191 }
192
193 AGX_FORCE_INLINE agx::Quat TileSpecification::getReferenceRotation() const
194 {
195 return m_referenceRotation;
196 }
197
198 AGX_FORCE_INLINE agx::Real TileSpecification::getTileSize() const
199 {
200 return m_tileSize;
201 }
202
203 AGX_FORCE_INLINE size_t TileSpecification::getTileMarginSize() const
204 {
205 return m_tileMarginSize;
206 }
207
208 AGX_FORCE_INLINE size_t TileSpecification::getTileResolution() const
209 {
210 return m_tileResolution;
211 }
212
213 AGX_FORCE_INLINE agx::Real TileSpecification::getMaximumDepth() const
214 {
215 return m_maximumDepth;
216 }
217
218 AGX_FORCE_INLINE agx::Vec3 TileSpecification::convertTilePositionToWorld( agxTerrain::TileId id, agx::Vec2 tilePos ) const
219 {
220 return convertTilePositionToWorld( id, agx::Vec3( tilePos, 0.0 ) );
221 }
222
223
224 AGX_FORCE_INLINE agx::Vec3 TileSpecification::convertWorldCoordinateToTilePosition( agx::Vec3 worldPos ) const
225 {
226 return worldPos * m_worldToGrid;
227 }
228
229
230
231 AGX_FORCE_INLINE agx::AffineMatrix4x4 TileSpecification::getTileTransform( agxTerrain::TileId id, agx::Real zPos ) const
232 {
233 agx::Vec3 center = getTileCenter( id );
234 center[2] += zPos;
235
236 return agx::AffineMatrix4x4::translate( center ) * m_gridToWorld;
237 }
238
239
240 AGX_FORCE_INLINE agx::AffineMatrix4x4 TileSpecification::getTileTransform( agxTerrain::TileId id, agx::Vec3 localOffset ) const
241 {
242 agx::Vec3 center = getTileCenter( id );
243
244 return agx::AffineMatrix4x4::translate( center + localOffset ) * m_gridToWorld;
245
246 }
247}
248
#define AGXTERRAIN_EXPORT
TileModifications are used to provide a delta for paged terrain changes.
A TileSpecification determines where in the world a 2D TileId is located and contains utility methods...
agx::Vec3 convertTilePositionToWorld(agxTerrain::TileId id, agx::Vec3 tilePos) const
The 2D version of this method is the same as calling this method with agx::Vec3(x,...
TileSpecification(agx::Vec3 refPoint, agx::Quat refRotation, agx::Real tileSize, size_t marginSize, size_t resolution, agx::Real maxDepth)
Constructor.
agxTerrain::TileId convertWorldCoordinateToTileId(agx::Vec3 worldPos) const
agx::Vec3 getTileCenter(agxTerrain::TileId id) const
Return the local center position for tile id in the plane with tiles.
static AffineMatrix4x4T< Real > translate(const Vec3T< Real > &dv)
Return a matrix which translates according to dv.
Vector containing 'raw' data.
Definition: agx/Vector.h:246
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
#define AGX_FORCE_INLINE
Definition: macros.h:58
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition: Geometry.h:60
agx::VectorPOD< TileModification > TileModificationVector
agx::Vec2i32 TileId
A TileId is a 2D-coordinate that specifies where a in grid a tile is located.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real
Definition: Real.h:42
std::pair< Real, Real > RealPair