| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 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 | |
|---|
| 22 | using namespace osgAnimation; |
|---|
| 23 | |
|---|
| 24 | StatsActionVisitor::StatsActionVisitor() {} |
|---|
| 25 | void StatsActionVisitor::reset() { _channels.clear(); } |
|---|
| 26 | |
|---|
| 27 | StatsActionVisitor::StatsActionVisitor(osg::Stats* stats,unsigned int frame) |
|---|
| 28 | { |
|---|
| 29 | _frame = frame; |
|---|
| 30 | _stats = stats; |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | void StatsActionVisitor::apply(Timeline& tm) |
|---|
| 34 | { |
|---|
| 35 | _stats->setAttribute(_frame,"Timeline", tm.getCurrentTime()); |
|---|
| 36 | tm.traverse(*this); |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | void 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 | |
|---|
| 48 | void 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 | |
|---|
| 57 | void 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 | |
|---|
| 66 | void 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 | |
|---|
| 75 | void 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 | } |
|---|