//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield //Distributed under the terms of the GNU Library General Public License (LGPL) //as published by the Free Software Foundation. //osgParticle - Copyright (C) 2002 Marco Jez #ifndef OSGPARTICLE_MODULARPROGRAM_ #define OSGPARTICLE_MODULARPROGRAM_ 1 #include #include #include #include #include #include #include namespace osgParticle { /** A program class for performing operations on particles using a sequence of operators. To use a ModularProgram you have to create some Operator objects and add them to the program. All operators will be applied to each particle in the same order they've been added to the program. */ class OSGPARTICLE_EXPORT ModularProgram: public Program { public: ModularProgram(); ModularProgram(const ModularProgram ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); META_Node(osgParticle,ModularProgram); /// Get the number of operators. inline int numOperators() const; /// Add an operator to the list. inline void addOperator(Operator *o); /// Get a pointer to an operator in the list. inline Operator *getOperator(int i); /// Get a const pointer to an operator in the list. inline const Operator *getOperator(int i) const; /// Remove an operator from the list. inline void removeOperator(int i); protected: virtual ~ModularProgram() {} ModularProgram &operator=(const ModularProgram &) { return *this; } void execute(double dt); private: typedef std::vector > Operator_vector; Operator_vector operators_; }; // INLINE FUNCTIONS inline int ModularProgram::numOperators() const { return static_cast(operators_.size()); } inline void ModularProgram::addOperator(Operator *o) { operators_.push_back(o); } inline Operator *ModularProgram::getOperator(int i) { return operators_[i].get(); } inline const Operator *ModularProgram::getOperator(int i) const { return operators_[i].get(); } inline void ModularProgram::removeOperator(int i) { operators_.erase(operators_.begin()+i); } } #endif