mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Tentative design of Layer View. Fix of UV coordinates for Mesh.
This commit is contained in:
@@ -259,6 +259,7 @@ set(VMIX_RSC_FILES
|
|||||||
./rsc/images/transparencygrid.png
|
./rsc/images/transparencygrid.png
|
||||||
./rsc/images/shadow.png
|
./rsc/images/shadow.png
|
||||||
./rsc/images/shadow_dark.png
|
./rsc/images/shadow_dark.png
|
||||||
|
./rsc/images/shadow_perspective.png
|
||||||
./rsc/mesh/point.ply
|
./rsc/mesh/point.ply
|
||||||
./rsc/mesh/disk.ply
|
./rsc/mesh/disk.ply
|
||||||
./rsc/mesh/shadow.ply
|
./rsc/mesh/shadow.ply
|
||||||
@@ -270,6 +271,8 @@ set(VMIX_RSC_FILES
|
|||||||
./rsc/mesh/border_handles_overlay.ply
|
./rsc/mesh/border_handles_overlay.ply
|
||||||
./rsc/mesh/border_large_sharp.ply
|
./rsc/mesh/border_large_sharp.ply
|
||||||
./rsc/mesh/border_vertical_overlay.ply
|
./rsc/mesh/border_vertical_overlay.ply
|
||||||
|
./rsc/mesh/perspective_layer.ply
|
||||||
|
./rsc/mesh/shadow_perspective.ply
|
||||||
./rsc/mesh/circle.ply
|
./rsc/mesh/circle.ply
|
||||||
./rsc/mesh/icon_video.ply
|
./rsc/mesh/icon_video.ply
|
||||||
./rsc/mesh/icon_image.ply
|
./rsc/mesh/icon_image.ply
|
||||||
|
|||||||
8
Mesh.cpp
8
Mesh.cpp
@@ -247,7 +247,7 @@ bool parsePLY(string ascii,
|
|||||||
has_uv = true;
|
has_uv = true;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
uv.y = parseValue<float>(stringstream);
|
uv.y = -parseValue<float>(stringstream);
|
||||||
has_uv = true;
|
has_uv = true;
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
@@ -403,6 +403,10 @@ Frame::Frame(Type style) : Node()
|
|||||||
border_ = new Mesh("mesh/border_round.ply");
|
border_ = new Mesh("mesh/border_round.ply");
|
||||||
shadow_ = new Mesh("mesh/shadow.ply", "images/shadow.png");
|
shadow_ = new Mesh("mesh/shadow.ply", "images/shadow.png");
|
||||||
break;
|
break;
|
||||||
|
case ROUND_SHADOW:
|
||||||
|
border_ = new Mesh("mesh/border_round.ply");
|
||||||
|
shadow_ = new Mesh("mesh/shadow_perspective.ply", "images/shadow_perspective.png");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,7 +475,7 @@ Handles::Handles(Type type) : Node(), type_(type)
|
|||||||
handle_ = new LineSquare(color, 2);
|
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Handles::~Handles()
|
Handles::~Handles()
|
||||||
|
|||||||
2
Mesh.h
2
Mesh.h
@@ -38,7 +38,7 @@ class Frame : public Node
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef enum { ROUND_THIN = 0, ROUND_LARGE, SHARP_THIN, SHARP_LARGE } Type;
|
typedef enum { ROUND_THIN = 0, ROUND_LARGE, SHARP_THIN, SHARP_LARGE, ROUND_SHADOW } Type;
|
||||||
Frame(Type style);
|
Frame(Type style);
|
||||||
~Frame();
|
~Frame();
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ 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 = new Frame(Frame::ROUND_SHADOW);
|
||||||
frame->translation_.z = 0.1;
|
frame->translation_.z = 0.1;
|
||||||
frame->color = glm::vec4( COLOR_DEFAULT_SOURCE, 0.9f);
|
frame->color = glm::vec4( COLOR_DEFAULT_SOURCE, 0.9f);
|
||||||
groups_[View::LAYER]->attach(frame);
|
groups_[View::LAYER]->attach(frame);
|
||||||
@@ -259,6 +259,10 @@ void MediaSource::init()
|
|||||||
node != groups_[View::GEOMETRY]->end(); node++) {
|
node != groups_[View::GEOMETRY]->end(); node++) {
|
||||||
(*node)->scale_.x = mediaplayer_->aspectRatio();
|
(*node)->scale_.x = mediaplayer_->aspectRatio();
|
||||||
}
|
}
|
||||||
|
for (NodeSet::iterator node = groups_[View::LAYER]->begin();
|
||||||
|
node != groups_[View::LAYER]->end(); node++) {
|
||||||
|
(*node)->scale_.x = mediaplayer_->aspectRatio();
|
||||||
|
}
|
||||||
|
|
||||||
// done init once and for all
|
// done init once and for all
|
||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
|
|||||||
@@ -253,6 +253,8 @@ void UserInterface::handleKeyboard()
|
|||||||
Mixer::manager().setCurrentView(View::MIXING);
|
Mixer::manager().setCurrentView(View::MIXING);
|
||||||
else if (ImGui::IsKeyPressed( GLFW_KEY_F2 ))
|
else if (ImGui::IsKeyPressed( GLFW_KEY_F2 ))
|
||||||
Mixer::manager().setCurrentView(View::GEOMETRY);
|
Mixer::manager().setCurrentView(View::GEOMETRY);
|
||||||
|
else if (ImGui::IsKeyPressed( GLFW_KEY_F3 ))
|
||||||
|
Mixer::manager().setCurrentView(View::LAYER);
|
||||||
else if (ImGui::IsKeyPressed( GLFW_KEY_F11 ))
|
else if (ImGui::IsKeyPressed( GLFW_KEY_F11 ))
|
||||||
Rendering::manager().ToggleFullscreen();
|
Rendering::manager().ToggleFullscreen();
|
||||||
else if (ImGui::IsKeyPressed( GLFW_KEY_ESCAPE )){
|
else if (ImGui::IsKeyPressed( GLFW_KEY_ESCAPE )){
|
||||||
|
|||||||
99
View.cpp
99
View.cpp
@@ -44,6 +44,24 @@ void View::update(float dt)
|
|||||||
scene.update( dt );
|
scene.update( dt );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void View::drag (glm::vec2 from, glm::vec2 to)
|
||||||
|
{
|
||||||
|
static glm::vec3 start_translation = glm::vec3(0.f);
|
||||||
|
static glm::vec2 start_position = glm::vec2(0.f);
|
||||||
|
|
||||||
|
if ( start_position != from ) {
|
||||||
|
start_position = from;
|
||||||
|
start_translation = scene.root()->translation_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// unproject
|
||||||
|
glm::vec3 gl_Position_from = Rendering::manager().unProject(from);
|
||||||
|
glm::vec3 gl_Position_to = Rendering::manager().unProject(to);
|
||||||
|
|
||||||
|
// compute delta translation
|
||||||
|
scene.root()->translation_ = start_translation + gl_Position_to - gl_Position_from;
|
||||||
|
}
|
||||||
|
|
||||||
MixingView::MixingView() : View(MIXING)
|
MixingView::MixingView() : View(MIXING)
|
||||||
{
|
{
|
||||||
// read default settings
|
// read default settings
|
||||||
@@ -88,24 +106,6 @@ void MixingView::zoom( float factor )
|
|||||||
scene.root()->scale_.y = z;
|
scene.root()->scale_.y = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MixingView::drag (glm::vec2 from, glm::vec2 to)
|
|
||||||
{
|
|
||||||
static glm::vec3 start_translation = glm::vec3(0.f);
|
|
||||||
static glm::vec2 start_position = glm::vec2(0.f);
|
|
||||||
|
|
||||||
if ( start_position != from ) {
|
|
||||||
start_position = from;
|
|
||||||
start_translation = scene.root()->translation_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// unproject
|
|
||||||
glm::vec3 gl_Position_from = Rendering::manager().unProject(from);
|
|
||||||
glm::vec3 gl_Position_to = Rendering::manager().unProject(to);
|
|
||||||
|
|
||||||
// compute delta translation
|
|
||||||
scene.root()->translation_ = start_translation + gl_Position_to - gl_Position_from;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MixingView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2>)
|
void MixingView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2>)
|
||||||
{
|
{
|
||||||
@@ -264,25 +264,6 @@ void GeometryView::zoom( float factor )
|
|||||||
scene.root()->scale_.y = z;
|
scene.root()->scale_.y = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometryView::drag (glm::vec2 from, glm::vec2 to)
|
|
||||||
{
|
|
||||||
static glm::vec3 start_translation = glm::vec3(0.f);
|
|
||||||
static glm::vec2 start_position = glm::vec2(0.f);
|
|
||||||
|
|
||||||
if ( start_position != from ) {
|
|
||||||
start_position = from;
|
|
||||||
start_translation = scene.root()->translation_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// unproject
|
|
||||||
glm::vec3 gl_Position_from = Rendering::manager().unProject(from);
|
|
||||||
glm::vec3 gl_Position_to = Rendering::manager().unProject(to);
|
|
||||||
|
|
||||||
// compute delta translation
|
|
||||||
scene.root()->translation_ = start_translation + gl_Position_to - gl_Position_from;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GeometryView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2> pick)
|
void GeometryView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2> pick)
|
||||||
{
|
{
|
||||||
// work on the given source
|
// work on the given source
|
||||||
@@ -349,7 +330,7 @@ void GeometryView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerView::LayerView() : View(LAYER)
|
LayerView::LayerView() : View(LAYER), aspect_ratio(1.f)
|
||||||
{
|
{
|
||||||
// read default settings
|
// read default settings
|
||||||
if ( Settings::application.views[View::LAYER].name.empty() ) {
|
if ( Settings::application.views[View::LAYER].name.empty() ) {
|
||||||
@@ -365,9 +346,14 @@ LayerView::LayerView() : View(LAYER)
|
|||||||
Surface *rect = new Surface;
|
Surface *rect = new Surface;
|
||||||
scene.bg()->attach(rect);
|
scene.bg()->attach(rect);
|
||||||
|
|
||||||
|
Mesh *persp = new Mesh("mesh/perspective_layer.ply");
|
||||||
|
persp->translation_.z = -0.1f;
|
||||||
|
scene.bg()->attach(persp);
|
||||||
|
|
||||||
Frame *border = new Frame(Frame::SHARP_THIN);
|
Frame *border = new Frame(Frame::SHARP_THIN);
|
||||||
border->color = glm::vec4( 0.8f, 0.f, 0.8f, 1.f );
|
border->color = glm::vec4( 0.8f, 0.f, 0.8f, 1.f );
|
||||||
scene.bg()->attach(border);
|
scene.bg()->attach(border);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerView::~LayerView()
|
LayerView::~LayerView()
|
||||||
@@ -377,6 +363,15 @@ LayerView::~LayerView()
|
|||||||
|
|
||||||
void LayerView::draw ()
|
void LayerView::draw ()
|
||||||
{
|
{
|
||||||
|
// update rendering of render frame
|
||||||
|
FrameBuffer *output = Mixer::manager().session()->frame();
|
||||||
|
if (output)
|
||||||
|
aspect_ratio = output->aspectRatio();
|
||||||
|
|
||||||
|
for (NodeSet::iterator node = scene.bg()->begin(); node != scene.bg()->end(); node++) {
|
||||||
|
(*node)->scale_.x = aspect_ratio;
|
||||||
|
}
|
||||||
|
|
||||||
// draw scene of this 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());
|
||||||
|
|
||||||
@@ -390,13 +385,33 @@ void LayerView::zoom (float factor)
|
|||||||
scene.root()->scale_.y = z;
|
scene.root()->scale_.y = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerView::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 LayerView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2> pick)
|
||||||
{
|
{
|
||||||
|
if (!s)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Group *sourceNode = s->group(View::LAYER);
|
||||||
|
|
||||||
|
static glm::vec3 start_translation = glm::vec3(0.f);
|
||||||
|
static glm::vec2 start_position = glm::vec2(0.f);
|
||||||
|
|
||||||
|
if ( start_position != from ) {
|
||||||
|
start_position = from;
|
||||||
|
start_translation = sourceNode->translation_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// unproject
|
||||||
|
glm::vec3 gl_Position_from = Rendering::manager().unProject(from, scene.root()->transform_);
|
||||||
|
glm::vec3 gl_Position_to = Rendering::manager().unProject(to, scene.root()->transform_);
|
||||||
|
|
||||||
|
// compute delta translation
|
||||||
|
sourceNode->translation_ = start_translation + gl_Position_to - gl_Position_from;
|
||||||
|
|
||||||
|
// diagonal movement only
|
||||||
|
sourceNode->translation_.x = CLAMP( sourceNode->translation_.x, -10.f, 0.f);
|
||||||
|
sourceNode->translation_.y = sourceNode->translation_.x / aspect_ratio;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
7
View.h
7
View.h
@@ -19,7 +19,7 @@ public:
|
|||||||
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) {}
|
||||||
virtual void drag (glm::vec2, glm::vec2) {}
|
virtual void drag (glm::vec2, glm::vec2);
|
||||||
virtual void grab (glm::vec2, glm::vec2, Source*, std::pair<Node *, glm::vec2>) {}
|
virtual void grab (glm::vec2, glm::vec2, Source*, std::pair<Node *, glm::vec2>) {}
|
||||||
|
|
||||||
virtual void restoreSettings();
|
virtual void restoreSettings();
|
||||||
@@ -40,7 +40,6 @@ public:
|
|||||||
|
|
||||||
void draw () override;
|
void draw () override;
|
||||||
void zoom (float factor) override;
|
void zoom (float factor) override;
|
||||||
void drag (glm::vec2 from, glm::vec2 to) override;
|
|
||||||
void grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2>) override;
|
void grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2>) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -72,7 +71,6 @@ public:
|
|||||||
|
|
||||||
void draw () override;
|
void draw () override;
|
||||||
void zoom (float factor) override;
|
void zoom (float factor) override;
|
||||||
void drag (glm::vec2 from, glm::vec2 to) override;
|
|
||||||
void grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2> pick) override;
|
void grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2> pick) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -87,11 +85,10 @@ public:
|
|||||||
|
|
||||||
void draw () override;
|
void draw () override;
|
||||||
void zoom (float factor) override;
|
void zoom (float factor) override;
|
||||||
void drag (glm::vec2 from, glm::vec2 to) override;
|
|
||||||
void grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2> pick) override;
|
void grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2> pick) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
float aspect_ratio;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ property uchar alpha
|
|||||||
element face 8
|
element face 8
|
||||||
property list uchar uint vertex_indices
|
property list uchar uint vertex_indices
|
||||||
end_header
|
end_header
|
||||||
1.000000 -1.000000 0.000000 0.202616 0.797384 255 255 255 255
|
1.000000 -1.000000 0.000000 0.827672 0.172328 255 255 255 255
|
||||||
-1.300000 -1.300000 0.000000 1.000000 1.000000 255 255 255 65
|
-1.300000 -1.300000 0.000000 -0.002507 -0.002507 255 255 255 0
|
||||||
1.300000 -1.300000 0.000000 0.000000 1.000000 255 255 255 65
|
1.300000 -1.300000 0.000000 1.002507 -0.002507 255 255 255 0
|
||||||
-1.000000 -1.000000 0.000000 0.797384 0.797384 255 255 255 255
|
-1.000000 -1.000000 0.000000 0.172328 0.172328 255 255 255 255
|
||||||
-1.300000 1.300000 0.000000 1.000000 0.000000 255 255 255 65
|
-1.300000 1.300000 0.000000 -0.002507 1.002507 255 255 255 0
|
||||||
1.000000 1.000000 0.000000 0.202616 0.202616 255 255 255 255
|
1.000000 1.000000 0.000000 0.827672 0.827672 255 255 255 255
|
||||||
1.300000 1.300000 0.000000 0.000000 0.000000 255 255 255 65
|
1.300000 1.300000 0.000000 1.002507 1.002507 255 255 255 0
|
||||||
-1.000000 1.000000 0.000000 0.797384 0.202616 255 255 255 255
|
-1.000000 1.000000 0.000000 0.172328 0.827672 255 255 255 255
|
||||||
3 0 1 2
|
3 0 1 2
|
||||||
3 3 4 1
|
3 3 4 1
|
||||||
3 5 2 6
|
3 5 2 6
|
||||||
|
|||||||
Reference in New Issue
Block a user