def mousemoved(x, y): """ Callback Funktion fuer Mausbewegung. Erlaubt Zoom und ArcBall Rotation """ global angle, axis, startPoint, moveP, fixedPoint, translate if isinstance(camList[actCam], FreeCamera): if doRotation: r = min(WIDTH, HEIGHT) / 2.0 moveP = g.projectOnSphere(x, y, r, WIDTH, HEIGHT) angle = math.acos(np.dot(startP, moveP)) axis = np.cross(startP, moveP) axis = (axis[0], -axis[1], axis[2]) camList[actCam].rotate(angle, axis) glutPostRedisplay() if doZoom: translate += (fixedPoint - y) / 1000. if translate < 0.1: translate = 0.1 if translate > 2: translate = 2 camList[actCam].zoom(translate) glutPostRedisplay() fixedPoint = y
def mousemoved(x, y): """ Callback Function f or MouseMotion """ global angle, axis, translate, startPoint, transX, transY, fixedPoint, objectPosition, moveP if doRotation: r = min(WIDTH, HEIGHT) / 2.0 moveP = geo.projectOnSphere(x, y, r, WIDTH, HEIGHT) angle = math.acos(dot(startP, moveP)) axis = cross(startP, moveP) glutPostRedisplay()
def mousebuttonpressed(button, state, x, y): """ Callback Function for Mouse-Event """ global startP, actOri, angle, doRotation, doZoom, startPoint, doTranslate, fixedPoint r = min(WIDTH, HEIGHT) / 2.0 if button == GLUT_LEFT_BUTTON: doZoom, doTranslate = False, False if state == GLUT_DOWN: doRotation = True startP = geo.projectOnSphere(x, y, r, WIDTH, HEIGHT) if state == GLUT_UP: doRotation = False actOri = actOri * geo.rotate(angle, axis) angle = 0
def mousebuttonpressed(button, state, x, y): """ Callback Funktion fuer Maustasten """ global startP, actOri, angle, doRotation, fixedPoint, doZoom if isinstance(camList[actCam], FreeCamera): r = min(WIDTH, HEIGHT) / 2.0 if button == GLUT_LEFT_BUTTON: if state == GLUT_DOWN: doRotation = True startP = g.projectOnSphere(x, y, r, WIDTH, HEIGHT) if state == GLUT_UP: doRotation = False camList[actCam].changeOrientation(angle, axis) angle = 0 if button == GLUT_RIGHT_BUTTON: # zoom if state == GLUT_DOWN: doZoom = True fixedPoint = y if state == GLUT_UP: doZoom = False