AGX Dynamics  2.38.0.2
RigidBodySystemDrawable.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_RIGID_BODY_SYSTEM_DRAWABLE_H
18 #define AGXOSG_RIGID_BODY_SYSTEM_DRAWABLE_H
19 
20 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
21 #include <osg/Drawable>
22 #include <osgViewer/Viewer>
23 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
24 
25 #include <agxOSG/export.h>
26 #include <agxOSG/Node.h>
28 
29 #include <agx/Task.h>
30 #include <agx/observer_ptr.h>
31 #include <agx/RigidBodyEmitter.h>
32 
33 
34 namespace agxOSG
35 {
36  class AGXOSG_EXPORT RigidBodySystemDrawable : public osg::Group
37  {
38  public:
40 
42  // RigidBodySystemDrawable( const RigidBodySystemDrawable&c, const osg::CopyOp& copyOp );
43 
44  virtual osg::Object* cloneType() const { return new RigidBodySystemDrawable ( m_emitter.get() ); }
45  virtual osg::Object* clone(const osg::CopyOp&) const { return new RigidBodySystemDrawable (*this); }
46  virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RigidBodySystemDrawable *>(obj)!=nullptr; }
47  virtual const char* libraryName() const { return "agxOSG"; }
48  virtual const char* className() const { return "RigidBodySystemDrawable"; }
49 
50  void createRigidBodyInstance( agx::RigidBody* body );
51 
52  static osg::Group* copyRigidBodyVisualChildren(agx::RigidBody* newBody, const RigidBodyRenderCache::RigidBodyVisualGroup& visualTemplateGroup);
53 
54  protected:
55  virtual ~RigidBodySystemDrawable();
56  void instanceCreated( agx::RigidBodyEmitter* emitter, agx::RigidBody* body, agx::RigidBodyEmitter::DistributionModel* model );
57  void addToBodyNodeCache( agx::RigidBody* body, RigidBodyRenderCache::RigidBodyVisualGroupRef group );
58  const RigidBodyRenderCache::RigidBodyVisualGroup& getCachedBodyNode( agx::RigidBody* body ) const;
59 
60  void initBodyCache( agx::RigidBodyEmitter* emitter );
61  bool bodyCacheIsEmpty();
62 
63  private:
64  mutable agx::RigidBodyEmitterObserver m_emitter;
65  agx::RigidBodyEmitter::Event::CallbackType m_createInstanceCallback;
67  // A placeholder for an empty visualization group
69  };
70 
71 }
72 
73 
74 #endif /* AGXOSG_RIGID_BODY_SYSTEM_DRAWABLE_H */
agxOSG::RigidBodyRenderCache::RigidBodyVisualGroup
A help class to store all information we need to copy a rigid body visualization to duplicate the rig...
Definition: RigidBodyRenderCache.h:44
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:51
Task.h
agxOSG::RigidBodySystemDrawable::clone
virtual osg::Object * clone(const osg::CopyOp &) const
Definition: RigidBodySystemDrawable.h:45
agxOSG::RigidBodySystemDrawable::cloneType
virtual osg::Object * cloneType() const
Definition: RigidBodySystemDrawable.h:44
Node.h
agx::observer_ptr< RigidBodyEmitter >
agxOSG::RigidBodySystemDrawable::libraryName
virtual const char * libraryName() const
Definition: RigidBodySystemDrawable.h:47
agx::ref_ptr
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
agxOSG
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
PushDisableWarnings.h
agxOSG::RigidBodySystemDrawable
Definition: RigidBodySystemDrawable.h:36
RigidBodyEmitter.h
agx::LinearProbingHashTable
Inheritance with partial specialization due to bug with ref_ptr containers.
Definition: LinearProbingHashTable.h:926
observer_ptr.h
agxOSG::RigidBodySystemDrawable::GeometryToNodeCache
agx::HashTable< agxCollide::Geometry *, GeometryNode * > GeometryToNodeCache
Definition: RigidBodySystemDrawable.h:39
agx::RigidBodyEmitter
Spawns new Rigid Bodies inside a volume given to the Emitter.
Definition: RigidBodyEmitter.h:43
agx::Callback3
Templated callback with three arguments.
Definition: Callback.h:181
agxOSG::RigidBodySystemDrawable::isSameKindAs
virtual bool isSameKindAs(const osg::Object *obj) const
Definition: RigidBodySystemDrawable.h:46
RigidBodyRenderCache.h
agx::RigidBodyEmitter::DistributionModel
DistributionModel()
Default constructor.
export.h
agxOSG::RigidBodySystemDrawable::className
virtual const char * className() const
Definition: RigidBodySystemDrawable.h:48
AGXOSG_EXPORT
#define AGXOSG_EXPORT
PopDisableWarnings.h