mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-14 11:49:59 +01:00
Implementation of OSC targets Position, Size, Angle and Seek
Creation of SourceCallback to seek in MediaSource
This commit is contained in:
@@ -619,18 +619,38 @@ bool Control::receiveSourceAttribute(Source *target, const std::string &attribut
|
|||||||
arguments >> x >> osc::EndMessage;
|
arguments >> x >> osc::EndMessage;
|
||||||
target->call( new SetDepth(x), true );
|
target->call( new SetDepth(x), true );
|
||||||
}
|
}
|
||||||
/// e.g. '/vimix/current/translation ff 10.0 2.2'
|
/// e.g. '/vimix/current/grab ff 10.0 2.2'
|
||||||
else if ( attribute.compare(OSC_SOURCE_GRAB) == 0) {
|
else if ( attribute.compare(OSC_SOURCE_GRAB) == 0) {
|
||||||
float x = 0.f, y = 0.f;
|
float x = 0.f, y = 0.f;
|
||||||
arguments >> x >> y >> osc::EndMessage;
|
arguments >> x >> y >> osc::EndMessage;
|
||||||
target->call( new Grab( x, y, 0.f), true );
|
target->call( new Grab( x, y, 0.f), true );
|
||||||
}
|
}
|
||||||
|
/// e.g. '/vimix/current/position ff 10.0 2.2'
|
||||||
|
else if ( attribute.compare(OSC_SOURCE_POSITION) == 0) {
|
||||||
|
float x = 0.f, y = 0.f;
|
||||||
|
arguments >> x >> y >> osc::EndMessage;
|
||||||
|
Group transform;
|
||||||
|
transform.copyTransform(target->group(View::GEOMETRY));
|
||||||
|
transform.translation_.x = x;
|
||||||
|
transform.translation_.y = y;
|
||||||
|
target->call( new SetGeometry( &transform, 0.f), true );
|
||||||
|
}
|
||||||
/// e.g. '/vimix/current/scale ff 10.0 2.2'
|
/// e.g. '/vimix/current/scale ff 10.0 2.2'
|
||||||
else if ( attribute.compare(OSC_SOURCE_RESIZE) == 0) {
|
else if ( attribute.compare(OSC_SOURCE_RESIZE) == 0) {
|
||||||
float x = 0.f, y = 0.f;
|
float x = 0.f, y = 0.f;
|
||||||
arguments >> x >> y >> osc::EndMessage;
|
arguments >> x >> y >> osc::EndMessage;
|
||||||
target->call( new Resize( x, y, 0.f), true );
|
target->call( new Resize( x, y, 0.f), true );
|
||||||
}
|
}
|
||||||
|
/// e.g. '/vimix/current/size ff 1.0 2.2'
|
||||||
|
else if ( attribute.compare(OSC_SOURCE_SIZE) == 0) {
|
||||||
|
float x = 0.f, y = 0.f;
|
||||||
|
arguments >> x >> y >> osc::EndMessage;
|
||||||
|
Group transform;
|
||||||
|
transform.copyTransform(target->group(View::GEOMETRY));
|
||||||
|
transform.scale_.x = x;
|
||||||
|
transform.scale_.y = y;
|
||||||
|
target->call( new SetGeometry( &transform, 0.f), true );
|
||||||
|
}
|
||||||
/// e.g. '/vimix/current/turn f 1.0'
|
/// e.g. '/vimix/current/turn f 1.0'
|
||||||
else if ( attribute.compare(OSC_SOURCE_TURN) == 0) {
|
else if ( attribute.compare(OSC_SOURCE_TURN) == 0) {
|
||||||
float x = 0.f, y = 0.f;
|
float x = 0.f, y = 0.f;
|
||||||
@@ -641,10 +661,25 @@ bool Control::receiveSourceAttribute(Source *target, const std::string &attribut
|
|||||||
arguments >> y >> osc::EndMessage;
|
arguments >> y >> osc::EndMessage;
|
||||||
target->call( new Turn( x, 0.f), true );
|
target->call( new Turn( x, 0.f), true );
|
||||||
}
|
}
|
||||||
|
/// e.g. '/vimix/current/angle f 3.1416'
|
||||||
|
else if ( attribute.compare(OSC_SOURCE_ANGLE) == 0) {
|
||||||
|
float a = 0.f;
|
||||||
|
arguments >> a >> osc::EndMessage;
|
||||||
|
Group transform;
|
||||||
|
transform.copyTransform(target->group(View::GEOMETRY));
|
||||||
|
transform.rotation_.z = a;
|
||||||
|
target->call( new SetGeometry( &transform, 0.f), true );
|
||||||
|
}
|
||||||
/// e.g. '/vimix/current/reset'
|
/// e.g. '/vimix/current/reset'
|
||||||
else if ( attribute.compare(OSC_SOURCE_RESET) == 0) {
|
else if ( attribute.compare(OSC_SOURCE_RESET) == 0) {
|
||||||
target->call( new ResetGeometry(), true );
|
target->call( new ResetGeometry(), true );
|
||||||
}
|
}
|
||||||
|
/// e.g. '/vimix/current/seek f 1.25'
|
||||||
|
else if ( attribute.compare(OSC_SOURCE_SEEK) == 0) {
|
||||||
|
float t = 0.f;
|
||||||
|
arguments >> t >> osc::EndMessage;
|
||||||
|
target->call( new Seek( t ), true );
|
||||||
|
}
|
||||||
#ifdef CONTROL_DEBUG
|
#ifdef CONTROL_DEBUG
|
||||||
else {
|
else {
|
||||||
Log::Info(CONTROL_OSC_MSG "Ignoring attribute '%s' for target %s.", attribute.c_str(), target->name().c_str());
|
Log::Info(CONTROL_OSC_MSG "Ignoring attribute '%s' for target %s.", attribute.c_str(), target->name().c_str());
|
||||||
|
|||||||
@@ -43,6 +43,10 @@
|
|||||||
#define OSC_SOURCE_RESIZE "/resize"
|
#define OSC_SOURCE_RESIZE "/resize"
|
||||||
#define OSC_SOURCE_TURN "/turn"
|
#define OSC_SOURCE_TURN "/turn"
|
||||||
#define OSC_SOURCE_RESET "/reset"
|
#define OSC_SOURCE_RESET "/reset"
|
||||||
|
#define OSC_SOURCE_POSITION "/position"
|
||||||
|
#define OSC_SOURCE_SIZE "/size"
|
||||||
|
#define OSC_SOURCE_ANGLE "/angle"
|
||||||
|
#define OSC_SOURCE_SEEK "/seek"
|
||||||
|
|
||||||
#define OSC_SESSION "/session"
|
#define OSC_SESSION "/session"
|
||||||
#define OSC_SESSION_VERSION "/version"
|
#define OSC_SESSION_VERSION "/version"
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "Source.h"
|
#include "Source.h"
|
||||||
|
#include "MediaSource.h"
|
||||||
|
#include "MediaPlayer.h"
|
||||||
#include "UpdateCallback.h"
|
#include "UpdateCallback.h"
|
||||||
#include "Visitor.h"
|
#include "Visitor.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
@@ -458,6 +460,38 @@ SourceCallback *RePlay::clone() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Seek::Seek(float time) : SourceCallback(), target_time_(time)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Seek::update(Source *s, float dt)
|
||||||
|
{
|
||||||
|
SourceCallback::update(s, dt);
|
||||||
|
|
||||||
|
// perform seek when ready
|
||||||
|
if ( status_ == READY ){
|
||||||
|
|
||||||
|
// access media player if target source is a media source
|
||||||
|
MediaSource *ms = dynamic_cast<MediaSource *>(s);
|
||||||
|
if (ms != nullptr)
|
||||||
|
ms->mediaplayer()->seek( GST_SECOND * target_time_ );
|
||||||
|
|
||||||
|
status_ = FINISHED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SourceCallback *Seek::clone() const
|
||||||
|
{
|
||||||
|
return new Seek(target_time_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Seek::accept(Visitor& v)
|
||||||
|
{
|
||||||
|
SourceCallback::accept(v);
|
||||||
|
v.visit(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SetGeometry::SetGeometry(const Group *g, float ms, bool revert) : SourceCallback(),
|
SetGeometry::SetGeometry(const Group *g, float ms, bool revert) : SourceCallback(),
|
||||||
duration_(ms), bidirectional_(revert)
|
duration_(ms), bidirectional_(revert)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ public:
|
|||||||
CALLBACK_PLAY = 8,
|
CALLBACK_PLAY = 8,
|
||||||
CALLBACK_REPLAY = 9,
|
CALLBACK_REPLAY = 9,
|
||||||
CALLBACK_RESETGEO = 10,
|
CALLBACK_RESETGEO = 10,
|
||||||
CALLBACK_LOCK = 11
|
CALLBACK_LOCK = 11,
|
||||||
|
CALLBACK_SEEK = 12
|
||||||
} CallbackType;
|
} CallbackType;
|
||||||
|
|
||||||
static SourceCallback *create(CallbackType type);
|
static SourceCallback *create(CallbackType type);
|
||||||
@@ -34,7 +35,7 @@ public:
|
|||||||
virtual ~SourceCallback() {}
|
virtual ~SourceCallback() {}
|
||||||
|
|
||||||
virtual void update (Source *, float);
|
virtual void update (Source *, float);
|
||||||
virtual void multiply (float) {};
|
virtual void multiply (float) {}
|
||||||
virtual SourceCallback *clone () const = 0;
|
virtual SourceCallback *clone () const = 0;
|
||||||
virtual SourceCallback *reverse (Source *) const { return nullptr; }
|
virtual SourceCallback *reverse (Source *) const { return nullptr; }
|
||||||
virtual CallbackType type () const { return CALLBACK_GENERIC; }
|
virtual CallbackType type () const { return CALLBACK_GENERIC; }
|
||||||
@@ -177,6 +178,22 @@ public:
|
|||||||
CallbackType type () const override { return CALLBACK_REPLAY; }
|
CallbackType type () const override { return CALLBACK_REPLAY; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Seek : public SourceCallback
|
||||||
|
{
|
||||||
|
float target_time_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Seek (float time = 0.f);
|
||||||
|
|
||||||
|
float value () const { return target_time_;}
|
||||||
|
void setValue (float t) { target_time_ = t; }
|
||||||
|
|
||||||
|
void update (Source *s, float dt) override;
|
||||||
|
SourceCallback *clone() const override;
|
||||||
|
CallbackType type () const override { return CALLBACK_SEEK; }
|
||||||
|
void accept (Visitor& v) override;
|
||||||
|
};
|
||||||
|
|
||||||
class ResetGeometry : public SourceCallback
|
class ResetGeometry : public SourceCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -223,7 +240,7 @@ public:
|
|||||||
glm::vec2 value () const { return speed_; }
|
glm::vec2 value () const { return speed_; }
|
||||||
void setValue (glm::vec2 d) { speed_ = d; }
|
void setValue (glm::vec2 d) { speed_ = d; }
|
||||||
float duration () const { return duration_; }
|
float duration () const { return duration_; }
|
||||||
void setDuration (float ns) { duration_ = ns; }
|
void setDuration (float ms) { duration_ = ms; }
|
||||||
|
|
||||||
void update (Source *s, float) override;
|
void update (Source *s, float) override;
|
||||||
void multiply (float factor) override;
|
void multiply (float factor) override;
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 571 KiB After Width: | Height: | Size: 636 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 788 KiB After Width: | Height: | Size: 943 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 2.2 MiB |
Reference in New Issue
Block a user