AGX Dynamics  2.38.0.2
GeometryNode.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 #pragma once
18 
19 #include <agxOSG/export.h>
20 
21 #include <agxCollide/Geometry.h>
22 #include <agxCollide/Space.h>
23 
24 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
25 #include <osg/MatrixTransform>
26 #include <osg/observer_ptr>
27 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
28 
29 namespace agxOSG
30 {
31 
32  class Node;
33 
41  class AGXOSG_EXPORT GeometryNode : public osg::MatrixTransform
42  {
43  public:
44 
46  {
47  RENDER_DATA=0x1,
48  GEOMETRY_DATA=0x2
49  };
50 
52  GeometryNode();
53 
59 
64  void setGeometry( agxCollide::Geometry* geometry );
65 
69  agxCollide::Geometry *getGeometry();
70 
75  bool getAutoRemove() const { return m_autoRemove; }
76 
81  void setAutoRemove( bool flag ) { m_autoRemove = flag; }
82 
83  virtual osg::Object* cloneType() const { return new GeometryNode (); }
84  virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new GeometryNode (*this,copyop); }
85  virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const GeometryNode *>(obj)!=nullptr; }
86  virtual const char* className() const { return "MatrixTransform"; }
87  virtual const char* libraryName() const { return "osg"; }
88 
89  virtual void traverse(osg::NodeVisitor& nv);
90 
92  GeometryNode( const GeometryNode& node, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY );
93 
94  void removeNode(agxCollide::Space* space, agxCollide::Geometry *geometry);
95  void removeFromParents();
96 
97  void selectRenderChild(RenderFlag flag);
98  RenderFlag getSelectedRenderChild() const;
99 
106  void setRenderChild(RenderFlag flag, osg::Node *node);
107 
108 
113  osg::Node *getRenderChild(RenderFlag flag);
114 
119  const osg::Node *getRenderChild(RenderFlag flag) const;
120 
124  void updateTransform();
125 
126  public:
128 
129  protected:
130  // agxCollide::Space::Event::CallbackType m_removeGeometryCallback;
132 
134 
135  virtual ~GeometryNode();
136 
137  osg::ref_ptr<osg::Group> m_geometryParent;
138  osg::ref_ptr<osg::Group> m_renderParent;
139  };
140 
141 
142 } // Namespace agxOSG
143 
agxOSG::GeometryNode::m_geometry
agx::observer_ptr< agxCollide::Geometry > m_geometry
Definition: GeometryNode.h:133
agxOSG::GeometryNode::m_geometryParent
osg::ref_ptr< osg::Group > m_geometryParent
Definition: GeometryNode.h:137
agxOSG::GeometryNode::className
virtual const char * className() const
Definition: GeometryNode.h:86
agxOSG::GeometryNode::getAutoRemove
bool getAutoRemove() const
Definition: GeometryNode.h:75
Geometry.h
agx::observer_ptr< agxCollide::Geometry >
Space.h
agxOSG::GeometryNode::shapeCallback
agxCollide::Geometry::ShapeChangeEvent::CallbackType shapeCallback
Definition: GeometryNode.h:127
agxOSG
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
PushDisableWarnings.h
agxOSG::GeometryNode::isSameKindAs
virtual bool isSameKindAs(const osg::Object *obj) const
Definition: GeometryNode.h:85
agxCollide::Geometry
The geometry representation used by the collision detection engine.
Definition: Geometry.h:91
agxOSG::GeometryNode::m_autoRemove
bool m_autoRemove
Definition: GeometryNode.h:131
agxCollide::Space
This class contains all Geometries and performs Broad Phase and Narrow Phase collision detection to c...
Definition: Space.h:81
agxOSG::GeometryNode::setAutoRemove
void setAutoRemove(bool flag)
Specify whether this node should be removed when the destructor of the associated geometry is called.
Definition: GeometryNode.h:81
agxOSG::GeometryNode::clone
virtual osg::Object * clone(const osg::CopyOp &copyop) const
Definition: GeometryNode.h:84
agx::Callback1
Templated callback with one argument.
Definition: Callback.h:100
export.h
agxOSG::GeometryNode::m_renderParent
osg::ref_ptr< osg::Group > m_renderParent
Definition: GeometryNode.h:138
agxOSG::GeometryNode::cloneType
virtual osg::Object * cloneType() const
Definition: GeometryNode.h:83
agxOSG::GeometryNode::RenderFlag
RenderFlag
Definition: GeometryNode.h:45
agxOSG::GeometryNode
A node that can be associated with a collision geometry so that the transformation of this node is up...
Definition: GeometryNode.h:41
agxOSG::GeometryNode::libraryName
virtual const char * libraryName() const
Definition: GeometryNode.h:87
AGXOSG_EXPORT
#define AGXOSG_EXPORT
PopDisableWarnings.h