mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
PickingVisitor first draft, with prototype integration in UserInterface
This commit is contained in:
@@ -7,28 +7,38 @@
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include <glm/gtc/matrix_access.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtx/string_cast.hpp>
|
||||
|
||||
|
||||
PickingVisitor::PickingVisitor(glm::vec2 coordinates) : Visitor(), point_(coordinates), node_(nullptr)
|
||||
PickingVisitor::PickingVisitor(glm::vec2 coordinates) : Visitor(), point_(coordinates)
|
||||
{
|
||||
|
||||
modelview_ = glm::mat4(1.f);
|
||||
}
|
||||
|
||||
void PickingVisitor::visit(Node &n)
|
||||
{
|
||||
|
||||
modelview_ *= n.transform_;
|
||||
// Log::Info("Node %d", n.id());
|
||||
// Log::Info("%s", glm::to_string(modelview_).c_str());
|
||||
}
|
||||
|
||||
void PickingVisitor::visit(Group &n)
|
||||
{
|
||||
// Log::Info("Group %d", n.id());
|
||||
glm::mat4 mv = modelview_;
|
||||
|
||||
for (NodeSet::iterator node = n.begin(); node != n.end(); node++) {
|
||||
(*node)->accept(*this);
|
||||
modelview_ = mv;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PickingVisitor::visit(Switch &n)
|
||||
{
|
||||
glm::mat4 mv = modelview_;
|
||||
(*n.activeChild())->accept(*this);
|
||||
modelview_ = mv;
|
||||
}
|
||||
|
||||
void PickingVisitor::visit(Animation &n)
|
||||
@@ -41,24 +51,21 @@ void PickingVisitor::visit(Primitive &n)
|
||||
|
||||
}
|
||||
|
||||
void PickingVisitor::visit(ImageSurface &n)
|
||||
void PickingVisitor::visit(Surface &n)
|
||||
{
|
||||
// test if point is inside rectangle
|
||||
|
||||
}
|
||||
// lower left corner
|
||||
glm::vec4 LL = modelview_ * glm::vec4( -1.f, -1.f, 0.f, 0.f );
|
||||
// up right corner
|
||||
glm::vec4 UR = modelview_ * glm::vec4( 1.f, 1.f, 0.f, 0.f );
|
||||
|
||||
void PickingVisitor::visit(FrameBufferSurface &n)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PickingVisitor::visit(MediaSurface &n)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PickingVisitor::visit(LineStrip &n)
|
||||
{
|
||||
// Log::Info("Surface %d", n.id());
|
||||
// Log::Info("LL %s", glm::to_string(LL).c_str());
|
||||
// Log::Info("UR %s", glm::to_string(UR).c_str());
|
||||
|
||||
if ( point_.x > LL.x && point_.x < UR.x && point_.y > LL.y && point_.y < UR.y )
|
||||
nodes_.push_back(&n);
|
||||
}
|
||||
|
||||
void PickingVisitor::visit(LineSquare &)
|
||||
@@ -71,11 +78,6 @@ void PickingVisitor::visit(LineCircle &n)
|
||||
|
||||
}
|
||||
|
||||
void PickingVisitor::visit(Mesh &n)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PickingVisitor::visit(Scene &n)
|
||||
{
|
||||
n.root()->accept(*this);
|
||||
|
||||
Reference in New Issue
Block a user