AlexanderAlexander
AlexanderAlexander

Reputation: 101

VTK Camera Clipping with 2 Renderers

Current Setup:

gridRenderer->SetLayer(0);
geoRenderer->SetLayer(1);
RenderWindow()->SetNumberOfLayers(2);
RenderWindow()->AddRenderer(geoRenderer);
RenderWindow()->AddRenderer(geoRenderer);
 gridRenderer->SetActiveCamera(geoRenderer->GetActiveCamera());

This successfully allows me to have a grid in the background, with a geometry in the foreground.

Problem:

enter image description here

Similar Issue:

Update:

double geoCB[6];
double gridCB[6];
geoRenderer->ComputeVisiblePropBounds(geoCB);
gridRenderer->ComputeVisiblePropBounds(gridCB);
double finalCB[6];
for (int i = 0; i < 6; i++) {
  if (i % 2 == 0) {
    // Even Index is Min
    if (geoCB[i] < gridCB[i]) {
      finalCB[i] = geoCB[i];
    } else {
      finalCB[i] = gridCB[i];
    }
  } else {
    // Odd Index is Max
    if (geoCB[i] > gridCB[i]) {
      finalCB[i] = geoCB[i];
    } else {
      finalCB[i] = gridCB[i];
    }
  }
}
geoRenderer->ResetCameraClippingRange(finalCB);

Unfortunately this still does not work properly at all...

Upvotes: 1

Views: 942

Answers (2)

AlexanderAlexander
AlexanderAlexander

Reputation: 101

Important Update:

  • The above code is correct, you just need to call it every single time before RenderWindow->Render().
  • After creating my own implmementation of vtkRenderWindow, I simply needed to overrride Render(), putting the above code inside, and then finisihing the ovveride with a call to the default Render()
  • If you simply set the min clipping planes to a very small value, and the max to a very large one, it might work but can destroy the depth filter, messing the whole render up completely.

Upvotes: 0

mmusy
mmusy

Reputation: 1337

Maybe you can set the clipping range explicitly to large values with: vtkCamera.SetClippingRange(x0,x1)

Upvotes: 1

Related Questions