OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AngularAccelOperator.h
Go to the documentation of this file.
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_ANGULARACCELOPERATOR
16 #define OSGPARTICLE_ANGULARACCELOPERATOR 1
17 
18 #include <osgParticle/ModularProgram>
19 #include <osgParticle/Operator>
20 #include <osgParticle/Particle>
21 
22 #include <osg/CopyOp>
23 #include <osg/Object>
24 #include <osg/Vec3>
25 
26 namespace osgParticle
27 {
28 
33  public:
34  inline AngularAccelOperator();
36 
38 
40  inline const osg::Vec3& getAngularAcceleration() const;
41 
43  inline void setAngularAcceleration(const osg::Vec3& v);
44 
46  inline void operate(Particle* P, double dt);
47 
49  inline void beginOperate(Program *prg);
50 
51  protected:
52  virtual ~AngularAccelOperator() {}
54 
55  private:
56  osg::Vec3 _angul_araccel;
57  osg::Vec3 _xf_angul_araccel;
58  };
59 
60  // INLINE FUNCTIONS
61 
63  : Operator(), _angul_araccel(0, 0, 0)
64  {
65  }
66 
68  : Operator(copy, copyop), _angul_araccel(copy._angul_araccel)
69  {
70  }
71 
73  {
74  return _angul_araccel;
75  }
76 
78  {
79  _angul_araccel = v;
80  }
81 
82  inline void AngularAccelOperator::operate(Particle* P, double dt)
83  {
84  P->addAngularVelocity(_xf_angul_araccel * dt);
85  }
86 
88  {
90  _xf_angul_araccel = prg->rotateLocalToWorld(_angul_araccel);
91  } else {
92  _xf_angul_araccel = _angul_araccel;
93  }
94  }
95 
96 }
97 
98 
99 #endif
osg::Vec3 rotateLocalToWorld(const osg::Vec3 &P)
Transform a vector from local to world coordinates, discarding translation (valid only during cull tr...
AngularAccelOperator & operator=(const AngularAccelOperator &)
ReferenceFrame getReferenceFrame() const
Get the reference frame.
void operate(Particle *P, double dt)
Apply the angular acceleration to a particle. Do not call this method manually.
void setAngularAcceleration(const osg::Vec3 &v)
Set the angular acceleration vector.
const osg::Vec3 & getAngularAcceleration() const
Get the angular acceleration vector.
META_Object(osgParticle, AngularAccelOperator)
void addAngularVelocity(const osg::Vec3 &dv)
Add a vector to the angular velocity vector.
Definition: Particle.h:539
void beginOperate(Program *prg)
Perform some initializations. Do not call this method manually.