AGX Dynamics  2.35.0.1
GeometryNode.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 
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 
53 
59 
64  void setGeometry( agxCollide::Geometry* geometry );
65 
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 
96 
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 
121  public:
123 
124  protected:
125  // agxCollide::Space::Event::CallbackType m_removeGeometryCallback;
127 
129 
130  virtual ~GeometryNode();
131 
132  osg::ref_ptr<osg::Group> m_geometryParent;
133  osg::ref_ptr<osg::Group> m_renderParent;
134  };
135 
136 
137 } // Namespace agxOSG
138 
#define AGXOSG_EXPORT
The geometry representation used by the collision detection engine.
Definition: Geometry.h:93
This class contains all Geometries and performs Broad Phase and Narrow Phase collision detection to c...
Definition: Space.h:82
A node that can be associated with a collision geometry so that the transformation of this node is up...
Definition: GeometryNode.h:42
osg::Node * getRenderChild(RenderFlag flag)
void setRenderChild(RenderFlag flag, osg::Node *node)
Set a child to this node so it can be toggled with the setRenderFlag.
virtual osg::Object * clone(const osg::CopyOp &copyop) const
Definition: GeometryNode.h:84
void setGeometry(agxCollide::Geometry *geometry)
Associate this node's transformation with the transformation of the specified geometry.
GeometryNode(agxCollide::Geometry *geometry)
Constructor that associates this node's transformation with the transformation of the specified geome...
void setAutoRemove(bool flag)
Specify whether this node should be removed when the destructor of the associated geometry is called.
Definition: GeometryNode.h:81
agxCollide::Geometry * getGeometry()
Get the associated geometry.
GeometryNode(const GeometryNode &node, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
void removeNode(agxCollide::Space *space, agxCollide::Geometry *geometry)
bool getAutoRemove() const
Definition: GeometryNode.h:75
const osg::Node * getRenderChild(RenderFlag flag) const
RenderFlag getSelectedRenderChild() const
osg::ref_ptr< osg::Group > m_renderParent
Definition: GeometryNode.h:133
agxCollide::Geometry::ShapeChangeEvent::CallbackType shapeCallback
Definition: GeometryNode.h:122
agx::observer_ptr< agxCollide::Geometry > m_geometry
Definition: GeometryNode.h:128
virtual const char * className() const
Definition: GeometryNode.h:86
virtual osg::Object * cloneType() const
Definition: GeometryNode.h:83
void selectRenderChild(RenderFlag flag)
GeometryNode()
Default constructor.
virtual bool isSameKindAs(const osg::Object *obj) const
Definition: GeometryNode.h:85
virtual void traverse(osg::NodeVisitor &nv)
osg::ref_ptr< osg::Group > m_geometryParent
Definition: GeometryNode.h:132
virtual const char * libraryName() const
Definition: GeometryNode.h:87
T CallbackType
Definition: Event.h:37
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.