示例#1
0
bool rotate_manipulator::handle_mouse_down(visionaray::mouse_event const& event)
{
    auto bdisc = flip( bounding_disc(), camera_.get_viewport() );

    if (bdisc.contains(event.get_pos()) && event.get_buttons() & buttons_)
    {
        dragging_ = true;

        auto brect = flip( bounding_rect(), camera_.get_viewport() );

        ball_.down_pos = ball_.project(
            event.get_pos().x,
            event.get_pos().y,
            brect
            );
        ball_.down_rotation = ball_.rotation;
        down_pos_ = event.get_pos();
//      selected_ = select_from_mouse_pointer(event);

        return true;
    }
    else
    {
        return false;
    }
}
示例#2
0
void pan_manipulator::handle_mouse_move(visionaray::mouse_event const& event)
{

    if (!dragging_)
    {
        return;
    }


    if (event.get_buttons() & buttons_)
    {

        auto w  =  camera_.get_viewport().w;
        auto h  =  camera_.get_viewport().h;
        auto dx =  static_cast<float>(last_pos_.x - event.get_pos().x) / w;
        auto dy = -static_cast<float>(last_pos_.y - event.get_pos().y) / h;
        auto s  = 2.0f * camera_.distance();
        auto zaxis = normalize( camera_.eye() - camera_.center() );
        auto yaxis = camera_.up();
        auto xaxis = cross( yaxis, zaxis );
        vec3 d  =  (dx * s) * xaxis + (dy * s) * yaxis;
        
        camera_.look_at( camera_.eye() + d, camera_.center() + d, camera_.up() );

        last_pos_ = event.get_pos();

    }

    camera_manipulator::handle_mouse_move(event);

}
void arcball_manipulator::handle_mouse_move(visionaray::mouse_event const& event)
{

    bool buttons   = event.get_buttons() & buttons_;
    bool modifiers = (modifiers_ == keyboard::NoKey && down_modifiers_ == keyboard::NoKey)
                   || down_modifiers_ & modifiers_;

    if (dragging_ && buttons && modifiers)
    {

        // rotation

        vec3 curr_pos = ball_.project(
                event.get_pos().x,
                event.get_pos().y,
                camera_.get_viewport()
                );
        ball_.rotation = quat::rotation(ball_.down_pos, curr_pos) * ball_.down_rotation;

        if (true)
        {

            // view transform

            mat4 rotation_matrix = rotation(conjugate(ball_.rotation));

            vec4 eye4(0, 0, camera_.distance(), 1.0);
            eye4 = rotation_matrix * eye4;
            vec3 eye = vec3(eye4[0], eye4[1], eye4[2]);
            eye += camera_.center();

            vec4 up4 = rotation_matrix(1);
            vec3 up(up4[0], up4[1], up4[2]);

            camera_.look_at(eye, camera_.center(), up);

        }
        else
        {

            // model transform

            mat4 model = rotation(ball_.rotation);
            VSNRAY_UNUSED(model);
            //camera_.set_model_matrix(model);

        }

    }

    camera_manipulator::handle_mouse_move(event);

}
示例#4
0
bool rotate_manipulator::handle_mouse_move(visionaray::mouse_event const& event)
{
    auto bdisc = flip( bounding_disc(), camera_.get_viewport() );

    mouse_over_ = bdisc.contains(event.get_pos());

    if (dragging_ && event.get_buttons() & buttons_)
    {
        auto brect = flip( bounding_rect(), camera_.get_viewport() );

        vec3 curr_pos = ball_.project(
                event.get_pos().x,
                event.get_pos().y,
                brect
                );

        auto last_vsr = rotation(ball_.rotation);
        ball_.rotation = quat::rotation(ball_.down_pos, curr_pos) * ball_.down_rotation;

        auto vsr = rotation(ball_.rotation);

        auto trans = model_matrix_(3);

        model_matrix_.col3 = vec4(0.0f, 0.0f, 0.0f, 1.0f);

        auto vm = camera_.get_view_matrix();
        vm.col3 = vec4(0.0f, 0.0f, 0.0f, 1.0f);

        model_matrix_ = inverse(vm) * vsr * inverse(last_vsr) * vm * model_matrix_;
        model_matrix_.col3 = trans;

        return true;
    }
    else
    {
        hovered_ = select_from_mouse_pointer(event);
        return false;
    }
}
void arcball_manipulator::handle_mouse_down(visionaray::mouse_event const& event)
{

    bool buttons   = event.get_buttons() & buttons_;
    bool modifiers = (modifiers_ == keyboard::NoKey && event.get_modifiers() == keyboard::NoKey)
                   || event.get_modifiers()  & modifiers_;

    if (!dragging_ && buttons && modifiers)
    {
        dragging_ = true;
        ball_.down_pos = ball_.project(
                event.get_pos().x,
                event.get_pos().y,
                camera_.get_viewport()
                );
        ball_.down_rotation = ball_.rotation;

        down_modifiers_ = event.get_modifiers();
    }

    camera_manipulator::handle_mouse_down(event);

}