root/OpenSceneGraph/trunk/src/osgAnimation/StackedRotateAxisElement.cpp @ 13041

Revision 13041, 2.1 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1/*  -*-c++-*-
2 *  Copyright (C) 2009 Cedric Pinson <cedric.pinson@plopbyte.net>
3 *
4 * This library is open source and may be redistributed and/or modified under
5 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
6 * (at your option) any later version.  The full license is in LICENSE file
7 * included with this distribution, and on the openscenegraph.org website.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * OpenSceneGraph Public License for more details.
13 */
14
15#include <osgAnimation/StackedRotateAxisElement>
16
17using namespace osgAnimation;
18
19StackedRotateAxisElement::StackedRotateAxisElement(const std::string& name, const osg::Vec3& axis, double angle) : StackedTransformElement(), _axis(axis), _angle(angle) { setName(name); }
20StackedRotateAxisElement::StackedRotateAxisElement(const osg::Vec3& axis, double angle) : _axis(axis), _angle(angle) { setName("rotateaxis"); }
21StackedRotateAxisElement::StackedRotateAxisElement() {}
22StackedRotateAxisElement::StackedRotateAxisElement(const StackedRotateAxisElement& rhs, const osg::CopyOp&) : StackedTransformElement(rhs), _axis(rhs._axis), _angle(rhs._angle)
23{
24    if (rhs._target.valid())
25        _target = new FloatTarget(*rhs._target);
26}
27
28
29osg::Matrix StackedRotateAxisElement::getAsMatrix() const { return osg::Matrix::rotate(osg::Quat(_angle, _axis)); }
30void StackedRotateAxisElement::update(float t)
31{
32    if (_target.valid())
33        _angle = _target->getValue();
34}
35
36const osg::Vec3& StackedRotateAxisElement::getAxis() const { return _axis; }
37double StackedRotateAxisElement::getAngle() const { return _angle; }
38void StackedRotateAxisElement::setAxis(const osg::Vec3& axis)
39{
40    _axis = axis;
41}
42
43void StackedRotateAxisElement::setAngle(double angle)
44{
45    _angle = angle;
46}
47
48Target* StackedRotateAxisElement::getOrCreateTarget()
49{
50    if (!_target.valid())
51        _target = new FloatTarget(_angle);
52    return _target.get();
53}
54
55void StackedRotateAxisElement::applyToMatrix(osg::Matrix& matrix) const {    matrix.preMultRotate(osg::Quat(_angle, _axis)); }
Note: See TracBrowser for help on using the browser.