void NavigateAxisArray::OnTimer(void) { vtkRenderWindowInteractor *rwi = Interactor; int Pos[2]; rwi->GetEventPosition(Pos); VisWindow *win = proxy; shouldSnap = win->GetInteractorAtts()->GetAxisArraySnap(); switch (State) { case VTKIS_PAN: PanCamera(Pos[0], Pos[1], shouldSnap); rwi->CreateTimer(VTKI_TIMER_UPDATE); break; case VTKIS_DOLLY: ZoomCamera(Pos[0], Pos[1]); rwi->CreateTimer(VTKI_TIMER_UPDATE); break; default: break; } }
void NavigateCurve::OnTimer(void) { vtkRenderWindowInteractor *rwi = Interactor; int Pos[2]; rwi->GetEventPosition(Pos); switch (State) { case VTKIS_PAN: PanCamera(Pos[0], Pos[1]); rwi->CreateTimer(VTKI_TIMER_UPDATE); break; case VTKIS_DOLLY: ZoomCamera(Pos[0], Pos[1]); rwi->CreateTimer(VTKI_TIMER_UPDATE); break; default: break; } }
void World::OnMouseMove(int nX, int nY) { // Although this works, the recast in ogWindowProc is a better solution. // if(nX > 32768) nX -= 65536; // if(nY > 32768) nY -= 65536; // printf("OnMouseMove: %d, %d\n", nX, nY); // fflush(stdout); UpdateMousePos(nX, nY); // lets try this - nope // RefreshPickPosition(); // Need to change this so it calls the callback during either render or update // so that the mouse pick position is up to date stringstream ss; ss << "OnMouseMove(" << m_vMouse2DPositionDelta.x << "," << m_vMouse2DPositionDelta.y << "," << nX << "," << nY << ")"; luaCall(ss.str()); if(m_bMouseMovesCamera) { if(m_bRightMouseDown) { if(glutGetModifiers() & GLUT_ACTIVE_SHIFT) { float fStepSize = m_vMouse2DPositionDelta.y * 0.2; mlVector3D vCamera = GetCameraTransform()->GetTranslation(); float fDistance = (m_vMousePickPosition - vCamera).Magnitude(); fStepSize *= fDistance * 0.05f; fStepSize = mlClamp(fStepSize, -20.0f, 20.0f); mlVector3D vForward = vCamera - m_vMousePickPosition; vForward.Normalise(); vForward *= fStepSize; m_trnCamera.ApplyTranslation(vForward); } else { PanCamera(m_vMouse2DPositionDelta.x, m_vMouse2DPositionDelta.y); } } if(m_bLeftMouseDown) { // This is a magic number which maps pixels of mouse motion to radians of rotation float fRotationSpeed = 0.008f; float fHeadingChange = fRotationSpeed * m_vMouse2DPositionDelta.x; float fPitchChange = fRotationSpeed * m_vMouse2DPositionDelta.y; if(m_bDoubleClick) { if(m_bUsePositionPreservingOrbitCamera) PositionPreservingOrbitCamera(m_vMousePickPosition, fHeadingChange * 0.5, fPitchChange * 0.5); else OrientationPreservingOrbitCamera(m_vMousePickPosition, fHeadingChange * 0.5, fPitchChange * 0.5); } else { RotateCamera(fHeadingChange, fPitchChange); } } } }