AGX Dynamics  2.37.3.2
GranularMergedBodyDrawableSprites.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_GRANULARMERGEDBODYDRAWABLESPRITES_H
18 #define AGXOSG_GRANULARMERGEDBODYDRAWABLESPRITES_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 <agx/PopDisableWarnings.h> // End of disabled warnings.
25 
26 #include <agxOSG/export.h>
27 #include <agx/Task.h>
28 #include <agx/observer_ptr.h>
29 #include <agxSDK/Simulation.h>
30 
31 namespace agxOSG
32 {
34  class AGXOSG_EXPORT GranularMergedBodyDrawableSprites : public osg::Drawable
35  {
36 
37  public:
39 
40  virtual osg::Object* cloneType() const { return new GranularMergedBodyDrawableSprites(m_particleSystem); }
41  virtual osg::Object* clone(const osg::CopyOp&) const { return new GranularMergedBodyDrawableSprites(*this); }
42  virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const GranularMergedBodyDrawableSprites *>(obj) != nullptr; }
43  virtual const char* libraryName() const { return "agxOSG"; }
44  virtual const char* className() const { return "GranularMergedBodyDrawableSprites"; }
45 
46 
48 # if OSG_VERSION_GREATER_OR_EQUAL(3,4,0)
49  virtual osg::BoundingSphere computeBound() const;
50  virtual osg::BoundingBox computeBoundingBox() const;
51 #else
52  virtual osg::BoundingBox computeBound() const;
53 #endif
54 
56  virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
57 
58  void setEnable(bool enable);
59 
60  bool getEnable() const;
61 
62  void updateMergedBodyDrawable();
63 
64  void addRigidBodyCallback(agxSDK::Simulation *, agx::RigidBody *body);
65 
66  void removeRigidBodyCallback(agxSDK::Simulation *, agx::RigidBody *body);
67 
68  void updateSimulation();
69 
70  bool hasParticleSystem() const;
71 
72  protected:
74 
76  // Variables
78  protected:
79 
82 
85 
87  bool m_enable;
89 
93 
95  };
96 
98 
99  AGX_FORCE_INLINE void GranularMergedBodyDrawableSprites::setEnable(bool enable) { m_enable = enable; }
100 
102  {
103  return m_particleSystem != nullptr;
104  }
105 
106 }
107 
108 #endif /* AGXOSG_PARTICLE_SYSTEMDRAWABLE_H */
agxSDK::Simulation::RigidBodyEvent::CallbackType m_addRigidBodyCallback
agx::HashTable< agx::RigidBody *, agx::Real > m_createdBodies
#define AGXOSG_EXPORT
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGX_FORCE_INLINE
Definition: Object.h:59
virtual bool isSameKindAs(const osg::Object *obj) const
A basic particle system that contains all the storages and buffers required for basic operation and a...
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
Templated callback with two arguments.
Definition: Callback.h:139
virtual osg::Object * clone(const osg::CopyOp &) const
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
Inheritance with partial specialization due to bug with ref_ptr containers.
agxSDK::Simulation::RigidBodyEvent::CallbackType m_removeRigidBodyCallback