[vtkusers] Cameras Link Problems

R M mlokida at yahoo.fr
Fri Dec 14 10:35:29 EST 2012


Hi,

I used vtk 5.8.0 and pcl 1.5.1.

Here 's my problem: I have 2 views that displays 2 objects that represent the same objet scanned from differents points of view. I need to place them in the same point of view. 

Like this when I rotate/ or move the camera in one view I can see the 2 objects moving/rotating exactly the same.

For this, i do:

--------------------

an init method when i link the 2 cameras:

vtkSmartPointer<vtkCamera> cam1 = renderer1->GetActiveCamera();
vtkSmartPointer<vtkCamera> cam2 = renderer2->GetActiveCamera();

matrixCam1->DeepCopy( cam1->GetViewTransformObject()->GetMatrix() );
matrixCam2->DeepCopy( cam2->GetViewTransformObject()->GetMatrix() );
        
vtkSmartPointer<vtkMatrix4x4> mat1Invert = vtkMatrix4x4::New();
vtkMatrix4x4::Invert( matrixCam1, mat1Invert);

vtkMatrix4x4::Multiply4x4(mat1Invert, matrixCam2, deltaMat);
vtkMatrix4x4::Invert( deltaMat, deltaMatInv);



Then during mouse event I do:

// Get the 2 cam

vtkSmartPointer<vtkCamera> cam1 = renderer1->GetActiveCamera();
vtkSmartPointer<vtkCamera> cam2 = renderer2->GetActiveCamera();

vtkSmartPointer<vtkMatrix4x4> camTo = vtkMatrix4x4::New();


vtkMatrix4x4::Multiply4x4(matrixCam1, deltaMat, camTo ); 
    
cam2->GetViewTransformObject()->SetMatrix( camTo );
cam2->Modified();

Renderer2->GetRenderWindow()->Render();

--------------------


When using this on my view1 (move/rotate the camera), the display on view2 is ok and updates well. But when I move/rotate from view2  the update in  view1 is wrong,  I recover an older view matrix whereas, I modify both matrix in my code.

Any ideas ?

Thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121214/d6b633a5/attachment.htm>


More information about the vtkusers mailing list