AGX Dynamics  2.35.0.1
CableDamageRenderer.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, 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 #pragma once
17 
18 #include <agxOSG/export.h>
19 
20 #include <agxCable/CableDamage.h>
21 
23 
24 #include <agx/Vector.h>
25 #include <agxOSG/Node.h>
26 #include <agxOSG/GeometryNode.h>
27 
28 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
29 #include <osg/observer_ptr>
30 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
31 
32 
33 
34 namespace agxOSG
35 {
37 
38 
45  {
46  public:
58  CableDamageRenderer(agxCable::CableDamage* damage, agx::Real colorRangeMax, osg::Group* root);
59 
60  void renderCurrent();
62 
63  bool isRenderingCurrent() const;
64  bool isRenderingAccumulated() const;
65 
72  void setEnableRendering(bool enable);
73 
74 
78  bool getEnableRendering() const;
79 
85 
92  void setColorRangeMax(agx::Real colorRangeMax);
93 
103 
108  virtual void last(const agx::Real& timeStamp) override;
109 
110  protected:
111  virtual ~CableDamageRenderer() {}
112 
113  private:
114  CableDamageRenderer& operator=(CableDamageRenderer&) = delete;
115 
116  private:
117  agxCable::CableDamageRef m_damage;
118  osg::observer_ptr<osg::Group> m_parent;
120  agx::Real m_colorRangeMax;
121  bool m_renderAccumulatedInsteadOfCurrent;
122  };
123 
124 }
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXOSG_EXPORT
The CableDamage class is used to estimate damage caused to a cable during a simulation.
Definition: CableDamage.h:58
Class that creates OSG rendering nodes for each segment of a cable and colors them with a color gradi...
void setColorRangeMax(agx::Real colorRangeMax)
Set the damage at which the color gradient should reach its maxmimu.
bool isRenderingAccumulated() const
CableDamageRenderer(agxCable::CableDamage *damage, agx::Real colorRangeMax, osg::Group *root)
Create a damage renderer for the given CableDamage instance.
agx::Real getColorRangeMax() const
virtual void last(const agx::Real &timeStamp) override
Update the rendering colors based on the current segment damages.
agxOSG::GeometryNode * getOsgNode(size_t index)
Gives access to the OSG nodes created for the cable segments.
void setEnableRendering(bool enable)
Enable or disable rendering by adding or removing the created OSG nodes from the node that was passed...
A node that can be associated with a collision geometry so that the transformation of this node is up...
Definition: GeometryNode.h:42
Derive from this class to implement a listener for simulation step events.
Templated vector class.
Definition: agx/Vector.h:53
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
AGXCORE_EXPORT Component * root()
double Real
Definition: Real.h:42