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;
142 bool getEnable( )
const;
147 bool isEnabled()
const;
158 float getAlpha( )
const;
325 void clear(
bool clearText =
true,
bool clearGlobalProxies =
true );
503 m_mgr->m_cacheVector.push_back(
this );
518 template <
typename T>
539 for (
size_t i = m_index; i < m_pool.size(); i++ )
542 m_pool.resize(
std::min( m_index, m_pool.size() ) );
551 for (
size_t i = 0; i < m_pool.size(); i++ )
585 template <
typename T,
typename P1>
600 T* acquire() {
return nullptr; }
769 void setEnable(
bool flag );
770 bool getEnable( )
const;
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();
#define AGX_DECLARE_POINTER_TYPES(type)
#define AGXPHYSICS_EXPORT
The geometry representation used by the collision detection engine.
A HeightField is a collision shape that can be created from a grid structure, like an image.
Class for listening for add/remove geometry events for an associated Space.
This class contains all Geometries and performs Broad Phase and Narrow Phase collision detection to c...
Triangle mesh for geometric intersection tests.
Abstract representation of a data buffer.
Data storage for a collection of entity instances of a specified EntityModel.
Abstract representation of a value.
Subclass that implements a BoxProxy.
Subclass that implements a CapsuleProxy.
Subclass that implements a ConeProxy.
Subclass that implements a CylinderProxy.
Abstract base class that acts as an interface and can render the data from a Graph.
Class that implements a simple graph for plotting scalar values.
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.
T * acquire(const P1 ¶m)
PrimitiveCache1(RenderManager *mgr)
Constructor.
Class for storing RenderProxies that are currently in use.
virtual ~PrimitiveCache()
Destructor: calls clear()
const_iterator begin() const
ProxyVector::const_iterator const_iterator
void clear()
Reduce number of proxies to 0.
const_iterator end() const
agx::Vector< agx::ref_ptr< T > > ProxyVector
void flush()
Reduce size of pooled RenderProxy down to the number of used ones.
ProxyVector::iterator iterator
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()
CacheVector m_cacheVector
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 updateParticleContactProxies()
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
float m_ContactsProxySize
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.
void setEnable(bool flag)
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.
virtual ~RenderProxyFactory()
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.
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...
A component is an object containing other objects, enabling hierarchical structuring.
@ SHRINK_BUFFER
Buffer is deallocated and replaced by an newly allocated empty buffer.
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
With this class you can attach an ObserverFrame object relative to a RigidBody.
A basic particle system that contains all the storages and buffers required for basic operation and a...
Base class providing referencing counted objects.
Smart pointer for observed objects, that automatically set pointers to them to null when they deleted...
Smart pointer for handling referenced counted objects.
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,...
Flags
Flags for specifying what is enabled in the debug rendering system.
@ RENDER_STATISTICS
Render statistics text/graphs onto screen.
@ RENDER_BATCH_WIRES
Wire content batch rendered.
@ RENDER_BODIES
Render rigid body mass centers.
@ RENDER_BOUNDING_VOLUMES
Render bounding volumes for geometries.
@ RENDER_GEOMETRY_CONTACTS
Render geometry contacts.
@ RENDER_RENDERABLES
Execute render for all registered Renderables.
@ RENDER_PARTICLE_EMITTERS
Render particle emitters.
@ RENDER_CONTACTS
Render all types of contacts.
@ RENDER_PARTICLE_GEOMETRY_CONTACTS
Render particle-geometry contacts.
@ RENDER_GEOMETRIES
Render collision geometries.
@ RENDER_NICE_CONTACTS
Render contacts with high fidelity.
@ RENDER_TEXT
Render text.
@ RENDER_MESH
Render trimesh/height field.
@ RENDER_CONSTRAINTS
Render rigid body constraint attachments.
@ RENDER_PARTICLE_CONTACTS
Render particle contacts.
@ RENDER_DEFAULT
The default rendering mode.
@ RENDER_AABB_TREES
Render AABB trees.
@ RENDER_BODY_PARTITION
Color for a RigidBody is selected based on which partition it belongs to.
@ RENDER_BATCH_BODIES
Batch render bodies.
@ RENDER_BATCH_CONTACTS
Render contacts as one batch call for all contacts.
@ RENDER_SENSORS
Render geometries which are sensors.
@ RENDER_PARTICLE_SYSTEMS
Render particle systems.
@ RENDER_OBSERVER_FRAMES
Render Observer frames.
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
AGXTERRAIN_EXPORT void clear()
Vec3T< T > min(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
LinearProbingHashSetImplementation< KeyT, HashT >::iterator begin(LinearProbingHashSetImplementation< KeyT, HashT > &set)
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
virtual void setAlpha(float alpha)=0
CacheBase(RenderManager *mgr)