Overte C++ Documentation
AnimBlendLinear.h
1 //
2 // AnimBlendLinear.h
3 //
4 // Created by Anthony J. Thibault on 9/2/15.
5 // Copyright (c) 2015 High Fidelity, Inc. All rights reserved.
6 //
7 // Distributed under the Apache License, Version 2.0.
8 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
9 //
10 
11 #ifndef hifi_AnimBlendLinear_h
12 #define hifi_AnimBlendLinear_h
13 
14 #include "AnimNode.h"
15 
16 // Linear blend between two AnimNodes.
17 // the amount of blending is determined by the alpha parameter.
18 // If the number of children is 2, then the alpha parameters should be between
19 // 0 and 1. The first animation will have a (1 - alpha) factor, and the second
20 // will have factor of alpha.
21 // This node supports more then 2 children. In this case the alpha should be
22 // between 0 and n - 1. This alpha can be used to linearly interpolate between
23 // the closest two children poses. This can be used to sweep through a series
24 // of animation poses.
25 
26 class AnimBlendLinear : public AnimNode {
27 public:
28  friend class AnimTests;
29 
30  AnimBlendLinear(const QString& id, float alpha, AnimBlendType blendType);
31  virtual ~AnimBlendLinear() override;
32 
33  virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, AnimVariantMap& triggersOut) override;
34 
35  void setAlphaVar(const QString& alphaVar) { _alphaVar = alphaVar; }
36 
37 protected:
38  // for AnimDebugDraw rendering
39  virtual const AnimPoseVec& getPosesInternal() const override;
40 
41  void evaluateAndBlendChildren(const AnimVariantMap& animVars, const AnimContext& context, AnimVariantMap& triggersOut, float alpha,
42  size_t prevPoseIndex, size_t nextPoseIndex, float dt);
43 
44  AnimPoseVec _poses;
45 
46  float _alpha;
47  AnimBlendType _blendType;
48 
49  QString _alphaVar;
50 
51  // no copies
52  AnimBlendLinear(const AnimBlendLinear&) = delete;
53  AnimBlendLinear& operator=(const AnimBlendLinear&) = delete;
54 };
55 
56 #endif // hifi_AnimBlendLinear_h