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_VARIABLERATE_COUNTER
16#define OSGPARTICLE_VARIABLERATE_COUNTER 1
18#include <osgParticle/Counter>
19#include <osgParticle/range>
27 class VariableRateCounter: public Counter {
29 inline VariableRateCounter();
30 inline VariableRateCounter(const VariableRateCounter& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
32 virtual const char* libraryName() const { return "osgParticle"; }
33 virtual const char* className() const { return "VariableRateCounter"; }
34 virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const VariableRateCounter *>(obj) != 0; }
36 inline const rangef& getRateRange() const;
37 inline void setRateRange(const rangef& r);
38 inline void setRateRange(float minrange, float maxrange);
40 virtual int getEstimatedMaxNumOfParticles(double lifeTime) const { return static_cast<int>(_rate_range.maximum * lifeTime); }
43 virtual ~VariableRateCounter() {}
51 inline VariableRateCounter::VariableRateCounter()
52 : Counter(), _rate_range(1, 1)
56 inline VariableRateCounter::VariableRateCounter(const VariableRateCounter& copy, const osg::CopyOp& copyop)
57 : Counter(copy, copyop), _rate_range(copy._rate_range)
61 inline const rangef &VariableRateCounter::getRateRange() const
66 inline void VariableRateCounter::setRateRange(const rangef& r)
71 inline void VariableRateCounter::setRateRange(float minrange, float maxrange)
73 _rate_range.set(minrange, maxrange);