root/OpenSceneGraph/trunk/include/osgParticle/ModularProgram @ 13041

Revision 13041, 2.9 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
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.
7 *
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.
12*/
13//osgParticle - Copyright (C) 2002 Marco Jez
14
15#ifndef OSGPARTICLE_MODULARPROGRAM
16#define OSGPARTICLE_MODULARPROGRAM 1
17
18#include <osgParticle/Export>
19#include <osgParticle/Program>
20#include <osgParticle/Operator>
21
22#include <osg/CopyOp>
23#include <osg/Object>
24#include <osg/Node>
25#include <osg/NodeVisitor>
26
27namespace osgParticle
28{
29
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.
34    */
35    class OSGPARTICLE_EXPORT ModularProgram: public Program {
36    public:
37        ModularProgram();
38        ModularProgram(const ModularProgram& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
39
40        META_Node(osgParticle,ModularProgram);
41
42        /// Get the number of operators.
43        inline int numOperators() const;
44
45        /// Add an operator to the list.
46        inline void addOperator(Operator* o);
47
48        /// Get a pointer to an operator in the list.
49        inline Operator* getOperator(int i);
50
51        /// Get a const pointer to an operator in the list.
52        inline const Operator* getOperator(int i) const;
53
54        /// Remove an operator from the list.
55        inline void removeOperator(int i);
56
57    protected:
58        virtual ~ModularProgram() {}
59        ModularProgram& operator=(const ModularProgram&) { return *this; }
60
61        void execute(double dt);
62
63    private:
64        typedef std::vector<osg::ref_ptr<Operator> > Operator_vector;
65
66        Operator_vector _operators;
67    };
68
69    // INLINE FUNCTIONS
70
71    inline int ModularProgram::numOperators() const
72    {
73        return static_cast<int>(_operators.size());
74    }
75
76    inline void ModularProgram::addOperator(Operator* o)
77    {
78        _operators.push_back(o);
79    }
80
81    inline Operator* ModularProgram::getOperator(int i)
82    {
83        return _operators[i].get();
84    }
85
86    inline const Operator* ModularProgram::getOperator(int i) const
87    {
88        return _operators[i].get();
89    }
90
91    inline void ModularProgram::removeOperator(int i)
92    {
93        _operators.erase(_operators.begin()+i);
94    }
95
96
97}
98
99#endif
Note: See TracBrowser for help on using the browser.