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

Revision 13041, 2.2 kB (checked in by robert, 2 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/StackedTranslateElement>
16
17using namespace osgAnimation;
18
19
20StackedTranslateElement::StackedTranslateElement(const std::string& name, const osg::Vec3& translate) : _translate(translate) { setName(name); }
21StackedTranslateElement::StackedTranslateElement(const osg::Vec3& translate) : _translate(translate) { setName("translate"); }
22
23
24StackedTranslateElement::StackedTranslateElement() {}
25StackedTranslateElement::StackedTranslateElement(const StackedTranslateElement& rhs, const osg::CopyOp&) : StackedTransformElement(rhs), _translate(rhs._translate)
26{
27    if (rhs._target.valid())
28        _target = new Vec3Target(*rhs._target);
29}
30
31void StackedTranslateElement::applyToMatrix(osg::Matrix& matrix) const {matrix.preMultTranslate(_translate);}
32osg::Matrix StackedTranslateElement::getAsMatrix() const { return osg::Matrix::translate(_translate); }
33bool StackedTranslateElement::isIdentity() const { return (_translate[0] == 0 && _translate[1] == 0 && _translate[2] == 0); }
34const osg::Vec3& StackedTranslateElement::getTranslate() const {    return _translate; }
35void StackedTranslateElement::setTranslate(const osg::Vec3& value) { _translate = value; }
36
37Target* StackedTranslateElement::getOrCreateTarget()
38{
39    if (!_target.valid())
40        _target = new Vec3Target(_translate);
41    return _target.get();
42}
43Target* StackedTranslateElement::getTarget() {return _target.get();}
44const Target* StackedTranslateElement::getTarget() const {return _target.get();}
45
46void StackedTranslateElement::update(float t)
47{
48    if (_target.valid())
49        _translate = _target->getValue();
50}
Note: See TracBrowser for help on using the browser.