AGX Dynamics  2.37.2.0
agxOSG/RenderProxy.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 #ifndef AGXOSG_RENDERPROXY_H
18 #define AGXOSG_RENDERPROXY_H
19 
20 #include <agxOSG/export.h>
21 #include <agxRender/RenderProxy.h>
23 
24 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
25 #include <osg/ref_ptr>
26 #include <osg/Group>
27 #include <osg/MatrixTransform>
28 #include <osg/Material>
29 #include <osg/AutoTransform>
30 #include <osg/Shape>
31 #include <osg/ShapeDrawable>
32 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
33 
34 #include <agxOSG/GraphRenderer.h>
35 #include <agxOSG/RenderText.h>
36 #include <agxOSG/utils.h>
38 
39 #ifdef _MSC_VER
40 # pragma warning(push)
41 # pragma warning( disable : 4355 ) // warning C4355: 'this' : used in base member initializer list
42 #endif
43 
44 namespace osg
45 {
46  class Material;
47  class ShapeDrawable;
48 }
49 
50 namespace osgText
51 {
52  class Text;
53 }
54 
55 namespace agxOSG
56 {
57 
58  class SphereProxy;
59  class LineProxy;
60 
62 
75  {
76  public:
80  static void setDefaultDetailRatio( float detailRatio );
81 
85  static float getDefaultDetailRatio();
86 
87  public:
89 
93  agxRender::Graph::GraphRenderer *getGraphRenderer() override;
94 
95 
100  agxRender::SphereProxy* createSphere( float radius ) override;
101 
107  agxRender::TextProxy* createText( const agx::String& text, const agx::Vec3& pos ) override;
108 
113  agxRender::LineProxy* createLine( const agx::Vec3& p1, const agx::Vec3& p2 ) override;
114 
120  agxRender::CylinderProxy* createCylinder( float radius, float height ) override;
121 
127  agxRender::HollowCylinderProxy* createHollowCylinder( float radius, float height, float thickness ) override;
128 
134  agxRender::CapsuleProxy* createCapsule( float radius, float height ) override;
135 
136 
144  agxRender::WireShapeProxy* createWireShape( float radius, float height,
145  const agx::Vec3& previousEndPoint0, const agx::Vec3& previousEndPoint1) override;
146 
147 
152  agxRender::BoxProxy* createBox( const agx::Vec3& halfExtents ) override;
153 
158  agxRender::HeightFieldProxy* createHeightfield( agxCollide::HeightField* hf ) override;
159 
165 
171  agxRender::ConeProxy *createCone( float radius, float height ) override;
172 
179  agxRender::TruncatedConeProxy *createTruncatedCone( float topRadius, float bottomRadius, float height ) override;
180 
187  agxRender::HollowTruncatedConeProxy* createHollowTruncatedCone( float topRadius, float bottomRadius, float height, float thickness ) override;
188 
194  agxRender::PlaneProxy *createPlane( const agx::Vec3& normal, agx::Real distance ) override;
195 
196 
201  agxRender::ContactsProxy* createContacts( const agxCollide::GeometryContactPtrVector& contacts ) override;
202 
203  agxRender::RigidBodyBatchRenderProxy* createRigidBodies( const agx::RigidBodyPtrSetVector* enabledBodies ) override;
204 
205  agxRender::WireRenderProxy* createWire( float radius, const agx::Vec3& color ) override;
206 
207 
208  void setSphereBatchRenderModeSprites(bool flag);
209  agxRender::RenderProxy* createSphereBatchRenderer(
210  agxData::Buffer* positions, agxData::Buffer* rotations, agxData::Buffer* radii, agxData::Buffer* colors,
211  agxData::Buffer* enableRendering, agxData::Value* bound, agx::Component* context) override;
212 
218  osg::Group *getTextNode() { return m_textParent.get(); }
219 
224  osg::Node *getRootNode() { return m_parent; }
225 
229  osg::Group *getSolidRootNode() { return m_solidParent; }
230 
234  osg::Group *getWireframeRootNode() { return m_wireframeParent; }
235 
243  void setGlobalTransform( const agx::AffineMatrix4x4& m );
244 
248  const agx::AffineMatrix4x4& getGlobalTransform() const { return m_invTransform; }
249 
253  void setRenderMode( agxRender::RenderProxy *proxy, osg::Node *node, agxRender::RenderProxy::RenderMode mode );
254 
255  public:
257  template<typename T>
258  struct ShapeData {
259  ShapeData() : material(nullptr) {}
260  ShapeData(const ShapeData& other)
261  {
262  shape = other.shape;
263  geode = other.geode;
264  material = other.material;
265  stateSet = other.stateSet;
266  }
267 
268  osg::ref_ptr<T> shape;
269  osg::ref_ptr<osg::Geode> geode;
270  osg::Material *material;
271  osg::ref_ptr<osg::StateSet> stateSet;
272  };
273 
274 
279  void addChild( osg::Node * node, agxRender::RenderProxy::RenderMode mode );
280  void addChild( osg::Node * node, agxRender::RenderProxy *proxy );
281 
282  protected:
284  virtual ~RenderProxyFactory();
285 
286  osg::ref_ptr<osg::Group> m_solidParent;
287  osg::ref_ptr<osg::Group> m_wireframeParent;
288  osg::ref_ptr<osg::MatrixTransform> m_parent;
289  osg::ref_ptr<osg::Group> m_textParent;
293  };
294 
295 
296 
298  template<typename T>
299  class OSGData
300  {
301  public:
303  : m_data(data), m_factory(factory), m_proxy(proxy)
304  {
305  m_transformNode = new osg::MatrixTransform;
306 
307  m_transformNode->addChild( m_data.geode );
308 
309  // Tell osg not to remove this transformation under optimization pass
310  m_transformNode->setDataVariance( osg::Object::DYNAMIC );
311 
312  m_data.stateSet = m_transformNode->getOrCreateStateSet();
313 
314  m_data.material = new osg::Material;
315  m_data.stateSet->setAttributeAndModes(m_data.material,osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE | osg::StateAttribute::PROTECTED);
316  setColorOSG( agx::Vec3( 1, 0, 0 ), 1.f );
317  }
318 
320  : m_data(), m_factory( factory ), m_proxy( proxy )
321  {
322  m_transformNode = new osg::MatrixTransform();
323  m_transformNode->setDataVariance( osg::Object::DYNAMIC );
324 
325  m_data.stateSet = m_transformNode->getOrCreateStateSet();
326  m_data.material = new osg::Material;
327  m_data.stateSet->setAttributeAndModes( m_data.material, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE | osg::StateAttribute::PROTECTED );
328  setColorOSG( agx::Vec3( 1, 0, 0 ), 1.f );
329  }
330 
333  {
335  agx::AffineMatrix4x4 m = transform * m_factory->getGlobalTransform();
336  m_transformNode->setMatrix( AGX_MAT4X4_TO_OSG( m ) );
337  }
338 
340  void setEnableOSG( bool flag )
341  {
342  if (!flag) { // Remove node from all its parents
343  while(m_transformNode->getNumParents())
344  {
345  m_transformNode->getParent(0)->removeChild( m_transformNode.get() );
346  }
347 
348  }
349  else //Add it for rendering again.
350  m_factory->addChild( m_transformNode.get(), m_proxy );
351  }
352 
354  void setAlphaOSG( float transparency )
355  {
356  m_data.material->setTransparency(osg::Material::FRONT_AND_BACK, 1-transparency);
357  }
358 
360  void setColorOSG(const agx::Vec3& color, float alpha)
361  {
362  osg::Vec4 col = m_data.material->getDiffuse(osg::Material::FRONT_AND_BACK);
363 
364  if ( agx::equivalent( (float)col[0], (float)color[0] ) &&
365  agx::equivalent( (float)col[1], (float)color[1] ) &&
366  agx::equivalent( (float)col[2], (float)color[2] ) )
367  return;
368 
369  osg::Vec4 osgCol( (float)color[0], (float)color[1], (float)color[2], alpha );
370  m_data.material->setDiffuse(osg::Material::FRONT_AND_BACK, osgCol);
371 
372  for ( unsigned int i = 0; m_data.geode != nullptr && i < m_data.geode->getNumDrawables(); ++i ) {
373  osg::ShapeDrawable* drawable = dynamic_cast< osg::ShapeDrawable* >( m_data.geode->getDrawable( i ) );
374  if ( drawable )
375  drawable->setColor( osgCol );
376  }
377  }
378 
380  void onRemoveOSG()
381  {
382  osg::ref_ptr<osg::MatrixTransform> r = m_transformNode;
383  while(m_transformNode->getNumParents())
384  {
385  m_transformNode->getParent(0)->removeChild( m_transformNode.get() );
386  }
387  }
388 
391  {
392  m_factory->setRenderMode( m_proxy, m_transformNode, mode );
393  }
394 
396  osg::MatrixTransform* getNode() { return m_transformNode.get(); }
397 
398  protected:
399  osg::ref_ptr<osg::MatrixTransform> m_transformNode;
404  };
405 
407 #define ADD_COMMON_METHODS() \
408  void onChange( RenderProxy::EventType type ) override { \
409  switch( type ) { \
410  case (RenderProxy::ENABLE): \
411  this->setEnableOSG(this->getEnable()); \
412  break; \
413  case (RenderProxy::ALPHA): \
414  this->setAlphaOSG(this->getAlpha()); \
415  break; \
416  case (RenderProxy::TRANSFORM): \
417  this->setTransformOSG(this->getTransform()); \
418  break; \
419  case (RenderProxy::COLOR): \
420  this->setColorOSG(this->getColor(), this->getAlpha()); \
421  break; \
422  case (RenderProxy::SHAPE): \
423  break; \
424  case (RenderProxy::REMOVE): \
425  this->onRemoveOSG(); \
426  break; \
427  case (RenderProxy::RENDERMODE): \
428  this->setRenderModeOSG(this->getRenderMode()); \
429  break; \
430  } \
431  } \
432  virtual void updateShape() override
433 
435  class AGXOSG_EXPORT SphereProxy : public agxRender::SphereProxy, public OSGData<osg::Sphere>
436  {
437  public:
439 
440  protected:
441  virtual ~SphereProxy() {}
442 
444  };
445 
447  class AGXOSG_EXPORT TextProxy : public agxRender::TextProxy, public OSGData<agxOSG::TextGeometry>
448  {
449  public:
451 
452  void setTransform(const agx::AffineMatrix4x4& transform) override;
453 
454  protected:
455  virtual ~TextProxy() {}
456 
458  };
459 
460 
462  class AGXOSG_EXPORT BoxProxy : public agxRender::BoxProxy, public OSGData<osg::Box>
463  {
464  public:
466 
467  protected:
468  virtual ~BoxProxy() {}
469 
471  };
472 
474  class AGXOSG_EXPORT LineProxy : public agxRender::LineProxy, public OSGData<osg::Geometry>
475  {
476  public:
478 
479  protected:
480  virtual ~LineProxy() {}
481 
483  };
484 
486  class AGXOSG_EXPORT CylinderProxy : public agxRender::CylinderProxy, public OSGData<osg::Cylinder>
487  {
488  public:
489  CylinderProxy( float radius, float height, RenderProxyFactory::ShapeData<osg::Cylinder> data, RenderProxyFactory* factory );
490 
491  protected:
492  virtual ~CylinderProxy() {}
493 
495  };
496 
499  {
500  public:
501  HollowCylinderProxy( float radius, float height, float thickness, RenderProxyFactory::ShapeData<osg::Geometry> data, RenderProxyFactory* factory );
502 
503  protected:
504  virtual ~HollowCylinderProxy() {}
505 
507  };
508 
510  class AGXOSG_EXPORT ConeProxy : public agxRender::ConeProxy, public OSGData<osg::Cone>
511  {
512  public:
513  ConeProxy( float radius, float height, RenderProxyFactory::ShapeData<osg::Cone> data, RenderProxyFactory* factory );
514 
515  protected:
516  virtual ~ConeProxy() {}
517 
519  };
520 
523  {
524  public:
525  TruncatedConeProxy( float topRadius, float bottomRadius, float height, RenderProxyFactory::ShapeData<osg::Geometry> data, RenderProxyFactory* factory );
526 
527  protected:
528  virtual ~TruncatedConeProxy() {}
529 
531  };
532 
535  {
536  public:
537  HollowTruncatedConeProxy( float topRadius, float bottomRadius, float height, float thickness,
539 
540  protected:
542 
544  };
545 
547  class AGXOSG_EXPORT PlaneProxy : public agxRender::PlaneProxy, public OSGData<osg::Geometry>
548  {
549  public:
551 
552  protected:
553  virtual ~PlaneProxy() {}
554 
556  };
557 
559  class AGXOSG_EXPORT CapsuleProxy : public agxRender::CapsuleProxy, public OSGData<osg::Capsule>
560  {
561  public:
562  CapsuleProxy( float radius, float height, RenderProxyFactory::ShapeData<osg::Capsule> data, RenderProxyFactory* factory );
563 
564  protected:
565  virtual ~CapsuleProxy() {}
566 
568  };
569 
570 
572  class AGXOSG_EXPORT WireShapeProxy : public agxRender::WireShapeProxy, public OSGData<osg::CompositeShape>
573  {
574  public:
575  WireShapeProxy( float radius, float height, const agx::Vec3& previousEndPoint0, const agx::Vec3& previousEndPoint1,
577 
578  protected:
579  virtual ~WireShapeProxy() {}
580 
582  };
583 
586  {
587  public:
589 
590  void set( const agx::Vec2iVector& modifiedIndices, const agx::RealVector& heights ) override;
591 
592  protected:
593  virtual ~HeightFieldProxy() {}
594 
596  };
597 
599  class AGXOSG_EXPORT TrimeshProxy : public agxRender::TrimeshProxy, public OSGData<osg::TriangleMesh>
600  {
601  public:
603 
604  protected:
605  virtual ~TrimeshProxy() {}
606 
608  };
609 
614  template< typename TransformType >
615  class ShapeBatchRenderer : public OSGData< osg::Group >
616  {
617  public:
621  void clear();
622 
627  void setScale( float scale );
628 
632  float getScale() const;
633 
634  protected:
641  ShapeBatchRenderer( osg::Shape* shape, agxOSG::RenderProxyFactory* factory, agxRender::RenderProxy* proxy );
642 
649  ShapeBatchRenderer( osg::Geode* geode, agxOSG::RenderProxyFactory* factory, agxRender::RenderProxy* proxy );
650 
654  virtual ~ShapeBatchRenderer() { clear(); }
655 
660  void prepare( size_t numObjects );
661 
665  void prepareWithScale( size_t numObjects );
666 
673  void setTransform( TransformType* obj, const agx::AffineMatrix4x4& transform, const agx::Vec3f& scale );
674 
675  protected:
676  osg::ref_ptr< osg::Geode > m_geode;
677  float m_scale;
678  };
679 
691  template< typename ContainerType, typename TransformType >
692  class ContainerShapeBatchRenderer : public ShapeBatchRenderer< TransformType >
693  {
694  public:
702  ContainerShapeBatchRenderer( osg::Geode* geode, const ContainerType* container, agxOSG::RenderProxyFactory* factory, agxRender::RenderProxy* proxy )
703  : ShapeBatchRenderer< TransformType >( geode, factory, proxy ), m_container( container ) {}
704 
708  virtual ~ContainerShapeBatchRenderer() { this->clear(); }
709 
713  void clear();
714 
718  void update( bool addScaleTransform = false );
719 
723  void setContainer( const ContainerType* container );
724 
725  protected:
731  agx::AffineMatrix4x4 findTransform( const typename ContainerType::value_type& val ) const;
732 
737  agx::Vec3f findScale( const typename ContainerType::value_type& val ) const;
738 
739  protected:
740  const ContainerType* m_container;
741  };
742 
743  #if 0
744  class SphereSpriteBatchRenderer : public ContainerShapeBatchRenderer< agxData::Array< agx::Vec3 >, osg::MatrixTransform >, public agxRender::SphereSpriteBatchRenderProxy
745  {
746  public:
747  SphereSpriteBatchRenderer( osg::Geode* geode, const agxData::Array< agx::Vec3 >* container, agxOSG::RenderProxyFactory* factory )
748  : ContainerShapeBatchRenderer< agxData::Array< agx::Vec3 >, osg::MatrixTransform >( geode, container, factory, this ),
749  agxRender::SphereSpriteBatchRenderProxy( container ) {}
750 
751  protected:
752  virtual ~SphereSpriteBatchRenderer() {}
753 
755  {
756  this->m_container = m_buffer;
757  this->update();
758  }
759 
760  virtual void reset() override
761  {
762  // I don't think we can or could do anything during reset.
763  }
764  };
765  #endif
766 
770  template< typename ContainerType, typename TransformType >
772  {
773  public:
774  RigidBodyBatchRenderProxy( osg::Geode* geode, const ContainerType* container, agxOSG::RenderProxyFactory* factory )
775  : ContainerShapeBatchRenderer< ContainerType, TransformType >( geode, container, factory, this ) {}
776 
777  protected:
779 
780  // This is virtual void updateShape().
782  {
783  this->m_container = &m_bodies;
785 
786  // Will update root transform given a global transform.
788 
789  this->update();
790  }
791 
792  virtual void reset() override
793  {
794  // I don't think we can or could do anything during reset.
795  }
796  };
797 
801  class ContactProxy : public ContainerShapeBatchRenderer< agxCollide::GeometryContactPtrVector, osg::AutoTransform >, public agxRender::ContactsProxy
802  {
803  public:
804  ContactProxy( osg::Geode* geode, const agxCollide::GeometryContactPtrVector* contacts, agxOSG::RenderProxyFactory* factory );
805 
806  protected:
807  virtual ~ContactProxy() {}
808 
810 
811  virtual void reset() override
812  {
813  // I don't think we can or could do anything during reset.
814  }
815  };
816 
818  {
819  public:
820  WireRenderProxy( float radius, const agx::Vec3& color, osg::Geode* segmentGeode, osg::Geode* edgeGeode, osg::Geode* nodeGeode, agxOSG::RenderProxyFactory* factory );
821 
822  osg::MatrixTransform* getSegmentTransform();
823  osg::MatrixTransform* getEdgeTransform();
824  osg::MatrixTransform* getSphereTransform();
825 
826  protected:
827  virtual ~WireRenderProxy();
828 
829  virtual void onAddNotification() override;
830  virtual void onRemoveNotification() override;
831 
832  void setTransformOSG( const agx::AffineMatrix4x4& transform );
833  void setEnableOSG( bool flag );
834  void setAlphaOSG( float transparency );
835  void setColorOSG(const agx::Vec3& color, float alpha);
836  void onRemoveOSG();
837  void setRenderModeOSG( agxRender::RenderProxy::RenderMode mode );
838 
840 
841  virtual void reset() override
842  {
843  // I don't think we can or could do anything during reset.
844  }
845 
846  protected:
850 
851  private:
852  // Not defined to call this method on this object.
853  osg::MatrixTransform* getNode() { return nullptr; }
854  };
855 
856  template< typename TransformType >
858  {
859  if ( m_transformNode )
860  m_transformNode->removeChild( 0, m_transformNode->getNumChildren() );
861  }
862 
863  template< typename TransformType >
865  {
866  m_scale = scale;
867  }
868 
869  template< typename TransformType >
871  {
872  return m_scale;
873  }
874 
875  template< typename ContainerType, typename TransformType >
877  {
879  m_container = nullptr;
880  }
881 
882  template< typename ContainerType, typename TransformType >
883  void ContainerShapeBatchRenderer< ContainerType, TransformType >::update( bool addScaleTransform /* = false */ )
884  {
885  if ( this->m_container == nullptr )
886  return;
887 
888  if ( addScaleTransform )
889  this->prepareWithScale( this->m_container->size() );
890  else
891  this->prepare( this->m_container->size() );
892 
893  unsigned int counter = 0;
894  for ( typename ContainerType::const_iterator i = m_container->begin(); i != m_container->end(); ++counter, ++i ) {
895  agxAssert( counter < this->m_transformNode->getNumChildren() );
896  TransformType* transform = static_cast< TransformType* >( this->m_transformNode->getChild( counter ) );
897  this->setTransform( transform, this->findTransform( *i ), this->findScale( *i ) );
898  }
899  }
900 
901  template< typename ContainerType, typename TransformType >
903  {
904  m_container = container;
905  }
906 
907  template< typename ContainerType, typename TransformType >
909  {
910  return val->getTransform();
911  }
912 
913  template<>
915  {
916  return agx::AffineMatrix4x4();
917  }
918 
919  template<>
921  {
922  return rbRefPtr->getCmTransform();
923  }
924 
925  template<>
927  {
928  return rbPtr->getCmTransform();
929  }
930 
931  template<>
933  {
935  }
936 
937  template< typename ContainerType, typename TransformType >
938  agx::Vec3f ContainerShapeBatchRenderer< ContainerType, TransformType >::findScale( const typename ContainerType::value_type& /*val*/ ) const
939  {
941  }
942 
943  template<>
945  {
946  return val->getScale();
947  }
948 }
949 
950 #ifdef _MSC_VER
951 # pragma warning(pop)
952 #endif
953 
954 #endif
osg::ref_ptr< osg::Group > m_textParent
agx::ref_ptr< agxOSG::GraphRenderer > m_graphRenderer
AGXTERRAIN_EXPORT void clear()
Class for storing OSG specific data for each RenderProxy.
#define AGX_MAT4X4_TO_OSG(X)
AffineMatrix4x4T< Real > AffineMatrix4x4
#define AGXOSG_EXPORT
virtual void setTransform(const agx::AffineMatrix4x4 &transform)
Set the transform of this RenderProxy, if overridden, set the m_transform and call onUpdate(TRANSFORM...
static AffineMatrix4x4T< Real > translate(const Vec3T< Real > &dv)
Return a matrix which translates according to dv.
Base class for batch rendering of any shape or shape composite.
virtual void reset() override
Will reset color, alpha and enabled state back to default state (as when initially created)...
Class that handles batch rendering of objects in forward iterator compliant container.
Implementation of osg-based TrimeshProxy.
Subclass that implements a BoxProxy.
A component is an object containing other objects, enabling hierarchical structuring.
Definition: Component.h:38
Abstract representation of a value.
Definition: Value.h:48
virtual ~ContainerShapeBatchRenderer()
Destructor.
void setTransformOSG(const agx::AffineMatrix4x4 &transform)
Transform a node.
Subclass that implements a TruncatedConeProxy.
virtual void reset() override
Will reset color, alpha and enabled state back to default state (as when initially created)...
Vec4T< Real > Vec4
Definition: Vec4.h:25
void AGXCORE_EXPORT transform(void *target, const Format *targetFormat, const void *source, const Format *sourceFormat, size_t numElements)
Transform data between two buffers.
void setColorOSG(const agx::Vec3 &color, float alpha)
Set the color and alpha value.
Subclass that implements a CylinderProxy.
void setRenderModeOSG(agxRender::RenderProxy::RenderMode mode)
Change the render mode.
osg::ref_ptr< osg::MatrixTransform > m_transformNode
ContainerShapeBatchRenderer< agxRender::WireRenderProxy::SegmentDefContainer, osg::MatrixTransform > m_edgeBatch
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
Subclass that implements a TrimeshProxy.
Implementation of the abstract class from the agxRender namespace, this class is responsible for crea...
Subclass that implements a CapsuleProxy.
Implementation of osg-based HollowCylinderProxy.
AGXOSG_EXPORT agxCollide::Trimesh * createTrimesh(osg::Node *node)
Extracts mesh data from an osg::Node, creates an agxCollide::Trimesh from it and returns the result...
Type-specific Array used for fast access into the data held by a Buffer.
Definition: agxData.h:30
Abstract class which is responsible for returning a pointer to a specified RenderProxy type...
osg::MatrixTransform * getNode()
\ return the node for this RenderProxy
void setEnableOSG(bool flag)
Enable/disable rendering.
const agx::AffineMatrix4x4 & getGlobalTransform() const
RenderProxyFactory::ShapeData< T > m_data
Implementation of osg-based SphereProxy.
Subclass that implements a SphereProxy.
T value_type
Definition: Vector.h:56
osg::Group * getTextNode()
The text node is not child of the node returned in getRootNode(), hence this node MUST be added separ...
Vector containing &#39;raw&#39; data.
Definition: Vector.h:245
Implementation of osg-based LineProxy.
const Node * getNode(const IteratorCompatibleContainer &container, agx::Real distanceFromStart)
Finds the wire node given current distance from the start of the wire (wire defined to be iterator co...
Definition: WireUtils.h:392
agx::AffineMatrix4x4 m_invTransform
Implementation of osg-based HollowTruncatedConeProxy.
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
osg::ref_ptr< osg::StateSet > stateSet
Class holding contacts that makes it possible to batch render these objects.
Abstract representation of a data buffer.
Definition: Buffer.h:55
osg::ref_ptr< osg::Geode > m_geode
osg::ref_ptr< osg::MatrixTransform > m_parent
Implementation of osg-based BoxProxy.
RigidBodyBatchRenderProxy(osg::Geode *geode, const ContainerType *container, agxOSG::RenderProxyFactory *factory)
Subclass that implements a PlaneProxy.
Implementation of osg-based TextProxy.
Vec3T< Real32 > Vec3f
Definition: Vec3.h:39
osg::ref_ptr< osg::Group > m_solidParent
Implementation of osg-based HeightfieldProxy.
ContainerShapeBatchRenderer(osg::Geode *geode, const ContainerType *container, agxOSG::RenderProxyFactory *factory, agxRender::RenderProxy *proxy)
Construct given shape composite and compatible container.
#define agxAssert(expr)
Definition: debug.h:143
Implementation of osg-based PlaneProxy.
ContainerShapeBatchRenderer< agxRender::WireRenderProxy::SegmentDefContainer, osg::MatrixTransform > m_segmentBatch
Abstract base class which encapsulated information for rendering a specific shape.
AGXPHYSICS_EXPORT agx::Bool equivalent(const agx::AddedMassInteraction::Matrix6x6 &lhs, const agx::AddedMassInteraction::Matrix6x6 &rhs, agx::Real eps=agx::RealEpsilon)
DataT value_type
Definition: SetVector.h:41
Subclass that implements a HollowTruncatedConeProxy.
Implementation of osg-based CylinderProxy.
Class for handling methods related to OSG such as setColor, setTransform etc.
Implementation of osg-based ConeProxy.
Implementation of batch rendering of contact points.
agx::AffineMatrix4x4 m_invTransform
Subclass that implements a TextProxy.
Abstract base class that acts as an interface and can render the data from a Graph.
Definition: Graph.h:45
ContainerShapeBatchRenderer< agxRender::WireRenderProxy::SphereDefContainer, osg::MatrixTransform > m_sphereBatch
AGXOSG_EXPORT osg::Geode * createLine(const agx::Vec3 &p1, const agx::Vec3 &p2, const agx::Vec4 &color, float width)
Create and return a new Line to render.
Implementation of osg-based TruncatedConeProxy.
void onRemoveOSG()
Remove the node from all its parents.
Implementation of osg-based CapsuleProxy.
OSGData(agxOSG::RenderProxyFactory *factory, agxRender::RenderProxy *proxy)
double Real
Definition: Real.h:42
virtual void reset() override
Will reset color, alpha and enabled state back to default state (as when initially created)...
#define ADD_COMMON_METHODS()
Macro for adding some methods for each specialization of RenderProxy.
AGXOSG_EXPORT osg::Geode * createText(const std::string &text, const agx::Vec3 &relPosition=agx::Vec3(0, 0, 0), const agx::Vec4f &color=agxRender::Color::Yellow(), agx::Real size=0.2)
Create a text object.
Implementation of osg-based WireShapeProxy.
agxOSG::RenderProxyFactory * m_factory
void setAlphaOSG(float transparency)
Set the alpha value.
OSGData(const RenderProxyFactory::ShapeData< T > &data, agxOSG::RenderProxyFactory *factory, agxRender::RenderProxy *proxy)
Subclass that implements a ConeProxy.
Implementation of batch rendering of rigid body center of mass position.
Subclass that implements a WireShapeProxy.
Class holding rigid bodies that makes it possible to batch render these objects.
Subclass that implements a HeightfieldProxy.
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:42
Subclass that implements a LineProxy.
agxRender::RenderProxy * m_proxy
virtual ~ShapeBatchRenderer()
Destructor.
virtual ~HeightFieldProxy()
Destructor.
Subclass that implements a CylinderProxy.
A HeightField is a collision shape that can be created from a grid structure, like an image...
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: SetVector.h:37
osg::ref_ptr< osg::Group > m_wireframeParent