root/OpenSceneGraph/trunk/src/osgAnimation/StackedScaleElement.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/StackedScaleElement>
16
17using namespace osgAnimation;
18
19StackedScaleElement::StackedScaleElement(const std::string& name, const osg::Vec3& scale) : _scale(scale) { setName(name); }
20StackedScaleElement::StackedScaleElement(const osg::Vec3& scale) : _scale(scale) { setName("scale"); }
21
22StackedScaleElement::StackedScaleElement(const StackedScaleElement& rhs, const osg::CopyOp&) : StackedTransformElement(rhs), _scale(rhs._scale)
23{
24    if (rhs._target.valid())
25        _target = new Vec3Target(*rhs._target);
26}
27
28const osg::Vec3& StackedScaleElement::getScale() const { return _scale; }
29void StackedScaleElement::setScale(const osg::Vec3& scale) { _scale = scale; }
30
31Target* StackedScaleElement::getTarget() {return _target.get();}
32const Target* StackedScaleElement::getTarget() const {return _target.get();}
33
34bool StackedScaleElement::isIdentity() const { return (_scale.x() == 1 && _scale.y() == 1 && _scale.z() == 1); }
35
36osg::Matrix StackedScaleElement::getAsMatrix() const { return osg::Matrix::scale(_scale); }
37
38void StackedScaleElement::applyToMatrix(osg::Matrix& matrix) const {    matrix.preMultScale(_scale); }
39
40StackedScaleElement::StackedScaleElement()
41{
42    _scale = osg::Vec3(1,1,1);
43}
44
45void StackedScaleElement::update(float t)
46{
47    if (_target.valid())
48        _scale = _target->getValue();
49}
50
51Target* StackedScaleElement::getOrCreateTarget()
52{
53    if (!_target.valid())
54        _target = new Vec3Target(_scale);
55    return _target.get();
56}
Note: See TracBrowser for help on using the browser.