17 #ifndef AGXRENDER_RENDERMANAGER_H 18 #define AGXRENDER_RENDERMANAGER_H 33 class StatisticsEntries;
39 class RenderProxyFactory;
45 class HeightFieldProxy;
47 class HollowCylinderProxy;
49 class TruncatedConeProxy;
50 class HollowTruncatedConeProxy;
137 void setEnable(
bool flag );
142 bool getEnable( )
const;
147 bool isEnabled()
const;
158 float getAlpha( )
const;
164 void disableFlags(
unsigned int flags );
170 void enableFlags(
unsigned int flags );
175 bool isEnabledFlags(
unsigned int flags )
const;
180 void setFlags(
unsigned int flags );
230 CylinderProxy* acquireCylinder(
float radius,
float height );
286 CapsuleProxy* acquireCapsule(
float radius,
float height );
325 void clear(
bool clearText =
true,
bool clearGlobalProxies =
true );
336 bool hasRenderable(
Renderable* renderable )
const;
342 bool removeRenderable(
Renderable* renderable );
365 void setScaleFactor(
float scaleFactor = 1.0f );
370 float getScaleFactor()
const;
438 void addAllGeometries();
447 void updateAABBProxies( );
450 void updateObserverFrames();
462 void updateParticleSystemProxies();
465 void updateRenderables();
468 void updateContactProxies();
471 void updateParticleContactProxies();
472 void updateParticleGeometryContactProxies();
475 void updateConstraintProxies();
478 void clearShapeProxies();
503 m_mgr->m_cacheVector.push_back(
this );
506 virtual void clear() = 0;
507 virtual void flush() = 0;
508 virtual void setAlpha(
float alpha ) = 0;
518 template <
typename T>
539 for (
size_t i = m_index; i < m_pool.size(); i++ )
540 m_pool[i]->callOnChange( RenderProxy::REMOVE );
542 m_pool.resize(
std::min( m_index, m_pool.size() ) );
551 for (
size_t i = 0; i < m_pool.size(); i++ )
560 ( *it )->callOnChange( RenderProxy::REMOVE );
570 iterator
begin() {
return m_pool.begin(); }
571 const_iterator
begin()
const {
return m_pool.begin(); }
573 iterator
end() {
return m_pool.end(); }
574 const_iterator
end()
const {
return m_pool.end(); }
585 template <
typename T,
typename P1>
596 T* acquire(
const P1& param );
600 T* acquire() {
return nullptr; }
653 virtual SphereProxy* createSphere(
float radius ) = 0;
662 virtual CylinderProxy* createCylinder(
float radius,
float height ) = 0;
665 virtual HollowCylinderProxy* createHollowCylinder(
float radius,
float height,
float thickness ) = 0;
668 virtual ConeProxy* createCone(
float radius,
float height ) = 0;
671 virtual TruncatedConeProxy* createTruncatedCone(
float topRadius,
float bottomRadius,
float height ) = 0;
674 virtual HollowTruncatedConeProxy* createHollowTruncatedCone(
float topRadius,
float bottomRadius,
float height,
float thickness ) = 0;
677 virtual CapsuleProxy* createCapsule(
float radius,
float height ) = 0;
680 virtual WireShapeProxy* createWireShape(
float radius,
float height,
769 void setEnable(
bool flag );
770 bool getEnable( )
const;
783 inline void RenderProxyFactory::setEnable(
bool flag )
787 inline bool RenderProxyFactory::getEnable( )
const 827 inline bool RenderManager::getEnable( )
const 833 inline float RenderManager::getAlpha( )
const 839 inline bool RenderManager::isEnabled()
const 848 return createSphere( radius );
853 return createBox( halfExtents );
863 return createCylinder( 1, 1 );
868 return createHollowCylinder( 1, 1, 0.1f );
874 return createCone( 1, 1 );
879 return createTruncatedCone( 1, 1, 1 );
884 return createHollowTruncatedCone( 1, 1, 1, 0.1f );
890 return createCapsule( 1, 1 );
900 return createPlane(
agx::Vec3( 0, 0, 1 ), 0 );
906 return createContacts( contacts );
911 return createRigidBodies( enabledBodies );
916 return m_defaultRenderMode;
919 template<
typename T>
922 if ( m_index < m_pool.size() ) {
923 T* proxy = m_pool[m_index++];
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();
939 template<
typename T,
typename P1>
942 if ( this->m_index < this->m_pool.size() ) {
943 T* proxy = this->m_pool[this->m_index++];
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();
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
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.
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
With this class you can attach an ObserverFrame object relative to a RigidBody.
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