From 540e676daebd6eadec2a38a35995d0aea69dc23e Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 11 Oct 2005 09:47:28 +0000 Subject: [PATCH] Added new shell of new class ConnectedParticleSystem, which will be used for managing connect particle system for the purpose of doing missile trails etc. --- VisualStudio/osgParticle/osgParticle.dsp | 8 +++ include/osgParticle/ConnectedParticleSystem | 58 +++++++++++++++++++++ include/osgParticle/Particle | 4 ++ src/osgParticle/ConnectedParticleSystem.cpp | 57 ++++++++++++++++++++ src/osgParticle/GNUmakefile | 1 + src/osgParticle/Particle.cpp | 4 +- 6 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 include/osgParticle/ConnectedParticleSystem create mode 100644 src/osgParticle/ConnectedParticleSystem.cpp diff --git a/VisualStudio/osgParticle/osgParticle.dsp b/VisualStudio/osgParticle/osgParticle.dsp index bc6611e24..b092f77cc 100644 --- a/VisualStudio/osgParticle/osgParticle.dsp +++ b/VisualStudio/osgParticle/osgParticle.dsp @@ -147,6 +147,10 @@ SOURCE=..\..\src\osgParticle\ParticleSystem.cpp # End Source File # Begin Source File +SOURCE=..\..\src\osgParticle\ConnectedParticleSystem.cpp +# End Source File +# Begin Source File + SOURCE=..\..\src\osgParticle\ParticleSystemUpdater.cpp # End Source File # Begin Source File @@ -255,6 +259,10 @@ SOURCE=..\..\include\osgParticle\ParticleSystem # End Source File # Begin Source File +SOURCE=..\..\include\osgParticle\ConnectedParticleSystem +# End Source File +# Begin Source File + SOURCE=..\..\include\osgParticle\ParticleSystemUpdater # End Source File # Begin Source File diff --git a/include/osgParticle/ConnectedParticleSystem b/include/osgParticle/ConnectedParticleSystem new file mode 100644 index 000000000..1f12d1dd0 --- /dev/null +++ b/include/osgParticle/ConnectedParticleSystem @@ -0,0 +1,58 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef OSGPARTICLE_CONNECTEDPARTICLESYSTEM +#define OSGPARTICLE_CONNECTEDPARTICLESYSTEM 1 + +#include + +namespace osgParticle +{ + + /** ConnectConnectedParticleSystem is a specialise ConnectedParticleSystem for effects + * like missle trails, where the individual particles are rendered as + * single ribbon. + */ + class OSGPARTICLE_EXPORT ConnectedParticleSystem: public osgParticle::ParticleSystem + { + public: + + ConnectedParticleSystem(); + ConnectedParticleSystem(const ConnectedParticleSystem& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY); + + META_Object(osgParticle, ConnectedParticleSystem); + + /// Create a new particle from the specified template (or the default one if ptemplate is null). + virtual Particle* createParticle(const Particle* ptemplate); + + /// Destroy the i-th particle. + virtual void destroyParticle(int i); + + /// Update the particles. Don't call this directly, use a ConnectedParticleSystemUpdater instead. + virtual void update(double dt); + + virtual void drawImplementation(osg::State& state) const; + + protected: + + virtual ~ConnectedParticleSystem(); + + ConnectedParticleSystem& operator=(const ConnectedParticleSystem&) { return *this; } + + Particle* _startParticle; + Particle* _lastParticleCreated; + }; + +} + +#endif diff --git a/include/osgParticle/Particle b/include/osgParticle/Particle index 7a4b2b93a..1b5b2a407 100644 --- a/include/osgParticle/Particle +++ b/include/osgParticle/Particle @@ -257,6 +257,10 @@ namespace osgParticle int _cur_tile; float _s_coord; float _t_coord; + + // previous and next Particles are only used in ConnectedParticleSystems + Particle* _previousParticle; + Particle* _nextParticle; }; // INLINE FUNCTIONS diff --git a/src/osgParticle/ConnectedParticleSystem.cpp b/src/osgParticle/ConnectedParticleSystem.cpp new file mode 100644 index 000000000..ba70e3ffd --- /dev/null +++ b/src/osgParticle/ConnectedParticleSystem.cpp @@ -0,0 +1,57 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#include +#include + +using namespace osgParticle; + +ConnectedParticleSystem::ConnectedParticleSystem(): + _startParticle(0), + _lastParticleCreated(0) +{ +} + +ConnectedParticleSystem::ConnectedParticleSystem(const ConnectedParticleSystem& copy, const osg::CopyOp& copyop): + ParticleSystem(copy,copyop), + _startParticle(0), + _lastParticleCreated(0) +{ + // need to think about how to copy _startParticle and _lastParticleCreated... + // should we just use indices? Should we compute offsets into the particle system? + osg::notify(osg::NOTICE)<<"Warning: ConnectedParticleSystem copy constructor incomplete."<