Orientation Widget "Padding"

Currently:

  • I have implemented an orientation widget into my application using:
orientationWidget = vtkSmartPointer<vtkOrientationMarkerWidget>::New();
axes = vtkSmartPointer<vtkAxesActor>::New();
orientationWidget->SetOrientationMarker(axes);
orientationWidget->SetInteractor(myInteractor);
orientationWidget->SetViewport(0.833, 0.744, 1, 1);
orientationWidget->SetEnabled(1);
orientationWidget->SetInteractive(0);
  • Which produces this:

capture

Problem:

  • I want to squeeze the actor closer to the corner of the window (up+right) but cannot manage to do so by messing with the view port.
  • When I enable interactivity and see an outline of the widget, some sort of padding is in place which leaves substantial negative space around the actor within the widget
  • What is the source of the padding? (I cannot find any indication in vtkOrientationWidget.cxx)

We have come across this problem in 3D Slicer, too, and fixed it here:

When we implemented this fix we didn’t have time to contribute this back to VTK. It would be nice if you could do it.

1 Like

Worked perfectly, thank you VTK Wizard.

In terms of contributing back, do you mean replacing the current vtkAxesActor::GetBounds() with this?

Also, now I notice that the vtkAxesActor is not accurate when compared to the 3D environment.

I even turned off all of my camera overrides and this still occurs. Do you know what could be causing this problem?

Maybe you need to enable parallel projection.

You can either use orthographic projection like @lassoan suggested, which is easier to do. Or, if you want to stick to perspective projection, you can narrow down the FOV angle to reduce the visual discrepancy between the main scene and the orientation axes. Decreasing the FOV angle will do a zoom-in, then you have to dolly (translate) the camera backwards to compensate.

Would there be any other way to remedy the issue?

I need the camera to use perspective projection (parallel doesn’t seem to even fix the issue), and lowering the camera viewing angle all the way down to 5 doesn’t really hide the dependencies that well…

(I can think of many 3D modeling applications and video game engines that use perspective projection and still have accurate axes)

You can keep using perspective projection for your main 3D content and keep using parallel projection for rendering the orientation widget. You can give this a try in 3D Slicer.

1 Like

What would be the best way to exclusively set the projection mode of the orientation widget.

When I try give it a new separate camera it either crashes my application if done so before I set the interactor, or freeze my main camera if done afterwards…

You can find the full implementation at the link I posted above.

Thanks to SetupWindowInteraction()

  vtkCamera* pcam = this->CurrentRenderer->GetActiveCamera();
  vtkCamera* cam = this->Renderer->GetActiveCamera();
  if (pcam && cam)
  {
    cam->SetParallelProjection(pcam->GetParallelProjection());
  }

It is very simple to exclusively make the orientation widget use parallel projection, just set your main camera to parallel mode, create the widget, and then set the main camera back to perspective mode.