AGXDynamics  2.35.0.3
agxOSG/RenderProxy.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 #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  {
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.
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  {
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 
833  void setEnableOSG( bool flag );
834  void setAlphaOSG( float transparency );
835  void setColorOSG(const agx::Vec3& color, float alpha);
836  void onRemoveOSG();
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
ADD_COMMON_METHODS
#define ADD_COMMON_METHODS()
Macro for adding some methods for each specialization of RenderProxy.
Definition: agxOSG/RenderProxy.h:407
agxOSG::WireRenderProxy
Definition: agxOSG/RenderProxy.h:817
agxOSG::WireRenderProxy::getSegmentTransform
osg::MatrixTransform * getSegmentTransform()
agxOSG::RenderProxyFactory::ShapeData::stateSet
osg::ref_ptr< osg::StateSet > stateSet
Definition: agxOSG/RenderProxy.h:271
agxData::Value
Abstract representation of a value.
Definition: Value.h:42
agxOSG::ConeProxy
Implementation of osg-based ConeProxy.
Definition: agxOSG/RenderProxy.h:510
agxOSG::WireRenderProxy::setRenderModeOSG
void setRenderModeOSG(agxRender::RenderProxy::RenderMode mode)
agxOSG::PlaneProxy::~PlaneProxy
virtual ~PlaneProxy()
Definition: agxOSG/RenderProxy.h:553
agx::Real
double Real
Definition: Real.h:42
agxOSG::RenderProxyFactory::ShapeData::geode
osg::ref_ptr< osg::Geode > geode
Definition: agxOSG/RenderProxy.h:269
agxOSG::RenderProxyFactory::ShapeData::material
osg::Material * material
Definition: agxOSG/RenderProxy.h:270
agxOSG::HollowTruncatedConeProxy
Implementation of osg-based HollowTruncatedConeProxy.
Definition: agxOSG/RenderProxy.h:534
agx::equivalent
AGXPHYSICS_EXPORT agx::Bool equivalent(const agx::AddedMassInteraction::Matrix6x6 &lhs, const agx::AddedMassInteraction::Matrix6x6 &rhs, agx::Real eps=agx::RealEpsilon)
agxOSG::CapsuleProxy::~CapsuleProxy
virtual ~CapsuleProxy()
Definition: agxOSG/RenderProxy.h:565
agxData::transform
void AGXCORE_EXPORT transform(void *target, const Format *targetFormat, const void *source, const Format *sourceFormat, size_t numElements)
Transform data between two buffers.
agxOSG::BoxProxy::~BoxProxy
virtual ~BoxProxy()
Definition: agxOSG/RenderProxy.h:468
agxOSG::WireRenderProxy::getSphereTransform
osg::MatrixTransform * getSphereTransform()
agxOSG::PlaneProxy
Implementation of osg-based PlaneProxy.
Definition: agxOSG/RenderProxy.h:547
agxOSG::SphereProxy::~SphereProxy
virtual ~SphereProxy()
Definition: agxOSG/RenderProxy.h:441
GraphRenderer.h
agxOSG::ContainerShapeBatchRenderer::findScale
agx::Vec3f findScale(const typename ContainerType::value_type &val) const
Find scale (agx::Vec3) given container value type.
Definition: agxOSG/RenderProxy.h:938
agxOSG::RigidBodyBatchRenderProxy::ADD_COMMON_METHODS
ADD_COMMON_METHODS()
Definition: agxOSG/RenderProxy.h:781
agxOSG::ShapeBatchRenderer::prepare
void prepare(size_t numObjects)
Prepare the root transform with the current amount of child nodes.
agxRender::ConeProxy
Subclass that implements a ConeProxy.
Definition: agxRender/RenderProxy.h:423
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
agxOSG::RenderProxyFactory::getRootNode
osg::Node * getRootNode()
Definition: agxOSG/RenderProxy.h:224
agxOSG::WireRenderProxy::m_segmentBatch
ContainerShapeBatchRenderer< agxRender::WireRenderProxy::SegmentDefContainer, osg::MatrixTransform > m_segmentBatch
Definition: agxOSG/RenderProxy.h:847
agx::AffineMatrix4x4T< Real >::translate
static AffineMatrix4x4T< Real > translate(const Vec3T< Real > &dv)
Return a matrix which translates according to dv.
Definition: AffineMatrix4x4.h:657
agxOSG::ShapeBatchRenderer::ShapeBatchRenderer
ShapeBatchRenderer(osg::Shape *shape, agxOSG::RenderProxyFactory *factory, agxRender::RenderProxy *proxy)
Construct given single shape.
agxOSG::WireRenderProxy::onRemoveOSG
void onRemoveOSG()
agxOSG::ShapeBatchRenderer::clear
void clear()
Clear the root transform node from all child transforms.
Definition: agxOSG/RenderProxy.h:857
agxOSG::WireRenderProxy::setAlphaOSG
void setAlphaOSG(float transparency)
agxOSG::RenderProxyFactory::ShapeData::ShapeData
ShapeData()
Definition: agxOSG/RenderProxy.h:259
agxOSG::RenderProxyFactory::m_textParent
osg::ref_ptr< osg::Group > m_textParent
Definition: agxOSG/RenderProxy.h:289
agxOSG::RenderProxyFactory::getTextNode
osg::Group * getTextNode()
The text node is not child of the node returned in getRootNode(), hence this node MUST be added separ...
Definition: agxOSG/RenderProxy.h:218
agxOSG::HeightFieldProxy
Implementation of osg-based HeightfieldProxy.
Definition: agxOSG/RenderProxy.h:585
agxOSG::RenderProxyFactory::getWireframeRootNode
osg::Group * getWireframeRootNode()
Definition: agxOSG/RenderProxy.h:234
PointSpriteDrawable.h
agxOSG::WireRenderProxy::onAddNotification
virtual void onAddNotification() override
Called when the wire is added to the simulation.
agxOSG::ContainerShapeBatchRenderer::setContainer
void setContainer(const ContainerType *container)
Assign compatible container.
Definition: agxOSG/RenderProxy.h:902
agxRender::HeightFieldProxy
Subclass that implements a HeightfieldProxy.
Definition: agxRender/RenderProxy.h:704
agxOSG::WireRenderProxy::~WireRenderProxy
virtual ~WireRenderProxy()
agxOSG::WireRenderProxy::setTransformOSG
void setTransformOSG(const agx::AffineMatrix4x4 &transform)
agxOSG::ShapeBatchRenderer::m_geode
osg::ref_ptr< osg::Geode > m_geode
Definition: agxOSG/RenderProxy.h:676
agxOSG::WireRenderProxy::setColorOSG
void setColorOSG(const agx::Vec3 &color, float alpha)
agx::RigidBody::getCmTransform
const agx::AffineMatrix4x4 & getCmTransform() const
Convenience methods for center of mass frame.
Definition: RigidBody.h:1504
agxOSG::OSGData::m_transformNode
osg::ref_ptr< osg::MatrixTransform > m_transformNode
Definition: agxOSG/RenderProxy.h:399
agxOSG::createText
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.
agx::AffineMatrix4x4T< Real >
agxOSG::OSGData::setTransformOSG
void setTransformOSG(const agx::AffineMatrix4x4 &transform)
Transform a node.
Definition: agxOSG/RenderProxy.h:332
agxRender::CapsuleProxy
Subclass that implements a CapsuleProxy.
Definition: agxRender/RenderProxy.h:562
agxCollide::HeightField
A HeightField is a collision shape that can be created from a grid structure, like an image.
Definition: agxCollide/HeightField.h:51
agxAssert
#define agxAssert(expr)
Definition: debug.h:143
agxOSG::ContainerShapeBatchRenderer
Class that handles batch rendering of objects in forward iterator compliant container.
Definition: agxOSG/RenderProxy.h:692
agxOSG::WireRenderProxy::setEnableOSG
void setEnableOSG(bool flag)
agx::Vec4
Vec4T< Real > Vec4
Definition: Vec4.h:25
agxOSG::RenderProxyFactory::m_parent
osg::ref_ptr< osg::MatrixTransform > m_parent
Definition: agxOSG/RenderProxy.h:288
agxOSG::OSGData::setColorOSG
void setColorOSG(const agx::Vec3 &color, float alpha)
Set the color and alpha value.
Definition: agxOSG/RenderProxy.h:360
agxRender::TruncatedConeProxy
Subclass that implements a TruncatedConeProxy.
Definition: agxRender/RenderProxy.h:462
agxOSG::WireRenderProxy::onRemoveNotification
virtual void onRemoveNotification() override
Called when the wire is removed from the simulation.
agxOSG::RigidBodyBatchRenderProxy::~RigidBodyBatchRenderProxy
virtual ~RigidBodyBatchRenderProxy()
Definition: agxOSG/RenderProxy.h:778
agxRender::BoxProxy
Subclass that implements a BoxProxy.
Definition: agxRender/RenderProxy.h:673
agxOSG::ContactProxy::reset
virtual void reset() override
Will reset color, alpha and enabled state back to default state (as when initially created).
Definition: agxOSG/RenderProxy.h:811
agxRender::RenderProxy::setTransform
virtual void setTransform(const agx::AffineMatrix4x4 &transform)
Set the transform of this RenderProxy, if overridden, set the m_transform and call onUpdate(TRANSFORM...
Definition: agxRender/RenderProxy.h:974
agxOSG::OSGData::setRenderModeOSG
void setRenderModeOSG(agxRender::RenderProxy::RenderMode mode)
Change the render mode.
Definition: agxOSG/RenderProxy.h:390
agxOSG::ContainerShapeBatchRenderer::findTransform
agx::AffineMatrix4x4 findTransform(const typename ContainerType::value_type &val) const
Find transform (agx::AffineMatrix4x4) given container value type.
Definition: agxOSG/RenderProxy.h:908
agxOSG::ShapeBatchRenderer
Base class for batch rendering of any shape or shape composite.
Definition: agxOSG/RenderProxy.h:615
agxOSG::RenderProxyFactory::m_invTransform
agx::AffineMatrix4x4 m_invTransform
Definition: agxOSG/RenderProxy.h:291
agx::VectorPOD< GeometryContact * >
agxOSG::TrimeshProxy
Implementation of osg-based TrimeshProxy.
Definition: agxOSG/RenderProxy.h:599
agxOSG::RenderProxyFactory::setRenderMode
void setRenderMode(agxRender::RenderProxy *proxy, osg::Node *node, agxRender::RenderProxy::RenderMode mode)
Set the RenderMode for a specified node.
agxOSG::OSGData::m_data
RenderProxyFactory::ShapeData< T > m_data
Definition: agxOSG/RenderProxy.h:400
agxOSG::SphereProxy
Implementation of osg-based SphereProxy.
Definition: agxOSG/RenderProxy.h:435
agxData::Array
Type-specific Array used for fast access into the data held by a Buffer.
Definition: agxData.h:30
agxOSG::RenderProxyFactory::m_graphRenderer
agx::ref_ptr< agxOSG::GraphRenderer > m_graphRenderer
Definition: agxOSG/RenderProxy.h:290
agxRender::TextProxy
Subclass that implements a TextProxy.
Definition: agxRender/RenderProxy.h:219
agxOSG::OSGData
Class for handling methods related to OSG such as setColor, setTransform etc.
Definition: agxOSG/RenderProxy.h:299
utils.h
agxOSG::RenderProxyFactory::addChild
void addChild(osg::Node *node, agxRender::RenderProxy::RenderMode mode)
Add a child to the root, default getDefaultRenderMode() will be used for determining if the node shou...
agxOSG::WireRenderProxy::ADD_COMMON_METHODS
ADD_COMMON_METHODS()
agxRender::RigidBodyBatchRenderProxy
Class holding rigid bodies that makes it possible to batch render these objects.
Definition: agxRender/RenderProxy.h:846
agxOSG::createTrimesh
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.
agxOSG::ShapeBatchRenderer::prepareWithScale
void prepareWithScale(size_t numObjects)
Including scale transform.
agxOSG::ContactProxy::ContactProxy
ContactProxy(osg::Geode *geode, const agxCollide::GeometryContactPtrVector *contacts, agxOSG::RenderProxyFactory *factory)
agxOSG::OSGData::getNode
osg::MatrixTransform * getNode()
\ return the node for this RenderProxy
Definition: agxOSG/RenderProxy.h:396
agxOSG::WireRenderProxy::reset
virtual void reset() override
Will reset color, alpha and enabled state back to default state (as when initially created).
Definition: agxOSG/RenderProxy.h:841
agxRender::RenderProxy::RenderMode
RenderMode
Definition: agxRender/RenderProxy.h:91
agxOSG::OSGData::setEnableOSG
void setEnableOSG(bool flag)
Enable/disable rendering.
Definition: agxOSG/RenderProxy.h:340
agx::ref_ptr< agxOSG::GraphRenderer >
agxOSG::RenderProxyFactory::ShapeData::shape
osg::ref_ptr< T > shape
Definition: agxOSG/RenderProxy.h:268
agxOSG::HollowCylinderProxy::~HollowCylinderProxy
virtual ~HollowCylinderProxy()
Definition: agxOSG/RenderProxy.h:504
agxRender::Graph::GraphRenderer
Abstract base class that acts as an interface and can render the data from a Graph.
Definition: Graph.h:45
agxOSG::ShapeBatchRenderer::getScale
float getScale() const
Definition: agxOSG/RenderProxy.h:870
agxOSG::RenderProxyFactory::ShapeData
Class for storing OSG specific data for each RenderProxy.
Definition: agxOSG/RenderProxy.h:258
agx::SetVector< RigidBody * >
agxOSG::BoxProxy
Implementation of osg-based BoxProxy.
Definition: agxOSG/RenderProxy.h:462
agxRender::HollowCylinderProxy
Subclass that implements a CylinderProxy.
Definition: agxRender/RenderProxy.h:376
agxOSG
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
PushDisableWarnings.h
agx::AffineMatrix4x4
AffineMatrix4x4T< Real > AffineMatrix4x4
Definition: AffineMatrix4x4.h:384
agxOSG::WireShapeProxy::~WireShapeProxy
virtual ~WireShapeProxy()
Definition: agxOSG/RenderProxy.h:579
agxOSG::ContainerShapeBatchRenderer::update
void update(bool addScaleTransform=false)
Updates transforms.
Definition: agxOSG/RenderProxy.h:883
agxOSG::HollowCylinderProxy
Implementation of osg-based HollowCylinderProxy.
Definition: agxOSG/RenderProxy.h:498
agxRender::PlaneProxy
Subclass that implements a PlaneProxy.
Definition: agxRender/RenderProxy.h:244
agxOSG::TextProxy
Implementation of osg-based TextProxy.
Definition: agxOSG/RenderProxy.h:447
agxOSG::HollowTruncatedConeProxy::~HollowTruncatedConeProxy
virtual ~HollowTruncatedConeProxy()
Definition: agxOSG/RenderProxy.h:541
agxOSG::ShapeBatchRenderer::~ShapeBatchRenderer
virtual ~ShapeBatchRenderer()
Destructor.
Definition: agxOSG/RenderProxy.h:654
agxOSG::OSGData::m_invTransform
agx::AffineMatrix4x4 m_invTransform
Definition: agxOSG/RenderProxy.h:402
agxOSG::CylinderProxy::~CylinderProxy
virtual ~CylinderProxy()
Definition: agxOSG/RenderProxy.h:492
agxRender::RenderProxy
Abstract base class which encapsulated information for rendering a specific shape.
Definition: agxRender/RenderProxy.h:76
agxOSG::RigidBodyBatchRenderProxy::RigidBodyBatchRenderProxy
RigidBodyBatchRenderProxy(osg::Geode *geode, const ContainerType *container, agxOSG::RenderProxyFactory *factory)
Definition: agxOSG/RenderProxy.h:774
agxData::Buffer
Abstract representation of a data buffer.
Definition: Buffer.h:55
agxOSG::RigidBodyBatchRenderProxy
Implementation of batch rendering of rigid body center of mass position.
Definition: agxOSG/RenderProxy.h:771
agxOSG::TruncatedConeProxy::~TruncatedConeProxy
virtual ~TruncatedConeProxy()
Definition: agxOSG/RenderProxy.h:528
agxOSG::RenderProxyFactory::getGlobalTransform
const agx::AffineMatrix4x4 & getGlobalTransform() const
Definition: agxOSG/RenderProxy.h:248
agxRender::HollowTruncatedConeProxy
Subclass that implements a HollowTruncatedConeProxy.
Definition: agxRender/RenderProxy.h:508
AGX_MAT4X4_TO_OSG
#define AGX_MAT4X4_TO_OSG(X)
agxOSG::CylinderProxy
Implementation of osg-based CylinderProxy.
Definition: agxOSG/RenderProxy.h:486
RenderManager.h
agxOSG::HeightFieldProxy::~HeightFieldProxy
virtual ~HeightFieldProxy()
Destructor.
Definition: agxOSG/RenderProxy.h:593
agxOSG::LineProxy
Implementation of osg-based LineProxy.
Definition: agxOSG/RenderProxy.h:474
agxOSG::TruncatedConeProxy
Implementation of osg-based TruncatedConeProxy.
Definition: agxOSG/RenderProxy.h:522
agx::Component
A component is an object containing other objects, enabling hierarchical structuring.
Definition: Component.h:38
agxOSG::ShapeBatchRenderer::setTransform
void setTransform(TransformType *obj, const agx::AffineMatrix4x4 &transform, const agx::Vec3f &scale)
Assign transform (given agx type) to a supported osg transform.
agxOSG::ContactProxy
Implementation of batch rendering of contact points.
Definition: agxOSG/RenderProxy.h:801
agxOSG::ContainerShapeBatchRenderer::~ContainerShapeBatchRenderer
virtual ~ContainerShapeBatchRenderer()
Destructor.
Definition: agxOSG/RenderProxy.h:708
agxRender::SphereProxy
Subclass that implements a SphereProxy.
Definition: agxRender/RenderProxy.h:277
agxOSG::RenderProxyFactory::m_wireframeParent
osg::ref_ptr< osg::Group > m_wireframeParent
Definition: agxOSG/RenderProxy.h:287
agxRender::CylinderProxy
Subclass that implements a CylinderProxy.
Definition: agxRender/RenderProxy.h:337
agxOSG::ContactProxy::~ContactProxy
virtual ~ContactProxy()
Definition: agxOSG/RenderProxy.h:807
agxOSG::RenderProxyFactory::ShapeData::ShapeData
ShapeData(const ShapeData &other)
Definition: agxOSG/RenderProxy.h:260
agxOSG::ShapeBatchRenderer::m_scale
float m_scale
Definition: agxOSG/RenderProxy.h:677
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
agxOSG::LineProxy::~LineProxy
virtual ~LineProxy()
Definition: agxOSG/RenderProxy.h:480
agxOSG::ContactProxy::ADD_COMMON_METHODS
ADD_COMMON_METHODS()
agxOSG::RenderProxyFactory::getSolidRootNode
osg::Group * getSolidRootNode()
Definition: agxOSG/RenderProxy.h:229
agxOSG::TextProxy::~TextProxy
virtual ~TextProxy()
Definition: agxOSG/RenderProxy.h:455
agxOSG::ConeProxy::~ConeProxy
virtual ~ConeProxy()
Definition: agxOSG/RenderProxy.h:516
agxRender::RigidBodyBatchRenderProxy::m_bodies
agxRender::RigidBodyBatchRenderProxy::Container m_bodies
Definition: agxRender/RenderProxy.h:874
agxOSG::ContainerShapeBatchRenderer::m_container
const ContainerType * m_container
Definition: agxOSG/RenderProxy.h:740
agxRender::WireRenderProxy
Definition: agxRender/RenderProxy.h:878
agxRender::RigidBodyBatchRenderProxy::m_scale
float m_scale
Definition: agxRender/RenderProxy.h:875
agxOSG::TrimeshProxy::~TrimeshProxy
virtual ~TrimeshProxy()
Definition: agxOSG/RenderProxy.h:605
export.h
RenderText.h
agxOSG::ContainerShapeBatchRenderer::clear
void clear()
Reset container pointer and removes all child transforms.
Definition: agxOSG/RenderProxy.h:876
agx::AgXString< std::string >
agxOSG::OSGData::setAlphaOSG
void setAlphaOSG(float transparency)
Set the alpha value.
Definition: agxOSG/RenderProxy.h:354
agxOSG::OSGData::m_factory
agxOSG::RenderProxyFactory * m_factory
Definition: agxOSG/RenderProxy.h:401
agx::Vec3T< Real >
agxRender::WireShapeProxy
Subclass that implements a WireShapeProxy.
Definition: agxRender/RenderProxy.h:603
agxOSG::WireShapeProxy
Implementation of osg-based WireShapeProxy.
Definition: agxOSG/RenderProxy.h:572
agxCollide::Trimesh
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:42
agxOSG::OSGData::onRemoveOSG
void onRemoveOSG()
Remove the node from all its parents.
Definition: agxOSG/RenderProxy.h:380
agxOSG::OSGData::m_proxy
agxRender::RenderProxy * m_proxy
Definition: agxOSG/RenderProxy.h:403
agxOSG::OSGData::OSGData
OSGData(agxOSG::RenderProxyFactory *factory, agxRender::RenderProxy *proxy)
Definition: agxOSG/RenderProxy.h:319
agxRender::LineProxy
Subclass that implements a LineProxy.
Definition: agxRender/RenderProxy.h:305
agxRender::RenderProxyFactory
Abstract class which is responsible for returning a pointer to a specified RenderProxy type.
Definition: RenderManager.h:647
agx::Vec3f
Vec3T< Real32 > Vec3f
Definition: Vec3.h:39
agxOSG::RenderProxyFactory
Implementation of the abstract class from the agxRender namespace, this class is responsible for crea...
Definition: agxOSG/RenderProxy.h:74
agxOSG::WireRenderProxy::m_sphereBatch
ContainerShapeBatchRenderer< agxRender::WireRenderProxy::SphereDefContainer, osg::MatrixTransform > m_sphereBatch
Definition: agxOSG/RenderProxy.h:849
RenderProxy.h
agxOSG::RigidBodyBatchRenderProxy::reset
virtual void reset() override
Will reset color, alpha and enabled state back to default state (as when initially created).
Definition: agxOSG/RenderProxy.h:792
agxOSG::CapsuleProxy
Implementation of osg-based CapsuleProxy.
Definition: agxOSG/RenderProxy.h:559
agxOSG::OSGData::OSGData
OSGData(const RenderProxyFactory::ShapeData< T > &data, agxOSG::RenderProxyFactory *factory, agxRender::RenderProxy *proxy)
Definition: agxOSG/RenderProxy.h:302
agxOSG::ShapeBatchRenderer::setScale
void setScale(float scale)
Assign transform scale.
Definition: agxOSG/RenderProxy.h:864
agxOSG::RenderProxyFactory::m_sphereBatchRenderModeSprites
bool m_sphereBatchRenderModeSprites
Definition: agxOSG/RenderProxy.h:292
agx::VectorPOD< GeometryContact * >::value_type
GeometryContact * value_type
Definition: Vector.h:249
agxOSG::WireRenderProxy::getEdgeTransform
osg::MatrixTransform * getEdgeTransform()
agxOSG::WireRenderProxy::m_edgeBatch
ContainerShapeBatchRenderer< agxRender::WireRenderProxy::SegmentDefContainer, osg::MatrixTransform > m_edgeBatch
Definition: agxOSG/RenderProxy.h:848
agxOSG::ContainerShapeBatchRenderer::ContainerShapeBatchRenderer
ContainerShapeBatchRenderer(osg::Geode *geode, const ContainerType *container, agxOSG::RenderProxyFactory *factory, agxRender::RenderProxy *proxy)
Construct given shape composite and compatible container.
Definition: agxOSG/RenderProxy.h:702
agxRender::TrimeshProxy
Subclass that implements a TrimeshProxy.
Definition: agxRender/RenderProxy.h:739
AGXOSG_EXPORT
#define AGXOSG_EXPORT
agxOSG::RenderProxyFactory::m_solidParent
osg::ref_ptr< osg::Group > m_solidParent
Definition: agxOSG/RenderProxy.h:286
agxOSG::WireRenderProxy::WireRenderProxy
WireRenderProxy(float radius, const agx::Vec3 &color, osg::Geode *segmentGeode, osg::Geode *edgeGeode, osg::Geode *nodeGeode, agxOSG::RenderProxyFactory *factory)
agxRender::ContactsProxy
Class holding contacts that makes it possible to batch render these objects.
Definition: agxRender/RenderProxy.h:821
PopDisableWarnings.h