AGX Dynamics  2.37.3.2
GranularImpactsDrawable.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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 AGXOSG_GRANULARIMPACTDRAWABLE_H
18 #define AGXOSG_GRANULARIMPACTDRAWABLE_H
19 
20 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
21 #include <osg/Drawable>
22 #include <osgViewer/Viewer>
23 #include <osg/Version>
24 #include <osgSim/ColorRange>
25 #include <osgSim/ScalarsToColors>
26 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
27 
28 #include <agxQt/export.h>
29 #include <agx/Task.h>
30 #include <agx/observer_ptr.h>
31 #include <agxSDK/Simulation.h>
32 
33 namespace agxQt
34 {
36  class AGXQT_EXPORT GranularImpactsDrawable : public osg::Drawable
37  {
38  public:
40 
41  virtual osg::Object* cloneType() const { return new GranularImpactsDrawable(m_particleSystem); }
42  virtual osg::Object* clone(const osg::CopyOp&) const { return new GranularImpactsDrawable(*this); }
43  virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const GranularImpactsDrawable *>(obj) != nullptr; }
44  virtual const char* libraryName() const { return "agxOSG"; }
45  virtual const char* className() const { return "GranularImpactsDrawable"; }
46 
47 
49 # if OSG_VERSION_GREATER_OR_EQUAL(3,4,0)
50  virtual osg::BoundingSphere computeBound() const;
51  virtual osg::BoundingBox computeBoundingBox() const;
52 #else
53  virtual osg::BoundingBox computeBound() const;
54 #endif
55 
57  virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
58 
59  void setEnable(bool enable);
60 
61  bool getEnable() const;
62 
63  void updateDrawable();
64 
65  bool hasParticleSystem() const;
66 
67  agx::Real getRenderPointRadius() const;
68 
69  void setRenderPointRadius(agx::Real radius);
70 
71  void setRenderParticleGeometryImpacts(bool enable);
72 
73  bool getRenderParticleGeometryImpacts() const;
74 
75  void setRenderParticleParticleImpacts(bool enable);
76 
77  bool getRenderParticleParticleImpacts() const;
78 
79  void setImpactRenderingEnergyColoringRange(const agx::RangeReal& range);
80 
81  agx::RangeReal getImpactRenderingEnergyColoringRange() const;
82 
83  void setImpactRenderingCutoffEnergy(agx::Real cutoffEnergy);
84 
85  agx::Real getImpactRenderingCutoffEnergy() const;
86 
87  void setUseParticleColorForImpactColoring(bool enable);
88 
89  void setImpactRenderingStartTime(agx::Real cutoffTime);
90 
91  agx::Real getImpactRenderingStartTime() const;
92 
93  protected:
94  virtual ~GranularImpactsDrawable();
95 
96  void initColors();
97 
99  // Variables
101  protected:
104 
106  mutable bool m_firstFrame;
107  bool m_enable;
109 
112 
114 
116 
117  osg::ref_ptr<osgSim::ColorRange> m_colorRange;
122 
126  };
127 
128  AGX_FORCE_INLINE bool GranularImpactsDrawable::getEnable() const { return m_enable; }
129 
130  AGX_FORCE_INLINE void GranularImpactsDrawable::setEnable(bool enable) { m_enable = enable; }
131 
132  AGX_FORCE_INLINE bool agxQt::GranularImpactsDrawable::hasParticleSystem() const { return m_particleSystem != nullptr; }
133 
135 
137 
139 
141 }
142 
143 #endif /* AGXOSG_GRANULARIMPACTDRAWABLE_H */
#define AGXQT_EXPORT
virtual const char * className() const
virtual bool isSameKindAs(const osg::Object *obj) const
Contains classes/utility functions for connecting AGX to QT with OSG.
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
virtual osg::Object * clone(const osg::CopyOp &) const
#define AGX_FORCE_INLINE
Definition: Object.h:59
void setImpactRenderingStartTime(agx::Real cutoffTime)
osg::ref_ptr< osgSim::ColorRange > m_colorRange
virtual const char * libraryName() const
A basic particle system that contains all the storages and buffers required for basic operation and a...
virtual osg::Object * cloneType() const
agx::ParticleSystemObserver m_particleSystem
agxSDK::SimulationObserver m_simulation
void setRenderPointRadius(agx::Real radius)
double Real
Definition: Real.h:42