Beispiel #1
0
void GLWidget::rotateView(const QPoint& newPos) {
    float dx = (float)(newPos.x() - _oldMousePos.x()) / (float)_width;
    float dy = (float)(newPos.y() - _oldMousePos.y()) / (float)_height;
    _oldMousePos = newPos;
    updateDir();
    // rotate eye around center
    _eye.rotate(_center, _dirx, -dx * PI );
    _eye.rotate(_center, _diry, dy*PI );
    
    // now calculate the new up-vector
    P3<float> upCenter = _center + _up;
    upCenter.rotate( _center , _diry, dy*PI);
    _up = upCenter - _center;
    _up *= 1.0/_up.norm();
    
    updateGL();
}