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

Revision 13041, 1.4 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/ActionBlendOut>
16
17using namespace osgAnimation;
18
19ActionBlendOut::ActionBlendOut() : _weight(0) {}
20ActionBlendOut::ActionBlendOut(const ActionBlendOut& a, const osg::CopyOp& c) : Action(a,c)
21{
22    _weight = a._weight;
23    _animation = a._animation;
24}
25
26ActionBlendOut::ActionBlendOut(Animation* animation, double duration)
27{
28    _animation = animation;
29    float d = duration * _fps;
30    setNumFrames(static_cast<unsigned int>(floor(d) + 1));
31    _weight = 1.0;
32    setName("BlendOut");
33}
34
35void ActionBlendOut::computeWeight(unsigned int frame)
36{
37    double ratio = ( (frame+1) * 1.0 / (getNumFrames()) );
38    double w = _weight * (1.0-ratio);
39    OSG_DEBUG << getName() << " BlendOut frame " << frame  << " weight " << w << std::endl;
40    _animation->setWeight(w);
41}
Note: See TracBrowser for help on using the browser.