mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Playing with picking
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <GLFW/glfw3native.h>
|
||||
|
||||
#include <glm/ext/matrix_transform.hpp> // glm::translate, glm::rotate, glm::scale
|
||||
#include <glm/ext/matrix_projection.hpp> // glm::unproject
|
||||
#include <glm/ext/matrix_clip_space.hpp> // glm::perspective
|
||||
|
||||
// Include GStreamer
|
||||
@@ -318,6 +319,18 @@ glm::mat4 Rendering::Projection()
|
||||
return projection * scale;
|
||||
}
|
||||
|
||||
|
||||
glm::vec3 Rendering::unProject(glm::vec2 screen_coordinate, glm::mat4 modelview)
|
||||
{
|
||||
glm::vec3 point;
|
||||
glm::vec3 coordinates = glm::vec3( glm::vec2(screen_coordinate), 0.f);
|
||||
glm::vec4 viewport = glm::vec4( 0.f, 0.f, main_window_attributes_.viewport.x, main_window_attributes_.viewport.y);
|
||||
|
||||
point = glm::unProject(coordinates, modelview, Projection(), viewport);
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
float Rendering::Width() { return main_window_attributes_.viewport.x; }
|
||||
float Rendering::Height() { return main_window_attributes_.viewport.y; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user