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/StackedMatrixElement> 16 17 using namespace osgAnimation; 18 StackedMatrixElement()19StackedMatrixElement::StackedMatrixElement() {} StackedMatrixElement(const std::string & name,const osg::Matrix & matrix)20StackedMatrixElement::StackedMatrixElement(const std::string& name, const osg::Matrix& matrix) : StackedTransformElement(), _matrix(matrix) { setName(name); } StackedMatrixElement(const osg::Matrix & matrix)21StackedMatrixElement::StackedMatrixElement(const osg::Matrix& matrix) : _matrix(matrix) { setName("matrix"); } 22 StackedMatrixElement(const StackedMatrixElement & rhs,const osg::CopyOp & c)23StackedMatrixElement::StackedMatrixElement(const StackedMatrixElement& rhs, const osg::CopyOp& c) : StackedTransformElement(rhs, c), _matrix(rhs._matrix) 24 { 25 if (rhs._target.valid()) 26 _target = new MatrixTarget(*rhs._target); 27 } 28 getOrCreateTarget()29Target* StackedMatrixElement::getOrCreateTarget() 30 { 31 if (!_target.valid()) 32 _target = new MatrixTarget(_matrix); 33 return _target.get(); 34 } 35 update(float)36void StackedMatrixElement::update(float /*t*/) 37 { 38 if (_target.valid()) 39 _matrix = _target->getValue(); 40 } 41