AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
TerrainVoxelRenderer.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. 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 having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid 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#if defined(SWIG) || AGX_USE_AGXTERRAIN()
21
22#include <agxOSG/Node.h>
25
26#include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
27#include <osg/Drawable>
28#include <osgViewer/Viewer>
29#include <osgSim/ColorRange>
30#include <osgSim/ScalarsToColors>
31#include <osg/Version>
32#include <agx/PopDisableWarnings.h> // End of disabled warnings.
33
36#include <agxTerrain/Terrain.h>
37#include <agx/Task.h>
38#include <vector>
39
40namespace agxOSG
41{
43
48 {
49 public:
54 static TerrainVoxelRenderer* find( const agxTerrain::Terrain* terrain, const agxSDK::Simulation* simulation );
55
56 public:
58 {
60 COMPACTION
61 };
62
63 public:
69 TerrainVoxelRenderer( agxTerrain::Terrain* terrain, osg::Group* group );
70
76 TerrainVoxelRenderer(agxSDK::TerrainInstance* terrainInstance, osg::Group* group);
77
82
87
92 void setRenderVoxelSolidMass(bool enable);
93
98
103 void setRenderVoxelFluidMass(bool enable);
104
109
114 void setRenderVoxelBoundingBox(bool enable);
115
120
125 void setRenderHeightField(bool enable);
126
131
136 void setRenderVoxelCompaction(bool enable);
137
142
147 void setRenderTerrainMaterials(bool enable);
148
153
154
161
166
171
176
181 void setRenderVelocityField(bool enable);
182
187
192 void setRenderSoilParticles(bool enable);
193
198
203 void setRenderSoilParticlesMesh(bool enable);
204
209
215 void setSoilParticleMeshData( const agx::String& modelFilename, const agx::String& textureFilename = "" );
216
221
226
262 bool enable,
263 agx::RangeReal heightRange = agx::RangeReal(),
264 bool useRelativeHeights = false,
265 const osg::Vec4& lowColor = osg::Vec4( 0.0, 0.0, 1.0, 1.0 ),
266 const osg::Vec4& midColor = osg::Vec4( 0.0, 1.0, 0.0, 1.0 ),
267 const osg::Vec4& highColor = osg::Vec4( 1.0, 0.0, 0.0, 1.0 ) );
268
272 bool getRenderHeights() const;
273
279 void setRenderCompaction(bool enable, agx::RangeReal compactionRange = agx::RangeReal( 0.75, 1.5 ));
280
285
290 void setColor(agx::Vec4f color);
291
296
301 void setVelocityFieldLineColor(const agx::Vec4& lineColor);
302
307 void setMaxVoxelValueColor(const agx::Vec4f& maxVoxelColor);
308
309#ifndef SWIG
310 public:
312 {
315
317
318 osg::ref_ptr<agxOSG::GeometryNode> node;
319 osg::observer_ptr<osg::Group> parent;
320 osg::ref_ptr<osg::Geometry> geometry;
321 osg::ref_ptr<osg::Geode> geode;
322 osg::StateSet* stateSet;
323
324 osg::ref_ptr<osgSim::ColorRange> colorRange;
325 osg::ref_ptr<osg::Vec4Array> colorArray;
326 };
327
329 {
330 osg::ref_ptr<osg::Node> node;
331 osg::ref_ptr<osg::Group> group;
334 };
335
336 public:
337 virtual void addNotification() override;
338 virtual void removeNotification() override;
339 virtual void last( const agx::TimeStamp& ) override;
340#endif
341
342 protected:
344
345 protected:
349 osg::Vec4 m_color;
350 osg::ref_ptr<TerrainVoxelDrawable> m_voxelDrawable;
351 osg::ref_ptr<SoilParticleSystemDrawable> m_soilParticleDrawable;
353 bool m_useRelativeHeights = false; // RELATIVE HEIGHT COLORING
354 std::vector<agx::Real> m_originalHeights; // RELATIVE HEIGHT COLORING
355 };
356
359}
360#endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXOSG_EXPORT
A node that can be associated with a collision geometry so that the transformation of this node is up...
Definition: GeometryNode.h:42
Rendering class for the agxTerrain::Terrain.
void setRenderVoxelFluidMass(bool enable)
Enable/disable rendering of fluid mass.
void setRenderVoxelBoundingBox(bool enable)
Enable/disable rendering of voxel bounding boxes.
std::vector< agx::Real > m_originalHeights
virtual void addNotification() override
Called when this listener is added to the simulation.
void setRenderTerrainMaterials(bool enable)
Enable/disable rendering of multiple terrain materials in the voxel grid.
void setVelocityFieldLineColor(const agx::Vec4 &lineColor)
Assign line color of velocity fields in the voxel renderer.
void setRenderCompaction(bool enable, agx::RangeReal compactionRange=agx::RangeReal(0.75, 1.5))
Enable/disable rendering of compaction.
void setTerrainMaterialsColors(const agxRender::ColorVector &colors)
Set the color array to use when rendering different terrain materials.
virtual void last(const agx::TimeStamp &) override
Called after a step is taken in the simulation Implement this method in the derived class to get call...
agxOSG::GeometryNode * getNode() const
agxTerrain::TerrainObserver m_terrain
bool getRenderVelocityField() const
void setRenderHeightField(bool enable)
Enable/disable rendering of the terrain.
SoilParticleMeshData m_soilParticleMeshData
bool getRenderVoxelBoundingBox() const
void setRenderHeights(bool enable, agx::RangeReal heightRange=agx::RangeReal(), bool useRelativeHeights=false, const osg::Vec4 &lowColor=osg::Vec4(0.0, 0.0, 1.0, 1.0), const osg::Vec4 &midColor=osg::Vec4(0.0, 1.0, 0.0, 1.0), const osg::Vec4 &highColor=osg::Vec4(1.0, 0.0, 0.0, 1.0))
Enable/disable rendering of terrain height using a scalar color range.
void setMaxVoxelValueColor(const agx::Vec4f &maxVoxelColor)
Assign max value color of velocity fields in the voxel renderer.
bool getRenderTerrainMaterials() const
void setRenderVoxelSolidMass(bool enable)
Enable/disable rendering of solid mass.
osg::ref_ptr< SoilParticleSystemDrawable > m_soilParticleDrawable
bool getRenderSoilParticlesMesh() const
bool getRenderDefaultTerrainMaterial() const
void setRenderVelocityField(bool enable)
Enable/disable rendering of the mass velocity field.
bool getRenderVoxelCompaction() const
void setColor(agx::Vec4f color)
Set color of the terrain.
static TerrainVoxelRenderer * find(const agxTerrain::Terrain *terrain, const agxSDK::Simulation *simulation)
Finds terrain renderer given terrain and simulation.
void setRenderSoilParticles(bool enable)
Enable/disable rendering of solid particles.
const agx::String & getSoilParticleMeshModelFilename() const
virtual void removeNotification() override
Called when this listener is removed from the simulation.
void setSoilParticleMeshData(const agx::String &modelFilename, const agx::String &textureFilename="")
Load soil particle mesh model and texture (optional).
void setRenderVoxelCompaction(bool enable)
Enable/disable rendering of compaction in the voxel grid.
agxRender::ColorVector getTerrainMaterialColors() const
Get the color array to use when rendering different terrain materials.
void setRenderSoilParticlesMesh(bool enable)
Set enable render particles as triangle meshes.
TerrainVoxelRenderer(agxSDK::TerrainInstance *terrainInstance, osg::Group *group)
Construct a TerrainVoxel renderer given a terrain instance and a visual root.
agxTerrain::Terrain * getTerrain() const
bool getRenderSoilParticles() const
osg::ref_ptr< TerrainVoxelDrawable > m_voxelDrawable
const agx::String & getSoilParticleMeshTextureFilename() const
bool getRenderVoxelFluidMass() const
void setRenderDefaultTerrainMaterial(bool enable)
Enable/disable rendering of the default terrain material during rendering of terrain materials (see s...
bool getRenderVoxelSolidMass() const
TerrainVoxelRenderer(agxTerrain::Terrain *terrain, osg::Group *group)
Construct a TerrainVoxel renderer given a terrain and a visual root.
agx::Vec4f getColor() const
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:131
Derive from this class to implement a listener for simulation step events.
agxTerrain::Terrain instance in a simulation, receiving step and contact callbacks in a controllable ...
A terrain model based a 3D grid model with overlapping height field that can be deformed by interacti...
Definition: Terrain.h:92
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:35
Templated vector class.
Definition: agx/Vector.h:53
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
AGXOSG_EXPORT void setupTerrainJournalPlaybackSettings(agxSDK::Simulation *simulation)
Setup journal playback settings for each TerrainVoxelRenderer in the specified simulation.
bool Bool
Definition: Integer.h:40
agx::Real TimeStamp
Definition: TimeStamp.h:26
osg::ref_ptr< osgSim::ColorRange > colorRange
osg::ref_ptr< agxOSG::GeometryNode > node
osg::observer_ptr< osg::Group > parent
osg::ref_ptr< osg::Vec4Array > colorArray