示例#1
0
文件: rglview.cpp 项目: jefferis/rgl
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();
}
示例#2
0
文件: rglview.cpp 项目: jefferis/rgl
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();
}
示例#3
0
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);
}
示例#4
0
文件: rglview.cpp 项目: jefferis/rgl
void RGLView::oneAxisBegin(int mouseX, int mouseY)
{
    rotBase = screenToVector(width,height,mouseX,height/2);
}
示例#5
0
文件: rglview.cpp 项目: jefferis/rgl
void RGLView::trackballBegin(int mouseX, int mouseY)
{
    rotBase = screenToVector(width,height,mouseX,height-mouseY);
}