AGX Dynamics  2.35.0.1
RenderManager.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 AGXRENDER_RENDERMANAGER_H
18 #define AGXRENDER_RENDERMANAGER_H
19 
20 #include <agx/agxPhysics_export.h>
21 #include <agx/Referenced.h>
22 #include <agx/HashVector.h>
23 #include <agx/AffineMatrix4x4.h>
24 #include <agxCollide/Space.h>
25 
26 #include <agxRender/RenderProxy.h>
27 #include <agxRender/Renderable.h>
28 #include <agxRender/Graph.h>
29 
30 namespace agxSDK
31 {
32  class Simulation;
33  class StatisticsEntries;
34 }
35 
36 namespace agxRender
37 {
38 
39  class RenderProxyFactory;
40  class RenderProxy;
41  class SpaceListener;
42  class SphereProxy;
43  class BoxProxy;
44  class LineProxy;
45  class HeightFieldProxy;
46  class CylinderProxy;
47  class HollowCylinderProxy;
48  class ConeProxy;
49  class TruncatedConeProxy;
50  class HollowTruncatedConeProxy;
51  class CapsuleProxy;
52  class TextProxy;
53  class PlaneProxy;
54  class GraphRenderer;
55  class Graph;
56 
58  enum Flags {
64  RENDER_CONSTRAINTS = 1 << 5,
65  RENDER_BODIES = 1 << 6,
68  RENDER_TEXT = 1 << 9,
69  RENDER_AABB_TREES = 1 << 10,
70  RENDER_SENSORS = 1 << 11,
71  RENDER_MESH = 1 << 12,
73  RENDER_STATISTICS = 1 << 14,
74  RENDER_RENDERABLES = 1 << 15,
77  RENDER_BATCH_BODIES = 1 << 18,
78  RENDER_BATCH_WIRES = 1 << 19,
91  RENDER_MESH |
93  };
94 
96 
107  {
108  public:
109 
115 
120  void update();
121 
127 
132 
137  void setEnable( bool flag );
138 
142  bool getEnable( ) const;
143 
147  bool isEnabled() const;
148 
153  void setAlpha( float alpha );
154 
158  float getAlpha( ) const;
159 
164  void disableFlags( unsigned int flags );
165 
170  void enableFlags( unsigned int flags );
171 
175  bool isEnabledFlags( unsigned int flags ) const;
176 
180  void setFlags( unsigned int flags );
181 
187 
193  SphereProxy* acquireSphere( float radius );
194 
200  BoxProxy* acquireBox( const agx::Vec3& halfExtents );
201 
207  LineProxy* acquireLine( const agx::Vec3& p1, const agx::Vec3& p2 );
208 
215  TextProxy* acquireText( const agx::String& text, const agx::Vec3& pos );
216 
222  PlaneProxy* acquirePlane( const agx::Vec3& normal, agx::Real distance );
223 
230  CylinderProxy* acquireCylinder( float radius, float height );
231 
239  CylinderProxy* acquireCylinder( const agx::Vec3& begin, const agx::Vec3& end, float radius );
240 
247  HollowCylinderProxy* acquireHollowCylinder( float radius, float height, float thickness );
248 
249 
257  ConeProxy* acquireCone( const agx::Vec3& p1, const agx::Vec3& p2, float radius );
258 
267  TruncatedConeProxy* acquireTruncatedCone( const agx::Vec3& p1, const agx::Vec3& p2, float topRadius, float bottomRadius );
268 
278  HollowTruncatedConeProxy* acquireHollowTruncatedCone( const agx::Vec3& p1, const agx::Vec3& p2, float topRadius, float bottomRadius, float thickness );
279 
286  CapsuleProxy* acquireCapsule( float radius, float height );
287 
295  CapsuleProxy* acquireCapsule( const agx::Vec3& begin, const agx::Vec3& end, float radius );
296 
304 
312 
318  WireRenderProxy* acquireWire( float radius, const agx::Vec3& color );
319 
325  void clear( bool clearText = true, bool clearGlobalProxies = true );
326 
331  void addRenderable( Renderable* renderable );
332 
336  bool hasRenderable( Renderable* renderable ) const;
337 
342  bool removeRenderable( Renderable* renderable );
343 
344  void acquireGeometry( const agxCollide::Geometry* geometry, const agx::Vec3& color );
345 
352 
358 
365  void setScaleFactor( float scaleFactor = 1.0f );
366 
370  float getScaleFactor() const;
371 
372  public:
373  typedef std::pair< const agx::ParticleSystem*, agxRender::RenderProxyRef > ConstParticleSystemPtrRenderProxyPtrPair;
375 
376  protected:
377 
381  void flush();
382 
383  friend class SpaceListener;
384  friend class agxCollide::Space;
385  friend class agxSDK::Simulation;
387 
388 
392  void setSpace( agxCollide::Space* space );
393 
398 
399  void add( const agx::ParticleSystem* particleSystem );
400  void remove( const agx::ParticleSystem* particleSystem );
401 
408  void add( const agxCollide::Geometry* geometry, const agx::Vec3& color = agx::Vec3( -1, 0, 0 ), bool addToProxies = true );
409 
417  RenderProxy* add( agxCollide::Shape* shape, const agxCollide::Geometry* geometry, const agx::Vec3& color = agx::Vec3( -1, 0, 0 ), bool addToProxies = true );
418 
423  void remove( const agxCollide::Shape* shape );
424 
429  void remove( const agxCollide::Geometry* geometry );
430 
433 
435  void renderAABBTrees( RenderProxy* proxy );
436 
439 
441  void updateText();
442 
444  void updateGraphs();
445 
448 
451 
453  void renderObserverFrame(const agx::ObserverFrame* observerFrame);
454 
456  void updateBodyProxies( agxData::EntityStorage* islandStorage = nullptr );
457 
459  void updateShapeProxies(agxData::EntityStorage* islandStorage = nullptr );
460 
463 
466 
469 
470 
473 
476 
479 
481  void updateProxy( RenderProxy* proxy, agxData::EntityStorage* islandStorage = nullptr );
482 
484  virtual ~RenderManager();
485 
486  // Attributes
490  bool m_enable;
491  float m_alpha;
494 
497 
499 
500  // Abstract base class for a ProxyCache
501  struct CacheBase {
502  CacheBase( RenderManager* mgr ) : m_mgr( mgr ) {
503  m_mgr->m_cacheVector.push_back( this );
504  }
505 
506  virtual void clear() = 0;
507  virtual void flush() = 0;
508  virtual void setAlpha( float alpha ) = 0;
510 
511  virtual ~CacheBase() {}
512  };
513 
514 
518  template <typename T>
519  class PrimitiveCache : public CacheBase
520  {
521  public:
522 
525  typedef typename ProxyVector::iterator iterator;
526 
528  PrimitiveCache( RenderManager* mgr ) : CacheBase( mgr ), m_index( 0 ) {}
529 
533  T* acquire();
534 
538  void flush() {
539  for ( size_t i = m_index; i < m_pool.size(); i++ )
540  m_pool[i]->callOnChange( RenderProxy::REMOVE );
541 
542  m_pool.resize( std::min( m_index, m_pool.size() ) );
543  m_index = 0;
544  }
545 
550  void setAlpha( float alpha ) {
551  for ( size_t i = 0; i < m_pool.size(); i++ )
552  m_pool[i]->setAlpha( alpha );
553  }
554 
558  void clear() {
559  for ( typename ProxyVector::iterator it = m_pool.begin(); it != m_pool.end(); ++it )
560  ( *it )->callOnChange( RenderProxy::REMOVE );
561  m_pool.clear( agx::Container::SHRINK_BUFFER );
562  m_index = 0;
563  }
564 
566  virtual ~PrimitiveCache() {
567  clear();
568  }
569 
570  iterator begin() { return m_pool.begin(); }
571  const_iterator begin() const { return m_pool.begin(); }
572 
573  iterator end() { return m_pool.end(); }
574  const_iterator end() const { return m_pool.end(); }
575 
576  protected:
577 
579  size_t m_index;
580  };
581 
585  template <typename T, typename P1>
586  class PrimitiveCache1 : public PrimitiveCache<T>
587  {
588  public:
589 
592 
596  T* acquire( const P1& param );
597 
598  private:
599 
600  T* acquire() { return nullptr; }
601  };
602 
605 
619 
621 
628 
635 
636  };
637 
638 
648  {
649  public:
651 
653  virtual SphereProxy* createSphere( float radius ) = 0;
654 
656  virtual BoxProxy* createBox( const agx::Vec3& halfExtents ) = 0;
657 
659  virtual LineProxy* createLine( const agx::Vec3& p1, const agx::Vec3& p2 ) = 0;
660 
662  virtual CylinderProxy* createCylinder( float radius, float height ) = 0;
663 
665  virtual HollowCylinderProxy* createHollowCylinder( float radius, float height, float thickness ) = 0;
666 
668  virtual ConeProxy* createCone( float radius, float height ) = 0;
669 
671  virtual TruncatedConeProxy* createTruncatedCone( float topRadius, float bottomRadius, float height ) = 0;
672 
674  virtual HollowTruncatedConeProxy* createHollowTruncatedCone( float topRadius, float bottomRadius, float height, float thickness ) = 0;
675 
677  virtual CapsuleProxy* createCapsule( float radius, float height ) = 0;
678 
680  virtual WireShapeProxy* createWireShape( float radius, float height,
681  const agx::Vec3& previousEndPoint0, const agx::Vec3& previousEndPoint1 ) = 0;
682 
684  virtual TextProxy* createText( const agx::String& text, const agx::Vec3& pos ) = 0;
685 
687  virtual PlaneProxy* createPlane( const agx::Vec3& normal, agx::Real distance ) = 0;
688 
691 
694 
697 
698  virtual WireRenderProxy* createWire( float radius, const agx::Vec3& color ) = 0;
699 
701  agxData::Buffer *positions,
702  agxData::Buffer *rotations,
703  agxData::Buffer *radii,
704  agxData::Buffer *colors,
705  agxData::Buffer *enableRendering,
706  agxData::Value *bound,
707  agx::Component *context ) = 0;
708 
711 
713  SphereProxy* create( float radius );
714 
716  BoxProxy* create( const agx::Vec3& halfExtents );
717 
719  LineProxy* create( const LineProxy* );
720 
722  CylinderProxy* create( const CylinderProxy* );
723 
725  HollowCylinderProxy* create( const HollowCylinderProxy* );
726 
728  ConeProxy* create( const ConeProxy* );
729 
731  TruncatedConeProxy* create( const TruncatedConeProxy* );
732 
735 
737  CapsuleProxy* create( const CapsuleProxy* );
738 
740  TextProxy* create( const TextProxy* );
741 
743  PlaneProxy* create( const PlaneProxy* );
744 
746  ContactsProxy* create( const agxCollide::GeometryContactPtrVector& contacts );
747 
749  RigidBodyBatchRenderProxy* create( const agx::RigidBodyPtrSetVector* enabledBodies );
750 
757 
763 
767  RenderProxy::RenderMode getDefaultRenderMode( ) const;
768 
769  void setEnable( bool flag );
770  bool getEnable( ) const;
771 
772  protected:
773  friend class RenderManager;
775  m_mgr = mgr;
776  }
780  bool m_enabled;
781  };
782 
783  inline void RenderProxyFactory::setEnable( bool flag )
784  {
785  m_enabled = flag;
786  }
787  inline bool RenderProxyFactory::getEnable( ) const
788  {
789  return m_enabled;
790  }
791 
794  {
795  public:
796 
799 
801  protected:
802 
804  virtual ~SpaceListener();
805 
808 
817 
820  };
821 
822 
823 
824 
825  // Implementation
826 
827  inline bool RenderManager::getEnable( ) const
828  {
829  return m_enable;
830  }
831 
832 
833  inline float RenderManager::getAlpha( ) const
834  {
835  return m_alpha;
836  }
837 
838 
839  inline bool RenderManager::isEnabled() const
840  {
841  return getEnable();
842  }
843 
844 
846  inline SphereProxy* RenderProxyFactory::create( float radius )
847  {
848  return createSphere( radius );
849  }
851  inline BoxProxy* RenderProxyFactory::create( const agx::Vec3& halfExtents )
852  {
853  return createBox( halfExtents );
854  }
857  {
858  return createLine( agx::Vec3( agx::Real( 0 ) ), agx::Vec3( agx::Real( 1 ) ) );
859  }
862  {
863  return createCylinder( 1, 1 );
864  }
867  {
868  return createHollowCylinder( 1, 1, 0.1f );
869  }
870 
873  {
874  return createCone( 1, 1 );
875  }
878  {
879  return createTruncatedCone( 1, 1, 1 );
880  }
883  {
884  return createHollowTruncatedCone( 1, 1, 1, 0.1f );
885  }
886 
889  {
890  return createCapsule( 1, 1 );
891  }
894  {
895  return createText( "", agx::Vec3( 0, 0, 0 ) );
896  }
899  {
900  return createPlane( agx::Vec3( 0, 0, 1 ), 0 );
901  }
902 
905  {
906  return createContacts( contacts );
907  }
908 
910  {
911  return createRigidBodies( enabledBodies );
912  }
913 
915  {
916  return m_defaultRenderMode;
917  }
918 
919  template< typename T>
921  {
922  if ( m_index < m_pool.size() ) {
923  T* proxy = m_pool[m_index++];
924 
925  // Reset color, alpha and enabled state
926  proxy->reset();
927  return proxy;
928  } else {
929  const void* p = nullptr;
930  const T* px = static_cast<const T*>( p );
931  T* proxy = m_mgr->getProxyFactory()->create( px);
932  proxy->setEnable( true );
933  m_pool.push_back( proxy );
934  m_index = m_pool.size();
935  return proxy;
936  }
937  }
938 
939  template< typename T, typename P1>
941  {
942  if ( this->m_index < this->m_pool.size() ) {
943  T* proxy = this->m_pool[this->m_index++];
944  // Reset color, alpha and enabled state
945  proxy->reset();
946  return proxy;
947  } else {
948  T* proxy = this->m_mgr->getProxyFactory()->create( param );
949  proxy->setEnable( true );
950  this->m_pool.push_back( proxy );
951  this->m_index = this->m_pool.size();
952  return proxy;
953  }
954  }
955 }
956 
957 #endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXPHYSICS_EXPORT
The geometry representation used by the collision detection engine.
Definition: Geometry.h:93
A HeightField is a collision shape that can be created from a grid structure, like an image.
Base class for a shape.
Definition: Shape.h:54
Class for listening for add/remove geometry events for an associated Space.
Definition: SpaceListener.h:30
This class contains all Geometries and performs Broad Phase and Narrow Phase collision detection to c...
Definition: Space.h:82
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:43
Abstract representation of a data buffer.
Definition: Buffer.h:56
Data storage for a collection of entity instances of a specified EntityModel.
Definition: EntityStorage.h:73
Abstract representation of a value.
Definition: Value.h:43
Subclass that implements a BoxProxy.
Subclass that implements a CapsuleProxy.
Subclass that implements a ConeProxy.
Class holding contacts that makes it possible to batch render these objects.
Subclass that implements a CylinderProxy.
Abstract base class that acts as an interface and can render the data from a Graph.
Definition: Graph.h:46
Class that implements a simple graph for plotting scalar values.
Definition: Graph.h:34
Subclass that implements a HeightfieldProxy.
Subclass that implements a CylinderProxy.
Subclass that implements a HollowTruncatedConeProxy.
Subclass that implements a LineProxy.
Subclass that implements a PlaneProxy.
Class for storing RenderProxies that are currently in use.
PrimitiveCache1(RenderManager *mgr)
Constructor.
Class for storing RenderProxies that are currently in use.
virtual ~PrimitiveCache()
Destructor: calls clear()
ProxyVector::const_iterator const_iterator
void clear()
Reduce number of proxies to 0.
agx::Vector< agx::ref_ptr< T > > ProxyVector
void flush()
Reduce size of pooled RenderProxy down to the number of used ones.
PrimitiveCache(RenderManager *mgr)
Constructor.
void setAlpha(float alpha)
Set alpha value for all proxies.
Class for managing the rendering of geometries, shapes, rigid bodies, constraints etc.
void renderAABBTrees(RenderProxy *proxy)
Render AABB tree for the specified proxy.
PrimitiveCache1< ContactsProxy, agxCollide::GeometryContactPtrVector > m_contactsCache
virtual ~RenderManager()
Destructor.
SphereProxy * acquireSphere(float radius)
Create and return a new proxy sphere from the Proxy factory.
void addRenderable(Renderable *renderable)
Add custom render object.
void setSpace(agxCollide::Space *space)
Associate a new space with this RenderManager, used by agxSDK::Simulation.
void setAlpha(float alpha)
Loop over all proxies and set alpha value to the specified value, also sets the new default alpha val...
RenderableRefVector m_renderables
float getScaleFactor() const
agx::ref_ptr< SpaceListener > m_listener
PrimitiveCache< ConeProxy > m_coneCache
void enableFlags(unsigned int flags)
Enable all rendering flags specified in flags.
void updateAABBProxies()
Update all AABB (for geometries) proxies (boxes)
PrimitiveCache< PlaneProxy > m_planeCache
void add(const agxCollide::Geometry *geometry, const agx::Vec3 &color=agx::Vec3(-1, 0, 0), bool addToProxies=true)
Add a geometry (and its shapes) to the set of active shape proxies.
agxRender::GraphRef m_graph
void updateGraphs()
Update the graphs.
HollowTruncatedConeProxy * acquireHollowTruncatedCone(const agx::Vec3 &p1, const agx::Vec3 &p2, float topRadius, float bottomRadius, float thickness)
Create and return a new proxy TruncatedCone from the Proxy factory.
PlaneProxy * acquirePlane(const agx::Vec3 &normal, agx::Real distance)
WireRenderProxy * acquireWire(float radius, const agx::Vec3 &color)
Create and return a new proxy wire from the proxy factory.
void updateParticleGeometryContactProxies()
PrimitiveCache1< RigidBodyBatchRenderProxy, const agx::RigidBodyPtrSetVector * > m_rbCache
CapsuleProxy * acquireCapsule(const agx::Vec3 &begin, const agx::Vec3 &end, float radius)
Create and return a new proxy Capsule from the Proxy factory.
bool isEnabledFlags(unsigned int flags) const
PrimitiveCache< CapsuleProxy > m_capsuleCache
ConeProxy * acquireCone(const agx::Vec3 &p1, const agx::Vec3 &p2, float radius)
Create and return a new proxy Cone from the Proxy factory.
PrimitiveCache< TruncatedConeProxy > m_truncatedConeCache
RenderProxyRef m_particleGeometryContactRenderProxy
void remove(const agxCollide::Shape *shape)
Remove a Shape from the set of shapes that should be rendered.
void setProxyFactory(RenderProxyFactory *factory)
Associate a new factory for creating RenderProxy's on request from the RenderManager.
TruncatedConeProxy * acquireTruncatedCone(const agx::Vec3 &p1, const agx::Vec3 &p2, float topRadius, float bottomRadius)
Create and return a new proxy TruncatedCone from the Proxy factory.
ParticleSystemProxyContainer m_particleSystems
CylinderProxy * acquireCylinder(const agx::Vec3 &begin, const agx::Vec3 &end, float radius)
Create and return a new proxy Cylinder from the Proxy factory.
void updateObserverFrames()
Update all observer frames.
PrimitiveCache< HollowTruncatedConeProxy > m_hollowTruncatedConeCache
RenderProxyHashVector m_proxies
RenderProxy * findShapeProxy(const agxCollide::Shape *shape)
Try to locate a RenderProxy which is associated (already added) for the specified shape.
void updateBodyProxies(agxData::EntityStorage *islandStorage=nullptr)
Go through all bodies and acquire proxies for them.
void updateConstraintProxies()
Update all constraints (call render)
TextProxy * acquireText(const agx::String &text, const agx::Vec3 &pos)
Create and return a new text sphere from the Proxy factory.
void disableFlags(unsigned int flags)
Disable all rendering flags specified in flags.
void updateAllProxies(agxRender::RenderProxy::EventType eventType)
Fires event given eventType for all proxies.
RenderManager(agxSDK::Simulation *sim)
Constructor.
bool hasRenderable(Renderable *renderable) const
agxData::BufferRef m_particleGeometryContactRadiusBuffer
agxData::ValueRef m_particleContactBound
agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > > RenderProxyHashVector
void clearShapeProxies()
Remove all shape proxies.
LineProxy * acquireLine(const agx::Vec3 &p1, const agx::Vec3 &p2)
Create and return a new proxy Line from the Proxy factory.
void clear(bool clearText=true, bool clearGlobalProxies=true)
Clear all acquired RenderProxy.
RenderProxy * add(agxCollide::Shape *shape, const agxCollide::Geometry *geometry, const agx::Vec3 &color=agx::Vec3(-1, 0, 0), bool addToProxies=true)
Add a shape to the set of active shape proxies.
CylinderProxy * acquireCylinder(float radius, float height)
Create and return a new proxy Cylinder from the Proxy factory.
void updateParticleSystemProxies()
Update particleSystems.
void remove(const agx::ParticleSystem *particleSystem)
ContactsProxy * acquireContacts(const agxCollide::GeometryContactPtrVector &contacts, float scale)
Create and return a new proxy Contact from the Proxy factory.
void setScaleFactor(float scaleFactor=1.0f)
Set the scale of the debug rendering of contacts and center of mass, it will not affect already creat...
RenderProxyRefContainer m_globalProxies
E.g., wires that hold their proxy (i.e., not doing acquire to fetch their render proxy).
PrimitiveCache< TextProxy > m_textCache
void update()
Updates a new state for the rendering, acquires renderable objects for shapes, text etc.
agx::Vector< RenderableRef > RenderableRefVector
void add(const agx::ParticleSystem *particleSystem)
PrimitiveCache< CylinderProxy > m_cylinderCache
PrimitiveCache< HollowCylinderProxy > m_hollowCylinderCache
BoxProxy * acquireBox(const agx::Vec3 &halfExtents)
Create and return a new proxy boxy from the Proxy factory.
agx::Vector< CacheBase * > CacheVector
HollowCylinderProxy * acquireHollowCylinder(float radius, float height, float thickness)
Create and return a new proxy HollowCylinder from the Proxy factory.
void updateRenderables()
Call render for all Renderables.
bool removeRenderable(Renderable *renderable)
Remove custom render object renderable.
void setEnable(bool flag)
Enable/disable the whole rendering system.
void setDefaultRenderMode(RenderProxy::RenderMode mode)
Set the new default render mode for all RenderProxies activated after this call.
RenderProxyFactory * getProxyFactory()
void updateContactProxies()
acquire proxies for contacts
void renderBoundingVolume(const agxCollide::Geometry *geometry)
Render bounding volume for the geom.
CapsuleProxy * acquireCapsule(float radius, float height)
Create and return a new proxy Capsule from the Proxy factory.
RigidBodyBatchRenderProxy * acquireRigidBodies(const agx::RigidBodyPtrSetVector *enabledBodies, float scale)
Create and return a new proxy rigid body batch from the Proxy factory.
RenderProxyRef m_particleContactRenderProxy
agxSDK::Simulation * m_simulation
void acquireGeometry(const agxCollide::Geometry *geometry, const agx::Vec3 &color)
void updateText()
Update only text proxies.
void updateProxy(RenderProxy *proxy, agxData::EntityStorage *islandStorage=nullptr)
Update size, color and transform.
agx::ref_ptr< RenderProxyFactory > m_factory
agxData::BufferRef m_particleContactRadiusBuffer
agx::Vector< ConstParticleSystemPtrRenderProxyPtrPair > ParticleSystemProxyContainer
void setFlags(unsigned int flags)
Set the render flags.
agx::Vector< agx::ref_ptr< agxRender::RenderProxy > > RenderProxyRefContainer
std::pair< const agx::ParticleSystem *, agxRender::RenderProxyRef > ConstParticleSystemPtrRenderProxyPtrPair
RenderProxy::RenderMode m_defaultRenderMode
PrimitiveCache< LineProxy > m_lineCache
PrimitiveCache1< BoxProxy, agx::Vec3 > m_boxCache
void renderObserverFrame(const agx::ObserverFrame *observerFrame)
Render an ObserverFrame.
PrimitiveCache1< SphereProxy, float > m_sphereCache
void addAllGeometries()
Go through space and add all geometries to the set of shapes that should be rendered.
agxData::ValueRef m_particleGeometryContactBound
void updateShapeProxies(agxData::EntityStorage *islandStorage=nullptr)
Update (transform and color) for all shapes.
void flush()
Based on the number of used RenderProxy (for each type), reduce the cache down to that size.
void remove(const agxCollide::Geometry *geometry)
Remove a Geometry (and its shapes) from the set of shapes that should be rendered.
Abstract class which is responsible for returning a pointer to a specified RenderProxy type.
void setRenderManager(RenderManager *mgr)
SphereProxy * create(float radius)
Create a SphereProxy without arguments.
void setDefaultRenderMode(RenderProxy::RenderMode mode)
Set the default RenderMode that will be used when a new RenderProxy is created.
virtual RenderProxy * createSphereBatchRenderer(agxData::Buffer *positions, agxData::Buffer *rotations, agxData::Buffer *radii, agxData::Buffer *colors, agxData::Buffer *enableRendering, agxData::Value *bound, agx::Component *context)=0
virtual HeightFieldProxy * createHeightfield(agxCollide::HeightField *hf)=0
Interface for creating and returning HeightfieldProxy.
virtual ContactsProxy * createContacts(const agxCollide::GeometryContactPtrVector &)=0
Interface for creating and returning ContactsProxy.
virtual HollowCylinderProxy * createHollowCylinder(float radius, float height, float thickness)=0
Interface for creating and returning a HollowCylinderProxy.
virtual WireRenderProxy * createWire(float radius, const agx::Vec3 &color)=0
virtual HollowTruncatedConeProxy * createHollowTruncatedCone(float topRadius, float bottomRadius, float height, float thickness)=0
Interface for creating and returning a HollowTruncatedConeProxy.
virtual CapsuleProxy * createCapsule(float radius, float height)=0
Interface for creating and returning a CapsuleProxy.
virtual BoxProxy * createBox(const agx::Vec3 &halfExtents)=0
Interface for creating and returning a BoxProxy.
virtual TextProxy * createText(const agx::String &text, const agx::Vec3 &pos)=0
Interface for creating and returning TextProxy.
virtual SphereProxy * createSphere(float radius)=0
Interface for creating and returning a SphereProxy.
virtual LineProxy * createLine(const agx::Vec3 &p1, const agx::Vec3 &p2)=0
Interface for creating and returning a LineProxy.
virtual WireShapeProxy * createWireShape(float radius, float height, const agx::Vec3 &previousEndPoint0, const agx::Vec3 &previousEndPoint1)=0
Interface for creating and returning a WireShapeProxy.
RenderProxy::RenderMode m_defaultRenderMode
virtual CylinderProxy * createCylinder(float radius, float height)=0
Interface for creating and returning a CylinderProxy.
RenderProxy::RenderMode getDefaultRenderMode() const
virtual TruncatedConeProxy * createTruncatedCone(float topRadius, float bottomRadius, float height)=0
Interface for creating and returning a TruncatedConeProxy.
virtual TrimeshProxy * createTrimesh(agxCollide::Trimesh *mesh)=0
Interface for creating and returning TrimeshProxy.
virtual PlaneProxy * createPlane(const agx::Vec3 &normal, agx::Real distance)=0
Interface for creating and returning PlaneProxy.
virtual Graph::GraphRenderer * getGraphRenderer()=0
This method should create and return an implementation of a GraphRenderer, a class that can render th...
virtual ConeProxy * createCone(float radius, float height)=0
Interface for creating and returning a ConeProxy.
virtual RigidBodyBatchRenderProxy * createRigidBodies(const agx::RigidBodyPtrSetVector *)=0
Interface for creating and returning batch rendering of rigid bodies (cm).
Abstract base class which encapsulated information for rendering a specific shape.
EventType
Enum for specifying a type of event which might change a RenderProxy.
@ REMOVE
The Shape has been removed from space, need to be removed from rendering.
Inherit from this class and implement the render() method to make it it self during debug rendering.
Definition: Renderable.h:39
Class holding rigid bodies that makes it possible to batch render these objects.
A listener that will be responsible for calling RenderManager every time a Shape is added/removed fro...
void addShapeNotification(agxCollide::Space *space, agxCollide::Geometry *geometry, agxCollide::Shape *shape)
Called when a Shape is added to a Geometry which is associated to Space.
void removeShapeNotification(agxCollide::Space *space, agxCollide::Geometry *geometry, agxCollide::Shape *shape)
Called when a Shape is removed from a Geometry which is associated to Space.
virtual ~SpaceListener()
Destructor.
void removeGeometryNotification(agxCollide::Space *space, agxCollide::Geometry *geometry)
Called when a Geometry is removed to the associated Space.
agxCollide::Space * getSpace()
void addNotification(agxCollide::Space *space)
Called when this listener is added to a Space.
SpaceListener(RenderManager *mgr)
Constructor.
agx::observer_ptr< agxCollide::Space > m_space
agx::observer_ptr< RenderManager > m_mgr
void addGeometryNotification(agxCollide::Space *space, agxCollide::Geometry *geometry)
Called when a Geometry is added to the associated Space.
Subclass that implements a SphereProxy.
Subclass that implements a TextProxy.
Subclass that implements a TrimeshProxy.
Subclass that implements a TruncatedConeProxy.
Subclass that implements a WireShapeProxy.
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:127
A component is an object containing other objects, enabling hierarchical structuring.
Definition: Component.h:39
@ SHRINK_BUFFER
Buffer is deallocated and replaced by an newly allocated empty buffer.
Definition: Container.h:44
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition: HashVector.h:41
With this class you can attach an ObserverFrame object relative to a RigidBody.
Definition: ObserverFrame.h:44
A basic particle system that contains all the storages and buffers required for basic operation and a...
Base class providing referencing counted objects.
Definition: Referenced.h:114
Smart pointer for observed objects, that automatically set pointers to them to null when they deleted...
Definition: observer_ptr.h:61
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
AGXOSG_EXPORT void setAlpha(osg::Node *node, float alpha)
Set the alpha part of the material for a node.
Namespace containing classes for handling debug rendering of collision geometries,...
Definition: Constraint.h:36
Flags
Flags for specifying what is enabled in the debug rendering system.
Definition: RenderManager.h:58
@ RENDER_STATISTICS
Render statistics text/graphs onto screen.
Definition: RenderManager.h:73
@ RENDER_BATCH_WIRES
Wire content batch rendered.
Definition: RenderManager.h:78
@ RENDER_BODIES
Render rigid body mass centers.
Definition: RenderManager.h:65
@ RENDER_BOUNDING_VOLUMES
Render bounding volumes for geometries.
Definition: RenderManager.h:60
@ RENDER_GEOMETRY_CONTACTS
Render geometry contacts.
Definition: RenderManager.h:61
@ RENDER_RENDERABLES
Execute render for all registered Renderables.
Definition: RenderManager.h:74
@ RENDER_PARTICLE_EMITTERS
Render particle emitters.
Definition: RenderManager.h:67
@ RENDER_CONTACTS
Render all types of contacts.
Definition: RenderManager.h:80
@ RENDER_PARTICLE_GEOMETRY_CONTACTS
Render particle-geometry contacts.
Definition: RenderManager.h:63
@ RENDER_GEOMETRIES
Render collision geometries.
Definition: RenderManager.h:59
@ RENDER_NICE_CONTACTS
Render contacts with high fidelity.
Definition: RenderManager.h:72
@ RENDER_TEXT
Render text.
Definition: RenderManager.h:68
@ RENDER_MESH
Render trimesh/height field.
Definition: RenderManager.h:71
@ RENDER_CONSTRAINTS
Render rigid body constraint attachments.
Definition: RenderManager.h:64
@ RENDER_PARTICLE_CONTACTS
Render particle contacts.
Definition: RenderManager.h:62
@ RENDER_DEFAULT
The default rendering mode.
Definition: RenderManager.h:82
@ RENDER_AABB_TREES
Render AABB trees.
Definition: RenderManager.h:69
@ RENDER_BODY_PARTITION
Color for a RigidBody is selected based on which partition it belongs to.
Definition: RenderManager.h:75
@ RENDER_BATCH_BODIES
Batch render bodies.
Definition: RenderManager.h:77
@ RENDER_BATCH_CONTACTS
Render contacts as one batch call for all contacts.
Definition: RenderManager.h:76
@ RENDER_SENSORS
Render geometries which are sensors.
Definition: RenderManager.h:70
@ RENDER_PARTICLE_SYSTEMS
Render particle systems.
Definition: RenderManager.h:66
@ RENDER_OBSERVER_FRAMES
Render Observer frames.
Definition: RenderManager.h:79
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
AGXTERRAIN_EXPORT void clear()
uint32_t UInt32
Definition: Integer.h:40
Vec3T< T > min(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
Definition: Vec3Template.h:880
LinearProbingHashSetImplementation< KeyT, HashT >::iterator begin(LinearProbingHashSetImplementation< KeyT, HashT > &set)
double Real
Definition: Real.h:42
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
virtual void setAlpha(float alpha)=0