mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-13 11:19:58 +01:00
Working on multiple sources selection: created bounding box decoration,
fixed Switch node in Scene, removed Animation node from scene, created display mode for Source.
This commit is contained in:
65
BoundingBoxVisitor.cpp
Normal file
65
BoundingBoxVisitor.cpp
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
|
|
||||||
|
#include "BoundingBoxVisitor.h"
|
||||||
|
|
||||||
|
#include "Log.h"
|
||||||
|
#include "Primitives.h"
|
||||||
|
#include "Decorations.h"
|
||||||
|
|
||||||
|
BoundingBoxVisitor::BoundingBoxVisitor(): Visitor()
|
||||||
|
{
|
||||||
|
modelview_ = glm::identity<glm::mat4>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BoundingBoxVisitor::setModelview(glm::mat4 modelview)
|
||||||
|
{
|
||||||
|
modelview_ = modelview;
|
||||||
|
}
|
||||||
|
|
||||||
|
GlmToolkit::AxisAlignedBoundingBox BoundingBoxVisitor::bbox()
|
||||||
|
{
|
||||||
|
return bbox_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BoundingBoxVisitor::visit(Node &n)
|
||||||
|
{
|
||||||
|
// use the transform modified during update
|
||||||
|
modelview_ *= n.transform_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BoundingBoxVisitor::visit(Group &n)
|
||||||
|
{
|
||||||
|
if (!n.visible_)
|
||||||
|
return;
|
||||||
|
glm::mat4 mv = modelview_;
|
||||||
|
for (NodeSet::iterator node = n.begin(); node != n.end(); node++) {
|
||||||
|
if ( (*node)->visible_ )
|
||||||
|
(*node)->accept(*this);
|
||||||
|
modelview_ = mv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BoundingBoxVisitor::visit(Switch &n)
|
||||||
|
{
|
||||||
|
if (!n.visible_ || n.numChildren() < 1)
|
||||||
|
return;
|
||||||
|
glm::mat4 mv = modelview_;
|
||||||
|
n.activeChild()->accept(*this);
|
||||||
|
modelview_ = mv;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BoundingBoxVisitor::visit(Primitive &n)
|
||||||
|
{
|
||||||
|
if (!n.visible_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
bbox_.extend(n.bbox().transformed(modelview_));
|
||||||
|
|
||||||
|
// Log::Info("visitor box (%f, %f)-(%f, %f)", bbox_.min().x, bbox_.min().y, bbox_.max().x, bbox_.max().y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BoundingBoxVisitor::visit(Scene &n)
|
||||||
|
{
|
||||||
|
n.ws()->accept(*this);
|
||||||
|
}
|
||||||
28
BoundingBoxVisitor.h
Normal file
28
BoundingBoxVisitor.h
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#ifndef BOUNDINGBOXVISITOR_H
|
||||||
|
#define BOUNDINGBOXVISITOR_H
|
||||||
|
|
||||||
|
#include "GlmToolkit.h"
|
||||||
|
#include "Visitor.h"
|
||||||
|
|
||||||
|
|
||||||
|
class BoundingBoxVisitor: public Visitor
|
||||||
|
{
|
||||||
|
glm::mat4 modelview_;
|
||||||
|
GlmToolkit::AxisAlignedBoundingBox bbox_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
BoundingBoxVisitor();
|
||||||
|
|
||||||
|
void setModelview(glm::mat4 modelview);
|
||||||
|
GlmToolkit::AxisAlignedBoundingBox bbox();
|
||||||
|
|
||||||
|
// Elements of Scene
|
||||||
|
void visit(Scene& n) override;
|
||||||
|
void visit(Node& n) override;
|
||||||
|
void visit(Group& n) override;
|
||||||
|
void visit(Switch& n) override;
|
||||||
|
void visit(Primitive& n) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BOUNDINGBOXVISITOR_H
|
||||||
@@ -225,6 +225,7 @@ set(VMIX_SRCS
|
|||||||
RenderingManager.cpp
|
RenderingManager.cpp
|
||||||
UserInterfaceManager.cpp
|
UserInterfaceManager.cpp
|
||||||
PickingVisitor.cpp
|
PickingVisitor.cpp
|
||||||
|
BoundingBoxVisitor.cpp
|
||||||
DrawVisitor.cpp
|
DrawVisitor.cpp
|
||||||
SearchVisitor.cpp
|
SearchVisitor.cpp
|
||||||
ImGuiToolkit.cpp
|
ImGuiToolkit.cpp
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "Decorations.h"
|
#include "Decorations.h"
|
||||||
|
|
||||||
#include "Visitor.h"
|
#include "Visitor.h"
|
||||||
|
#include "BoundingBoxVisitor.h"
|
||||||
#include "ImageShader.h"
|
#include "ImageShader.h"
|
||||||
#include "GlmToolkit.h"
|
#include "GlmToolkit.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
@@ -15,11 +16,11 @@ Frame::Frame(Type type) : Node(), type_(type), side_(nullptr), top_(nullptr), sh
|
|||||||
color = glm::vec4( 1.f, 1.f, 1.f, 1.f);
|
color = glm::vec4( 1.f, 1.f, 1.f, 1.f);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SHARP_LARGE:
|
case SHARP_LARGE:
|
||||||
square_ = new LineSquare(color, 3 );
|
square_ = new LineSquare( 3 );
|
||||||
shadow_ = new Mesh("mesh/glow.ply", "images/glow.dds");
|
shadow_ = new Mesh("mesh/glow.ply", "images/glow.dds");
|
||||||
break;
|
break;
|
||||||
case SHARP_THIN:
|
case SHARP_THIN:
|
||||||
square_ = new LineSquare(color, 3 );
|
square_ = new LineSquare( 3 );
|
||||||
break;
|
break;
|
||||||
case ROUND_LARGE:
|
case ROUND_LARGE:
|
||||||
side_ = new Mesh("mesh/border_large_round.ply");
|
side_ = new Mesh("mesh/border_large_round.ply");
|
||||||
@@ -245,10 +246,10 @@ void Handles::accept(Visitor& v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Icon::Icon(Type style) : Node()
|
Icon::Icon(Type style, glm::vec3 pos) : Node()
|
||||||
{
|
{
|
||||||
color = glm::vec4( 1.f, 1.f, 1.f, 1.f);
|
color = glm::vec4( 1.f, 1.f, 1.f, 1.f);
|
||||||
translation_ = glm::vec3(0.8f, 0.8f, 0.f);
|
translation_ = pos;
|
||||||
|
|
||||||
switch (style) {
|
switch (style) {
|
||||||
case IMAGE:
|
case IMAGE:
|
||||||
@@ -272,7 +273,6 @@ Icon::Icon(Type style) : Node()
|
|||||||
default:
|
default:
|
||||||
case GENERIC:
|
case GENERIC:
|
||||||
icon_ = new Mesh("mesh/point.ply");
|
icon_ = new Mesh("mesh/point.ply");
|
||||||
translation_ = glm::vec3(0.f, 0.f, 0.f);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,3 +312,56 @@ void Icon::accept(Visitor& v)
|
|||||||
Node::accept(v);
|
Node::accept(v);
|
||||||
v.visit(*this);
|
v.visit(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Selection::Selection()
|
||||||
|
{
|
||||||
|
// color = glm::vec4( 1.f, 1.f, 1.f, 1.f);
|
||||||
|
color = glm::vec4( 1.f, 0.f, 0.f, 1.f);
|
||||||
|
square_ = new LineSquare( 3 );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Selection::draw (glm::mat4 modelview, glm::mat4 projection)
|
||||||
|
{
|
||||||
|
if ( !initialized() ) {
|
||||||
|
square_->init();
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (visible_) {
|
||||||
|
|
||||||
|
// use a visitor bounding box to calculate extend of all selected nodes
|
||||||
|
BoundingBoxVisitor vbox;
|
||||||
|
|
||||||
|
// visit every child of the selection
|
||||||
|
for (NodeSet::iterator node = children_.begin();
|
||||||
|
node != children_.end(); node++) {
|
||||||
|
// reset the transform before
|
||||||
|
vbox.setModelview(glm::identity<glm::mat4>());
|
||||||
|
(*node)->accept(vbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the bounding box
|
||||||
|
bbox_ = vbox.bbox();
|
||||||
|
|
||||||
|
// Log::Info(" -------- visitor box (%f, %f)-(%f, %f)", bbox_.min().x, bbox_.min().y, bbox_.max().x, bbox_.max().y);
|
||||||
|
|
||||||
|
// set color
|
||||||
|
square_->shader()->color = color;
|
||||||
|
|
||||||
|
// compute transformation from bounding box
|
||||||
|
// glm::mat4 ctm = modelview * GlmToolkit::transform(glm::vec3(0.f), glm::vec3(0.f), glm::vec3(1.f));
|
||||||
|
glm::mat4 ctm = modelview * GlmToolkit::transform(bbox_.center(), glm::vec3(0.f), bbox_.scale());
|
||||||
|
|
||||||
|
// draw bbox
|
||||||
|
// square_->draw( modelview, projection);
|
||||||
|
square_->draw( ctm, projection);
|
||||||
|
|
||||||
|
// DEBUG
|
||||||
|
// visible_=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class Icon : public Node
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef enum { GENERIC = 0, IMAGE, VIDEO, SESSION, CLONE, RENDER, EMPTY } Type;
|
typedef enum { GENERIC = 0, IMAGE, VIDEO, SESSION, CLONE, RENDER, EMPTY } Type;
|
||||||
Icon(Type type);
|
Icon(Type type = GENERIC, glm::vec3 pos = glm::vec3(0.f));
|
||||||
~Icon();
|
~Icon();
|
||||||
|
|
||||||
void draw (glm::mat4 modelview, glm::mat4 projection) override;
|
void draw (glm::mat4 modelview, glm::mat4 projection) override;
|
||||||
@@ -71,6 +71,22 @@ protected:
|
|||||||
Type type_;
|
Type type_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Selection : public Group
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Selection();
|
||||||
|
|
||||||
|
void draw (glm::mat4 modelview, glm::mat4 projection) override;
|
||||||
|
|
||||||
|
glm::vec4 color;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
LineSquare *square_;
|
||||||
|
GlmToolkit::AxisAlignedBoundingBox bbox_;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// TODO Shadow mesh with unique vao
|
// TODO Shadow mesh with unique vao
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,15 +50,10 @@ void DrawVisitor::visit(Scene &n)
|
|||||||
void DrawVisitor::visit(Switch &n)
|
void DrawVisitor::visit(Switch &n)
|
||||||
{
|
{
|
||||||
glm::mat4 mv = modelview_;
|
glm::mat4 mv = modelview_;
|
||||||
(*n.activeChild())->accept(*this);
|
n.activeChild()->accept(*this);
|
||||||
modelview_ = mv;
|
modelview_ = mv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawVisitor::visit(Animation &n)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawVisitor::visit(Primitive &n)
|
void DrawVisitor::visit(Primitive &n)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ public:
|
|||||||
void visit(Node& n) override;
|
void visit(Node& n) override;
|
||||||
void visit(Group& n) override;
|
void visit(Group& n) override;
|
||||||
void visit(Switch& n) override;
|
void visit(Switch& n) override;
|
||||||
void visit(Animation& n) override;
|
|
||||||
void visit(Primitive& n) override;
|
void visit(Primitive& n) override;
|
||||||
void visit(Surface& n) override;
|
void visit(Surface& n) override;
|
||||||
void visit(ImageSurface& n) override;
|
void visit(ImageSurface& n) override;
|
||||||
|
|||||||
@@ -77,11 +77,6 @@ void GarbageVisitor::visit(Switch &n)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GarbageVisitor::visit(Animation &n)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void GarbageVisitor::visit(Primitive &n)
|
void GarbageVisitor::visit(Primitive &n)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ public:
|
|||||||
void visit(Node& n) override;
|
void visit(Node& n) override;
|
||||||
void visit(Group& n) override;
|
void visit(Group& n) override;
|
||||||
void visit(Switch& n) override;
|
void visit(Switch& n) override;
|
||||||
void visit(Animation& n) override;
|
|
||||||
void visit(Primitive& n) override;
|
void visit(Primitive& n) override;
|
||||||
void visit(Surface& n) override;
|
void visit(Surface& n) override;
|
||||||
void visit(ImageSurface& n) override;
|
void visit(ImageSurface& n) override;
|
||||||
|
|||||||
@@ -71,6 +71,19 @@ glm::vec3 GlmToolkit::AxisAlignedBoundingBox::center() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::vec3 GlmToolkit::AxisAlignedBoundingBox::scale() const
|
||||||
|
{
|
||||||
|
if (!isNull())
|
||||||
|
{
|
||||||
|
glm::vec3 d = mMax - mMin;
|
||||||
|
return d * 0.5f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return glm::vec3(0.f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool GlmToolkit::AxisAlignedBoundingBox::intersect(const AxisAlignedBoundingBox& bb, bool ignore_z) const
|
bool GlmToolkit::AxisAlignedBoundingBox::intersect(const AxisAlignedBoundingBox& bb, bool ignore_z) const
|
||||||
{
|
{
|
||||||
if (isNull() || bb.isNull())
|
if (isNull() || bb.isNull())
|
||||||
@@ -134,3 +147,16 @@ GlmToolkit::AxisAlignedBoundingBox GlmToolkit::AxisAlignedBoundingBox::scaled(gl
|
|||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GlmToolkit::AxisAlignedBoundingBox GlmToolkit::AxisAlignedBoundingBox::transformed(glm::mat4 m)
|
||||||
|
{
|
||||||
|
GlmToolkit::AxisAlignedBoundingBox bb;
|
||||||
|
glm::vec4 vec;
|
||||||
|
vec = m * glm::vec4(mMin, 1.f);
|
||||||
|
bb.mMin = glm::vec3(vec);
|
||||||
|
|
||||||
|
vec = m * glm::vec4(mMax, 1.f);
|
||||||
|
bb.mMax = glm::vec3(vec);
|
||||||
|
|
||||||
|
return bb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ public:
|
|||||||
inline glm::vec3 min() const { return mMin; }
|
inline glm::vec3 min() const { return mMin; }
|
||||||
inline glm::vec3 max() const { return mMax; }
|
inline glm::vec3 max() const { return mMax; }
|
||||||
glm::vec3 center() const;
|
glm::vec3 center() const;
|
||||||
|
glm::vec3 scale() const;
|
||||||
bool intersect(const AxisAlignedBoundingBox& bb, bool ignore_z = true) const;
|
bool intersect(const AxisAlignedBoundingBox& bb, bool ignore_z = true) const;
|
||||||
bool contains(const AxisAlignedBoundingBox& bb, bool ignore_z = true) const;
|
bool contains(const AxisAlignedBoundingBox& bb, bool ignore_z = true) const;
|
||||||
bool contains(glm::vec3 point, bool ignore_z = true) const;
|
bool contains(glm::vec3 point, bool ignore_z = true) const;
|
||||||
@@ -40,6 +41,7 @@ public:
|
|||||||
|
|
||||||
AxisAlignedBoundingBox translated(glm::vec3 t);
|
AxisAlignedBoundingBox translated(glm::vec3 t);
|
||||||
AxisAlignedBoundingBox scaled(glm::vec3 s);
|
AxisAlignedBoundingBox scaled(glm::vec3 s);
|
||||||
|
AxisAlignedBoundingBox transformed(glm::mat4 m);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,14 +94,8 @@ void ImGuiVisitor::visit(Group &n)
|
|||||||
|
|
||||||
void ImGuiVisitor::visit(Switch &n)
|
void ImGuiVisitor::visit(Switch &n)
|
||||||
{
|
{
|
||||||
// TODO : display selection of active child
|
if (n.numChildren()>0)
|
||||||
(*n.activeChild())->accept(*this);
|
n.activeChild()->accept(*this);
|
||||||
}
|
|
||||||
|
|
||||||
void ImGuiVisitor::visit(Animation &n)
|
|
||||||
{
|
|
||||||
// TODO : display group and animation parameters
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiVisitor::visit(Scene &n)
|
void ImGuiVisitor::visit(Scene &n)
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ public:
|
|||||||
void visit(Node& n) override;
|
void visit(Node& n) override;
|
||||||
void visit(Group& n) override;
|
void visit(Group& n) override;
|
||||||
void visit(Switch& n) override;
|
void visit(Switch& n) override;
|
||||||
void visit(Animation& n) override;
|
|
||||||
void visit(Primitive& n) override;
|
void visit(Primitive& n) override;
|
||||||
void visit(MediaSurface& n) override;
|
void visit(MediaSurface& n) override;
|
||||||
void visit(FrameBufferSurface& n) override;
|
void visit(FrameBufferSurface& n) override;
|
||||||
|
|||||||
2
Log.cpp
2
Log.cpp
@@ -173,7 +173,7 @@ void Log::Notify(const char* fmt, ...)
|
|||||||
notifications_timeout = 0.f;
|
notifications_timeout = 0.f;
|
||||||
|
|
||||||
// always log
|
// always log
|
||||||
Log::Info("%s\n", buf.c_str());
|
Log::Info("%s", buf.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -82,16 +82,17 @@ void MediaSource::init()
|
|||||||
|
|
||||||
// icon in mixing view
|
// icon in mixing view
|
||||||
if (mediaplayer_->duration() == GST_CLOCK_TIME_NONE) {
|
if (mediaplayer_->duration() == GST_CLOCK_TIME_NONE) {
|
||||||
overlays_[View::MIXING]->attach( new Icon(Icon::IMAGE) );
|
overlays_[View::MIXING]->attach( new Icon(Icon::IMAGE, glm::vec3(0.8f, 0.8f, 0.01f)) );
|
||||||
overlays_[View::LAYER]->attach( new Icon(Icon::IMAGE) );
|
overlays_[View::LAYER]->attach( new Icon(Icon::IMAGE, glm::vec3(0.8f, 0.8f, 0.01f)) );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
overlays_[View::MIXING]->attach( new Icon(Icon::VIDEO) );
|
overlays_[View::MIXING]->attach( new Icon(Icon::VIDEO, glm::vec3(0.8f, 0.8f, 0.01f)) );
|
||||||
overlays_[View::LAYER]->attach( new Icon(Icon::VIDEO) );
|
overlays_[View::LAYER]->attach( new Icon(Icon::VIDEO, glm::vec3(0.8f, 0.8f, 0.01f)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// done init
|
// done init
|
||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
|
Log::Info("Source Media linked to Media %s.", mediaplayer()->uri().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ void Mixer::update()
|
|||||||
// update session and associated sources
|
// update session and associated sources
|
||||||
session_->update(dt);
|
session_->update(dt);
|
||||||
|
|
||||||
|
// delete failed sources (one by one)
|
||||||
if (session()->failedSource() != nullptr)
|
if (session()->failedSource() != nullptr)
|
||||||
deleteSource(session()->failedSource());
|
deleteSource(session()->failedSource());
|
||||||
|
|
||||||
@@ -203,7 +204,7 @@ void Mixer::update()
|
|||||||
geometry_.update(dt);
|
geometry_.update(dt);
|
||||||
layer_.update(dt);
|
layer_.update(dt);
|
||||||
|
|
||||||
// optimize the reordering in depth for views
|
// optimize the reordering in depth for views;
|
||||||
// deep updates shall be performed only 1 frame
|
// deep updates shall be performed only 1 frame
|
||||||
View::need_deep_update_ = false;
|
View::need_deep_update_ = false;
|
||||||
}
|
}
|
||||||
@@ -382,7 +383,7 @@ void Mixer::setCurrentSource(SourceList::iterator it)
|
|||||||
if ( it != session_->end() ) {
|
if ( it != session_->end() ) {
|
||||||
current_source_ = it;
|
current_source_ = it;
|
||||||
current_source_index_ = session_->index(it);
|
current_source_index_ = session_->index(it);
|
||||||
(*current_source_)->setOverlayVisible(true);
|
(*current_source_)->setMode(Source::CURRENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,7 +424,7 @@ void Mixer::unsetCurrentSource()
|
|||||||
{
|
{
|
||||||
// discard overlay for previously current source
|
// discard overlay for previously current source
|
||||||
if ( current_source_ != session_->end() )
|
if ( current_source_ != session_->end() )
|
||||||
(*current_source_)->setOverlayVisible(false);
|
(*current_source_)->setMode(Source::NORMAL);
|
||||||
|
|
||||||
// deselect current source
|
// deselect current source
|
||||||
current_source_ = session_->end();
|
current_source_ = session_->end();
|
||||||
@@ -606,6 +607,8 @@ void Mixer::clear()
|
|||||||
|
|
||||||
// swap current with empty
|
// swap current with empty
|
||||||
sessionSwapRequested_ = true;
|
sessionSwapRequested_ = true;
|
||||||
|
|
||||||
|
Log::Info("New session ready.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mixer::set(Session *s)
|
void Mixer::set(Session *s)
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ void PickingVisitor::visit(Node &n)
|
|||||||
|
|
||||||
void PickingVisitor::visit(Group &n)
|
void PickingVisitor::visit(Group &n)
|
||||||
{
|
{
|
||||||
|
if (!n.visible_)
|
||||||
|
return;
|
||||||
glm::mat4 mv = modelview_;
|
glm::mat4 mv = modelview_;
|
||||||
for (NodeSet::iterator node = n.begin(); node != n.end(); node++) {
|
for (NodeSet::iterator node = n.begin(); node != n.end(); node++) {
|
||||||
if ( (*node)->visible_ )
|
if ( (*node)->visible_ )
|
||||||
@@ -39,8 +41,10 @@ void PickingVisitor::visit(Group &n)
|
|||||||
|
|
||||||
void PickingVisitor::visit(Switch &n)
|
void PickingVisitor::visit(Switch &n)
|
||||||
{
|
{
|
||||||
|
if (!n.visible_ || n.numChildren()<1)
|
||||||
|
return;
|
||||||
glm::mat4 mv = modelview_;
|
glm::mat4 mv = modelview_;
|
||||||
(*n.activeChild())->accept(*this);
|
n.activeChild()->accept(*this);
|
||||||
modelview_ = mv;
|
modelview_ = mv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ class PickingVisitor: public Visitor
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
PickingVisitor(glm::vec2 coordinates);
|
PickingVisitor(glm::vec2 coordinates);
|
||||||
std::vector< std::pair<Node *, glm::vec2> > picked() { return nodes_; }
|
std::vector< std::pair<Node *, glm::vec2> > picked() { return nodes_; }
|
||||||
|
|
||||||
|
|||||||
@@ -233,12 +233,12 @@ void Points::accept(Visitor& v)
|
|||||||
v.visit(*this);
|
v.visit(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
LineStrip::LineStrip(std::vector<glm::vec3> points, glm::vec4 color, uint linewidth) : Primitive(new Shader), linewidth_(linewidth)
|
LineStrip::LineStrip(std::vector<glm::vec3> points, std::vector<glm::vec4> colors, uint linewidth) : Primitive(new Shader), linewidth_(linewidth)
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i < points.size(); ++i)
|
for(size_t i = 0; i < points.size(); ++i)
|
||||||
{
|
{
|
||||||
points_.push_back( points[i] );
|
points_.push_back( points[i] );
|
||||||
colors_.push_back( color );
|
colors_.push_back( colors[i] );
|
||||||
indices_.push_back ( i );
|
indices_.push_back ( i );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,13 +255,13 @@ void LineStrip::draw(glm::mat4 modelview, glm::mat4 projection)
|
|||||||
glm::mat4 mv = modelview;
|
glm::mat4 mv = modelview;
|
||||||
glm::mat4 scale = glm::scale(glm::identity<glm::mat4>(), glm::vec3(1.001f, 1.001f, 1.f));
|
glm::mat4 scale = glm::scale(glm::identity<glm::mat4>(), glm::vec3(1.001f, 1.001f, 1.f));
|
||||||
|
|
||||||
|
// TODO FIXME drawing multiple times is not correct to draw lines of different width
|
||||||
|
// TODO Draw LineStrip using polygons
|
||||||
for (uint i = 0 ; i < linewidth_ ; ++i ) {
|
for (uint i = 0 ; i < linewidth_ ; ++i ) {
|
||||||
Primitive::draw(mv, projection);
|
Primitive::draw(mv, projection);
|
||||||
mv *= scale;
|
mv *= scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// glLineWidth(1);
|
// glLineWidth(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,7 +279,13 @@ static const std::vector<glm::vec3> square_points {
|
|||||||
glm::vec3( -1.f, -1.f, 0.f )
|
glm::vec3( -1.f, -1.f, 0.f )
|
||||||
};
|
};
|
||||||
|
|
||||||
LineSquare::LineSquare(glm::vec4 color, uint linewidth) : LineStrip(square_points, color, linewidth)
|
static const std::vector<glm::vec4> square_colors {
|
||||||
|
glm::vec4( 1.f, 1.f, 1.f, 1.f ), glm::vec4( 1.f, 1.f, 1.f, 1.f ),
|
||||||
|
glm::vec4( 1.f, 1.f, 1.f, 1.f ), glm::vec4( 1.f, 1.f, 1.f, 1.f ),
|
||||||
|
glm::vec4( 1.f, 1.f, 1.f, 1.f )
|
||||||
|
};
|
||||||
|
|
||||||
|
LineSquare::LineSquare(uint linewidth) : LineStrip(square_points, square_colors, linewidth)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,22 +330,23 @@ LineSquare::~LineSquare()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LineCircle::LineCircle(glm::vec4 color, uint linewidth) : LineStrip(std::vector<glm::vec3>(), color, linewidth)
|
LineCircle::LineCircle(uint linewidth) : LineStrip(std::vector<glm::vec3>(), std::vector<glm::vec4>(), linewidth)
|
||||||
{
|
{
|
||||||
static int N = 72;
|
static int N = 72;
|
||||||
static float a = glm::two_pi<float>() / static_cast<float>(N);
|
static float a = glm::two_pi<float>() / static_cast<float>(N);
|
||||||
|
static glm::vec4 circle_color_points = glm::vec4(1.f, 1.f, 1.f, 1.f);
|
||||||
// loop to build a circle
|
// loop to build a circle
|
||||||
glm::vec3 P(1.f, 0.f, 0.f);
|
glm::vec3 P(1.f, 0.f, 0.f);
|
||||||
for (int i = 0; i < N ; i++ ){
|
for (int i = 0; i < N ; i++ ){
|
||||||
points_.push_back( glm::vec3(P) );
|
points_.push_back( glm::vec3(P) );
|
||||||
colors_.push_back( color );
|
colors_.push_back( circle_color_points );
|
||||||
indices_.push_back ( i );
|
indices_.push_back ( i );
|
||||||
|
|
||||||
P = glm::rotateZ(P, a);
|
P = glm::rotateZ(P, a);
|
||||||
}
|
}
|
||||||
// close loop
|
// close loop
|
||||||
points_.push_back( glm::vec3(1.f, 0.f, 0.f) );
|
points_.push_back( glm::vec3(1.f, 0.f, 0.f) );
|
||||||
colors_.push_back( color );
|
colors_.push_back( circle_color_points );
|
||||||
indices_.push_back ( N );
|
indices_.push_back ( N );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -133,13 +133,13 @@ class LineStrip : public Primitive {
|
|||||||
uint linewidth_;
|
uint linewidth_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LineStrip(std::vector<glm::vec3> points, glm::vec4 color, uint linewidth = 1);
|
LineStrip(std::vector<glm::vec3> points, std::vector<glm::vec4> colors, uint linewidth = 1);
|
||||||
|
|
||||||
virtual void draw(glm::mat4 modelview, glm::mat4 projection) override;
|
virtual void draw(glm::mat4 modelview, glm::mat4 projection) override;
|
||||||
virtual void accept(Visitor& v) override;
|
virtual void accept(Visitor& v) override;
|
||||||
|
|
||||||
std::vector<glm::vec3> getPoints() { return points_; }
|
std::vector<glm::vec3> getPoints() { return points_; }
|
||||||
glm::vec4 getColor() { return colors_[0]; }
|
std::vector<glm::vec4> getColors() { return colors_; }
|
||||||
|
|
||||||
inline void setLineWidth(uint v) { linewidth_ = v; }
|
inline void setLineWidth(uint v) { linewidth_ = v; }
|
||||||
inline uint getLineWidth() const { return linewidth_; }
|
inline uint getLineWidth() const { return linewidth_; }
|
||||||
@@ -152,7 +152,7 @@ public:
|
|||||||
class LineSquare : public LineStrip {
|
class LineSquare : public LineStrip {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LineSquare(glm::vec4 color, uint linewidth = 1);
|
LineSquare(uint linewidth = 1);
|
||||||
|
|
||||||
void init() override;
|
void init() override;
|
||||||
void accept(Visitor& v) override;
|
void accept(Visitor& v) override;
|
||||||
@@ -167,7 +167,7 @@ public:
|
|||||||
class LineCircle : public LineStrip {
|
class LineCircle : public LineStrip {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LineCircle(glm::vec4 color, uint linewidth = 1);
|
LineCircle(uint linewidth = 1);
|
||||||
|
|
||||||
void init() override;
|
void init() override;
|
||||||
void accept(Visitor& v) override;
|
void accept(Visitor& v) override;
|
||||||
|
|||||||
120
Scene.cpp
120
Scene.cpp
@@ -49,6 +49,12 @@ void Node::copyTransform(Node *other)
|
|||||||
|
|
||||||
void Node::update( float )
|
void Node::update( float )
|
||||||
{
|
{
|
||||||
|
std::list<Node::NodeUpdateCallback>::iterator iter;
|
||||||
|
for (iter=update_callbacks_.begin(); iter != update_callbacks_.end(); iter++)
|
||||||
|
{
|
||||||
|
(*iter)(this);
|
||||||
|
}
|
||||||
|
|
||||||
// update transform matrix from attributes
|
// update transform matrix from attributes
|
||||||
transform_ = GlmToolkit::transform(translation_, rotation_, scale_);
|
transform_ = GlmToolkit::transform(translation_, rotation_, scale_);
|
||||||
}
|
}
|
||||||
@@ -296,8 +302,8 @@ void Switch::update( float dt )
|
|||||||
Node::update(dt);
|
Node::update(dt);
|
||||||
|
|
||||||
// update active child node
|
// update active child node
|
||||||
if (active_ != children_.end())
|
if (!children_.empty())
|
||||||
(*active_)->update( dt );
|
(children_[active_])->update( dt );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Switch::draw(glm::mat4 modelview, glm::mat4 projection)
|
void Switch::draw(glm::mat4 modelview, glm::mat4 projection)
|
||||||
@@ -307,8 +313,8 @@ void Switch::draw(glm::mat4 modelview, glm::mat4 projection)
|
|||||||
|
|
||||||
if ( visible_ ) {
|
if ( visible_ ) {
|
||||||
// draw current child
|
// draw current child
|
||||||
if (active_ != children_.end())
|
if (!children_.empty())
|
||||||
(*active_)->draw( modelview * transform_, projection);
|
(children_[active_])->draw( modelview * transform_, projection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,95 +324,39 @@ void Switch::accept(Visitor& v)
|
|||||||
v.visit(*this);
|
v.visit(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Switch::attach(Node *child)
|
void Switch::setActive (uint index)
|
||||||
{
|
{
|
||||||
Group::attach(child);
|
active_ = CLAMP(index, 0, children_.size() - 1);
|
||||||
setActiveChild(child);
|
}
|
||||||
|
|
||||||
|
Node *Switch::child(uint index) const
|
||||||
|
{
|
||||||
|
if (!children_.empty()) {
|
||||||
|
uint i = CLAMP(index, 0, children_.size() - 1);
|
||||||
|
return children_.at(i);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint Switch::attach(Node *child)
|
||||||
|
{
|
||||||
|
children_.push_back(child);
|
||||||
|
active_ = children_.size() - 1;
|
||||||
|
return active_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Switch::detatch(Node *child)
|
void Switch::detatch(Node *child)
|
||||||
{
|
{
|
||||||
Group::detatch(child);
|
// find the node with this id, and erase it out of the list of children
|
||||||
active_ = children_.begin();
|
// NB: do NOT delete with remove : this takes all nodes with same depth (i.e. equal depth in set)
|
||||||
}
|
std::vector<Node *>::iterator it = std::find_if(children_.begin(), children_.end(), hasId(child->id()));
|
||||||
|
if ( it != children_.end()) {
|
||||||
|
// detatch child from group parent
|
||||||
void Switch::unsetActiveChild ()
|
children_.erase(it);
|
||||||
{
|
child->refcount_--;
|
||||||
active_ = children_.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Switch::setActiveChild(Node *child)
|
|
||||||
{
|
|
||||||
setActiveChild( std::find_if(children_.begin(), children_.end(), hasId(child->id())) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void Switch::setActiveChild(NodeSet::iterator n)
|
|
||||||
{
|
|
||||||
if ( n != children_.end())
|
|
||||||
active_ = n;
|
|
||||||
else
|
|
||||||
active_ = children_.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
NodeSet::iterator Switch::activeChild() const
|
|
||||||
{
|
|
||||||
return active_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Switch::setIndexActiveChild(int index)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
for (NodeSet::iterator node = children_.begin();
|
|
||||||
node != children_.end(); node++, i++) {
|
|
||||||
if ( i == index ) {
|
|
||||||
active_ = node;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Switch::getIndexActiveChild() const
|
|
||||||
{
|
|
||||||
int index = 0;
|
|
||||||
for (NodeSet::iterator node = children_.begin();
|
|
||||||
node != children_.end(); node++, index++) {
|
|
||||||
if (node == active_)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Animation::init()
|
|
||||||
{
|
|
||||||
Group::init();
|
|
||||||
|
|
||||||
animation_ = glm::identity<glm::mat4>();
|
|
||||||
// animation_ = glm::translate(glm::identity<glm::mat4>(), glm::vec3(2.f, 0.f, 0.f));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Animation::update( float dt )
|
|
||||||
{
|
|
||||||
Group::update(dt);
|
|
||||||
|
|
||||||
// incremental rotation
|
|
||||||
animation_ = glm::rotate(animation_, speed_ * dt, axis_);
|
|
||||||
|
|
||||||
// calculate translation of a point at distance radius_ after rotation by animation_
|
|
||||||
static glm::vec3 any = glm::linearRand( glm::vec3(0.f, 0.f, 0.f), glm::vec3(1.f, 1.f, 1.f));
|
|
||||||
glm::vec3 pos = glm::normalize( glm::cross(any, axis_) ) * radius_;
|
|
||||||
glm::vec4 delta = glm::vec4(pos, 0.f) * animation_;
|
|
||||||
|
|
||||||
// apply this translation to the Group transform
|
|
||||||
transform_ *= glm::translate(glm::identity<glm::mat4>(), glm::vec3(delta.x, delta.y, 0.f));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Animation::accept(Visitor& v)
|
|
||||||
{
|
|
||||||
Group::accept(v);
|
|
||||||
v.visit(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
Scene::Scene()
|
Scene::Scene()
|
||||||
{
|
{
|
||||||
|
|||||||
61
Scene.h
61
Scene.h
@@ -10,6 +10,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "GlmToolkit.h"
|
#include "GlmToolkit.h"
|
||||||
|
|
||||||
@@ -71,6 +72,10 @@ public:
|
|||||||
glm::mat4 transform_;
|
glm::mat4 transform_;
|
||||||
glm::vec3 scale_, rotation_, translation_;
|
glm::vec3 scale_, rotation_, translation_;
|
||||||
|
|
||||||
|
// animation update callbacks
|
||||||
|
typedef void (* NodeUpdateCallback)(Node *);
|
||||||
|
// list of functions to call at each update
|
||||||
|
std::list<NodeUpdateCallback> update_callbacks_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -164,10 +169,10 @@ public:
|
|||||||
virtual void accept (Visitor& v) override;
|
virtual void accept (Visitor& v) override;
|
||||||
virtual void draw (glm::mat4 modelview, glm::mat4 projection) override;
|
virtual void draw (glm::mat4 modelview, glm::mat4 projection) override;
|
||||||
|
|
||||||
virtual void clear();
|
void clear();
|
||||||
virtual void attach (Node *child);
|
void attach (Node *child);
|
||||||
virtual void detatch (Node *child);
|
void detatch (Node *child);
|
||||||
virtual void sort();
|
void sort();
|
||||||
|
|
||||||
NodeSet::iterator begin();
|
NodeSet::iterator begin();
|
||||||
NodeSet::iterator end();
|
NodeSet::iterator end();
|
||||||
@@ -187,53 +192,27 @@ protected:
|
|||||||
* draw() will draw only the active child
|
* draw() will draw only the active child
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Switch : public Group {
|
class Switch : public Node {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Switch() : Group(), active_(end()) {}
|
Switch() : Node(), active_(0) {}
|
||||||
|
|
||||||
virtual void update (float dt) override;
|
virtual void update (float dt) override;
|
||||||
virtual void accept (Visitor& v) override;
|
virtual void accept (Visitor& v) override;
|
||||||
virtual void draw (glm::mat4 modelview, glm::mat4 projection) override;
|
virtual void draw (glm::mat4 modelview, glm::mat4 projection) override;
|
||||||
|
|
||||||
void attach (Node *child) override;
|
uint attach (Node *child);
|
||||||
void detatch (Node *child) override;
|
void detatch (Node *child);
|
||||||
|
void setActive (uint index);
|
||||||
|
|
||||||
void unsetActiveChild ();
|
uint active () const { return active_; }
|
||||||
void setActiveChild (Node *child);
|
Node *activeChild () const { return child(active_); }
|
||||||
void setActiveChild (NodeSet::iterator n);
|
uint numChildren () const { return children_.size(); }
|
||||||
NodeSet::iterator activeChild () const;
|
Node *child (uint index) const;
|
||||||
|
|
||||||
void setIndexActiveChild (int index);
|
|
||||||
int getIndexActiveChild () const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NodeSet::iterator active_;
|
uint active_;
|
||||||
};
|
std::vector<Node *> children_;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The Animation class is a Group with an update() function
|
|
||||||
*
|
|
||||||
* The update() computes a transformation of the Group to apply a movement
|
|
||||||
* which is applied to all children.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class Animation : public Group {
|
|
||||||
|
|
||||||
public:
|
|
||||||
Animation() : Group(), axis_(glm::vec3(0.f, 0.f, 1.f)), speed_(0.f), radius_(1.f) { }
|
|
||||||
|
|
||||||
virtual void init () override;
|
|
||||||
virtual void update (float dt) override;
|
|
||||||
virtual void accept (Visitor& v) override;
|
|
||||||
|
|
||||||
// circular path
|
|
||||||
glm::vec3 axis_;
|
|
||||||
float speed_;
|
|
||||||
float radius_;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
glm::mat4 animation_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ void SearchVisitor::visit(Group &n)
|
|||||||
|
|
||||||
void SearchVisitor::visit(Switch &n)
|
void SearchVisitor::visit(Switch &n)
|
||||||
{
|
{
|
||||||
(*n.activeChild())->accept(*this);
|
if (n.numChildren()>0)
|
||||||
|
n.activeChild()->accept(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ public:
|
|||||||
void visit(Scene& n) override {}
|
void visit(Scene& n) override {}
|
||||||
void visit(Group& n) override {}
|
void visit(Group& n) override {}
|
||||||
void visit(Switch& n) override {}
|
void visit(Switch& n) override {}
|
||||||
void visit(Animation& n) override {}
|
|
||||||
void visit(Primitive& n) override {}
|
void visit(Primitive& n) override {}
|
||||||
void visit(Surface& n) override {}
|
void visit(Surface& n) override {}
|
||||||
void visit(ImageSurface& n) override {}
|
void visit(ImageSurface& n) override {}
|
||||||
|
|||||||
@@ -121,8 +121,8 @@ void SessionSource::init()
|
|||||||
attach(renderbuffer);
|
attach(renderbuffer);
|
||||||
|
|
||||||
// icon in mixing view
|
// icon in mixing view
|
||||||
overlays_[View::MIXING]->attach( new Icon(Icon::SESSION) );
|
overlays_[View::MIXING]->attach( new Icon(Icon::SESSION, glm::vec3(0.8f, 0.8f, 0.01f)) );
|
||||||
overlays_[View::LAYER]->attach( new Icon(Icon::SESSION) );
|
overlays_[View::LAYER]->attach( new Icon(Icon::SESSION, glm::vec3(0.8f, 0.8f, 0.01f)) );
|
||||||
|
|
||||||
// done init
|
// done init
|
||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
@@ -201,8 +201,8 @@ void RenderSource::init()
|
|||||||
attach(renderbuffer);
|
attach(renderbuffer);
|
||||||
|
|
||||||
// icon in mixing view
|
// icon in mixing view
|
||||||
overlays_[View::MIXING]->attach( new Icon(Icon::RENDER) );
|
overlays_[View::MIXING]->attach( new Icon(Icon::RENDER, glm::vec3(0.8f, 0.8f, 0.01f)) );
|
||||||
overlays_[View::LAYER]->attach( new Icon(Icon::RENDER) );
|
overlays_[View::LAYER]->attach( new Icon(Icon::RENDER, glm::vec3(0.8f, 0.8f, 0.01f)) );
|
||||||
|
|
||||||
// done init
|
// done init
|
||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
|
|||||||
@@ -78,32 +78,19 @@ void SessionVisitor::visit(Switch &n)
|
|||||||
{
|
{
|
||||||
// Node of a different type
|
// Node of a different type
|
||||||
xmlCurrent_->SetAttribute("type", "Switch");
|
xmlCurrent_->SetAttribute("type", "Switch");
|
||||||
xmlCurrent_->SetAttribute("active", n.getIndexActiveChild());
|
xmlCurrent_->SetAttribute("active", n.active());
|
||||||
|
|
||||||
if (recursive_) {
|
if (recursive_) {
|
||||||
// loop over members of the group
|
// loop over members of the group
|
||||||
XMLElement *group = xmlCurrent_;
|
XMLElement *group = xmlCurrent_;
|
||||||
for (NodeSet::iterator node = n.begin(); node != n.end(); node++) {
|
for(uint i = 0; i < n.numChildren(); i++) {
|
||||||
(*node)->accept(*this);
|
n.child(i)->accept(*this);
|
||||||
// revert to group as current
|
// revert to group as current
|
||||||
xmlCurrent_ = group;
|
xmlCurrent_ = group;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionVisitor::visit(Animation &n)
|
|
||||||
{
|
|
||||||
// Group of a different type
|
|
||||||
xmlCurrent_->SetAttribute("type", "Animation");
|
|
||||||
|
|
||||||
XMLElement *anim = xmlDoc_->NewElement("Movement");
|
|
||||||
anim->SetAttribute("speed", n.speed_);
|
|
||||||
anim->SetAttribute("radius", n.radius_);
|
|
||||||
XMLElement *axis = XMLElementFromGLM(xmlDoc_, n.axis_);
|
|
||||||
anim->InsertEndChild(axis);
|
|
||||||
xmlCurrent_->InsertEndChild(anim);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SessionVisitor::visit(Primitive &n)
|
void SessionVisitor::visit(Primitive &n)
|
||||||
{
|
{
|
||||||
// Node of a different type
|
// Node of a different type
|
||||||
@@ -229,17 +216,25 @@ void SessionVisitor::visit(LineStrip &n)
|
|||||||
// Node of a different type
|
// Node of a different type
|
||||||
xmlCurrent_->SetAttribute("type", "LineStrip");
|
xmlCurrent_->SetAttribute("type", "LineStrip");
|
||||||
|
|
||||||
XMLElement *color = xmlDoc_->NewElement("color");
|
XMLElement *points_node = xmlDoc_->NewElement("points");
|
||||||
color->InsertEndChild( XMLElementFromGLM(xmlDoc_, n.getColor()) );
|
|
||||||
xmlCurrent_->InsertEndChild(color);
|
|
||||||
|
|
||||||
std::vector<glm::vec3> points = n.getPoints();
|
std::vector<glm::vec3> points = n.getPoints();
|
||||||
for(size_t i = 0; i < points.size(); ++i)
|
for(size_t i = 0; i < points.size(); ++i)
|
||||||
{
|
{
|
||||||
XMLElement *p = XMLElementFromGLM(xmlDoc_, points[i]);
|
XMLElement *p = XMLElementFromGLM(xmlDoc_, points[i]);
|
||||||
p->SetAttribute("index", (int) i);
|
p->SetAttribute("index", (int) i);
|
||||||
xmlCurrent_->InsertEndChild(p);
|
points_node->InsertEndChild(p);
|
||||||
}
|
}
|
||||||
|
xmlCurrent_->InsertEndChild(points_node);
|
||||||
|
|
||||||
|
XMLElement *colors_node = xmlDoc_->NewElement("colors");
|
||||||
|
std::vector<glm::vec4> colors = n.getColors();
|
||||||
|
for(size_t i = 0; i < colors.size(); ++i)
|
||||||
|
{
|
||||||
|
XMLElement *p = XMLElementFromGLM(xmlDoc_, colors[i]);
|
||||||
|
p->SetAttribute("index", (int) i);
|
||||||
|
colors_node->InsertEndChild(p);
|
||||||
|
}
|
||||||
|
xmlCurrent_->InsertEndChild(colors_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionVisitor::visit(LineSquare &)
|
void SessionVisitor::visit(LineSquare &)
|
||||||
@@ -254,9 +249,9 @@ void SessionVisitor::visit(LineCircle &n)
|
|||||||
// Node of a different type
|
// Node of a different type
|
||||||
xmlCurrent_->SetAttribute("type", "LineCircle");
|
xmlCurrent_->SetAttribute("type", "LineCircle");
|
||||||
|
|
||||||
XMLElement *color = xmlDoc_->NewElement("color");
|
// XMLElement *color = xmlDoc_->NewElement("color");
|
||||||
color->InsertEndChild( XMLElementFromGLM(xmlDoc_, n.getColor()) );
|
// color->InsertEndChild( XMLElementFromGLM(xmlDoc_, n.getColor()) );
|
||||||
xmlCurrent_->InsertEndChild(color);
|
// xmlCurrent_->InsertEndChild(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionVisitor::visit(Mesh &n)
|
void SessionVisitor::visit(Mesh &n)
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ public:
|
|||||||
void visit(Node& n) override;
|
void visit(Node& n) override;
|
||||||
void visit(Group& n) override;
|
void visit(Group& n) override;
|
||||||
void visit(Switch& n) override;
|
void visit(Switch& n) override;
|
||||||
void visit(Animation& n) override;
|
|
||||||
void visit(Primitive& n) override;
|
void visit(Primitive& n) override;
|
||||||
void visit(Surface& n) override;
|
void visit(Surface& n) override;
|
||||||
void visit(ImageSurface& n) override;
|
void visit(ImageSurface& n) override;
|
||||||
|
|||||||
91
Source.cpp
91
Source.cpp
@@ -20,6 +20,7 @@ Source::Source() : initialized_(false), need_update_(true)
|
|||||||
{
|
{
|
||||||
sprintf(initials_, "__");
|
sprintf(initials_, "__");
|
||||||
name_ = "Source";
|
name_ = "Source";
|
||||||
|
mode_ = Source::HIDDEN;
|
||||||
|
|
||||||
// create groups and overlays for each view
|
// create groups and overlays for each view
|
||||||
|
|
||||||
@@ -30,39 +31,45 @@ Source::Source() : initialized_(false), need_update_(true)
|
|||||||
// default mixing nodes
|
// default mixing nodes
|
||||||
groups_[View::MIXING] = new Group;
|
groups_[View::MIXING] = new Group;
|
||||||
groups_[View::MIXING]->visible_ = false;
|
groups_[View::MIXING]->visible_ = false;
|
||||||
|
groups_[View::MIXING]->scale_ = glm::vec3(0.15f, 0.15f, 1.f);
|
||||||
|
groups_[View::MIXING]->translation_ = glm::vec3(-1.f, 1.f, 0.f);
|
||||||
|
|
||||||
|
frames_[View::MIXING] = new Switch;
|
||||||
Frame *frame = new Frame(Frame::ROUND_THIN);
|
Frame *frame = new Frame(Frame::ROUND_THIN);
|
||||||
frame->translation_.z = 0.1;
|
frame->translation_.z = 0.1;
|
||||||
frame->color = glm::vec4( COLOR_DEFAULT_SOURCE, 0.7f);
|
frame->color = glm::vec4( COLOR_DEFAULT_SOURCE, 0.7f);
|
||||||
groups_[View::MIXING]->attach(frame);
|
frames_[View::MIXING]->attach(frame);
|
||||||
groups_[View::MIXING]->scale_ = glm::vec3(0.15f, 0.15f, 1.f);
|
frame = new Frame(Frame::ROUND_LARGE);
|
||||||
groups_[View::MIXING]->translation_ = glm::vec3(-1.f, 1.f, 0.f);
|
frame->translation_.z = 0.01;
|
||||||
|
frame->color = glm::vec4( COLOR_HIGHLIGHT_SOURCE, 1.f);
|
||||||
|
frames_[View::MIXING]->attach(frame);
|
||||||
|
groups_[View::MIXING]->attach(frames_[View::MIXING]);
|
||||||
|
|
||||||
overlays_[View::MIXING] = new Group;
|
overlays_[View::MIXING] = new Group;
|
||||||
overlays_[View::MIXING]->translation_.z = 0.1;
|
overlays_[View::MIXING]->translation_.z = 0.1;
|
||||||
overlays_[View::MIXING]->visible_ = false;
|
overlays_[View::MIXING]->visible_ = false;
|
||||||
frame = new Frame(Frame::ROUND_LARGE);
|
Icon *center = new Icon(Icon::GENERIC, glm::vec3(0.f, 0.f, 0.1f));
|
||||||
frame->translation_.z = 0.1;
|
|
||||||
frame->color = glm::vec4( COLOR_HIGHLIGHT_SOURCE, 1.f);
|
|
||||||
overlays_[View::MIXING]->attach(frame);
|
|
||||||
Icon *center = new Icon(Icon::GENERIC);
|
|
||||||
center->translation_.z = 0.1;
|
|
||||||
overlays_[View::MIXING]->attach(center);
|
overlays_[View::MIXING]->attach(center);
|
||||||
groups_[View::MIXING]->attach(overlays_[View::MIXING]);
|
groups_[View::MIXING]->attach(overlays_[View::MIXING]);
|
||||||
|
|
||||||
// default geometry nodes
|
// default geometry nodes
|
||||||
groups_[View::GEOMETRY] = new Group;
|
groups_[View::GEOMETRY] = new Group;
|
||||||
groups_[View::GEOMETRY]->visible_ = false;
|
groups_[View::GEOMETRY]->visible_ = false;
|
||||||
|
|
||||||
|
frames_[View::GEOMETRY] = new Switch;
|
||||||
frame = new Frame(Frame::SHARP_THIN);
|
frame = new Frame(Frame::SHARP_THIN);
|
||||||
frame->translation_.z = 0.1;
|
frame->translation_.z = 0.1;
|
||||||
frame->color = glm::vec4( COLOR_DEFAULT_SOURCE, 0.7f);
|
frame->color = glm::vec4( COLOR_DEFAULT_SOURCE, 0.7f);
|
||||||
groups_[View::GEOMETRY]->attach(frame);
|
frames_[View::GEOMETRY]->attach(frame);
|
||||||
|
frame = new Frame(Frame::SHARP_LARGE);
|
||||||
|
frame->translation_.z = 0.1;
|
||||||
|
frame->color = glm::vec4( COLOR_HIGHLIGHT_SOURCE, 1.f);
|
||||||
|
frames_[View::GEOMETRY]->attach(frame);
|
||||||
|
groups_[View::GEOMETRY]->attach(frames_[View::GEOMETRY]);
|
||||||
|
|
||||||
overlays_[View::GEOMETRY] = new Group;
|
overlays_[View::GEOMETRY] = new Group;
|
||||||
overlays_[View::GEOMETRY]->translation_.z = 0.15;
|
overlays_[View::GEOMETRY]->translation_.z = 0.15;
|
||||||
overlays_[View::GEOMETRY]->visible_ = false;
|
overlays_[View::GEOMETRY]->visible_ = false;
|
||||||
frame = new Frame(Frame::SHARP_LARGE);
|
|
||||||
frame->color = glm::vec4( COLOR_HIGHLIGHT_SOURCE, 1.f);
|
|
||||||
overlays_[View::GEOMETRY]->attach(frame);
|
|
||||||
resize_handle_ = new Handles(Handles::RESIZE);
|
resize_handle_ = new Handles(Handles::RESIZE);
|
||||||
resize_handle_->color = glm::vec4( COLOR_HIGHLIGHT_SOURCE, 1.f);
|
resize_handle_->color = glm::vec4( COLOR_HIGHLIGHT_SOURCE, 1.f);
|
||||||
resize_handle_->translation_.z = 0.1;
|
resize_handle_->translation_.z = 0.1;
|
||||||
@@ -81,21 +88,24 @@ Source::Source() : initialized_(false), need_update_(true)
|
|||||||
overlays_[View::GEOMETRY]->attach(rotate_handle_);
|
overlays_[View::GEOMETRY]->attach(rotate_handle_);
|
||||||
groups_[View::GEOMETRY]->attach(overlays_[View::GEOMETRY]);
|
groups_[View::GEOMETRY]->attach(overlays_[View::GEOMETRY]);
|
||||||
|
|
||||||
// default mixing nodes
|
// default layer nodes
|
||||||
groups_[View::LAYER] = new Group;
|
groups_[View::LAYER] = new Group;
|
||||||
groups_[View::LAYER]->visible_ = false;
|
groups_[View::LAYER]->visible_ = false;
|
||||||
|
|
||||||
|
frames_[View::LAYER] = new Switch;
|
||||||
frame = new Frame(Frame::ROUND_SHADOW);
|
frame = new Frame(Frame::ROUND_SHADOW);
|
||||||
frame->translation_.z = 0.1;
|
frame->translation_.z = 0.1;
|
||||||
frame->color = glm::vec4( COLOR_DEFAULT_SOURCE, 0.8f);
|
frame->color = glm::vec4( COLOR_DEFAULT_SOURCE, 0.8f);
|
||||||
groups_[View::LAYER]->attach(frame);
|
frames_[View::LAYER]->attach(frame);
|
||||||
|
frame = new Frame(Frame::ROUND_LARGE);
|
||||||
|
frame->translation_.z = 0.1;
|
||||||
|
frame->color = glm::vec4( COLOR_HIGHLIGHT_SOURCE, 1.f);
|
||||||
|
frames_[View::LAYER]->attach(frame);
|
||||||
|
groups_[View::LAYER]->attach(frames_[View::LAYER]);
|
||||||
|
|
||||||
overlays_[View::LAYER] = new Group;
|
overlays_[View::LAYER] = new Group;
|
||||||
overlays_[View::LAYER]->translation_.z = 0.15;
|
overlays_[View::LAYER]->translation_.z = 0.15;
|
||||||
overlays_[View::LAYER]->visible_ = false;
|
overlays_[View::LAYER]->visible_ = false;
|
||||||
frame = new Frame(Frame::ROUND_LARGE);
|
|
||||||
frame->translation_.z = 0.1;
|
|
||||||
frame->color = glm::vec4( COLOR_HIGHLIGHT_SOURCE, 1.f);
|
|
||||||
overlays_[View::LAYER]->attach(frame);
|
|
||||||
groups_[View::LAYER]->attach(overlays_[View::LAYER]);
|
groups_[View::LAYER]->attach(overlays_[View::LAYER]);
|
||||||
|
|
||||||
// will be associated to nodes later
|
// will be associated to nodes later
|
||||||
@@ -103,6 +113,7 @@ Source::Source() : initialized_(false), need_update_(true)
|
|||||||
rendershader_ = new ImageProcessingShader;
|
rendershader_ = new ImageProcessingShader;
|
||||||
renderbuffer_ = nullptr;
|
renderbuffer_ = nullptr;
|
||||||
rendersurface_ = nullptr;
|
rendersurface_ = nullptr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Source::~Source()
|
Source::~Source()
|
||||||
@@ -138,19 +149,33 @@ void Source::accept(Visitor& v)
|
|||||||
v.visit(*this);
|
v.visit(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source::setOverlayVisible(bool on)
|
|
||||||
|
Source::Mode Source::mode() const
|
||||||
{
|
{
|
||||||
for (auto o = overlays_.begin(); o != overlays_.end(); o++)
|
return mode_;
|
||||||
(*o).second->visible_ = on;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source::setVisible(bool on)
|
void Source::setMode(Source::Mode m)
|
||||||
{
|
{
|
||||||
// make visible
|
mode_ = m;
|
||||||
groups_[View::RENDERING]->visible_ = on;
|
|
||||||
groups_[View::MIXING]->visible_ = on;
|
bool visible = mode_ != Source::HIDDEN;
|
||||||
groups_[View::GEOMETRY]->visible_ = on;
|
for (auto g = groups_.begin(); g != groups_.end(); g++)
|
||||||
groups_[View::LAYER]->visible_ = on;
|
(*g).second->visible_ = visible;
|
||||||
|
|
||||||
|
uint index_frame = mode_ == Source::NORMAL ? 0 : 1;
|
||||||
|
for (auto f = frames_.begin(); f != frames_.end(); f++)
|
||||||
|
(*f).second->setActive(index_frame);
|
||||||
|
|
||||||
|
bool current = mode_ == Source::CURRENT;
|
||||||
|
for (auto o = overlays_.begin(); o != overlays_.end(); o++)
|
||||||
|
(*o).second->visible_ = current;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void fix_ar(Node *n)
|
||||||
|
{
|
||||||
|
n->scale_.y = n->scale_.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source::attach(FrameBuffer *renderbuffer)
|
void Source::attach(FrameBuffer *renderbuffer)
|
||||||
@@ -186,7 +211,11 @@ void Source::attach(FrameBuffer *renderbuffer)
|
|||||||
(*node)->scale_.x = renderbuffer_->aspectRatio();
|
(*node)->scale_.x = renderbuffer_->aspectRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
setVisible(true);
|
|
||||||
|
// test update callback
|
||||||
|
// groups_[View::GEOMETRY]->update_callbacks_.push_front(fix_ar);
|
||||||
|
|
||||||
|
setMode(Source::NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source::update(float dt)
|
void Source::update(float dt)
|
||||||
@@ -307,8 +336,8 @@ void CloneSource::init()
|
|||||||
attach(renderbuffer);
|
attach(renderbuffer);
|
||||||
|
|
||||||
// icon in mixing view
|
// icon in mixing view
|
||||||
overlays_[View::MIXING]->attach( new Icon(Icon::CLONE) );
|
overlays_[View::MIXING]->attach( new Icon(Icon::CLONE, glm::vec3(0.8f, 0.8f, 0.01f)) );
|
||||||
overlays_[View::LAYER]->attach( new Icon(Icon::CLONE) );
|
overlays_[View::LAYER]->attach( new Icon(Icon::CLONE, glm::vec3(0.8f, 0.8f, 0.01f)) );
|
||||||
|
|
||||||
// done init
|
// done init
|
||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
|
|||||||
20
Source.h
20
Source.h
@@ -41,11 +41,15 @@ public:
|
|||||||
// cloning mechanism
|
// cloning mechanism
|
||||||
virtual CloneSource *clone();
|
virtual CloneSource *clone();
|
||||||
|
|
||||||
// make visible or hidden
|
// Display mode
|
||||||
void setVisible(bool on);
|
typedef enum {
|
||||||
|
HIDDEN = 0,
|
||||||
// an overlay can be displayed on top of the source
|
NORMAL = 1,
|
||||||
void setOverlayVisible(bool on);
|
ACTIVE = 2,
|
||||||
|
CURRENT = 3
|
||||||
|
} Mode;
|
||||||
|
Mode mode() const;
|
||||||
|
void setMode(Mode m);
|
||||||
|
|
||||||
// get handle on the nodes used to manipulate the source in a view
|
// get handle on the nodes used to manipulate the source in a view
|
||||||
inline Group *group(View::Mode m) const { return groups_.at(m); }
|
inline Group *group(View::Mode m) const { return groups_.at(m); }
|
||||||
@@ -108,8 +112,12 @@ protected:
|
|||||||
// blendingshader provides mixing controls
|
// blendingshader provides mixing controls
|
||||||
ImageShader *blendingshader_;
|
ImageShader *blendingshader_;
|
||||||
|
|
||||||
// overlay to be displayed on top of source
|
// mode for display
|
||||||
|
Mode mode_;
|
||||||
|
|
||||||
|
// overlays and frames to be displayed on top of source
|
||||||
std::map<View::Mode, Group*> overlays_;
|
std::map<View::Mode, Group*> overlays_;
|
||||||
|
std::map<View::Mode, Switch*> frames_;
|
||||||
Handles *resize_handle_, *resize_H_handle_, *resize_V_handle_, *rotate_handle_;
|
Handles *resize_handle_, *resize_H_handle_, *resize_V_handle_, *rotate_handle_;
|
||||||
|
|
||||||
// update
|
// update
|
||||||
|
|||||||
@@ -248,6 +248,10 @@ void UserInterface::handleKeyboard()
|
|||||||
// Logs
|
// Logs
|
||||||
Settings::application.media_player = !Settings::application.media_player;
|
Settings::application.media_player = !Settings::application.media_player;
|
||||||
}
|
}
|
||||||
|
else if (ImGui::IsKeyPressed( GLFW_KEY_A )) {
|
||||||
|
// select all
|
||||||
|
Mixer::manager().currentView()->selectall();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// No CTRL modifier
|
// No CTRL modifier
|
||||||
@@ -386,13 +390,15 @@ void UserInterface::handleMouse()
|
|||||||
else {
|
else {
|
||||||
// Log::Info("Mouse drag (%.1f,%.1f)(%.1f,%.1f)", io.MouseClickedPos[0].x, io.MouseClickedPos[0].y, io.MousePos.x, io.MousePos.y);
|
// Log::Info("Mouse drag (%.1f,%.1f)(%.1f,%.1f)", io.MouseClickedPos[0].x, io.MouseClickedPos[0].y, io.MousePos.x, io.MousePos.y);
|
||||||
// Selection area
|
// Selection area
|
||||||
// ImGui::GetBackgroundDrawList()->AddRect(io.MouseClickedPos[ImGuiMouseButton_Left], io.MousePos,
|
ImGui::GetBackgroundDrawList()->AddRect(io.MouseClickedPos[ImGuiMouseButton_Left], io.MousePos,
|
||||||
// ImGui::GetColorU32(ImGuiCol_ResizeGripHovered));
|
ImGui::GetColorU32(ImGuiCol_ResizeGripHovered));
|
||||||
// ImGui::GetBackgroundDrawList()->AddRectFilled(io.MouseClickedPos[ImGuiMouseButton_Left], io.MousePos,
|
ImGui::GetBackgroundDrawList()->AddRectFilled(io.MouseClickedPos[ImGuiMouseButton_Left], io.MousePos,
|
||||||
// ImGui::GetColorU32(ImGuiCol_ResizeGripHovered, 0.3f));
|
ImGui::GetColorU32(ImGuiCol_ResizeGripHovered, 0.3f));
|
||||||
|
|
||||||
// TODO Multiple sources selection
|
// TODO Multiple sources selection
|
||||||
|
|
||||||
|
Mixer::manager().currentView()->select(mouseclic[ImGuiMouseButton_Left], mousepos);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( ImGui::IsMouseDown(ImGuiMouseButton_Left) ) {
|
else if ( ImGui::IsMouseDown(ImGuiMouseButton_Left) ) {
|
||||||
@@ -412,6 +418,9 @@ void UserInterface::handleMouse()
|
|||||||
navigator.showPannelSource( Mixer::manager().indexCurrentSource() );
|
navigator.showPannelSource( Mixer::manager().indexCurrentSource() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO deselect if current source is not in selection
|
||||||
|
Mixer::manager().currentView()->deselect();
|
||||||
}
|
}
|
||||||
else if ( ImGui::IsMouseReleased(ImGuiMouseButton_Left) )
|
else if ( ImGui::IsMouseReleased(ImGuiMouseButton_Left) )
|
||||||
{
|
{
|
||||||
@@ -723,7 +732,7 @@ void UserInterface::RenderMediaPlayer()
|
|||||||
ImGui::SetNextWindowPos(ImVec2(1180, 400), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(1180, 400), ImGuiCond_FirstUseEver);
|
||||||
ImGui::SetNextWindowSize(ImVec2(400, 400), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowSize(ImVec2(400, 400), ImGuiCond_FirstUseEver);
|
||||||
ImGui::SetNextWindowSizeConstraints(ImVec2(350, 300), ImVec2(FLT_MAX, FLT_MAX));
|
ImGui::SetNextWindowSizeConstraints(ImVec2(350, 300), ImVec2(FLT_MAX, FLT_MAX));
|
||||||
if ( !ImGui::Begin(IMGUI_TITLE_MEDIAPLAYER, &Settings::application.media_player, ImGuiWindowFlags_NoScrollbar) || !show)
|
if ( !ImGui::Begin(IMGUI_TITLE_MEDIAPLAYER, &Settings::application.media_player, ImGuiWindowFlags_NoScrollbar ) || !show)
|
||||||
{
|
{
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
return;
|
return;
|
||||||
@@ -1090,14 +1099,16 @@ void Navigator::Render()
|
|||||||
{
|
{
|
||||||
Mixer::manager().setCurrentView(View::MIXING);
|
Mixer::manager().setCurrentView(View::MIXING);
|
||||||
}
|
}
|
||||||
if (ImGui::Selectable( ICON_FA_SIGN , &selected_view[2], 0, iconsize))
|
if (ImGui::Selectable( ICON_FA_OBJECT_UNGROUP , &selected_view[2], 0, iconsize))
|
||||||
{
|
{
|
||||||
Mixer::manager().setCurrentView(View::GEOMETRY);
|
Mixer::manager().setCurrentView(View::GEOMETRY);
|
||||||
}
|
}
|
||||||
if (ImGui::Selectable( ICON_FA_LAYER_GROUP, &selected_view[3], 0, iconsize))
|
if (ImGui::Selectable( ICON_FA_IMAGES, &selected_view[3], 0, iconsize))
|
||||||
|
// if (ImGui::Selectable( ICON_FA_LAYER_GROUP, &selected_view[3], 0, iconsize))
|
||||||
{
|
{
|
||||||
Mixer::manager().setCurrentView(View::LAYER);
|
Mixer::manager().setCurrentView(View::LAYER);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
|
|||||||
35
View.cpp
35
View.cpp
@@ -14,6 +14,7 @@
|
|||||||
#include "View.h"
|
#include "View.h"
|
||||||
#include "Source.h"
|
#include "Source.h"
|
||||||
#include "Primitives.h"
|
#include "Primitives.h"
|
||||||
|
#include "Decorations.h"
|
||||||
#include "PickingVisitor.h"
|
#include "PickingVisitor.h"
|
||||||
#include "DrawVisitor.h"
|
#include "DrawVisitor.h"
|
||||||
#include "Mesh.h"
|
#include "Mesh.h"
|
||||||
@@ -29,6 +30,9 @@ bool View::need_deep_update_ = true;
|
|||||||
|
|
||||||
View::View(Mode m) : mode_(m)
|
View::View(Mode m) : mode_(m)
|
||||||
{
|
{
|
||||||
|
selection_ = new Selection;
|
||||||
|
selection_->visible_ = false;
|
||||||
|
scene.ws()->attach(selection_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::restoreSettings()
|
void View::restoreSettings()
|
||||||
@@ -95,12 +99,43 @@ std::pair<Node *, glm::vec2> View::pick(glm::vec3 point)
|
|||||||
// select top-most Node picked
|
// select top-most Node picked
|
||||||
picked = pv.picked().back();
|
picked = pv.picked().back();
|
||||||
|
|
||||||
|
//DEBUG
|
||||||
|
select(glm::vec2(-1.f, -1.f), glm::vec2(1.f, 1.f));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
// cancel selection on clic in background
|
||||||
|
else {
|
||||||
|
deselect();
|
||||||
}
|
}
|
||||||
|
|
||||||
return picked;
|
return picked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void View::select(glm::vec2 A, glm::vec2 B)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void View::selectall()
|
||||||
|
{
|
||||||
|
for(auto it = scene.ws()->begin(); it != scene.ws()->end(); it++) {
|
||||||
|
if ( *it != selection_)
|
||||||
|
selection_->attach(*it);
|
||||||
|
}
|
||||||
|
|
||||||
|
selection_->visible_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void View::deselect()
|
||||||
|
{
|
||||||
|
selection_->clear();
|
||||||
|
selection_->visible_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MixingView::MixingView() : View(MIXING)
|
MixingView::MixingView() : View(MIXING)
|
||||||
{
|
{
|
||||||
// read default settings
|
// read default settings
|
||||||
|
|||||||
15
View.h
15
View.h
@@ -43,26 +43,37 @@ public:
|
|||||||
Cursor(CursorType t, std::string i = "") { type = t; info = i;}
|
Cursor(CursorType t, std::string i = "") { type = t; info = i;}
|
||||||
} Cursor;
|
} Cursor;
|
||||||
|
|
||||||
|
// picking of nodes in a view provided a point coordinates in scene reference frame
|
||||||
virtual std::pair<Node *, glm::vec2> pick(glm::vec3 point);
|
virtual std::pair<Node *, glm::vec2> pick(glm::vec3 point);
|
||||||
|
|
||||||
|
// drag the view provided a start and an end point in screen coordinates
|
||||||
virtual Cursor drag (glm::vec2, glm::vec2);
|
virtual Cursor drag (glm::vec2, glm::vec2);
|
||||||
|
|
||||||
|
// grab a source provided a start and an end point in screen coordinates and the picking point
|
||||||
virtual Cursor grab (glm::vec2, glm::vec2, Source*, std::pair<Node *, glm::vec2>) {
|
virtual Cursor grab (glm::vec2, glm::vec2, Source*, std::pair<Node *, glm::vec2>) {
|
||||||
return Cursor();
|
return Cursor();
|
||||||
}
|
}
|
||||||
|
// test mouse over provided a point in screen coordinates and the picking point
|
||||||
virtual Cursor over (glm::vec2, Source*, std::pair<Node *, glm::vec2>) {
|
virtual Cursor over (glm::vec2, Source*, std::pair<Node *, glm::vec2>) {
|
||||||
return Cursor();
|
return Cursor();
|
||||||
}
|
}
|
||||||
|
// select sources provided a start and end selection points in screen coordinates
|
||||||
|
virtual void select(glm::vec2, glm::vec2);
|
||||||
|
virtual void selectall();
|
||||||
|
virtual void deselect();
|
||||||
|
|
||||||
virtual void restoreSettings();
|
virtual void restoreSettings();
|
||||||
virtual void saveSettings();
|
virtual void saveSettings();
|
||||||
|
|
||||||
|
// accessible scene
|
||||||
Scene scene;
|
Scene scene;
|
||||||
|
|
||||||
// hack to avoid reordering scene of view if not necessary
|
// avoid reordering scene of view if not necessary
|
||||||
static bool need_deep_update_;
|
static bool need_deep_update_;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Mode mode_;
|
Mode mode_;
|
||||||
|
class Selection *selection_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
class Node;
|
class Node;
|
||||||
class Group;
|
class Group;
|
||||||
class Switch;
|
class Switch;
|
||||||
class Animation;
|
|
||||||
class Primitive;
|
class Primitive;
|
||||||
class Scene;
|
class Scene;
|
||||||
class Surface;
|
class Surface;
|
||||||
@@ -42,7 +41,6 @@ public:
|
|||||||
|
|
||||||
// not mandatory for all others
|
// not mandatory for all others
|
||||||
virtual void visit (Switch&) {}
|
virtual void visit (Switch&) {}
|
||||||
virtual void visit (Animation&) {}
|
|
||||||
virtual void visit (Surface&) {}
|
virtual void visit (Surface&) {}
|
||||||
virtual void visit (ImageSurface&) {}
|
virtual void visit (ImageSurface&) {}
|
||||||
virtual void visit (MediaSurface&) {}
|
virtual void visit (MediaSurface&) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user