[vtkusers] Panning, Rotating using cursor keys & rotating about an axis with origin at view center (MFC)

Ted Christiansen ted at caept.com
Wed Nov 5 16:57:17 EST 2003


Hello,

I am trying to add support for panning and rotating using the cursor keys to my application.  Here is what I have tried, which doesnt work quite right:

			pCamera->GetPosition(pos[0], pos[1], pos[2]);
			pCamera->GetFocalPoint(fp[0], fp[1], fp[2]);
			pos[0] = 1.1 * pos[0];
			fp[0]  = 1.1 * fp[0];
			pCamera->SetPosition(pos[0], pos[1], pos[2]);
			pCamera->SetFocalPoint(fp[0], fp[1], fp[2]);
			pCamera->OrthogonalizeViewUp();
			Invalidate(FALSE);

What am I doing incorrectly?



Also, I would like to rotate the model about an axis with the origin at the view center.  Here is what I have which doesnt work:


		vtkCamera*    pCam    = Renderer->GetActiveCamera();
		vtkTransform* rot = vtkTransform::New();
		rot->Identity();
		rot->RotateX(2);

		vtkMatrix4x4* result = vtkMatrix4x4::New();

		vtkMatrix4x4* pMatrix = pCam->GetViewTransformMatrix();
		pMatrix->Multiply4x4(rot->GetMatrix(), result, pMatrix);

		for (int i=0;i<4;i++) {
			for (int j=0;j<4;j++) {
				pMatrix->SetElement(i, j, result->GetElement(i, j));
			}
		}
		pCam->OrthogonalizeViewUp();

What am I doing incorrectly?


Ted




More information about the vtkusers mailing list