Ejemplo n.º 1
0
void motion(int x, int y)
{
    if (moving_eye) {
        scene->view.spinDegrees(-0.2*(x-begin_x));
        scene->view.lift(0.02*(y-begin_y));

        glutPostRedisplay();
        begin_x = x;
        begin_y = y;
    }
    if (moving_light) {
        LightPtr light = scene->light_list[0];

        light->spinDegrees(0.2*(x-begin_light_x));
        light->lift(-0.02*(y-begin_light_y));

        glutPostRedisplay();
        begin_light_x = x;
        begin_light_y = y;
    }
    if (spin_object) {
        trackball(lastquat,
            (2.0 * begin_spin_x - window_widthf) / window_widthf,
            (window_heightf - 2.0 * begin_spin_y) / window_heightf,
            (2.0 * x - window_widthf) / window_widthf,
            (window_heightf - 2.0 * y) / window_heightf
            );
        begin_spin_x = x;
        begin_spin_y = y;
        animate_object_spinning = true;
        glutIdleFunc(spin_animate);
    }
}