AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
ParticleSystemDrawable.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGXOSG_PARTICLE_SYSTEMDRAWABLE_H
18#define AGXOSG_PARTICLE_SYSTEMDRAWABLE_H
19
21#include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
22#include <osg/Drawable>
23#include <osgViewer/Viewer>
24#include <osg/Version>
25#include <agx/PopDisableWarnings.h> // End of disabled warnings.
26
27#include <agxOSG/export.h>
28#include <agx/Task.h>
29#include <agx/observer_ptr.h>
30#include <agx/ParticleSystem.h>
31
32#ifndef DEFAULT_PARTICLE_RENDERING_MODE
33 #if defined(__APPLE__)
34 // The shader for quad sprites does not compile on macOS, since OpenGL 2.1 is used.
35 // It should be updated to OpenGL 3.x, but that requires setting up the context a bit differently.
36 #define DEFAULT_PARTICLE_RENDERING_MODE agxOSG::ParticleSystemDrawable::SPRITES
37 #else
38 #define DEFAULT_PARTICLE_RENDERING_MODE agxOSG::ParticleSystemDrawable::QUAD_SPRITES
39 #endif
40#endif
41
42namespace agxOSG
43{
44 class AGXOSG_EXPORT ParticleSystemDrawable : public osg::Drawable
45 {
46 public:
50 TRIANGLES
51 #if AGX_USE_OPENGL_INSTANCING()
52 , INSTANCES
53 #endif
54 };
55
57 {
61 };
62
63 public:
64
65 ParticleSystemDrawable( agx::ParticleSystem *particleSystem, ParticleRenderingMode renderMode = DEFAULT_PARTICLE_RENDERING_MODE, ParticleShaderMode particleShaderMode = ROTATION_SPRITES);
66 // ParticleSystemDrawable( const ParticleSystemDrawable&c, const osg::CopyOp& copyOp );
67
68
71
72
73 virtual osg::Object* cloneType() const { return new ParticleSystemDrawable ( m_particleSystem.get() ); }
74 virtual osg::Object* clone(const osg::CopyOp&) const { return new ParticleSystemDrawable (*this); }
75 virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const ParticleSystemDrawable *>(obj)!=nullptr; }
76 virtual const char* libraryName() const { return "agxOSG"; }
77 virtual const char* className() const { return "ParticleSystemDrawable"; }
78
79
81# if OSG_VERSION_GREATER_OR_EQUAL(3,4,0)
82 virtual osg::BoundingSphere computeBound() const;
83 virtual osg::BoundingBox computeBoundingBox() const;
84#else
85 virtual osg::BoundingBox computeBound() const;
86#endif
87
89 virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
90
91 void setEnable(bool enable);
92
93 bool getEnable() const;
94
96
99
102
103 protected:
105
111 private:
112 static ParticleRenderingMode s_allowedRenderMode;
113 };
114
116
118}
119
120#endif /* AGXOSG_PARTICLE_SYSTEMDRAWABLE_H */
#define DEFAULT_PARTICLE_RENDERING_MODE
#define AGXOSG_EXPORT
virtual const char * libraryName() const
agx::ParticleSystemObserver m_particleSystem
static ParticleRenderingMode getAllowedRenderMode()
Get the minimum allowed ParticleRenderingMode for the particles.
virtual osg::Object * clone(const osg::CopyOp &) const
ParticleSystemDrawable(agx::ParticleSystem *particleSystem, ParticleRenderingMode renderMode=DEFAULT_PARTICLE_RENDERING_MODE, ParticleShaderMode particleShaderMode=ROTATION_SPRITES)
ParticleShaderMode getParticleShaderMode() const
virtual osg::BoundingBox computeBound() const
Compute the bounding box around Drawables's geometry.
static void setAllowedRenderMode(ParticleRenderingMode mode)
Set the minimum allowed ParticleRenderingMode for the particles.
virtual bool isSameKindAs(const osg::Object *obj) const
agx::ParticleSystem * getParticleSystem()
virtual osg::Object * cloneType() const
virtual void drawImplementation(osg::RenderInfo &renderInfo) const
The actual draw method for the particle system.
void setParticleShaderMode(ParticleShaderMode flag)
virtual const char * className() const
A basic particle system that contains all the storages and buffers required for basic operation and a...
#define AGX_FORCE_INLINE
Definition: macros.h:58
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.