World Rotation in 3D


I have a question concerning the rotation of the whole VR Environment.
With the currently implemented OnPinch() and OnPan() Methods the whole environment can be scaled and moved. Now i want to use the OnRotate() method to rotate the whole world.

I think this is not working as in the OnPinch() method the vtkInteractorStyle3D::SetScale() method is called. Here the position of the HMD should be moved to compensate for the scaling. In a comment it is noted:

“New camera properties are overridden by virtual reality render window if head-mounted display is tracked”

Is this also the case for the rotation of the camera?

I tried:

vtkRenderWindowInteractor3D* rwi = static_cast<vtkRenderWindowInteractor3D*>(this->Interactor);
vtkCamera* camera = this->CurrentRenderer->GetActiveCamera();
double angle = rwi->GetRotation() - rwi->GetLastRotation();

  • camera->Roll(angle);
  • vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();
    transform->Translate(camerPos[0], camerPos[1], camerPos[2]);

But nothing moves? Is there a workaround besides rotating every actor in the scene?

This is implemented in 3D Slicer’s VirtualReality extension. You may consider porting it back to VTK.

Thank you very much for the reply!!
I have taken a look at your extension. I tried to get the rotation working by setting the PhysicalToWorldMatrix:

vtkOpenVRRenderWindowInteractor* rwi = static_cast<vtkOpenVRRenderWindowInteractor*>(this->Interactor);
vtkOpenVRRenderWindow* rw = static_cast<vtkOpenVRRenderWindow*>(rwi->GetRenderWindow());

vtkCamera* camera = this->CurrentRenderer->GetActiveCamera();
double* cameraPos = camera->GetPosition();
double angle = rwi->GetRotation() - rwi->GetLastRotation();
double physicalScale = rwi->GetPhysicalScale();

vtkSmartPointer m = vtkSmartPointer::New();

vtkSmartPointer transform = vtkSmartPointer::New();

vtkSmartPointer tMInv = vtkSmartPointer::New();
vtkMatrix4x4::Invert(transform->GetMatrix(), tMInv);


The problem is, although the world can now be rotated, I see everything double until the end of the rotation. That means the original orientation of the Wolrd and its Objects remains visible as well as its currently rotated state until i exit the rotation mode - then i only see the correct rotated objects.
(I start the rotation by pressing the grip button on both controllers which calls the OnRotate() method)

Did you run into the same problems?

This should not happen. Maybe you need to update OpenVR driver to latest version and use very latest Slicer Preview Release.