AGX Dynamics  2.38.0.2
GranularMergedBodyDrawable.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_GRANULARMERGEDBODYDRAWABLE_H
18 #define AGXOSG_GRANULARMERGEDBODYDRAWABLE_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 <agxOSG/Node.h>
28 #include <agxOSG/GeometryNode.h>
29 #include <agx/Task.h>
30 #include <agx/observer_ptr.h>
31 #include <agxSDK/Simulation.h>
32 
33 namespace agxOSG
34 {
36  class AGXOSG_EXPORT GranularMergedBodyDrawable : public osg::Drawable
37  {
38 
39  public:
40  GranularMergedBodyDrawable(agxSDK::Simulation *simulation, osg::Group * root = nullptr);
41 
42  virtual osg::Object* cloneType() const { return new GranularMergedBodyDrawable(m_simulation, m_root); }
43  virtual osg::Object* clone(const osg::CopyOp&) const { return new GranularMergedBodyDrawable(*this); }
44  virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const GranularMergedBodyDrawable *>(obj) != nullptr; }
45  virtual const char* libraryName() const { return "agxOSG"; }
46  virtual const char* className() const { return "GranularMergedBodyDrawable"; }
47 
48 
50 # if OSG_VERSION_GREATER_OR_EQUAL(3,4,0)
51  virtual osg::BoundingSphere computeBound() const;
52  virtual osg::BoundingBox computeBoundingBox() const;
53 #else
54  virtual osg::BoundingBox computeBound() const;
55 #endif
56 
58  virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
59 
60  void setEnable(bool enable);
61 
62  bool getEnable() const;
63 
64  agxSDK::Simulation * getSimulation();
65 
66  void updateMergedBodyDrawable();
67 
68  void addRigidBodyCallback(agxSDK::Simulation *, agx::RigidBody *body);
69 
70  void removeRigidBodyCallback(agxSDK::Simulation *, agx::RigidBody *body);
71 
72  protected:
73  virtual ~GranularMergedBodyDrawable();
74 
76  // Variables
78  protected:
79 
82 
84  osg::Group * m_root;
86 
87  bool m_enable;
88 
90  };
91 
93 
95 
97 
98 }
99 
100 #endif /* AGXOSG_PARTICLE_SYSTEMDRAWABLE_H */
agxOSG::GranularMergedBodyDrawable::clone
virtual osg::Object * clone(const osg::CopyOp &) const
Definition: GranularMergedBodyDrawable.h:43
agxOSG::GranularMergedBodyDrawable::m_renderTask
agx::TaskGroupRef m_renderTask
Definition: GranularMergedBodyDrawable.h:85
agxOSG::GranularMergedBodyDrawable::className
virtual const char * className() const
Definition: GranularMergedBodyDrawable.h:46
agxOSG::GranularMergedBodyDrawable::isSameKindAs
virtual bool isSameKindAs(const osg::Object *obj) const
Definition: GranularMergedBodyDrawable.h:44
agxOSG::GranularMergedBodyDrawable::m_removeRigidBodyCallback
agxSDK::Simulation::RigidBodyEvent::CallbackType m_removeRigidBodyCallback
Definition: GranularMergedBodyDrawable.h:81
Simulation.h
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:51
Task.h
agxOSG::GranularMergedBodyDrawable::libraryName
virtual const char * libraryName() const
Definition: GranularMergedBodyDrawable.h:45
Node.h
agx::observer_ptr< Simulation >
agxOSG::GranularMergedBodyDrawable::m_simulation
agxSDK::SimulationObserver m_simulation
Definition: GranularMergedBodyDrawable.h:83
agxOSG::GranularMergedBodyDrawable::getSimulation
agxSDK::Simulation * getSimulation()
Definition: GranularMergedBodyDrawable.h:92
agx::ref_ptr< TaskGroup >
agxSDK::Simulation
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:125
agxOSG
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
PushDisableWarnings.h
GeometryNode.h
agx::LinearProbingHashTable
Inheritance with partial specialization due to bug with ref_ptr containers.
Definition: LinearProbingHashTable.h:926
observer_ptr.h
agx::root
AGXCORE_EXPORT Component * root()
agxOSG::GranularMergedBodyDrawable::m_createdBodies
agx::HashTable< agx::RigidBody *, osg::Group * > m_createdBodies
Definition: GranularMergedBodyDrawable.h:89
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
agxOSG::GranularMergedBodyDrawable::m_enable
bool m_enable
Definition: GranularMergedBodyDrawable.h:87
agxOSG::GranularMergedBodyDrawable
Definition: GranularMergedBodyDrawable.h:36
export.h
agx::Callback2
Templated callback with two arguments.
Definition: Callback.h:139
agxOSG::GranularMergedBodyDrawable::getEnable
bool getEnable() const
Definition: GranularMergedBodyDrawable.h:94
agxOSG::GranularMergedBodyDrawable::setEnable
void setEnable(bool enable)
Definition: GranularMergedBodyDrawable.h:96
agxOSG::GranularMergedBodyDrawable::cloneType
virtual osg::Object * cloneType() const
Definition: GranularMergedBodyDrawable.h:42
agxOSG::GranularMergedBodyDrawable::m_addRigidBodyCallback
agxSDK::Simulation::RigidBodyEvent::CallbackType m_addRigidBodyCallback
Definition: GranularMergedBodyDrawable.h:80
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
AGXOSG_EXPORT
#define AGXOSG_EXPORT
PopDisableWarnings.h
agxOSG::GranularMergedBodyDrawable::m_root
osg::Group * m_root
Definition: GranularMergedBodyDrawable.h:84