AGX Dynamics  2.35.0.1
GranularImpactsDrawable.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 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 
64 
65  bool hasParticleSystem() const;
66 
67  agx::Real getRenderPointRadius() const;
68 
69  void setRenderPointRadius(agx::Real radius);
70 
72 
74 
76 
78 
80 
82 
84 
86 
88 
89  void setImpactRenderingStartTime(agx::Real cutoffTime);
90 
91  agx::Real getImpactRenderingStartTime() const;
92 
93  protected:
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 
129 
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 AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXQT_EXPORT
void setImpactRenderingCutoffEnergy(agx::Real cutoffEnergy)
void setImpactRenderingEnergyColoringRange(const agx::RangeReal &range)
virtual bool isSameKindAs(const osg::Object *obj) const
virtual osg::Object * clone(const osg::CopyOp &) const
void setRenderParticleParticleImpacts(bool enable)
void setRenderPointRadius(agx::Real radius)
virtual const char * libraryName() const
virtual osg::BoundingBox computeBound() const
Compute the bounding box around Drawables's geometry.
void setUseParticleColorForImpactColoring(bool enable)
bool getRenderParticleGeometryImpacts() const
agx::ParticleSystemObserver m_particleSystem
virtual osg::Object * cloneType() const
virtual const char * className() const
virtual void drawImplementation(osg::RenderInfo &renderInfo) const
The actual draw method for the merged bodies.
void setImpactRenderingStartTime(agx::Real cutoffTime)
agx::RangeReal getImpactRenderingEnergyColoringRange() const
osg::ref_ptr< osgSim::ColorRange > m_colorRange
bool getRenderParticleParticleImpacts() const
GranularImpactsDrawable(agx::ParticleSystem *particleSystem)
void setRenderParticleGeometryImpacts(bool enable)
agx::Real getImpactRenderingCutoffEnergy() const
agxSDK::SimulationObserver m_simulation
A basic particle system that contains all the storages and buffers required for basic operation and a...
#define AGX_FORCE_INLINE
Definition: macros.h:58
Contains classes/utility functions for connecting AGX to QT with OSG.
double Real
Definition: Real.h:42