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

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