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
|
||||
{
|
||||
return static_cast<float>(width()) / static_cast<float>(height());
|
||||
return static_cast<float>(attrib_.viewport.x) / static_cast<float>(attrib_.viewport.y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -35,37 +35,48 @@ void ImGuiVisitor::visit(Group &n)
|
||||
// if (ImGui::TreeNode(id.c_str(), "Group %d", n.id()))
|
||||
// {
|
||||
// MODEL VIEW
|
||||
if (ImGuiToolkit::ButtonIcon(6, 15)) {
|
||||
n.translation_.x = 0.f;
|
||||
n.translation_.y = 0.f;
|
||||
}
|
||||
ImGui::SameLine(0, 10);
|
||||
float translation[2] = { n.translation_.x, n.translation_.y};
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
if ( ImGui::SliderFloat2("position", translation, -5.0, 5.0) )
|
||||
{
|
||||
n.translation_.x = translation[0];
|
||||
n.translation_.y = translation[1];
|
||||
}
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(4, 15))
|
||||
n.rotation_.z = 0.f;
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
ImGui::SliderAngle("angle", &(n.rotation_.z), -180.f, 180.f) ;
|
||||
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(3, 15)) {
|
||||
n.scale_.x = 1.f;
|
||||
n.scale_.y = 1.f;
|
||||
}
|
||||
ImGui::SameLine(0, 10);
|
||||
float scale[2] = { n.scale_.x, n.scale_.y} ;
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
if ( ImGui::SliderFloat2("scale", scale, -5.0, 5.0, "%.2f") )
|
||||
{
|
||||
n.scale_.x = scale[0];
|
||||
n.scale_.y = scale[1];
|
||||
}
|
||||
if (ImGuiToolkit::ButtonIcon(6, 15)) {
|
||||
n.translation_.x = 0.f;
|
||||
n.translation_.y = 0.f;
|
||||
}
|
||||
ImGui::SameLine(0, 10);
|
||||
float translation[2] = { n.translation_.x, n.translation_.y};
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
if ( ImGui::SliderFloat2("position", translation, -5.0, 5.0) )
|
||||
{
|
||||
n.translation_.x = translation[0];
|
||||
n.translation_.y = translation[1];
|
||||
}
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(18, 9))
|
||||
n.rotation_.z = 0.f;
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
ImGui::SliderAngle("angle", &(n.rotation_.z), -180.f, 180.f) ;
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(3, 15)) {
|
||||
n.scale_.x = 1.f;
|
||||
n.scale_.y = 1.f;
|
||||
}
|
||||
ImGui::SameLine(0, 10);
|
||||
float scale[2] = { n.scale_.x, n.scale_.y} ;
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
if ( ImGui::SliderFloat2("scale", scale, -5.0, 5.0, "%.2f") )
|
||||
{
|
||||
n.scale_.x = scale[0];
|
||||
n.scale_.y = scale[1];
|
||||
}
|
||||
|
||||
// // loop over members of a group
|
||||
// for (NodeSet::iterator node = n.begin(); node != n.end(); node++) {
|
||||
|
||||
5
Mesh.cpp
5
Mesh.cpp
@@ -466,10 +466,9 @@ Handles::Handles(Type type) : Node(), type_(type)
|
||||
|
||||
if ( type_ == ROTATE ) {
|
||||
handle_ = new Mesh("mesh/border_handles_rotation.ply");
|
||||
// handle_->scale_ = glm::vec3( 0.01f, 0.01f, 1.f);
|
||||
}
|
||||
else {
|
||||
handle_ = new LineSquare(color, 3);
|
||||
handle_ = new LineSquare(color, 2);
|
||||
handle_->scale_ = glm::vec3( 0.05f, 0.05f, 1.f);
|
||||
}
|
||||
// handle_ = new Mesh("mesh/border_handles_overlay.ply");
|
||||
@@ -499,7 +498,6 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
|
||||
|
||||
// set color
|
||||
handle_->shader()->color = color;
|
||||
// handle_->scale_ = glm::vec3( 0.01f, 0.01f, 1.f);
|
||||
|
||||
glm::mat4 ctm;
|
||||
|
||||
@@ -535,7 +533,6 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
|
||||
}
|
||||
else if ( type_ == ROTATE ){
|
||||
// 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);
|
||||
ctm = GlmToolkit::transform(glm::vec3(pos), glm::vec3(0.f), glm::vec3(1.f));
|
||||
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));
|
||||
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" );
|
||||
render->InsertEndChild( SessionVisitor::NodeToXML(*session->config(View::RENDERING), &xmlDoc));
|
||||
views->InsertEndChild(render);
|
||||
@@ -157,6 +161,7 @@ void Mixer::update()
|
||||
// update views
|
||||
mixing_.update(dt);
|
||||
geometry_.update(dt);
|
||||
layer_.update(dt);
|
||||
// TODO other views
|
||||
|
||||
|
||||
@@ -190,11 +195,10 @@ void Mixer::insertSource(Source *s)
|
||||
// Add source to Session and set it as current
|
||||
setCurrentSource( session_->addSource(s) );
|
||||
|
||||
// add sources Nodes to ALL views
|
||||
// Mixing Node
|
||||
// add sources Nodes to all views
|
||||
mixing_.scene.fg()->attach(s->group(View::MIXING));
|
||||
// Geometry Node
|
||||
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..
|
||||
unsetCurrentSource();
|
||||
|
||||
// remove source Nodes from views
|
||||
// remove source Nodes from all views
|
||||
mixing_.scene.fg()->detatch( s->group(View::MIXING) );
|
||||
geometry_.scene.fg()->detatch( s->group(View::GEOMETRY) );
|
||||
layer_.scene.fg()->detatch( s->group(View::LAYER) );
|
||||
|
||||
// delete source
|
||||
session_->deleteSource(s);
|
||||
@@ -309,6 +314,9 @@ void Mixer::setCurrentView(View::Mode m)
|
||||
case View::GEOMETRY:
|
||||
current_view_ = &geometry_;
|
||||
break;
|
||||
case View::LAYER:
|
||||
current_view_ = &layer_;
|
||||
break;
|
||||
case View::MIXING:
|
||||
default:
|
||||
current_view_ = &mixing_;
|
||||
@@ -323,6 +331,8 @@ View *Mixer::getView(View::Mode m)
|
||||
switch (m) {
|
||||
case View::GEOMETRY:
|
||||
return &geometry_;
|
||||
case View::LAYER:
|
||||
return &layer_;
|
||||
case View::MIXING:
|
||||
return &mixing_;
|
||||
default:
|
||||
@@ -352,6 +362,7 @@ void Mixer::saveas(const std::string& filename)
|
||||
// optional copy of views config
|
||||
session_->config(View::MIXING)->copyTransform( mixing_.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
|
||||
std::thread (saveSession, filename, session_).detach();
|
||||
@@ -386,6 +397,7 @@ void Mixer::swap()
|
||||
{
|
||||
mixing_.scene.fg()->detatch( (*source_iter)->group(View::MIXING) );
|
||||
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) );
|
||||
geometry_.scene.fg()->attach( (*source_iter)->group(View::GEOMETRY) );
|
||||
layer_.scene.fg()->attach( (*source_iter)->group(View::LAYER) );
|
||||
}
|
||||
|
||||
// optional copy of views config
|
||||
mixing_.scene.root()->copyTransform( session_->config(View::MIXING) );
|
||||
geometry_.scene.root()->copyTransform( session_->config(View::GEOMETRY) );
|
||||
layer_.scene.root()->copyTransform( session_->config(View::LAYER) );
|
||||
|
||||
// set resolution
|
||||
session_->setResolution( session_->config(View::RENDERING)->scale_ );
|
||||
|
||||
1
Mixer.h
1
Mixer.h
@@ -82,6 +82,7 @@ protected:
|
||||
|
||||
MixingView mixing_;
|
||||
GeometryView geometry_;
|
||||
LayerView layer_;
|
||||
View *current_view_;
|
||||
|
||||
gint64 update_time_;
|
||||
|
||||
@@ -10,6 +10,7 @@ Session::Session()
|
||||
config_[View::RENDERING] = new Group;
|
||||
config_[View::RENDERING]->scale_ = render_.resolution();
|
||||
config_[View::GEOMETRY] = new Group;
|
||||
config_[View::LAYER] = new Group;
|
||||
config_[View::MIXING] = new Group;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,6 +85,7 @@ void SessionCreator::loadConfig(XMLElement *viewsNode)
|
||||
// ok, ready to read views
|
||||
SessionCreator::XMLToNode( viewsNode->FirstChildElement("Mixing"), *session_->config(View::MIXING));
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,11 @@ Source::Source(const std::string &name) : name_(name), initialized_(false)
|
||||
|
||||
// default mixing nodes
|
||||
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]->translation_.z = 0.15;
|
||||
overlays_[View::LAYER]->visible_ = false;
|
||||
|
||||
@@ -978,7 +978,7 @@ void Navigator::Render()
|
||||
}
|
||||
if (ImGui::Selectable( ICON_FA_LAYER_GROUP, &selected_view[3], 0, iconsize))
|
||||
{
|
||||
// TODO : Layers view
|
||||
Mixer::manager().setCurrentView(View::LAYER);
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
@@ -1049,7 +1049,6 @@ void Navigator::RenderSourcePannel(Source *s)
|
||||
ImGui::Image((void*)(uintptr_t) s->frame()->texture(), imagesize);
|
||||
// image processing pannel
|
||||
s->processingShader()->accept(v);
|
||||
ImGui::Text("Geometry");
|
||||
s->groupNode(View::GEOMETRY)->accept(v);
|
||||
// delete button
|
||||
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 LayersView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2> pick)
|
||||
void LayerView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2> pick)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user