[vtk-developers] add method to vtkCamera

Jeff Lee jeff at cdnorthamerica.com
Wed Mar 20 07:15:58 EST 2002


Hi All,
I was wondering if anyone had objections to having a method in vtkCamera 
which takes a vtkTransform and converts it into FocalPoint, Position and 
ViewUp so that you can have more control of the camera.
Something like

vtkCamera::ApplyTransform(vtkTransform t) {

 double posOld[4], posNew[4], fpOld[4], fpNew[4], vuOld[4], vuNew[4];

 for (int i = 0; i < 3; ++i) {
   posOld[i] = this->Position[i];
   fpOld[i] = this->FocalPoint[i];
   vuOld[i] = this->ViewUp[i];
 }
 posOld[3] = 1.0;
 fpOld[3] = 1.0;
 vuOld[3] = 1.0;

 vuOld[0] += posOld[0];
 vuOld[1] += posOld[1];
 vuOld[2] += posOld[2];

 t->MultiplyPoint(posOld, posNew);
 t->MultiplyPoint(fpOld, fpNew);
 t->MultiplyPoint(vuOld, vuNew);

 vuNew[0] -= posNew[0];
 vuNew[1] -= posNew[1];
 vuNew[2] -= posNew[2];

 for (int i = 0; i < 3; ++i) {
   this->Position[i] = posNew[i];
   this->FocalPoint[i] = fpNew[i];
   this->ViewUp[i] = vuNew[i];
 }

}

-It's simple and doesn't really clutter up anything and it adds alot of 
flexibility for those writing their own interactors.  Thanks,
-Jeff




More information about the vtk-developers mailing list