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

Revision 13041, 2.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/StatsVisitor>
16#include <osgAnimation/Timeline>
17#include <osgAnimation/ActionBlendIn>
18#include <osgAnimation/ActionBlendOut>
19#include <osgAnimation/ActionStripAnimation>
20#include <osgAnimation/ActionAnimation>
21
22using namespace osgAnimation;
23
24StatsActionVisitor::StatsActionVisitor() {}
25void StatsActionVisitor::reset() { _channels.clear(); }
26
27StatsActionVisitor::StatsActionVisitor(osg::Stats* stats,unsigned int frame)
28{
29    _frame = frame;
30    _stats = stats;
31}
32
33void StatsActionVisitor::apply(Timeline& tm)
34{
35    _stats->setAttribute(_frame,"Timeline", tm.getCurrentTime());
36    tm.traverse(*this);
37}
38
39void StatsActionVisitor::apply(Action& action)
40{
41    if (isActive(action))
42    {
43        _channels.push_back(action.getName());
44        _stats->setAttribute(_frame,action.getName(),1);
45    }
46}
47
48void StatsActionVisitor::apply(ActionBlendIn& action)
49{
50    if (isActive(action))
51    {
52        _channels.push_back(action.getName());
53        _stats->setAttribute(_frame,action.getName(), action.getWeight());
54    }
55}
56
57void StatsActionVisitor::apply(ActionBlendOut& action)
58{
59    if (isActive(action))
60    {
61        _channels.push_back(action.getName());
62        _stats->setAttribute(_frame,action.getName(), action.getWeight());
63    }
64}
65
66void StatsActionVisitor::apply(ActionAnimation& action)
67{
68    if (isActive(action))
69    {
70        _channels.push_back(action.getName());
71        _stats->setAttribute(_frame,action.getName(), action.getAnimation()->getWeight());
72    }
73}
74
75void StatsActionVisitor::apply(ActionStripAnimation& action)
76{
77    if (isActive(action))
78    {
79        _channels.push_back(action.getName());
80        double value;
81        std::string name = action.getName();
82        if (_stats->getAttribute(_frame, name, value))
83            name += "+";
84        _stats->setAttribute(_frame, action.getName(), action.getAnimation()->getAnimation()->getWeight());
85    }
86}
Note: See TracBrowser for help on using the browser.