AGXDynamics  2.35.0.3
FrameTrajectoryDrawable.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, is 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_FRAME_TRAJECTORY_DRAWABLE_H
18 #define AGXOSG_FRAME_TRAJECTORY_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 <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 FrameTrajectoryDrawable : public osg::Drawable
35  {
36  typedef std::deque<agx::Vec3> PositionBuffer;
37  typedef std::deque<agx::Vec4f> ColorsBuffer;
38  typedef std::pair<PositionBuffer, ColorsBuffer> TrajectoryData;
39 
41 
42  public:
44 
45  virtual osg::Object* cloneType() const { return new FrameTrajectoryDrawable(m_simulation); }
46  virtual osg::Object* clone(const osg::CopyOp&) const { return new FrameTrajectoryDrawable(*this); }
47  virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const FrameTrajectoryDrawable *>(obj) != nullptr; }
48  virtual const char* libraryName() const { return "agxOSG"; }
49  virtual const char* className() const { return "FrameTrajectoryDrawable"; }
50 
51 
53 # if OSG_VERSION_GREATER_OR_EQUAL(3,4,0)
54  virtual osg::BoundingSphere computeBound() const;
55  virtual osg::BoundingBox computeBoundingBox() const;
56 #else
57  virtual osg::BoundingBox computeBound() const;
58 #endif
59 
61  virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
62 
64  void updateTrajectories();
65 
67  void setNumTrajectoryPositions(agx::UInt num);
68 
70  agx::UInt getNumTrajectoryPositions() const;
71 
73  void setDefaultTrajectoryColor(const agx::Vec4f& color);
74 
76  void resetTrajectories();
77 
79  bool addTrajectory(agx::Frame* frame);
80 
82  bool addTrajectory(agx::Frame* frame, agx::Vec4f color);
83 
85  bool removeTrajectory(agx::Frame* frame);
86 
88  void setEnable(bool enable);
89 
91  bool getEnable() const;
92 
94  agxSDK::Simulation * getSimulation();
95 
96  protected:
97  virtual ~FrameTrajectoryDrawable();
98 
99  void updateKernelBuffers();
100 
101  void popOldPositionsInDeadTrajectories();
102 
104  // Variables
106  protected:
107 
110 
114 
120  bool m_enable;
121 
122  };
123 
125 
127 
129 
131 
133 }
134 
135 #endif /* AGXOSG_PARTICLE_SYSTEMDRAWABLE_H */
agxOSG::FrameTrajectoryDrawable::m_defaultTrajectoryColor
agx::Vec4f m_defaultTrajectoryColor
Definition: FrameTrajectoryDrawable.h:113
agxOSG::FrameTrajectoryDrawable::m_colorBuffer
agxData::BufferRef m_colorBuffer
Definition: FrameTrajectoryDrawable.h:116
agxOSG::FrameTrajectoryDrawable::className
virtual const char * className() const
Definition: FrameTrajectoryDrawable.h:49
agxOSG::FrameTrajectoryDrawable::m_verticesBuffer
agxData::BufferRef m_verticesBuffer
Definition: FrameTrajectoryDrawable.h:115
agxOSG::FrameTrajectoryDrawable::m_firstsBuffer
agxData::BufferRef m_firstsBuffer
Definition: FrameTrajectoryDrawable.h:118
agxOSG::FrameTrajectoryDrawable::clone
virtual osg::Object * clone(const osg::CopyOp &) const
Definition: FrameTrajectoryDrawable.h:46
agx::Vector< TrajectoryData >
agxOSG::FrameTrajectoryDrawable::m_activeTrajectories
agx::Vector< std::tuple< agx::FrameRef, agx::Vec4f, TrajectoryData > > m_activeTrajectories
Definition: FrameTrajectoryDrawable.h:112
Simulation.h
Task.h
agx::Vec4T
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:34
agxOSG::FrameTrajectoryDrawable::m_countBuffer
agxData::BufferRef m_countBuffer
Definition: FrameTrajectoryDrawable.h:117
agxOSG::FrameTrajectoryDrawable::m_renderTask
agx::TaskGroupRef m_renderTask
Definition: FrameTrajectoryDrawable.h:109
agxOSG::FrameTrajectoryDrawable::getSimulation
agxSDK::Simulation * getSimulation()
Get the simulation related to the drawable.
Definition: FrameTrajectoryDrawable.h:124
agx::observer_ptr< Simulation >
agx::ref_ptr< TaskGroup >
agxOSG::FrameTrajectoryDrawable::getEnable
bool getEnable() const
Return true of the drawable is enabled.
Definition: FrameTrajectoryDrawable.h:126
agxSDK::Simulation
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
agxOSG::FrameTrajectoryDrawable::libraryName
virtual const char * libraryName() const
Definition: FrameTrajectoryDrawable.h:48
agxOSG
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
PushDisableWarnings.h
agxOSG::FrameTrajectoryDrawable::setEnable
void setEnable(bool enable)
Enable the drawable.
Definition: FrameTrajectoryDrawable.h:128
agx::LinearProbingHashTable
Inheritance with partial specialization due to bug with ref_ptr containers.
Definition: LinearProbingHashTable.h:871
agxOSG::FrameTrajectoryDrawable::m_destroyedTrajectories
agx::Vector< TrajectoryData > m_destroyedTrajectories
Definition: FrameTrajectoryDrawable.h:111
observer_ptr.h
agxOSG::FrameTrajectoryDrawable::getNumTrajectoryPositions
agx::UInt getNumTrajectoryPositions() const
Get the number of positions used in the trajectories.
Definition: FrameTrajectoryDrawable.h:130
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
agx::UInt
uint32_t UInt
Definition: Integer.h:34
agxOSG::FrameTrajectoryDrawable::cloneType
virtual osg::Object * cloneType() const
Definition: FrameTrajectoryDrawable.h:45
agxOSG::FrameTrajectoryDrawable::m_maxPosCounts
agx::UInt m_maxPosCounts
Definition: FrameTrajectoryDrawable.h:119
agxOSG::FrameTrajectoryDrawable::isSameKindAs
virtual bool isSameKindAs(const osg::Object *obj) const
Definition: FrameTrajectoryDrawable.h:47
export.h
agxOSG::FrameTrajectoryDrawable::m_enable
bool m_enable
Definition: FrameTrajectoryDrawable.h:120
agx::Frame
The object defining a frame of reference and providing transformations operations.
Definition: Frame.h:67
agxOSG::FrameTrajectoryDrawable::m_simulation
agxSDK::SimulationObserver m_simulation
Definition: FrameTrajectoryDrawable.h:108
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
agxOSG::FrameTrajectoryDrawable::setDefaultTrajectoryColor
void setDefaultTrajectoryColor(const agx::Vec4f &color)
Set default color of trajectories.
Definition: FrameTrajectoryDrawable.h:132
AGXOSG_EXPORT
#define AGXOSG_EXPORT
PopDisableWarnings.h
agxOSG::FrameTrajectoryDrawable
Definition: FrameTrajectoryDrawable.h:34