work in progress: Mixer manage creation of sources

Views displayed independently
This commit is contained in:
brunoherbelin
2020-04-19 19:28:51 +02:00
parent 4f5a71970d
commit 8424d9a6c7
15 changed files with 279 additions and 156 deletions

View File

@@ -69,7 +69,12 @@ void ImGuiVisitor::visit(Group &n)
void ImGuiVisitor::visit(Switch &n) void ImGuiVisitor::visit(Switch &n)
{ {
// TODO : display selection of active child
}
void ImGuiVisitor::visit(Animation &n)
{
// TODO : display group and animation parameters
} }
void ImGuiVisitor::visit(Primitive &n) void ImGuiVisitor::visit(Primitive &n)
@@ -82,9 +87,9 @@ void ImGuiVisitor::visit(Primitive &n)
ImGui::PopID(); ImGui::PopID();
} }
void ImGuiVisitor::visit(ImageSurface &n) void ImGuiVisitor::visit(FrameBufferSurface &n)
{ {
ImGui::Text("Framebuffer");
} }
void ImGuiVisitor::visit(MediaSurface &n) void ImGuiVisitor::visit(MediaSurface &n)
@@ -127,26 +132,6 @@ void ImGuiVisitor::visit(ImageShader &n)
ImGui::PopID(); ImGui::PopID();
} }
void ImGuiVisitor::visit(LineStrip &n)
{
ImGui::Text("Lines");
}
void ImGuiVisitor::visit(LineSquare &n)
{
ImGui::Text("Square");
}
void ImGuiVisitor::visit(LineCircle &n)
{
ImGui::Text("Circle");
}
void ImGuiVisitor::visit(Mesh &n)
{
ImGui::Text("Mesh");
}
void ImGuiVisitor::visit(Scene &n) void ImGuiVisitor::visit(Scene &n)
{ {
ImGui::SetNextItemOpen(true, ImGuiCond_Once); ImGui::SetNextItemOpen(true, ImGuiCond_Once);

View File

@@ -9,22 +9,24 @@ public:
ImGuiVisitor(); ImGuiVisitor();
// Elements of Scene // Elements of Scene
void visit(Scene& n) override; void visit(Scene& n);
void visit(Node& n) override; void visit(Node& n);
void visit(Group& n) override; void visit(Group& n);
void visit(Switch& n) override; void visit(Switch& n);
void visit(Primitive& n) override; void visit(Animation& n);
void visit(ImageSurface& n) override; void visit(Primitive& n);
void visit(MediaSurface& n) override; void visit(ImageSurface&) {}
void visit(LineStrip& n) override; void visit(MediaSurface& n);
void visit(LineSquare& n) override; void visit(FrameBufferSurface& n);
void visit(LineCircle& n) override; void visit(LineStrip&) {}
void visit(Mesh& n) override; void visit(LineSquare&) {}
void visit(LineCircle&) {}
void visit(Mesh&) {}
// Elements with attributes // Elements with attributes
void visit(MediaPlayer& n) override; void visit(MediaPlayer& n);
void visit(Shader& n) override; void visit(Shader& n);
void visit(ImageShader& n) override; void visit(ImageShader& n);
}; };
#endif // IMGUIVISITOR_H #endif // IMGUIVISITOR_H

View File

