AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
FrameTrajectoryDrawable.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx 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
31namespace 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
65
68
70 agx::UInt getNumTrajectoryPositions() const;
71
73 void setDefaultTrajectoryColor(const agx::Vec4f& color);
74
77
80
82 bool addTrajectory(agx::Frame* frame, agx::Vec4f color);
83
86
88 void setEnable(bool enable);
89
91 bool getEnable() const;
92
94 agxSDK::Simulation * getSimulation();
95
96 protected:
98
100
102
104 // Variables
106 protected:
107
110
114
121
122 };
123
125
127
129
131
133}
134
135#endif /* AGXOSG_PARTICLE_SYSTEMDRAWABLE_H */
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXOSG_EXPORT
void setDefaultTrajectoryColor(const agx::Vec4f &color)
Set default color of trajectories.
virtual osg::Object * clone(const osg::CopyOp &) const
bool addTrajectory(agx::Frame *frame, agx::Vec4f color)
Add a trajectory to be drawn given a frame and a color.
agx::Vector< std::tuple< agx::FrameRef, agx::Vec4f, TrajectoryData > > m_activeTrajectories
bool getEnable() const
Return true of the drawable is enabled.
void setNumTrajectoryPositions(agx::UInt num)
Set the number of positions used in the trajectories.
virtual const char * className() const
FrameTrajectoryDrawable(agxSDK::Simulation *simulation)
agxSDK::SimulationObserver m_simulation
agx::Vector< TrajectoryData > m_destroyedTrajectories
agx::UInt getNumTrajectoryPositions() const
Get the number of positions used in the trajectories.
agxSDK::Simulation * getSimulation()
Get the simulation related to the drawable.
bool removeTrajectory(agx::Frame *frame)
Remove the current stored trajectory from the drawable for a particle with given id.
void setEnable(bool enable)
Enable the drawable.
virtual osg::BoundingBox computeBound() const
Compute the bounding box around Drawables's geometry.
virtual osg::Object * cloneType() const
void resetTrajectories()
Reset trajectories.
virtual const char * libraryName() const
virtual void drawImplementation(osg::RenderInfo &renderInfo) const
The actual draw method for the particle system.
void updateTrajectories()
Update the trajectory structures.
bool addTrajectory(agx::Frame *frame)
Add a trajectory to be drawn given a frame.
virtual bool isSameKindAs(const osg::Object *obj) const
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:131
The object defining a frame of reference and providing transformations operations.
Definition: agx/Frame.h:68
Inheritance with partial specialization due to bug with ref_ptr containers.
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:35
Templated vector class.
Definition: agx/Vector.h:53
#define AGX_FORCE_INLINE
Definition: macros.h:58
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
uint64_t UInt
Definition: Integer.h:27