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_ANGULARACCELOPERATOR
16#define OSGPARTICLE_ANGULARACCELOPERATOR 1
18#include <osgParticle/ModularProgram>
19#include <osgParticle/Operator>
20#include <osgParticle/Particle>
29 /** An operator class that applies a constant angular acceleration to
32 class AngularAccelOperator: public Operator {
34 inline AngularAccelOperator();
35 inline AngularAccelOperator(const AngularAccelOperator& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
37 META_Object(osgParticle, AngularAccelOperator);
39 /// Get the angular acceleration vector.
40 inline const osg::Vec3& getAngularAcceleration() const;
42 /// Set the angular acceleration vector.
43 inline void setAngularAcceleration(const osg::Vec3& v);
45 /// Apply the angular acceleration to a particle. Do not call this method manually.
46 inline void operate(Particle* P, double dt);
48 /// Perform some initializations. Do not call this method manually.
49 inline void beginOperate(Program *prg);
52 virtual ~AngularAccelOperator() {}
53 AngularAccelOperator& operator=(const AngularAccelOperator& ) { return *this; }
56 osg::Vec3 _angul_araccel;
57 osg::Vec3 _xf_angul_araccel;
62 inline AngularAccelOperator::AngularAccelOperator()
63 : Operator(), _angul_araccel(0, 0, 0)
67 inline AngularAccelOperator::AngularAccelOperator(const AngularAccelOperator& copy, const osg::CopyOp& copyop)
68 : Operator(copy, copyop), _angul_araccel(copy._angul_araccel)
72 inline const osg::Vec3& AngularAccelOperator::getAngularAcceleration() const
74 return _angul_araccel;
77 inline void AngularAccelOperator::setAngularAcceleration(const osg::Vec3& v)
82 inline void AngularAccelOperator::operate(Particle* P, double dt)
84 P->addAngularVelocity(_xf_angul_araccel * dt);
87 inline void AngularAccelOperator::beginOperate(Program *prg)
89 if (prg->getReferenceFrame() == ModularProgram::RELATIVE_RF) {
90 _xf_angul_araccel = prg->rotateLocalToWorld(_angul_araccel);
92 _xf_angul_araccel = _angul_araccel;