@@ -21,7 +21,7 @@ void Mixer::update()
if (update_time_ == GST_CLOCK_TIME_NONE) if (update_time_ == GST_CLOCK_TIME_NONE)
update_time_ = gst_util_get_timestamp (); update_time_ = gst_util_get_timestamp ();
gint64 current_time = gst_util_get_timestamp (); gint64 current_time = gst_util_get_timestamp ();
gint64 dt = current_time - update_time_; float dt = static_cast<float>( GST_TIME_AS_MSECONDS(current_time - update_time_) ) * 0.001f;
update_time_ = current_time; update_time_ = current_time;
// render of all sources // render of all sources
@@ -29,8 +29,9 @@ void Mixer::update()
(*it)->render(); (*it)->render();
} }
// recursive update of all views // recursive update of ALL views
mixing_.update( static_cast<float>( GST_TIME_AS_MSECONDS(dt)) * 0.001f ); render_.update(dt);
mixing_.update(dt);
// TODO other views // TODO other views
@@ -49,6 +50,15 @@ void Mixer::draw()
// manangement of sources // manangement of sources
void Mixer::createSourceMedia(std::string uri) void Mixer::createSourceMedia(std::string uri)
{ {
// create source
MediaSource *m = new MediaSource("s", uri);
// add Nodes to ALL views
//
// Render Node
render_.scene.root()->addChild(m->group(View::RENDERING));
// Mixing Node
mixing_.scene.root()->addChild(m->group(View::MIXING));
} }
@@ -72,10 +82,10 @@ Source *Mixer::currentSource()
} }
// management of view // management of view
void Mixer::setCurrentView(viewMode m) void Mixer::setCurrentView(View::Mode m)
{ {
switch (m) { switch (m) {
case MIXING: case View::MIXING:
current_view_ = &mixing_; current_view_ = &mixing_;
break; break;
default: default:
@@ -84,12 +94,12 @@ void Mixer::setCurrentView(viewMode m)
} }
} }
View *Mixer::getView(viewMode m) View *Mixer::getView(View::Mode m)
{ {
switch (m) { switch (m) {
case RENDERING: case View::RENDERING:
return &render_; return &render_;
case MIXING: case View::MIXING:
return &mixing_; return &mixing_;
default: default:
return nullptr; return nullptr;

View File

@@ -14,8 +14,8 @@ class Mixer
{ {
// Private Constructor // Private Constructor
Mixer(); Mixer();
Mixer(Rendering const& copy); // Not Implemented Mixer(Mixer const& copy); // Not Implemented
Mixer& operator=(Rendering const& copy); // Not Implemented Mixer& operator=(Mixer const& copy); // Not Implemented
public: public:
@@ -40,9 +40,8 @@ public:
Source *currentSource(); Source *currentSource();
// management of view // management of view
typedef enum {RENDERING = 0, MIXING=1, GEOMETRY=2, LAYER=3, INVALID=4 } viewMode; View *getView(View::Mode m);
View *getView(viewMode m); void setCurrentView(View::Mode m);
void setCurrentView(viewMode m);
View *currentView(); View *currentView();
inline FrameBuffer *frame() const { return render_.frameBuffer(); } inline FrameBuffer *frame() const { return render_.frameBuffer(); }

View File

@@ -337,11 +337,8 @@ glm::mat4 Rendering::Projection()
glm::vec3 Rendering::unProject(glm::vec2 screen_coordinate, glm::mat4 modelview) glm::vec3 Rendering::unProject(glm::vec2 screen_coordinate, glm::mat4 modelview)
{ {
glm::vec3 coordinates = glm::vec3( screen_coordinate.x, -screen_coordinate.y, 0.f); glm::vec3 coordinates = glm::vec3( screen_coordinate.x, main_window_attributes_.viewport.y - screen_coordinate.y, 0.f);
glm::vec4 viewport = glm::vec4( 0.f, 0.f, main_window_attributes_.viewport.x, main_window_attributes_.viewport.y); glm::vec4 viewport = glm::vec4( 0.f, 0.f, main_window_attributes_.viewport.x, main_window_attributes_.viewport.y);
// glm::mat4 mv = glm::scale(modelview, glm::vec3(1.f, -1.f, 1.f));
// glm::mat4 mv = glm::inverse(modelview);
glm::vec3 point = glm::unProject(coordinates, modelview, Projection(), viewport); glm::vec3 point = glm::unProject(coordinates, modelview, Projection(), viewport);
return point; return point;

View File

@@ -175,7 +175,11 @@ void Primitive::deleteGLBuffers_()
Group::~Group() Group::~Group()
{ {
children_.clear(); // for(auto it = children_.begin(); it != children_.end(); )
// it = children_.erase(it);
// TODO vrify that desctructor of node is called
children_.erase(children_.begin(), children_.end());
} }
void Group::update( float dt ) void Group::update( float dt )
@@ -354,7 +358,7 @@ void Animation::update( float dt )
void Animation::accept(Visitor& v) void Animation::accept(Visitor& v)
{ {
Node::accept(v); Group::accept(v);
v.visit(*this); v.visit(*this);
} }

View File

@@ -60,6 +60,19 @@ void SessionVisitor::visit(Switch &n)
xmlCurrent_->SetAttribute("active", n.getIndexActiveChild()); xmlCurrent_->SetAttribute("active", n.getIndexActiveChild());
} }
void SessionVisitor::visit(Animation &n)
{
// Node 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
@@ -88,6 +101,12 @@ void SessionVisitor::visit(ImageSurface &n)
xmlCurrent_->InsertEndChild(image); xmlCurrent_->InsertEndChild(image);
} }
void SessionVisitor::visit(FrameBufferSurface &n)
{
// Node of a different type
xmlCurrent_->SetAttribute("type", "FrameBufferSurface");
}
void SessionVisitor::visit(MediaSurface &n) void SessionVisitor::visit(MediaSurface &n)
{ {
// Node of a different type // Node of a different type

View File

@@ -16,22 +16,24 @@ public:
tinyxml2::XMLElement *root() {return xmlRoot_;} tinyxml2::XMLElement *root() {return xmlRoot_;}
// Elements of Scene // Elements of Scene
void visit(Scene& n) override; void visit(Scene& n);
void visit(Node& n) override; void visit(Node& n);
void visit(Group& n) override; void visit(Group& n);
void visit(Switch& n) override; void visit(Switch& n);
void visit(Primitive& n) override; void visit(Animation& n);
void visit(ImageSurface& n) override; void visit(Primitive& n);
void visit(MediaSurface& n) override; void visit(ImageSurface& n);
void visit(LineStrip& n) override; void visit(MediaSurface& n);
void visit(LineSquare&) override; void visit(FrameBufferSurface& n);
void visit(LineCircle& n) override; void visit(LineStrip& n);
void visit(Mesh& n) override; void visit(LineSquare&);
void visit(LineCircle& n);
void visit(Mesh& n);
// Elements with attributes // Elements with attributes
void visit(MediaPlayer& n) override; void visit(MediaPlayer& n);
void visit(Shader& n) override; void visit(Shader& n);
void visit(ImageShader& n) override; void visit(ImageShader& n);
}; };
#endif // XMLVISITOR_H #endif // XMLVISITOR_H

View File

@@ -3,21 +3,45 @@
#include "Source.h" #include "Source.h"
#include "FrameBuffer.h"
#include "ImageShader.h"
#include "Primitives.h"
#include "Mesh.h"
#include "MediaPlayer.h"
// gobal static list of all sources // gobal static list of all sources
SourceList Source::sources_; SourceList Source::sources_;
Source::Source(std::string name = "") : name_("")
Source::Source(std::string name = "") : name_(""), buffer_(nullptr), shader_(nullptr), surface_(nullptr)
{ {
// set a name // set a name
rename(name); rename(name);
// create groups for each view
// default rendering node
groups_[View::RENDERING] = new Group;
groups_[View::RENDERING]->scale_ = glm::vec3(5.f, 5.f, 1.f); // fit height full window
// default mixing nodes
groups_[View::MIXING] = new Group;
Frame *frame = new Frame;
groups_[View::MIXING]->addChild(frame);
groups_[View::MIXING]->scale_ = glm::vec3(0.25f, 0.25f, 1.f);
// add source to the list // add source to the list
sources_.push_back(this); sources_.push_back(this);
} }
Source::~Source() Source::~Source()
{ {
// delete groups and their children
delete groups_[View::RENDERING];
delete groups_[View::MIXING];
groups_.clear();
// remove this source from the list
sources_.remove(this); sources_.remove(this);
} }
@@ -46,7 +70,6 @@ std::string Source::rename (std::string newname)
return name_; return name_;
} }
SourceList::iterator Source::begin() SourceList::iterator Source::begin()
{ {
return sources_.begin(); return sources_.begin();
@@ -61,3 +84,47 @@ uint Source::numSource()
{ {
return sources_.size(); return sources_.size();
} }
MediaSource::MediaSource(std::string name, std::string uri) : Source(name)
{
surface_ = new MediaSurface(uri);
// add the surface to draw in the views
groups_[View::RENDERING]->addChild(surface_);
groups_[View::MIXING]->addChild(surface_);
}
MediaSource::~MediaSource()
{
// TODO verify that surface_ node is deleted in Source destructor
}
Shader *MediaSource::shader() const
{
return surface_->shader();
}
std::string MediaSource::uri() const
{
return surface_->getUri();
}
MediaPlayer *MediaSource::mediaplayer() const
{
return surface_->getMediaPlayer();
}
void MediaSource::render()
{
// surface_->shader()
// scalle all mixing nodes to match scale of surface
for (NodeSet::iterator node = groups_[View::MIXING]->begin();
node != groups_[View::MIXING]->end(); node++) {
(*node)->scale_ = surface_->scale_;
}
// read position of the mixing node and interpret this as transparency change
}

View File

@@ -2,11 +2,16 @@
#define SOURCE_H #define SOURCE_H
#include <string> #include <string>
#include <map>
#include <list> #include <list>
#include "FrameBuffer.h" #include "View.h"
#include "ImageShader.h"
#include "Primitives.h" class ImageShader;
class Surface;
class FrameBuffer;
class MediaPlayer;
class MediaSurface;
class Source; class Source;
// TODO : source set sorted by shader // TODO : source set sorted by shader
@@ -17,6 +22,7 @@ class Source
{ {
public: public:
// create a source and add it to the list // create a source and add it to the list
// only subclasses of sources can actually be instanciated
Source(std::string name); Source(std::string name);
virtual ~Source(); virtual ~Source();
@@ -24,13 +30,13 @@ public:
inline std::string name () const { return name_; } inline std::string name () const { return name_; }
std::string rename (std::string newname); std::string rename (std::string newname);
// void setCustomShader(); // get handle on the node used to manipulate the source in a view
inline Shader *shader() const { return shader_; } inline Group *group(View::Mode m) { return groups_[m]; }
// for scene // every Source have a shader to control visual effects
inline FrameBufferSurface *surface() const { return surface_; } virtual Shader *shader() const = 0;
// only subclasses of sources can actually be instanciated // every Source shall be rendered before draw
virtual void render() = 0; virtual void render() = 0;
// global management of list of sources // global management of list of sources
@@ -42,12 +48,8 @@ protected:
// name // name
std::string name_; std::string name_;
// a source draws in a frame buffer an input using a given shader // nodes
FrameBuffer *buffer_; std::map<View::Mode, Group*> groups_;
ImageShader *shader_;
// a surface is used to draw in the scenes
FrameBufferSurface *surface_;
// static global list of sources // static global list of sources
static SourceList sources_; static SourceList sources_;
@@ -68,4 +70,25 @@ private:
}; };
class MediaSource : public Source
{
public:
MediaSource(std::string name, std::string uri);
~MediaSource();
void render();
// Source interface
Shader *shader() const;
// Media specific interface
std::string uri() const;
MediaPlayer *mediaplayer() const;
protected:
MediaSurface *surface_;
};
#endif // SOURCE_H #endif // SOURCE_H

View File

@@ -21,6 +21,7 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/string_cast.hpp>
// generic image loader // generic image loader
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
@@ -161,34 +162,47 @@ void UserInterface::handleMouse()
// if not on any window // if not on any window
if ( !ImGui::IsAnyWindowHovered() && !ImGui::IsAnyWindowFocused() ) if ( !ImGui::IsAnyWindowHovered() && !ImGui::IsAnyWindowFocused() )
{ {
ImGui::FocusWindow(0);
//
// Mouse wheel over background // Mouse wheel over background
//
if ( io.MouseWheel != 0) { if ( io.MouseWheel != 0) {
// scroll => zoom current view
Mixer::manager().currentView()->zoom( io.MouseWheel ); Mixer::manager().currentView()->zoom( io.MouseWheel );
}
//
// RIGHT Mouse button
//
if ( ImGui::IsMouseDown(ImGuiMouseButton_Right)) {
Log::Info("Right Mouse press (%.1f,%.1f)", io.MousePos.x, io.MousePos.y);
glm::vec3 point = Rendering::manager().unProject(glm::vec2(io.MousePos.x, io.MousePos.y),
Mixer::manager().currentView()->scene.root()->transform_ );
Log::Info(" (%.1f,%.1f)", point.x, point.y);
Log::Info(" wheel %.1f", io.MouseWheel);
} }
if ( ImGui::IsMouseDragging(ImGuiMouseButton_Right, 10.0f) ) if ( ImGui::IsMouseDragging(ImGuiMouseButton_Right, 10.0f) )
{ {
// Log::Info("Mouse drag (%.1f,%.1f)(%.1f,%.1f)", io.MouseDelta.x, io.MouseDelta.y, io.MousePos.x, io.MousePos.y); // right mouse drag => drag current view
Mixer::manager().currentView()->drag( glm::vec2(io.MouseClickedPos[ImGuiMouseButton_Right].x, io.MouseClickedPos[ImGuiMouseButton_Right].y), glm::vec2(io.MousePos.x, io.MousePos.y)); Mixer::manager().currentView()->drag( glm::vec2(io.MouseClickedPos[ImGuiMouseButton_Right].x, io.MouseClickedPos[ImGuiMouseButton_Right].y), glm::vec2(io.MousePos.x, io.MousePos.y));
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeAll); ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeAll);
} }
else { else
ImGui::SetMouseCursor(ImGuiMouseCursor_Arrow); ImGui::SetMouseCursor(ImGuiMouseCursor_Arrow);
}
//
// RIGHT Mouse button
//
if ( ImGui::IsMouseDown(ImGuiMouseButton_Left)) { if ( ImGui::IsMouseDown(ImGuiMouseButton_Left)) {
Log::Info("Mouse press (%.1f,%.1f)", io.MousePos.x, io.MousePos.y); Log::Info("Mouse press (%.1f,%.1f)", io.MousePos.x, io.MousePos.y);
glm::mat4 mv = glm::identity<glm::mat4>(); glm::vec3 point = Rendering::manager().unProject(glm::vec2(io.MousePos.x, io.MousePos.y),
glm::vec3 point = Rendering::manager().unProject(glm::vec2(io.MousePos.x, io.MousePos.y), mv); Mixer::manager().currentView()->scene.root()->transform_ );
Log::Info(" (%.1f,%.1f)", point.x, point.y); Log::Info(" (%.1f,%.1f)", point.x, point.y);

View File

@@ -23,6 +23,7 @@ void View::update(float dt)
MixingView::MixingView() : View() MixingView::MixingView() : View()
{ {
// Mixing scene
Mesh *disk = new Mesh("mesh/disk.ply", "images/transparencygrid.png"); Mesh *disk = new Mesh("mesh/disk.ply", "images/transparencygrid.png");
backgound_.addChild(disk); backgound_.addChild(disk);
@@ -30,26 +31,18 @@ MixingView::MixingView() : View()
LineCircle *circle = new LineCircle(pink, 5); LineCircle *circle = new LineCircle(pink, 5);
backgound_.addChild(circle); backgound_.addChild(circle);
scene.root()->addChild(&backgound_); scene.root()->addChild(&backgound_);
scene.root()->addChild(&foreground_);
// make sure there is no depth fight
// foreground.translation_ = glm::vec3(0.f, 0.f, 0.1f);
} }
MixingView::~MixingView() MixingView::~MixingView()
{ {
// delete background
for (NodeSet::iterator node = backgound_.begin(); node != backgound_.end(); node++) {
delete (*node);
}
} }
void MixingView::draw() void MixingView::draw()
{ {
// draw in main view // draw scene of this view
scene.root()->draw(glm::identity<glm::mat4>(), Rendering::manager().Projection()); scene.root()->draw(glm::identity<glm::mat4>(), Rendering::manager().Projection());
} }
@@ -104,7 +97,7 @@ void RenderView::setResolution(uint width, uint height)
void RenderView::draw() void RenderView::draw()
{ {
static glm::mat4 projection = glm::ortho(-SCENE_UNIT, SCENE_UNIT, -SCENE_UNIT, SCENE_UNIT, SCENE_DEPTH, 0.f); static glm::mat4 projection = glm::ortho(-SCENE_UNIT, SCENE_UNIT, -SCENE_UNIT, SCENE_UNIT, SCENE_DEPTH, 0.f);
glm::mat4 P = glm::scale( projection, glm::vec3(1.f, frame_buffer_->aspectRatio(), 1.f)); glm::mat4 P = glm::scale( projection, glm::vec3(1.f / frame_buffer_->aspectRatio(), 1.f, 1.f));
frame_buffer_->begin(); frame_buffer_->begin();
scene.root()->draw(glm::identity<glm::mat4>(), P); scene.root()->draw(glm::identity<glm::mat4>(), P);
frame_buffer_->end(); frame_buffer_->end();

4
View.h
View File

@@ -11,6 +11,8 @@ class View
public: public:
View(); View();
typedef enum {RENDERING = 0, MIXING=1, GEOMETRY=2, LAYER=3, INVALID=4 } Mode;
virtual void update (float dt); virtual void update (float dt);
virtual void draw () = 0; virtual void draw () = 0;
virtual void zoom (float) {} virtual void zoom (float) {}
@@ -20,7 +22,6 @@ public:
protected: protected:
Group backgound_; Group backgound_;
Group foreground_;
}; };
@@ -33,6 +34,7 @@ public:
void draw () override; void draw () override;
void zoom (float factor); void zoom (float factor);
void drag (glm::vec2 from, glm::vec2 to); void drag (glm::vec2 from, glm::vec2 to);
}; };
class RenderView : public View class RenderView : public View

View File

@@ -7,10 +7,12 @@
class Node; class Node;
class Group; class Group;
class Switch; class Switch;
class Animation;
class Primitive; class Primitive;
class Scene; class Scene;
class ImageSurface; class ImageSurface;
class MediaSurface; class MediaSurface;
class FrameBufferSurface;
class LineStrip; class LineStrip;
class LineSquare; class LineSquare;
class LineCircle; class LineCircle;
@@ -24,20 +26,23 @@ class Visitor {
public: public:
// Declare overloads for each kind of Node to visit // Declare overloads for each kind of Node to visit
virtual void visit(Scene& n) = 0; virtual void visit (Scene&) = 0;
virtual void visit(Node& n) = 0; virtual void visit (Node&) = 0;
virtual void visit(Group& n) = 0; virtual void visit (Group&) = 0;
virtual void visit(Switch& n) = 0; virtual void visit (Switch&) = 0;
virtual void visit(Primitive& n) = 0; virtual void visit (Animation&) = 0;
virtual void visit(ImageSurface& n) = 0; virtual void visit (Primitive&) = 0;
virtual void visit(MediaSurface& n) = 0; virtual void visit (ImageSurface&) = 0;
virtual void visit(LineStrip& n) = 0; virtual void visit (MediaSurface&) = 0;
virtual void visit(LineSquare& n) = 0; virtual void visit (FrameBufferSurface&) = 0;
virtual void visit(LineCircle& n) = 0; virtual void visit (LineStrip&) = 0;
virtual void visit(Mesh& n) = 0; virtual void visit (LineSquare&) = 0;
virtual void visit(MediaPlayer& n) = 0; virtual void visit (LineCircle&) = 0;
virtual void visit(Shader& n) = 0; virtual void visit (Mesh&) = 0;
virtual void visit(ImageShader& n) = 0;
virtual void visit (MediaPlayer&) = 0;
virtual void visit (Shader&) = 0;
virtual void visit (ImageShader&) = 0;
}; };

View File

@@ -31,7 +31,7 @@
#include "Mixer.h" #include "Mixer.h"
#include "RenderingManager.h" #include "RenderingManager.h"
#include "UserInterfaceManager.h" #include "UserInterfaceManager.h"
#include "FrameBuffer.h"
#include "MediaPlayer.h" #include "MediaPlayer.h"
#include "Scene.h" #include "Scene.h"
@@ -55,9 +55,9 @@
//// ("file:///Users/Herbelin/Movies/mp2test.mpg"); //// ("file:///Users/Herbelin/Movies/mp2test.mpg");
MediaSurface testnode1("file:///home/bhbn/Videos/iss.mov"); //MediaSurface testnode1("file:///home/bhbn/Videos/iss.mov");
MediaSurface testnode2("file:///home/bhbn/Videos/fish.mp4"); MediaSurface testnode2("file:///home/bhbn/Videos/fish.mp4");
ImageSurface testnode3("images/seed_512.jpg"); //ImageSurface testnode3("images/seed_512.jpg");
void drawMediaPlayer() void drawMediaPlayer()
@@ -200,7 +200,8 @@ void drawScene()
// draw GUI tree scene // draw GUI tree scene
ImGui::Begin(IMGUI_TITLE_MAINWINDOW); ImGui::Begin(IMGUI_TITLE_MAINWINDOW);
static ImGuiVisitor v; static ImGuiVisitor v;
Mixer::manager().currentView()->scene.accept(v); // Mixer::manager().currentView()->scene.accept(v);
Mixer::manager().getView(View::RENDERING)->scene.accept(v);
ImGui::End(); ImGui::End();
} }
@@ -255,56 +256,56 @@ int main(int, char**)
// UserInterface::manager().OpenTextEditor( Resource::getText("shaders/texture-shader.fs") ); // UserInterface::manager().OpenTextEditor( Resource::getText("shaders/texture-shader.fs") );
// init the scene // init the scene
Mixer::manager().setCurrentView(Mixer::MIXING); Mixer::manager().setCurrentView(View::MIXING);
Rendering::manager().PushFrontDrawCallback(drawScene); Rendering::manager().PushFrontDrawCallback(drawScene);
// init elements to the scene // init elements to the scene
//testnode3.getShader()->blending = Shader::BLEND_OPACITY; //testnode3.getShader()->blending = Shader::BLEND_OPACITY;
Mesh disk("mesh/disk.ply", "images/transparencygrid.png"); Mixer::manager().createSourceMedia("file:///home/bhbn/Videos/iss.mov");
Mixer::manager().createSourceMedia("file:///home/bhbn/Videos/fish.mp4");
glm::vec4 pink( 0.8f, 0.f, 0.8f, 1.f ); // Mesh disk("mesh/disk.ply", "images/transparencygrid.png");
LineCircle circle(pink, 5);
// glm::vec4 pink( 0.8f, 0.f, 0.8f, 1.f );
// LineCircle circle(pink, 5);
// glm::vec4 color( 0.8f, 0.8f, 0.f, 1.f); // glm::vec4 color( 0.8f, 0.8f, 0.f, 1.f);
// LineSquare border(color, 5); // LineSquare border(color, 5);
// Mesh shadow("mesh/shadow.ply", "mesh/shadow.png"); // Mesh shadow("mesh/shadow.ply", "mesh/shadow.png");
// Mesh meshicon("mesh/icon_video.ply"); // Mesh meshicon("mesh/icon_video.ply");
Frame frame; // Frame frame;
frame.scale_ = glm::vec3(1.7777778f, 1.f, 1.f); // frame.scale_ = glm::vec3(1.7777778f, 1.f, 1.f);
Group g1; // Group g1;
g1.translation_ = glm::vec3(1.f, 1.f, 1.f); // g1.translation_ = glm::vec3(1.f, 1.f, 1.f);
g1.scale_ = glm::vec3(0.8f, 0.8f, 1.f); // g1.scale_ = glm::vec3(0.8f, 0.8f, 1.f);
Group g2; // Group g2;
g2.translation_ = glm::vec3(-1.f, -1.f, 2.f); // g2.translation_ = glm::vec3(-1.f, -1.f, 2.f);
Animation A; // Animation A;
A.translation_ = glm::vec3(0.f, 0.f, 3.f); // A.translation_ = glm::vec3(0.f, 0.f, 3.f);
A.speed_ = 0.1f; // A.speed_ = 0.1f;
A.axis_ = glm::vec3(1.f, 1.f, 1.f); // A.axis_ = glm::vec3(1.f, 1.f, 1.f);
// std::vector<glm::vec3> pts = std::vector<glm::vec3> { glm::vec3( 0.f, 0.f, 0.f ) }; //// std::vector<glm::vec3> pts = std::vector<glm::vec3> { glm::vec3( 0.f, 0.f, 0.f ) };
// Points P(pts, pink); //// Points P(pts, pink);
// P.setPointSize(60); //// P.setPointSize(60);
Mesh P("mesh/point.ply"); // Mesh P("mesh/point.ply");
P.scale_ = glm::vec3(0.15f); // P.scale_ = glm::vec3(0.15f);
// build tree
Mixer::manager().currentView()->scene.root()->addChild(&disk);
Mixer::manager().currentView()->scene.root()->addChild(&circle);
g1.addChild(&testnode3); // g1.addChild(&testnode3);
Mixer::manager().currentView()->scene.root()->addChild(&g1); // Mixer::manager().currentView()->scene.root()->addChild(&g1);
g2.addChild(&testnode1); // g2.addChild(&testnode1);
g2.addChild(&frame); // g2.addChild(&frame);
Mixer::manager().currentView()->scene.root()->addChild(&g2); // Mixer::manager().currentView()->scene.root()->addChild(&g2);
A.addChild(&P); // A.addChild(&P);
Mixer::manager().currentView()->scene.root()->addChild(&A); // Mixer::manager().currentView()->scene.root()->addChild(&A);
// init output FBO // init output FBO
Rendering::manager().PushBackDrawCallback(drawPreview); Rendering::manager().PushBackDrawCallback(drawPreview);