Rumba C++ SDK
AnimCurve.h
Go to the documentation of this file.
1 /*
2 
3  *
4  ***
5  *****
6  ********************* Mercenaries Engineering SARL
7  ***************** Copyright (C) 2018
8  *************
9  ********* http://www.mercenaries-engineering.com
10  ***********
11  **** ****
12  ** **
13 
14 */
15 #pragma once
16 
17 #include "Value.h"
18 #include "Impl.h"
19 
20 namespace maquina
21 {
22  enum class CycleMode
23  {
28  };
29 
32  {
33  public:
35 
36  AnimCurve(const Value &v);
37 
39  AnimCurve create_empty() const;
40 
42  size_t size() const;
43 
45 
46  AnimCurve copy_keys(const gsl::span<const int>& keys) const;
47 
49  std::vector<int> selected_keys() const;
50 
52  int key_index(float t) const;
53 
55  int previous_key(float t) const;
56 
58  int next_key(float t) const;
59 
62  {
63  friend class AnimCurve;
64  public:
66  float time() const;
68  float value() const;
69  private:
70  Key(Impl* curve, size_t index) : _curve(curve), _index(index) {}
71  Impl* _curve;
72  size_t _index;
73  };
74 
77  size_t insert_key(const Key& key, bool before=true);
78 
80  void remove_key(size_t i);
81 
83  const Key operator[](size_t i) const { return {_impl.get(), i}; }
84 
86  float interpolate(float t, CycleMode pre_cycle_mode, CycleMode post_cycle_mode) const;
87 
89  void normalize(bool repeat);
90 
92  AnimCurve(std::shared_ptr<Impl> impl) { _impl=impl; }
93  };
94 
96  {
97  public:
98  enum class CycleMode
99  {
100  constant=0,
101  repeat,
102  repeat_continuous,
103  linear
104  };
105 
107  AnimCurveFloat();
108 
110 
111  AnimCurveFloat(const Value &v);
112 
114  size_t size() const;
115 
117  class Key
118  {
119  public:
120  class Tangent
121  {
122  public:
123  enum class Mode
124  {
125  linear=0,
126  auto_,
127  custom,
128  spline,
129  flat,
130  step,
131  };
132 
134  MAQUINA_EXPORT Tangent(Mode mode=Mode::auto_);
136  MAQUINA_EXPORT Tangent(const Imath::V2f& tangent, Mode mode=Mode::custom);
137 
141  };
142 
144  MAQUINA_EXPORT Key(const Imath::V2f& key);
145 
147 
148  MAQUINA_EXPORT Key(const Imath::V2f& key, const Tangent& right);
149 
151 
152  MAQUINA_EXPORT Key(const Imath::V2f& key, const Tangent& left, const Tangent& right);
153 
156 
159 
162  };
163 
165  const Key operator[](size_t n) const;
166 
168  void set_key(size_t n, const Key& key);
169 
172  size_t insert_key(const Key& key, bool before=true);
173 
175  float interpolate(float t, CycleMode left_mode=CycleMode::constant, CycleMode right_mode=CycleMode::constant) const;
176  };
177 }
Definition: AnimCurve.h:95
const Key operator[](size_t i) const
Get a key.
Definition: AnimCurve.h:83
CycleMode
Definition: AnimCurve.h:22
CycleMode
Definition: AnimCurve.h:98
Quat< T > spline(const Quat< T > &q0, const Quat< T > &q1, const Quat< T > &q2, const Quat< T > &q3, T t)
Definition: ImathQuat.h:544
An anim curve key.
Definition: AnimCurve.h:117
This version of the SDK is unstable, i-e, it may change with no warning.
Definition: AddCurveAction.h:20
An animation curve.
Definition: AnimCurve.h:31
Mode mode
Definition: AnimCurve.h:140
A curve key.
Definition: AnimCurve.h:61
#define MAQUINA_EXPORT
Definition: Export.h:31
Imath::V2f tangent
The key.
Definition: AnimCurve.h:139
Tangent right
The right tangent.
Definition: AnimCurve.h:161
Definition: ImathVec.h:61
MAQUINA_EXPORT Value copy_keys(Node &anim_layer)
Return a copy of the active key selection in a layer.
Imath::V2f key
The key.
Definition: AnimCurve.h:155
Tangent left
The left tangent.
Definition: AnimCurve.h:158
Mode
Definition: AnimCurve.h:123
MAQUINA_EXPORT int insert_key(const Plug &plug, float t, float v)
MAQUINA_EXPORT void remove_key(Plug &plug, const float frame)
Remove the key at frame in the active layer.
Definition: AnimCurve.h:120
Base class of all Rumba values.
Definition: Value.h:34