AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
TerrainVoxelRenderer.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 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
19#include <agx/config/AGX_USE_AGXTERRAIN.h>
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
34#include <agx/config/AGX_USE_AGXTERRAIN.h>
36#include <agxTerrain/Terrain.h>
37#include <agx/Task.h>
38
39namespace agxOSG
40{
42
47 {
48 public:
53 static TerrainVoxelRenderer* find( const agxTerrain::Terrain* terrain, const agxSDK::Simulation* simulation );
54
55 public:
57 {
59 COMPACTION
60 };
61
62 public:
68 TerrainVoxelRenderer( agxTerrain::Terrain* terrain, osg::Group* group );
69
75 TerrainVoxelRenderer(agxSDK::TerrainInstance* terrainInstance, osg::Group* group);
76
81
86
91 void setRenderVoxelSolidMass(bool enable);
92
97
102 void setRenderVoxelFluidMass(bool enable);
103
108
113 void setRenderVoxelBoundingBox(bool enable);
114
119
124 void setRenderHeightField(bool enable);
125
130
135 void setRenderVoxelCompaction(bool enable);
136
141
146 void setRenderTerrainMaterials(bool enable);
147
152
153
160
165
170
175
180 void setRenderVelocityField(bool enable);
181
186
191 void setRenderSoilParticles(bool enable);
192
197
202 void setRenderSoilParticlesMesh(bool enable);
203
208
214 void setSoilParticleMeshData( const agx::String& modelFilename, const agx::String& textureFilename = "" );
215
220
225
234 void setRenderHeights(bool enable, agx::RangeReal heightRange = agx::RangeReal());
235
239 bool getRenderHeights() const;
240
246 void setRenderCompaction(bool enable, agx::RangeReal compactionRange = agx::RangeReal( 0.75, 1.5 ));
247
252
257 void setColor(agx::Vec4f color);
258
263
268 void setVelocityFieldLineColor(const agx::Vec4& lineColor);
269
274 void setMaxVoxelValueColor(const agx::Vec4f& maxVoxelColor);
275
276#ifndef SWIG
277 public:
279 {
282
284
285 osg::ref_ptr<agxOSG::GeometryNode> node;
286 osg::observer_ptr<osg::Group> parent;
287 osg::ref_ptr<osg::Geometry> geometry;
288 osg::ref_ptr<osg::Geode> geode;
289 osg::StateSet* stateSet;
290
291 osg::ref_ptr<osgSim::ColorRange> colorRange;
292 osg::ref_ptr<osg::Vec4Array> colorArray;
293 };
294
296 {
297 osg::ref_ptr<osg::Node> node;
298 osg::ref_ptr<osg::Group> group;
301 };
302
303 public:
304 virtual void addNotification() override;
305 virtual void removeNotification() override;
306 virtual void last( const agx::TimeStamp& ) override;
307#endif
308
309 protected:
311
312 protected:
316 osg::Vec4 m_color;
317 osg::ref_ptr<TerrainVoxelDrawable> m_voxelDrawable;
318 osg::ref_ptr<SoilParticleSystemDrawable> m_soilParticleDrawable;
320 };
321
324}
325#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...
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.
virtual void addNotification() override
Called when this listener is added to the simulation.
void setRenderTerrainMaterials(bool enable)
Enable/disable rendering of inhomogeneous 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())
Enable/disable rendering of terrain height as a color range ranging from lowest as blue,...
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:126
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:86
A class holding 4 dimensional vectors and providing basic arithmetic.
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