Hi. I am new to VTK and I just encountered a strange behavior. If the camera is far away from the focal point, that is, if I set camera position as SetPosition(700,700,700) in the code below, VTK only produces a blank window with blue background without any actors. Only upon clicking the window that I see the actors.
#include <vtkActor.h>
#include <vtkCamera.h>
#include <vtkConeSource.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkPolyDataMapper.h>
#include <vtkCamera.h>
int main(int, char *[])
{
//Create a cone
vtkNew<vtkConeSource> cone;
cone->SetHeight(400.0);
cone->SetRadius(200.0);
cone->SetResolution(10);
//Create a mapper and actor
vtkNew<vtkPolyDataMapper> coneMapper;
coneMapper->SetInputConnection(cone->GetOutputPort());
vtkNew<vtkActor> coneActor;
coneActor->SetMapper(coneMapper);
//Create a renderer and add cone to it.
vtkNew<vtkRenderer> ren1;
ren1->AddActor(coneActor);
// Set background color of the renderer
vtkNew<vtkNamedColors> colors;
ren1->SetBackground(colors->GetColor3d("MidnightBlue").GetData());
// Create a new visualization window and add the renderer to it.
vtkNew<vtkRenderWindow> renWin;
renWin->AddRenderer(ren1);
renWin->SetSize(300,300);
// Create a virtual camera
vtkNew<vtkCamera> orientation;
orientation->SetFocalPoint(0,0,0);
orientation->SetPosition(700,700,700);
ren1->SetActiveCamera(orientation);
// Make the render window interacting
vtkNew<vtkRenderWindowInteractor> renWinInteractor;
renWinInteractor->SetRenderWindow(renWin);
//Render and interact
renWin->Render();
renWinInteractor->Start();
return EXIT_SUCCESS;
}
If I set the position as SetPosition(500,500,500) in the code above, I get a nice cone, but I get no cone with SetPosition(700,700,700) (it only shows when I click on the window). This is really confusing and is making it very difficult for me to use VTK for large datasets, since the PNG writer produces the PNG file without any actors in it. Thank you for all the help.