17 #ifndef AGXRENDER_RENDERMANAGER_H 18 #define AGXRENDER_RENDERMANAGER_H 33 class StatisticsEntries;
45 class RenderProxyFactory;
51 class HeightFieldProxy;
53 class HollowCylinderProxy;
55 class TruncatedConeProxy;
56 class HollowTruncatedConeProxy;
141 void setEnable(
bool flag );
146 bool getEnable( )
const;
151 bool isEnabled()
const;
162 float getAlpha( )
const;
168 void disableFlags(
unsigned int flags );
174 void enableFlags(
unsigned int flags );
179 bool isEnabledFlags(
unsigned int flags )
const;
184 void setFlags(
unsigned int flags );
234 CylinderProxy* acquireCylinder(
float radius,
float height );
290 CapsuleProxy* acquireCapsule(
float radius,
float height );
329 void clear(
bool clearText =
true,
bool clearGlobalProxies =
true );
340 bool hasRenderable(
Renderable* renderable )
const;
346 bool removeRenderable(
Renderable* renderable );
369 void setScaleFactor(
float scaleFactor = 1.0f );
374 float getScaleFactor()
const;
442 void addAllGeometries();
451 void updateAABBProxies( );
460 void updateParticleSystemProxies();
463 void updateRenderables();
466 void updateContactProxies();
469 void updateParticleContactProxies();
470 void updateParticleGeometryContactProxies();
473 void updateConstraintProxies();
476 void clearShapeProxies();
501 m_mgr->m_cacheVector.push_back(
this );
504 virtual void clear() = 0;
505 virtual void flush() = 0;
506 virtual void setAlpha(
float alpha ) = 0;
516 template <
typename T>
537 for (
size_t i = m_index; i < m_pool.size(); i++ )
538 m_pool[i]->callOnChange( RenderProxy::REMOVE );
540 m_pool.resize(
std::min( m_index, m_pool.size() ) );
549 for (
size_t i = 0; i < m_pool.size(); i++ )
558 ( *it )->callOnChange( RenderProxy::REMOVE );
568 iterator
begin() {
return m_pool.begin(); }
569 const_iterator
begin()
const {
return m_pool.begin(); }
571 iterator
end() {
return m_pool.end(); }
572 const_iterator
end()
const {
return m_pool.end(); }
583 template <
typename T,
typename P1>
594 T* acquire(
const P1& param );
598 T* acquire() {
return nullptr; }
651 virtual SphereProxy* createSphere(
float radius ) = 0;
660 virtual CylinderProxy* createCylinder(
float radius,
float height ) = 0;
663 virtual HollowCylinderProxy* createHollowCylinder(
float radius,
float height,
float thickness ) = 0;
666 virtual ConeProxy* createCone(
float radius,
float height ) = 0;
669 virtual TruncatedConeProxy* createTruncatedCone(
float topRadius,
float bottomRadius,
float height ) = 0;
672 virtual HollowTruncatedConeProxy* createHollowTruncatedCone(
float topRadius,
float bottomRadius,
float height,
float thickness ) = 0;
675 virtual CapsuleProxy* createCapsule(
float radius,
float height ) = 0;
678 virtual WireShapeProxy* createWireShape(
float radius,
float height,
767 void setEnable(
bool flag );
768 bool getEnable( )
const;
781 inline void RenderProxyFactory::setEnable(
bool flag )
785 inline bool RenderProxyFactory::getEnable( )
const 825 inline bool RenderManager::getEnable( )
const 831 inline float RenderManager::getAlpha( )
const 837 inline bool RenderManager::isEnabled()
const 846 return createSphere( radius );
851 return createBox( halfExtents );
861 return createCylinder( 1, 1 );
866 return createHollowCylinder( 1, 1, 0.1f );
872 return createCone( 1, 1 );
877 return createTruncatedCone( 1, 1, 1 );
882 return createHollowTruncatedCone( 1, 1, 1, 0.1f );
888 return createCapsule( 1, 1 );
898 return createPlane(
agx::Vec3( 0, 0, 1 ), 0 );
904 return createContacts( contacts );
909 return createRigidBodies( enabledBodies );
914 return m_defaultRenderMode;
917 template<
typename T>
920 if ( m_index < m_pool.size() ) {
921 T* proxy = m_pool[m_index++];
927 const void* p =
nullptr;
928 const T* px =
static_cast<const T*
>( p );
929 T* proxy = m_mgr->getProxyFactory()->create( px);
930 proxy->setEnable(
true );
931 m_pool.push_back( proxy );
932 m_index = m_pool.size();
937 template<
typename T,
typename P1>
940 if ( this->m_index < this->m_pool.size() ) {
941 T* proxy = this->m_pool[this->m_index++];
946 T* proxy = this->m_mgr->getProxyFactory()->create( param );
947 proxy->setEnable(
true );
948 this->m_pool.push_back( proxy );
949 this->m_index = this->m_pool.size();
agx::Vector< RenderableRef > RenderableRefVector
PrimitiveCache1< BoxProxy, agx::Vec3 > m_boxCache
AGXTERRAIN_EXPORT void clear()
Class that implements a simple graph for plotting scalar values.
Render collision geometries.
agx::Vector< agx::ref_ptr< agxRender::RenderProxy > > RenderProxyRefContainer
Execute render for all registered Renderables.
Vec3T< T > min(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
AGXOSG_EXPORT void setAlpha(osg::Node *node, float alpha)
Set the alpha part of the material for a node.
Class for listening for add/remove geometry events for an associated Space.
Render particle contacts.
ParticleSystemProxyContainer m_particleSystems
Smart pointer for observed objects, that automatically set pointers to them to null when they deleted...
Data storage for a collection of entity instances of a specified EntityModel.
Subclass that implements a BoxProxy.
A component is an object containing other objects, enabling hierarchical structuring.
Abstract representation of a value.
void setRenderManager(RenderManager *mgr)
agx::Vector< CacheBase * > CacheVector
Subclass that implements a TruncatedConeProxy.
const_iterator end() const
agx::Vector< agx::ref_ptr< T > > ProxyVector
PrimitiveCache< TruncatedConeProxy > m_truncatedConeCache
RenderProxyRef m_particleGeometryContactRenderProxy
Subclass that implements a CylinderProxy.
The default rendering mode.
#define AGXPHYSICS_EXPORT
Render geometries which are sensors.
void flush()
Reduce size of pooled RenderProxy down to the number of used ones.
const_iterator begin() const
#define AGX_DECLARE_POINTER_TYPES(type)
Color for a RigidBody is selected based on which partition it belongs to.
Subclass that implements a TrimeshProxy.
RenderProxyRef m_particleContactRenderProxy
Namespace containing classes for handling debug rendering of collision geometries, constraints, contacts and rigid bodies.
PrimitiveCache< HollowCylinderProxy > m_hollowCylinderCache
Render statistics text/graphs onto screen.
agxData::ValueRef m_particleContactBound
Class for storing RenderProxies that are currently in use.
Render contacts as one batch call for all contacts.
void setAlpha(float alpha)
Set alpha value for all proxies.
Class for managing the rendering of geometries, shapes, rigid bodies, constraints etc...
PrimitiveCache1(RenderManager *mgr)
Constructor.
Subclass that implements a CapsuleProxy.
agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > > RenderProxyHashVector
RenderProxyHashVector m_proxies
PrimitiveCache< CapsuleProxy > m_capsuleCache
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...
PrimitiveCache1< ContactsProxy, agxCollide::GeometryContactPtrVector > m_contactsCache
A listener that will be responsible for calling RenderManager every time a Shape is added/removed fro...
Abstract class which is responsible for returning a pointer to a specified RenderProxy type...
Render rigid body constraint attachments.
PrimitiveCache< CylinderProxy > m_cylinderCache
Base class providing referencing counted objects.
The geometry representation used by the collision detection engine.
Subclass that implements a SphereProxy.
Wire content batch rendered.
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
agxData::BufferRef m_particleContactRadiusBuffer
agxRender::GraphRef m_graph
Buffer is deallocated and replaced by an newly allocated empty buffer.
Render rigid body mass centers.
A basic particle system that contains all the storages and buffers required for basic operation and a...
Render bounding volumes for geometries.
Vector containing 'raw' data.
PrimitiveCache1< RigidBodyBatchRenderProxy, const agx::RigidBodyPtrSetVector * > m_rbCache
This class contains all Geometries and performs Broad Phase and Narrow Phase collision detection to c...
agx::ref_ptr< RenderProxyFactory > m_factory
Abstract representation of a data buffer.
RenderProxyRefContainer m_globalProxies
E.g., wires that hold their proxy (i.e., not doing acquire to fetch their render proxy).
ProxyVector::const_iterator const_iterator
PrimitiveCache1< SphereProxy, float > m_sphereCache
ProxyVector::iterator iterator
Smart pointer for handling referenced counted objects.
RenderableRefVector m_renderables
LinearProbingHashSetImplementation< KeyT, HashT >::iterator begin(LinearProbingHashSetImplementation< KeyT, HashT > &set)
std::pair< const agx::ParticleSystem *, agxRender::RenderProxyRef > ConstParticleSystemPtrRenderProxyPtrPair
Subclass that implements a PlaneProxy.
agx::Vector< ConstParticleSystemPtrRenderProxyPtrPair > ParticleSystemProxyContainer
PrimitiveCache< PlaneProxy > m_planeCache
virtual ~PrimitiveCache()
Destructor: calls clear()
Inherit from this class and implement the render() method to make it it self during debug rendering...
float m_ContactsProxySize
Abstract base class which encapsulated information for rendering a specific shape.
agxData::BufferRef m_particleGeometryContactRadiusBuffer
Render trimesh/height field.
CacheBase(RenderManager *mgr)
Subclass that implements a HollowTruncatedConeProxy.
void clear()
Reduce number of proxies to 0.
Class for storing RenderProxies that are currently in use.
Render particle emitters.
agx::ref_ptr< SpaceListener > m_listener
Render geometry contacts.
PrimitiveCache< ConeProxy > m_coneCache
Render particle-geometry contacts.
Subclass that implements a TextProxy.
Abstract base class that acts as an interface and can render the data from a Graph.
PrimitiveCache< LineProxy > m_lineCache
Render contacts with high fidelity.
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
CacheVector m_cacheVector
agxSDK::Simulation * m_simulation
RenderProxy::RenderMode m_defaultRenderMode
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
agxData::ValueRef m_particleGeometryContactBound
EventType
Enum for specifying a type of event which might change a 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.
Subclass that implements a ConeProxy.
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.
Subclass that implements a LineProxy.
Render all types of contacts.
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Subclass that implements a CylinderProxy.
PrimitiveCache< HollowTruncatedConeProxy > m_hollowTruncatedConeCache
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...
PrimitiveCache(RenderManager *mgr)
Constructor.
agx::observer_ptr< agxCollide::Space > m_space
agx::observer_ptr< RenderManager > m_mgr
RenderProxy::RenderMode m_defaultRenderMode
Flags
Flags for specifying what is enabled in the debug rendering system.
PrimitiveCache< TextProxy > m_textCache