void RGLView::trackballUpdate(int mouseX, int mouseY) { Viewpoint* viewpoint = scene->getViewpoint(); rotCurrent = screenToVector(width,height,mouseX,height-mouseY); windowImpl->beginGL(); viewpoint->updateMouseMatrix(rotBase,rotCurrent); windowImpl->endGL(); View::update(); }
void RGLView::oneAxisUpdate(int mouseX, int mouseY) { Viewpoint* viewpoint = scene->getViewpoint(); rotCurrent = screenToVector(width,height,mouseX,height/2); windowImpl->beginGL(); viewpoint->mouseOneAxis(rotBase,rotCurrent,axis[drag-1]); windowImpl->endGL(); View::update(); }
void CObjectView::OnMouseMove(UINT nFlags, CPoint point) { if (GetCapture() == this && (nFlags & MK_LBUTTON)){ if (mode == PAN){ Point2D pL, pC; screenToFrustum(&pL, lastPt); screenToFrustum(&pC, point); // update translate tr[0] += (pC.x - pL.x)*1000.0/scale; tr[1] += (pC.y - pL.y)*1000.0/scale; } else if (mode == ROTATE || mode == LIGHT){ Vector3D vL, vC; screenToVector(&vL, lastPt); screenToVector(&vC, point); // calculate angle prop to length mouse movement float dX = vC.x - vL.x; float dY = vC.y - vL.y; float dZ = vC.z - vL.z; float ang = 90.0 * sqrt(dX*dX + dY*dY + dZ*dZ); // vector is just cross product Vector3D v; v.cross(vL, vC); v.norm(); if (mode == ROTATE) applyRotation(m, ang, v); else applyRotation(mL, ang, v); } lastPt = point; RedrawWindow(); } CView ::OnMouseMove(nFlags, point); }
void RGLView::oneAxisBegin(int mouseX, int mouseY) { rotBase = screenToVector(width,height,mouseX,height/2); }
void RGLView::trackballBegin(int mouseX, int mouseY) { rotBase = screenToVector(width,height,mouseX,height-mouseY); }