Tentative design of Layer View. Fix of UV coordinates for Mesh.

This commit is contained in:
brunoherbelin
2020-05-17 22:27:38 +02:00
parent 569a097c4a
commit 69a58de026
8 changed files with 84 additions and 59 deletions

View File

@@ -259,6 +259,7 @@ set(VMIX_RSC_FILES
./rsc/images/transparencygrid.png
./rsc/images/shadow.png
./rsc/images/shadow_dark.png
./rsc/images/shadow_perspective.png
./rsc/mesh/point.ply
./rsc/mesh/disk.ply
./rsc/mesh/shadow.ply
@@ -270,6 +271,8 @@ set(VMIX_RSC_FILES
./rsc/mesh/border_handles_overlay.ply
./rsc/mesh/border_large_sharp.ply
./rsc/mesh/border_vertical_overlay.ply
./rsc/mesh/perspective_layer.ply
./rsc/mesh/shadow_perspective.ply
./rsc/mesh/circle.ply
./rsc/mesh/icon_video.ply
./rsc/mesh/icon_image.ply

View File

@@ -247,7 +247,7 @@ bool parsePLY(string ascii,
has_uv = true;
break;
case 't':
uv.y = parseValue<float>(stringstream);
uv.y = -parseValue<float>(stringstream);
has_uv = true;
break;
case 'r':
@@ -403,6 +403,10 @@ Frame::Frame(Type style) : Node()
border_ = new Mesh("mesh/border_round.ply");
shadow_ = new Mesh("mesh/shadow.ply", "images/shadow.png");
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_->scale_ = glm::vec3( 0.05f, 0.05f, 1.f);
}
// handle_ = new Mesh("mesh/border_handles_overlay.ply");
}
Handles::~Handles()

2
Mesh.h
View File

@@ -38,7 +38,7 @@ class Frame : public Node
{
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();

View File

@@ -50,7 +50,7 @@ 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 = new Frame(Frame::ROUND_SHADOW);
frame->translation_.z = 0.1;
frame->color = glm::vec4( COLOR_DEFAULT_SOURCE, 0.9f);
groups_[View::LAYER]->attach(frame);
@@ -259,6 +259,10 @@ void MediaSource::init()
node != groups_[View::GEOMETRY]->end(); node++) {
(*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
initialized_ = true;

View File

@@ -253,6 +253,8 @@ void UserInterface::handleKeyboard()
Mixer::manager().setCurrentView(View::MIXING);
else if (ImGui::IsKeyPressed( GLFW_KEY_F2 ))
Mixer::manager().setCurrentView(View::GEOMETRY);
else if (ImGui::IsKeyPressed( GLFW_KEY_F3 ))
Mixer::manager().setCurrentView(View::LAYER);
else if (ImGui::IsKeyPressed( GLFW_KEY_F11 ))
Rendering::manager().ToggleFullscreen();
else if (ImGui::IsKeyPressed( GLFW_KEY_ESCAPE )){

View File

@@ -44,6 +44,24 @@ void View::update(float 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)
{
// read default settings
@@ -88,24 +106,6 @@ void MixingView::zoom( float factor )
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>)
{
@@ -264,25 +264,6 @@ void GeometryView::zoom( float factor )
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)
{
// 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
if ( Settings::application.views[View::LAYER].name.empty() ) {
@@ -365,9 +346,14 @@ LayerView::LayerView() : View(LAYER)
Surface *rect = new Surface;
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);
border->color = glm::vec4( 0.8f, 0.f, 0.8f, 1.f );
scene.bg()->attach(border);
}
LayerView::~LayerView()
@@ -377,6 +363,15 @@ LayerView::~LayerView()
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
scene.root()->draw(glm::identity<glm::mat4>(), Rendering::manager().Projection());
@@ -390,13 +385,33 @@ void LayerView::zoom (float factor)
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)
{
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
View File

@@ -19,7 +19,7 @@ public:
virtual void update (float dt);
virtual void draw () = 0;
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 restoreSettings();
@@ -40,7 +40,6 @@ public:
void draw () 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;
private:
@@ -72,7 +71,6 @@ public:
void draw () 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;
private:
@@ -87,11 +85,10 @@ public:
void draw () 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;
private:
float aspect_ratio;
};

View File

@@ -14,14 +14,14 @@ property uchar alpha
element face 8
property list uchar uint vertex_indices
end_header
1.000000 -1.000000 0.000000 0.202616 0.797384 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.000000 1.000000 255 255 255 65
-1.000000 -1.000000 0.000000 0.797384 0.797384 255 255 255 255
-1.300000 1.300000 0.000000 1.000000 0.000000 255 255 255 65
1.000000 1.000000 0.000000 0.202616 0.202616 255 255 255 255
1.300000 1.300000 0.000000 0.000000 0.000000 255 255 255 65
-1.000000 1.000000 0.000000 0.797384 0.202616 255 255 255 255
1.000000 -1.000000 0.000000 0.827672 0.172328 255 255 255 255
-1.300000 -1.300000 0.000000 -0.002507 -0.002507 255 255 255 0
1.300000 -1.300000 0.000000 1.002507 -0.002507 255 255 255 0
-1.000000 -1.000000 0.000000 0.172328 0.172328 255 255 255 255
-1.300000 1.300000 0.000000 -0.002507 1.002507 255 255 255 0
1.000000 1.000000 0.000000 0.827672 0.827672 255 255 255 255
1.300000 1.300000 0.000000 1.002507 1.002507 255 255 255 0
-1.000000 1.000000 0.000000 0.172328 0.827672 255 255 255 255
3 0 1 2
3 3 4 1
3 5 2 6