mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 02:40:00 +01:00
Created new Object MixingGoup
This commit is contained in:
@@ -275,6 +275,7 @@ set(VMIX_SRCS
|
|||||||
RenderView.cpp
|
RenderView.cpp
|
||||||
GeometryView.cpp
|
GeometryView.cpp
|
||||||
MixingView.cpp
|
MixingView.cpp
|
||||||
|
MixingGroup.cpp
|
||||||
LayerView.cpp
|
LayerView.cpp
|
||||||
TextureView.cpp
|
TextureView.cpp
|
||||||
TransitionView.cpp
|
TransitionView.cpp
|
||||||
|
|||||||
@@ -683,6 +683,7 @@ void Mixer::groupSelection()
|
|||||||
// avoid name duplicates
|
// avoid name duplicates
|
||||||
renameSource(group, "group");
|
renameSource(group, "group");
|
||||||
|
|
||||||
|
Mixer::manager().setCurrentSource(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mixer::renameSource(Source *s, const std::string &newname)
|
void Mixer::renameSource(Source *s, const std::string &newname)
|
||||||
|
|||||||
115
MixingGroup.cpp
Normal file
115
MixingGroup.cpp
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <glm/gtx/vector_angle.hpp>
|
||||||
|
|
||||||
|
#include "Source.h"
|
||||||
|
#include "Decorations.h"
|
||||||
|
#include "Log.h"
|
||||||
|
|
||||||
|
#include "MixingGroup.h"
|
||||||
|
|
||||||
|
// utility to sort Sources in MixingView in a clockwise order
|
||||||
|
// in reference to a center point
|
||||||
|
struct clockwise_centered {
|
||||||
|
clockwise_centered(glm::vec2 c) : center(c) { }
|
||||||
|
bool operator() (Source * first, Source * second) {
|
||||||
|
glm::vec2 pos_first = glm::vec2(first->group(View::MIXING)->translation_)-center;
|
||||||
|
float angle_first = glm::orientedAngle( glm::normalize(pos_first), glm::vec2(1.f, 0.f) );
|
||||||
|
glm::vec2 pos_second = glm::vec2(second->group(View::MIXING)->translation_)-center;
|
||||||
|
float angle_second = glm::orientedAngle( glm::normalize(pos_second), glm::vec2(1.f, 0.f) );
|
||||||
|
return (angle_first < angle_second);
|
||||||
|
}
|
||||||
|
glm::vec2 center;
|
||||||
|
};
|
||||||
|
|
||||||
|
MixingGroup::MixingGroup (SourceList sources) : root_(nullptr), lines_(nullptr), center_(nullptr), pos_(glm::vec2(0.f, 0.f))
|
||||||
|
{
|
||||||
|
// fill the vector of sources with the given list
|
||||||
|
for (auto it = sources.begin(); it != sources.end(); it++){
|
||||||
|
(*it)->mixinggroup_ = this;
|
||||||
|
sources_.push_back(*it);
|
||||||
|
// compute barycenter (1)
|
||||||
|
pos_ += glm::vec2((*it)->group(View::MIXING)->translation_);
|
||||||
|
}
|
||||||
|
// compute barycenter (2)
|
||||||
|
pos_ /= sources_.size();
|
||||||
|
|
||||||
|
// sort the vector of sources in clockwise order around the center pos_
|
||||||
|
std::sort(sources_.begin(), sources_.end(), clockwise_centered(pos_));
|
||||||
|
|
||||||
|
root_ = new Group;
|
||||||
|
center_ = new Symbol(Symbol::CIRCLE_POINT);
|
||||||
|
center_->color = glm::vec4(0.f, 1.f, 0.f, 0.8f);
|
||||||
|
center_->translation_ = glm::vec3(pos_, 0.f);
|
||||||
|
root_->attach(center_);
|
||||||
|
createLineStrip();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MixingGroup::detach (Source *s)
|
||||||
|
{
|
||||||
|
// find the source
|
||||||
|
std::vector<Source *>::iterator its = std::find(sources_.begin(), sources_.end(), s);
|
||||||
|
// ok, its in the list !
|
||||||
|
if (its != sources_.end()) {
|
||||||
|
// erase the source from the list
|
||||||
|
sources_.erase(its);
|
||||||
|
|
||||||
|
// clear index, delete lines_, and recreate path and index with remaining sources
|
||||||
|
createLineStrip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MixingGroup::update (Source *s)
|
||||||
|
{
|
||||||
|
// find the source
|
||||||
|
std::vector<Source *>::iterator its = std::find(sources_.begin(), sources_.end(), s);
|
||||||
|
|
||||||
|
if (its != sources_.end() && lines_) {
|
||||||
|
|
||||||
|
lines_->editPath(index_points_[s], glm::vec2(s->group(View::MIXING)->translation_));//
|
||||||
|
// lines_->editPath(0, glm::vec2(s->group(View::MIXING)->translation_));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MixingGroup::draw ()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//void MixingGroup::grab (glm::vec2 from, glm::vec2 to, std::pair<Node *, glm::vec2>)
|
||||||
|
//{
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
void MixingGroup::createLineStrip()
|
||||||
|
{
|
||||||
|
if (lines_) {
|
||||||
|
root_->detach(lines_);
|
||||||
|
delete lines_;
|
||||||
|
}
|
||||||
|
|
||||||
|
index_points_.clear();
|
||||||
|
|
||||||
|
if (sources_.size() > 1) {
|
||||||
|
std::vector<glm::vec2> path;
|
||||||
|
auto it = sources_.begin();
|
||||||
|
// link sources
|
||||||
|
for (; it != sources_.end(); it++){
|
||||||
|
index_points_[*it] = path.size();
|
||||||
|
path.push_back(glm::vec2((*it)->group(View::MIXING)->translation_));
|
||||||
|
}
|
||||||
|
// // loop
|
||||||
|
// it = sources_.begin();
|
||||||
|
// index_points_[*it] = path.size();
|
||||||
|
// path.push_back(glm::vec2((*it)->group(View::MIXING)->translation_));
|
||||||
|
// create
|
||||||
|
lines_ = new LineLoop(path, 2.f);
|
||||||
|
lines_->shader()->color = glm::vec4(0.f, 1.f, 0.f, 0.8f);
|
||||||
|
|
||||||
|
root_->attach(lines_);
|
||||||
|
}
|
||||||
|
}
|
||||||
33
MixingGroup.h
Normal file
33
MixingGroup.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef MIXINGGROUP_H
|
||||||
|
#define MIXINGGROUP_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include "View.h"
|
||||||
|
|
||||||
|
class LineLoop;
|
||||||
|
class Symbol;
|
||||||
|
|
||||||
|
class MixingGroup
|
||||||
|
{
|
||||||
|
Group *root_;
|
||||||
|
LineLoop *lines_;
|
||||||
|
Symbol *center_;
|
||||||
|
glm::vec2 pos_;
|
||||||
|
std::vector<Source *> sources_;
|
||||||
|
std::map< Source *, uint> index_points_;
|
||||||
|
|
||||||
|
void createLineStrip();
|
||||||
|
|
||||||
|
public:
|
||||||
|
MixingGroup (SourceList sources);
|
||||||
|
|
||||||
|
inline Node *node () { return root_; }
|
||||||
|
|
||||||
|
void detach (Source *s);
|
||||||
|
void update (Source *s);
|
||||||
|
|
||||||
|
void draw ();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MIXINGGROUP_H
|
||||||
@@ -18,9 +18,15 @@
|
|||||||
#include "Decorations.h"
|
#include "Decorations.h"
|
||||||
#include "UserInterfaceManager.h"
|
#include "UserInterfaceManager.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
#include "MixingGroup.h"
|
||||||
|
|
||||||
#include "MixingView.h"
|
#include "MixingView.h"
|
||||||
|
|
||||||
|
// internal utility
|
||||||
|
float sin_quad_texture(float x, float y);
|
||||||
|
uint textureMixingQuadratic();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MixingView::MixingView() : View(MIXING), limbo_scale_(MIXING_LIMBO_SCALE)
|
MixingView::MixingView() : View(MIXING), limbo_scale_(MIXING_LIMBO_SCALE)
|
||||||
{
|
{
|
||||||
@@ -96,14 +102,7 @@ MixingView::MixingView() : View(MIXING), limbo_scale_(MIXING_LIMBO_SCALE)
|
|||||||
stashCircle_->color = glm::vec4( COLOR_STASH_CIRCLE, 0.6f );
|
stashCircle_->color = glm::vec4( COLOR_STASH_CIRCLE, 0.6f );
|
||||||
// scene.bg()->attach(stashCircle_);
|
// scene.bg()->attach(stashCircle_);
|
||||||
|
|
||||||
// points_.push_back(glm::vec2(0.f, 0.f));
|
|
||||||
// points_.push_back(glm::vec2(0.f, 1.f));
|
|
||||||
// points_.push_back(glm::vec2(1.f, 1.f));
|
|
||||||
// points_.push_back(glm::vec2(1.f, 0.f));
|
|
||||||
// lines_ = new LineStrip(points_, 1.f);
|
|
||||||
// scene.fg()->attach(lines_);
|
|
||||||
|
|
||||||
lines_ = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -129,6 +128,11 @@ void MixingView::draw()
|
|||||||
|
|
||||||
// special action of Mixing view
|
// special action of Mixing view
|
||||||
if (ImGui::Selectable( ICON_FA_DRAW_POLYGON " Link" )){
|
if (ImGui::Selectable( ICON_FA_DRAW_POLYGON " Link" )){
|
||||||
|
// TODO create MixingGroup
|
||||||
|
MixingGroup *mg = new MixingGroup(Mixer::selection().getCopy());
|
||||||
|
groups_.push_back(mg);
|
||||||
|
scene.fg()->attach(mg->node());
|
||||||
|
Mixer::selection().clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
@@ -141,7 +145,7 @@ void MixingView::draw()
|
|||||||
(*it)->touch();
|
(*it)->touch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ImGui::Selectable( ICON_FA_EXPAND_ARROWS_ALT " Expand to hide" )){
|
if (ImGui::Selectable( ICON_FA_EXPAND_ARROWS_ALT " Expand & Hide" )){
|
||||||
SourceList::iterator it = Mixer::selection().begin();
|
SourceList::iterator it = Mixer::selection().begin();
|
||||||
for (; it != Mixer::selection().end(); it++) {
|
for (; it != Mixer::selection().end(); it++) {
|
||||||
(*it)->setAlpha(0.f);
|
(*it)->setAlpha(0.f);
|
||||||
@@ -326,6 +330,12 @@ View::Cursor MixingView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pai
|
|||||||
// compute delta translation
|
// compute delta translation
|
||||||
s->group(mode_)->translation_ = s->stored_status_->translation_ + gl_Position_to - gl_Position_from;
|
s->group(mode_)->translation_ = s->stored_status_->translation_ + gl_Position_to - gl_Position_from;
|
||||||
|
|
||||||
|
// manage mixing groups
|
||||||
|
if (s->mixinggroup_ != nullptr) {
|
||||||
|
s->mixinggroup_->update(s);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// // diagonal translation with SHIFT
|
// // diagonal translation with SHIFT
|
||||||
// if (UserInterface::manager().shiftModifier()) {
|
// if (UserInterface::manager().shiftModifier()) {
|
||||||
// s->group(mode_)->translation_.y = s->group(mode_)->translation_.x * s->stored_status_->translation_.y / s->stored_status_->translation_.x;
|
// s->group(mode_)->translation_.y = s->group(mode_)->translation_.x * s->stored_status_->translation_.y / s->stored_status_->translation_.x;
|
||||||
@@ -421,17 +431,6 @@ void MixingView::updateSelectionOverlay()
|
|||||||
// slightly extend the boundary of the selection
|
// slightly extend the boundary of the selection
|
||||||
overlay_selection_frame_->scale_ = glm::vec3(1.f) + glm::vec3(0.01f, 0.01f, 1.f) / overlay_selection_->scale_;
|
overlay_selection_frame_->scale_ = glm::vec3(1.f) + glm::vec3(0.01f, 0.01f, 1.f) / overlay_selection_->scale_;
|
||||||
|
|
||||||
// if (lines_) {
|
|
||||||
// scene.fg()->detach(lines_);
|
|
||||||
// delete lines_;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// points_.push_back(glm::vec2(0.f, 0.f));
|
|
||||||
// points_.push_back(glm::vec2(0.f, 1.f));
|
|
||||||
// points_.push_back(glm::vec2(1.f, 1.f));
|
|
||||||
// points_.push_back(glm::vec2(1.f, 0.f));
|
|
||||||
// lines_ = new LineStrip(points_, 1.f);
|
|
||||||
// scene.fg()->attach(lines_);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,7 +447,7 @@ float sin_quad_texture(float x, float y) {
|
|||||||
return 0.5f + 0.5f * cos( M_PI * CLAMP( D * sqrt(D), 0.f, 1.f ) );
|
return 0.5f + 0.5f * cos( M_PI * CLAMP( D * sqrt(D), 0.f, 1.f ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
uint MixingView::textureMixingQuadratic()
|
uint textureMixingQuadratic()
|
||||||
{
|
{
|
||||||
static GLuint texid = 0;
|
static GLuint texid = 0;
|
||||||
if (texid == 0) {
|
if (texid == 0) {
|
||||||
|
|||||||
11
MixingView.h
11
MixingView.h
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include "View.h"
|
#include "View.h"
|
||||||
|
|
||||||
|
class MixingGroup;
|
||||||
|
|
||||||
class MixingView : public View
|
class MixingView : public View
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -22,7 +24,8 @@ public:
|
|||||||
inline float limboScale() { return limbo_scale_; }
|
inline float limboScale() { return limbo_scale_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint textureMixingQuadratic();
|
void updateSelectionOverlay() override;
|
||||||
|
|
||||||
float limbo_scale_;
|
float limbo_scale_;
|
||||||
|
|
||||||
Group *slider_root_;
|
Group *slider_root_;
|
||||||
@@ -33,10 +36,8 @@ private:
|
|||||||
Mesh *mixingCircle_;
|
Mesh *mixingCircle_;
|
||||||
Mesh *circle_;
|
Mesh *circle_;
|
||||||
|
|
||||||
// TEST
|
// linked sources
|
||||||
std::vector<glm::vec2> points_;
|
std::list< MixingGroup *> groups_;
|
||||||
class LineStrip *lines_;
|
|
||||||
void updateSelectionOverlay() override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
19
Scene.cpp
19
Scene.cpp
@@ -1,5 +1,13 @@
|
|||||||
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
#include <glm/gtc/matrix_access.hpp>
|
||||||
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
|
#include <glm/gtc/random.hpp>
|
||||||
|
|
||||||
|
#include <glad/glad.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "Scene.h"
|
|
||||||
#include "Shader.h"
|
#include "Shader.h"
|
||||||
#include "Primitives.h"
|
#include "Primitives.h"
|
||||||
#include "Visitor.h"
|
#include "Visitor.h"
|
||||||
@@ -8,14 +16,7 @@
|
|||||||
#include "GlmToolkit.h"
|
#include "GlmToolkit.h"
|
||||||
#include "SessionVisitor.h"
|
#include "SessionVisitor.h"
|
||||||
|
|
||||||
#include <glad/glad.h>
|
#include "Scene.h"
|
||||||
|
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
|
||||||
#include <glm/gtc/matrix_access.hpp>
|
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
|
||||||
#include <glm/gtc/random.hpp>
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
// Node
|
// Node
|
||||||
Node::Node() : initialized_(false), visible_(true), refcount_(0)
|
Node::Node() : initialized_(false), visible_(true), refcount_(0)
|
||||||
|
|||||||
13
Source.cpp
13
Source.cpp
@@ -4,20 +4,19 @@
|
|||||||
#include <glm/gtc/matrix_access.hpp>
|
#include <glm/gtc/matrix_access.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
|
|
||||||
#include "Source.h"
|
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "FrameBuffer.h"
|
#include "FrameBuffer.h"
|
||||||
#include "Decorations.h"
|
#include "Decorations.h"
|
||||||
#include "Resource.h"
|
#include "Resource.h"
|
||||||
#include "Session.h"
|
|
||||||
#include "SearchVisitor.h"
|
#include "SearchVisitor.h"
|
||||||
#include "ImageShader.h"
|
#include "ImageShader.h"
|
||||||
#include "ImageProcessingShader.h"
|
#include "ImageProcessingShader.h"
|
||||||
#include "SystemToolkit.h"
|
#include "SystemToolkit.h"
|
||||||
#include "SessionVisitor.h"
|
#include "SessionVisitor.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Mixer.h"
|
#include "MixingGroup.h"
|
||||||
|
|
||||||
|
#include "Source.h"
|
||||||
|
|
||||||
Source::Source() : initialized_(false), symbol_(nullptr), active_(true), locked_(false), need_update_(true), workspace_(STAGE)
|
Source::Source() : initialized_(false), symbol_(nullptr), active_(true), locked_(false), need_update_(true), workspace_(STAGE)
|
||||||
{
|
{
|
||||||
@@ -179,7 +178,6 @@ Source::Source() : initialized_(false), symbol_(nullptr), active_(true), locked_
|
|||||||
// empty transition node
|
// empty transition node
|
||||||
groups_[View::TRANSITION] = new Group;
|
groups_[View::TRANSITION] = new Group;
|
||||||
|
|
||||||
//
|
|
||||||
// locker switch button : locked / unlocked icons
|
// locker switch button : locked / unlocked icons
|
||||||
locker_ = new Switch;
|
locker_ = new Switch;
|
||||||
lock_ = new Handles(Handles::LOCKED);
|
lock_ = new Handles(Handles::LOCKED);
|
||||||
@@ -204,6 +202,7 @@ Source::Source() : initialized_(false), symbol_(nullptr), active_(true), locked_
|
|||||||
// for drawing in mixing view
|
// for drawing in mixing view
|
||||||
mixingshader_ = new ImageShader;
|
mixingshader_ = new ImageShader;
|
||||||
mixingshader_->stipple = 1.0;
|
mixingshader_->stipple = 1.0;
|
||||||
|
mixinggroup_ = nullptr;
|
||||||
|
|
||||||
// create media surface:
|
// create media surface:
|
||||||
// - textured with original texture from media player
|
// - textured with original texture from media player
|
||||||
@@ -228,6 +227,10 @@ Source::~Source()
|
|||||||
(*it)->detach();
|
(*it)->detach();
|
||||||
clones_.clear();
|
clones_.clear();
|
||||||
|
|
||||||
|
// inform group
|
||||||
|
if (mixinggroup_)
|
||||||
|
mixinggroup_->detach(this);
|
||||||
|
|
||||||
// delete objects
|
// delete objects
|
||||||
delete stored_status_;
|
delete stored_status_;
|
||||||
if (renderbuffer_)
|
if (renderbuffer_)
|
||||||
|
|||||||
6
Source.h
6
Source.h
@@ -20,6 +20,7 @@ class Frame;
|
|||||||
class Handles;
|
class Handles;
|
||||||
class Symbol;
|
class Symbol;
|
||||||
class CloneSource;
|
class CloneSource;
|
||||||
|
class MixingGroup;
|
||||||
|
|
||||||
typedef std::list<CloneSource *> CloneList;
|
typedef std::list<CloneSource *> CloneList;
|
||||||
|
|
||||||
@@ -28,6 +29,7 @@ class Source
|
|||||||
friend class CloneSource;
|
friend class CloneSource;
|
||||||
friend class View;
|
friend class View;
|
||||||
friend class MixingView;
|
friend class MixingView;
|
||||||
|
friend class MixingGroup;
|
||||||
friend class GeometryView;
|
friend class GeometryView;
|
||||||
friend class LayerView;
|
friend class LayerView;
|
||||||
friend class TextureView;
|
friend class TextureView;
|
||||||
@@ -135,7 +137,6 @@ public:
|
|||||||
float alpha () const;
|
float alpha () const;
|
||||||
void setAlpha (float a);
|
void setAlpha (float a);
|
||||||
|
|
||||||
|
|
||||||
struct hasNode: public std::unary_function<Source*, bool>
|
struct hasNode: public std::unary_function<Source*, bool>
|
||||||
{
|
{
|
||||||
bool operator()(const Source* elem) const;
|
bool operator()(const Source* elem) const;
|
||||||
@@ -247,6 +248,9 @@ protected:
|
|||||||
|
|
||||||
// clones
|
// clones
|
||||||
CloneList clones_;
|
CloneList clones_;
|
||||||
|
|
||||||
|
// Mixing
|
||||||
|
MixingGroup *mixinggroup_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user