mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Initial implementation of Layer view (not effective, but integrated in
mixer).
This commit is contained in:
@@ -84,7 +84,7 @@ uint FrameBuffer::texture() const
|
|||||||
|
|
||||||
float FrameBuffer::aspectRatio() const
|
float FrameBuffer::aspectRatio() const
|
||||||
{
|
{
|
||||||
return static_cast<float>(width()) / static_cast<float>(height());
|
return static_cast<float>(attrib_.viewport.x) / static_cast<float>(attrib_.viewport.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,17 @@ void ImGuiVisitor::visit(Group &n)
|
|||||||
// if (ImGui::TreeNode(id.c_str(), "Group %d", n.id()))
|
// if (ImGui::TreeNode(id.c_str(), "Group %d", n.id()))
|
||||||
// {
|
// {
|
||||||
// MODEL VIEW
|
// MODEL VIEW
|
||||||
|
|
||||||
|
if (ImGuiToolkit::ButtonIcon(1, 16)) {
|
||||||
|
n.translation_.x = 0.f;
|
||||||
|
n.translation_.y = 0.f;
|
||||||
|
n.rotation_.z = 0.f;
|
||||||
|
n.scale_.x = 1.f;
|
||||||
|
n.scale_.y = 1.f;
|
||||||
|
}
|
||||||
|
ImGui::SameLine(0, 10);
|
||||||
|
ImGui::Text("Geometry");
|
||||||
|
|
||||||
if (ImGuiToolkit::ButtonIcon(6, 15)) {
|
if (ImGuiToolkit::ButtonIcon(6, 15)) {
|
||||||
n.translation_.x = 0.f;
|
n.translation_.x = 0.f;
|
||||||
n.translation_.y = 0.f;
|
n.translation_.y = 0.f;
|
||||||
@@ -48,7 +59,7 @@ void ImGuiVisitor::visit(Group &n)
|
|||||||
n.translation_.y = translation[1];
|
n.translation_.y = translation[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGuiToolkit::ButtonIcon(4, 15))
|
if (ImGuiToolkit::ButtonIcon(18, 9))
|
||||||
n.rotation_.z = 0.f;
|
n.rotation_.z = 0.f;
|
||||||
ImGui::SameLine(0, 10);
|
ImGui::SameLine(0, 10);
|
||||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||||
|
|||||||
5
Mesh.cpp
5
Mesh.cpp
@@ -466,10 +466,9 @@ Handles::Handles(Type type) : Node(), type_(type)
|
|||||||
|
|
||||||
if ( type_ == ROTATE ) {
|
if ( type_ == ROTATE ) {
|
||||||
handle_ = new Mesh("mesh/border_handles_rotation.ply");
|
handle_ = new Mesh("mesh/border_handles_rotation.ply");
|
||||||
// handle_->scale_ = glm::vec3( 0.01f, 0.01f, 1.f);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
handle_ = new LineSquare(color, 3);
|
handle_ = new LineSquare(color, 2);
|
||||||
handle_->scale_ = glm::vec3( 0.05f, 0.05f, 1.f);
|
handle_->scale_ = glm::vec3( 0.05f, 0.05f, 1.f);
|
||||||
}
|
}
|
||||||
// handle_ = new Mesh("mesh/border_handles_overlay.ply");
|
// handle_ = new Mesh("mesh/border_handles_overlay.ply");
|
||||||
@@ -499,7 +498,6 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
|
|||||||
|
|
||||||
// set color
|
// set color
|
||||||
handle_->shader()->color = color;
|
handle_->shader()->color = color;
|
||||||
// handle_->scale_ = glm::vec3( 0.01f, 0.01f, 1.f);
|
|
||||||
|
|
||||||
glm::mat4 ctm;
|
glm::mat4 ctm;
|
||||||
|
|
||||||
@@ -535,7 +533,6 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
|
|||||||
}
|
}
|
||||||
else if ( type_ == ROTATE ){
|
else if ( type_ == ROTATE ){
|
||||||
// only once in upper top right corner
|
// only once in upper top right corner
|
||||||
// ctm = modelview * glm::translate(glm::identity<glm::mat4>(), glm::vec3(1.08f, +1.08f, 0.f));
|
|
||||||
glm::vec4 pos = modelview * glm::vec4(1.08f, 1.08f, 0.f, 1.f);
|
glm::vec4 pos = modelview * glm::vec4(1.08f, 1.08f, 0.f, 1.f);
|
||||||
ctm = GlmToolkit::transform(glm::vec3(pos), glm::vec3(0.f), glm::vec3(1.f));
|
ctm = GlmToolkit::transform(glm::vec3(pos), glm::vec3(0.f), glm::vec3(1.f));
|
||||||
handle_->draw( ctm, projection );
|
handle_->draw( ctm, projection );
|
||||||
|
|||||||
22
Mixer.cpp
22
Mixer.cpp
@@ -89,6 +89,10 @@ static void saveSession(const std::string& filename, Session *session)
|
|||||||
geometry->InsertEndChild( SessionVisitor::NodeToXML(*session->config(View::GEOMETRY), &xmlDoc));
|
geometry->InsertEndChild( SessionVisitor::NodeToXML(*session->config(View::GEOMETRY), &xmlDoc));
|
||||||
views->InsertEndChild(geometry);
|
views->InsertEndChild(geometry);
|
||||||
|
|
||||||
|
XMLElement *layer = xmlDoc.NewElement( "Layer" );
|
||||||
|
layer->InsertEndChild( SessionVisitor::NodeToXML(*session->config(View::LAYER), &xmlDoc));
|
||||||
|
views->InsertEndChild(layer);
|
||||||
|
|
||||||
XMLElement *render = xmlDoc.NewElement( "Rendering" );
|
XMLElement *render = xmlDoc.NewElement( "Rendering" );
|
||||||
render->InsertEndChild( SessionVisitor::NodeToXML(*session->config(View::RENDERING), &xmlDoc));
|
render->InsertEndChild( SessionVisitor::NodeToXML(*session->config(View::RENDERING), &xmlDoc));
|
||||||
views->InsertEndChild(render);
|
views->InsertEndChild(render);
|
||||||
@@ -157,6 +161,7 @@ void Mixer::update()
|
|||||||
// update views
|
// update views
|
||||||
mixing_.update(dt);
|
mixing_.update(dt);
|
||||||
geometry_.update(dt);
|
geometry_.update(dt);
|
||||||
|
layer_.update(dt);
|
||||||
// TODO other views
|
// TODO other views
|
||||||
|
|
||||||
|
|
||||||
@@ -190,11 +195,10 @@ void Mixer::insertSource(Source *s)
|
|||||||
// Add source to Session and set it as current
|
// Add source to Session and set it as current
|
||||||
setCurrentSource( session_->addSource(s) );
|
setCurrentSource( session_->addSource(s) );
|
||||||
|
|
||||||
// add sources Nodes to ALL views
|
// add sources Nodes to all views
|
||||||
// Mixing Node
|
|
||||||
mixing_.scene.fg()->attach(s->group(View::MIXING));
|
mixing_.scene.fg()->attach(s->group(View::MIXING));
|
||||||
// Geometry Node
|
|
||||||
geometry_.scene.fg()->attach(s->group(View::GEOMETRY));
|
geometry_.scene.fg()->attach(s->group(View::GEOMETRY));
|
||||||
|
layer_.scene.fg()->attach(s->group(View::LAYER));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,9 +213,10 @@ void Mixer::deleteSource(Source *s)
|
|||||||
// in case..
|
// in case..
|
||||||
unsetCurrentSource();
|
unsetCurrentSource();
|
||||||
|
|
||||||
// remove source Nodes from views
|
// remove source Nodes from all views
|
||||||
mixing_.scene.fg()->detatch( s->group(View::MIXING) );
|
mixing_.scene.fg()->detatch( s->group(View::MIXING) );
|
||||||
geometry_.scene.fg()->detatch( s->group(View::GEOMETRY) );
|
geometry_.scene.fg()->detatch( s->group(View::GEOMETRY) );
|
||||||
|
layer_.scene.fg()->detatch( s->group(View::LAYER) );
|
||||||
|
|
||||||
// delete source
|
// delete source
|
||||||
session_->deleteSource(s);
|
session_->deleteSource(s);
|
||||||
@@ -309,6 +314,9 @@ void Mixer::setCurrentView(View::Mode m)
|
|||||||
case View::GEOMETRY:
|
case View::GEOMETRY:
|
||||||
current_view_ = &geometry_;
|
current_view_ = &geometry_;
|
||||||
break;
|
break;
|
||||||
|
case View::LAYER:
|
||||||
|
current_view_ = &layer_;
|
||||||
|
break;
|
||||||
case View::MIXING:
|
case View::MIXING:
|
||||||
default:
|
default:
|
||||||
current_view_ = &mixing_;
|
current_view_ = &mixing_;
|
||||||
@@ -323,6 +331,8 @@ View *Mixer::getView(View::Mode m)
|
|||||||
switch (m) {
|
switch (m) {
|
||||||
case View::GEOMETRY:
|
case View::GEOMETRY:
|
||||||
return &geometry_;
|
return &geometry_;
|
||||||
|
case View::LAYER:
|
||||||
|
return &layer_;
|
||||||
case View::MIXING:
|
case View::MIXING:
|
||||||
return &mixing_;
|
return &mixing_;
|
||||||
default:
|
default:
|
||||||
@@ -352,6 +362,7 @@ void Mixer::saveas(const std::string& filename)
|
|||||||
// optional copy of views config
|
// optional copy of views config
|
||||||
session_->config(View::MIXING)->copyTransform( mixing_.scene.root() );
|
session_->config(View::MIXING)->copyTransform( mixing_.scene.root() );
|
||||||
session_->config(View::GEOMETRY)->copyTransform( geometry_.scene.root() );
|
session_->config(View::GEOMETRY)->copyTransform( geometry_.scene.root() );
|
||||||
|
session_->config(View::LAYER)->copyTransform( layer_.scene.root() );
|
||||||
|
|
||||||
// launch a thread to save the session
|
// launch a thread to save the session
|
||||||
std::thread (saveSession, filename, session_).detach();
|
std::thread (saveSession, filename, session_).detach();
|
||||||
@@ -386,6 +397,7 @@ void Mixer::swap()
|
|||||||
{
|
{
|
||||||
mixing_.scene.fg()->detatch( (*source_iter)->group(View::MIXING) );
|
mixing_.scene.fg()->detatch( (*source_iter)->group(View::MIXING) );
|
||||||
geometry_.scene.fg()->detatch( (*source_iter)->group(View::GEOMETRY) );
|
geometry_.scene.fg()->detatch( (*source_iter)->group(View::GEOMETRY) );
|
||||||
|
layer_.scene.fg()->detatch( (*source_iter)->group(View::LAYER) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,11 +411,13 @@ void Mixer::swap()
|
|||||||
{
|
{
|
||||||
mixing_.scene.fg()->attach( (*source_iter)->group(View::MIXING) );
|
mixing_.scene.fg()->attach( (*source_iter)->group(View::MIXING) );
|
||||||
geometry_.scene.fg()->attach( (*source_iter)->group(View::GEOMETRY) );
|
geometry_.scene.fg()->attach( (*source_iter)->group(View::GEOMETRY) );
|
||||||
|
layer_.scene.fg()->attach( (*source_iter)->group(View::LAYER) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional copy of views config
|
// optional copy of views config
|
||||||
mixing_.scene.root()->copyTransform( session_->config(View::MIXING) );
|
mixing_.scene.root()->copyTransform( session_->config(View::MIXING) );
|
||||||
geometry_.scene.root()->copyTransform( session_->config(View::GEOMETRY) );
|
geometry_.scene.root()->copyTransform( session_->config(View::GEOMETRY) );
|
||||||
|
layer_.scene.root()->copyTransform( session_->config(View::LAYER) );
|
||||||
|
|
||||||
// set resolution
|
// set resolution
|
||||||
session_->setResolution( session_->config(View::RENDERING)->scale_ );
|
session_->setResolution( session_->config(View::RENDERING)->scale_ );
|
||||||
|
|||||||
1
Mixer.h
1
Mixer.h
@@ -82,6 +82,7 @@ protected:
|
|||||||
|
|
||||||
MixingView mixing_;
|
MixingView mixing_;
|
||||||
GeometryView geometry_;
|
GeometryView geometry_;
|
||||||
|
LayerView layer_;
|
||||||
View *current_view_;
|
View *current_view_;
|
||||||
|
|
||||||
gint64 update_time_;
|
gint64 update_time_;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ Session::Session()
|
|||||||
config_[View::RENDERING] = new Group;
|
config_[View::RENDERING] = new Group;
|
||||||
config_[View::RENDERING]->scale_ = render_.resolution();
|
config_[View::RENDERING]->scale_ = render_.resolution();
|
||||||
config_[View::GEOMETRY] = new Group;
|
config_[View::GEOMETRY] = new Group;
|
||||||
|
config_[View::LAYER] = new Group;
|
||||||
config_[View::MIXING] = new Group;
|
config_[View::MIXING] = new Group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ void SessionCreator::loadConfig(XMLElement *viewsNode)
|
|||||||
// ok, ready to read views
|
// ok, ready to read views
|
||||||
SessionCreator::XMLToNode( viewsNode->FirstChildElement("Mixing"), *session_->config(View::MIXING));
|
SessionCreator::XMLToNode( viewsNode->FirstChildElement("Mixing"), *session_->config(View::MIXING));
|
||||||
SessionCreator::XMLToNode( viewsNode->FirstChildElement("Geometry"), *session_->config(View::GEOMETRY));
|
SessionCreator::XMLToNode( viewsNode->FirstChildElement("Geometry"), *session_->config(View::GEOMETRY));
|
||||||
|
SessionCreator::XMLToNode( viewsNode->FirstChildElement("Layer"), *session_->config(View::LAYER));
|
||||||
SessionCreator::XMLToNode( viewsNode->FirstChildElement("Rendering"), *session_->config(View::RENDERING));
|
SessionCreator::XMLToNode( viewsNode->FirstChildElement("Rendering"), *session_->config(View::RENDERING));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,11 @@ Source::Source(const std::string &name) : name_(name), initialized_(false)
|
|||||||
|
|
||||||
// default mixing nodes
|
// default mixing nodes
|
||||||
groups_[View::LAYER] = new Group;
|
groups_[View::LAYER] = new Group;
|
||||||
|
frame = new Frame(Frame::ROUND_THIN);
|
||||||
|
frame->translation_.z = 0.1;
|
||||||
|
frame->color = glm::vec4( COLOR_DEFAULT_SOURCE, 0.9f);
|
||||||
|
groups_[View::LAYER]->attach(frame);
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -978,7 +978,7 @@ void Navigator::Render()
|
|||||||
}
|
}
|
||||||
if (ImGui::Selectable( ICON_FA_LAYER_GROUP, &selected_view[3], 0, iconsize))
|
if (ImGui::Selectable( ICON_FA_LAYER_GROUP, &selected_view[3], 0, iconsize))
|
||||||
{
|
{
|
||||||
// TODO : Layers view
|
Mixer::manager().setCurrentView(View::LAYER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
@@ -1049,7 +1049,6 @@ void Navigator::RenderSourcePannel(Source *s)
|
|||||||
ImGui::Image((void*)(uintptr_t) s->frame()->texture(), imagesize);
|
ImGui::Image((void*)(uintptr_t) s->frame()->texture(), imagesize);
|
||||||
// image processing pannel
|
// image processing pannel
|
||||||
s->processingShader()->accept(v);
|
s->processingShader()->accept(v);
|
||||||
ImGui::Text("Geometry");
|
|
||||||
s->groupNode(View::GEOMETRY)->accept(v);
|
s->groupNode(View::GEOMETRY)->accept(v);
|
||||||
// delete button
|
// delete button
|
||||||
ImGui::Text(" ");
|
ImGui::Text(" ");
|
||||||
|
|||||||
46
View.cpp
46
View.cpp
@@ -349,23 +349,53 @@ void GeometryView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LayerView::LayerView() : View(LAYER)
|
||||||
|
{
|
||||||
|
// read default settings
|
||||||
|
if ( Settings::application.views[View::LAYER].name.empty() ) {
|
||||||
|
// no settings found: store application default
|
||||||
|
Settings::application.views[View::LAYER].name = "Layer";
|
||||||
|
scene.root()->scale_ = glm::vec3(1.0f, 1.0f, 1.0f);
|
||||||
|
saveSettings();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
restoreSettings();
|
||||||
|
|
||||||
void LayersView::draw ()
|
// Geometry Scene background
|
||||||
|
Surface *rect = new Surface;
|
||||||
|
scene.bg()->attach(rect);
|
||||||
|
|
||||||
|
Frame *border = new Frame(Frame::SHARP_THIN);
|
||||||
|
border->color = glm::vec4( 0.8f, 0.f, 0.8f, 1.f );
|
||||||
|
scene.bg()->attach(border);
|
||||||
|
}
|
||||||
|
|
||||||
|
LayerView::~LayerView()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayersView::zoom (float factor)
|
void LayerView::draw ()
|
||||||
|
{
|
||||||
|
// draw scene of this view
|
||||||
|
scene.root()->draw(glm::identity<glm::mat4>(), Rendering::manager().Projection());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayerView::zoom (float factor)
|
||||||
|
{
|
||||||
|
float z = scene.root()->scale_.x;
|
||||||
|
z = CLAMP( z + 0.1f * factor, 0.2f, 10.f);
|
||||||
|
scene.root()->scale_.x = z;
|
||||||
|
scene.root()->scale_.y = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayerView::drag (glm::vec2 from, glm::vec2 to)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayersView::drag (glm::vec2 from, glm::vec2 to)
|
void LayerView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2> pick)
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void LayersView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2> pick)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
6
View.h
6
View.h
@@ -79,11 +79,11 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class LayersView : public View
|
class LayerView : public View
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LayersView();
|
LayerView();
|
||||||
~LayersView();
|
~LayerView();
|
||||||
|
|
||||||
void draw () override;
|
void draw () override;
|
||||||
void zoom (float factor) override;
|
void zoom (float factor) override;
|
||||||
|
|||||||
Reference in New Issue
Block a user