Control manager and TouchOSC sync

This commit is contained in:
Bruno Herbelin
2021-12-23 22:17:05 +01:00
parent eb8e33e311
commit 0a27c14041
8 changed files with 234 additions and 88 deletions

View File

@@ -27,6 +27,16 @@ SourceCallback::SourceCallback(): active_(true), finished_(false), initialized_(
{
}
void ResetGeometry::update(Source *s, float)
{
s->group(View::GEOMETRY)->scale_ = glm::vec3(1.f);
s->group(View::GEOMETRY)->rotation_.z = 0;
s->group(View::GEOMETRY)->crop_ = glm::vec3(1.f);
s->group(View::GEOMETRY)->translation_ = glm::vec3(0.f);
s->touch();
finished_ = true;
}
SetAlpha::SetAlpha(float alpha) : SourceCallback(), alpha_(CLAMP(alpha, 0.f, 1.f))
{
step_ = glm::normalize(glm::vec2(1.f, 1.f)); // step in diagonal by default
@@ -196,3 +206,36 @@ void Resize::update(Source *s, float dt)
else
finished_ = true;
}
Turn::Turn(float da, float duration) : SourceCallback(), speed_(da),
duration_(duration), progress_(0.f)
{
}
void Turn::update(Source *s, float dt)
{
if (s && !s->locked()) {
// reset on first run or upon call of reset()
if (!initialized_){
// start animation
progress_ = 0.f;
// initial position
start_ = s->group(View::GEOMETRY)->rotation_.z;
initialized_ = true;
}
// calculate amplitude of movement
progress_ += dt;
// perform movement
s->group(View::GEOMETRY)->rotation_.z = start_ + speed_ * ( dt * -0.001f / M_PI);
// timeout
if ( progress_ > duration_ ) {
// done
finished_ = true;
}
}
else
finished_ = true;
}