1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
13//osgParticle - Copyright (C) 2002 Marco Jez
15#ifndef OSGPARTICLE_MODULARPROGRAM
16#define OSGPARTICLE_MODULARPROGRAM 1
18#include <osgParticle/Export>
19#include <osgParticle/Program>
20#include <osgParticle/Operator>
25#include <osg/NodeVisitor>
30 /** A program class for performing operations on particles using a sequence of <I>operators</I>.
31 To use a <CODE>ModularProgram</CODE> you have to create some <CODE>Operator</CODE> objects and
32 add them to the program.
33 All operators will be applied to each particle in the same order they've been added to the program.
35 class OSGPARTICLE_EXPORT ModularProgram: public Program {
38 ModularProgram(const ModularProgram& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
40 META_Node(osgParticle,ModularProgram);
42 /// Get the number of operators.
43 inline int numOperators() const;
45 /// Add an operator to the list.
46 inline void addOperator(Operator* o);
48 /// Get a pointer to an operator in the list.
49 inline Operator* getOperator(int i);
51 /// Get a const pointer to an operator in the list.
52 inline const Operator* getOperator(int i) const;
54 /// Remove an operator from the list.
55 inline void removeOperator(int i);
58 virtual ~ModularProgram() {}
59 ModularProgram& operator=(const ModularProgram&) { return *this; }
61 void execute(double dt);
64 typedef std::vector<osg::ref_ptr<Operator> > Operator_vector;
66 Operator_vector _operators;
71 inline int ModularProgram::numOperators() const
73 return static_cast<int>(_operators.size());
76 inline void ModularProgram::addOperator(Operator* o)
78 _operators.push_back(o);
81 inline Operator* ModularProgram::getOperator(int i)
83 return _operators[i].get();
86 inline const Operator* ModularProgram::getOperator(int i) const
88 return _operators[i].get();
91 inline void ModularProgram::removeOperator(int i)
93 _operators.erase(_operators.begin()+i);