#
root/OpenSceneGraph/trunk/src/osgAnimation/StackedScaleElement.cpp
@
11009

Revision 11009, 2.1 kB (checked in by robert, 7 years ago) |
---|

Rev | Line | |
---|---|---|

[11009] | 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 | ||

17 | using namespace osgAnimation; | |

18 | ||

19 | StackedScaleElement::StackedScaleElement(const std::string& name, const osg::Vec3& scale) : _scale(scale) { setName(name); } | |

20 | StackedScaleElement::StackedScaleElement(const osg::Vec3& scale) : _scale(scale) { setName("scale"); } | |

21 | ||

22 | StackedScaleElement::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 | ||

28 | const osg::Vec3& StackedScaleElement::getScale() const { return _scale; } | |

29 | void StackedScaleElement::setScale(const osg::Vec3& scale) { _scale = scale; } | |

30 | ||

31 | Target* StackedScaleElement::getTarget() {return _target.get();} | |

32 | const Target* StackedScaleElement::getTarget() const {return _target.get();} | |

33 | ||

34 | bool StackedScaleElement::isIdentity() const { return (_scale.x() == 1 && _scale.y() == 1 && _scale.z() == 1); } | |

35 | ||

36 | osg::Matrix StackedScaleElement::getAsMatrix() const { return osg::Matrix::scale(_scale); } | |

37 | ||

38 | void StackedScaleElement::applyToMatrix(osg::Matrix& matrix) const { matrix.preMultScale(_scale); } | |

39 | ||

40 | StackedScaleElement::StackedScaleElement() | |

41 | { | |

42 | _scale = osg::Vec3(1,1,1); | |

43 | } | |

44 | ||

45 | void StackedScaleElement::update() | |

46 | { | |

47 | if (_target.valid()) | |

48 | _scale = _target->getValue(); | |

49 | } | |

50 | ||

51 | Target* 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.