# Strange behavior. If camera is far away, VTK only renders upon clicking on the render window.

**URL:** https://discourse.vtk.org/t/strange-behavior-if-camera-is-far-away-vtk-only-renders-upon-clicking-on-the-render-window/327
**Category:** Support
**Created:** [February 26, 2019, 3:17am UTC](https://discourse.vtk.org/t/strange-behavior-if-camera-is-far-away-vtk-only-renders-upon-clicking-on-the-render-window/327 "2019-02-26T03:17:16Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![singularity](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/898d66/32.png) [@singularity](https://discourse.vtk.org/u/singularity)
#### Post date: [February 26, 2019, 3:17am UTC](https://discourse.vtk.org/t/strange-behavior-if-camera-is-far-away-vtk-only-renders-upon-clicking-on-the-render-window/327/1 "2019-02-26T03:17:16Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![banesullivan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/banesullivan/32/7143_2.png) [@banesullivan](https://discourse.vtk.org/u/banesullivan)
#### Post date: [February 27, 2019, 2:02am UTC](https://discourse.vtk.org/t/strange-behavior-if-camera-is-far-away-vtk-only-renders-upon-clicking-on-the-render-window/327/2 "2019-02-27T02:02:37Z")

</div>

This has to do with the locations of your camera’s clipping planes set by default.

Instead of making a new camera, use the renderer’s active camera and/or perhaps tweak the Thickness attribute of the camera:

```auto
...
orientation = ren1->GetActiveCamera();
orientation->SetFocalPoint(0,0,0);
orientation->SetPosition(700,700,700);
orientation->SetThickness(1000);
...

```

---

<div class="post-metadata">

### Author: ![singularity](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/898d66/32.png) [@singularity](https://discourse.vtk.org/u/singularity)
#### Post date: [March 2, 2019, 11:26pm UTC](https://discourse.vtk.org/t/strange-behavior-if-camera-is-far-away-vtk-only-renders-upon-clicking-on-the-render-window/327/3 "2019-03-02T23:26:43Z")

</div>

Thanks a lot, Bane. That solved the problem for me. VTK is a bit overwhelming and so I am missing things even after reading the user guide.

---

<div class="post-metadata">

### Author: ![lorensen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lorensen/32/20_2.png) [@lorensen](https://discourse.vtk.org/u/lorensen)
#### Post date: [March 3, 2019, 1:16am UTC](https://discourse.vtk.org/t/strange-behavior-if-camera-is-far-away-vtk-only-renders-upon-clicking-on-the-render-window/327/4 "2019-03-03T01:16:10Z")

</div>

Have you looked at the VTK Examples Project: [https://lorensen.github.io/VTKExamples/site/](https://lorensen.github.io/VTKExamples/site/)

---

<div class="post-metadata">

### Author: ![banesullivan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/banesullivan/32/7143_2.png) [@banesullivan](https://discourse.vtk.org/u/banesullivan)
#### Post date: [March 3, 2019, 1:21am UTC](https://discourse.vtk.org/t/strange-behavior-if-camera-is-far-away-vtk-only-renders-upon-clicking-on-the-render-window/327/5 "2019-03-03T01:21:01Z")

</div>

> [@singularity](#):
>
> VTK is a bit overwhelming and so I am missing things even after reading the user guide.

I find it difficult to prototype with C++, perhaps give Python a try - I’ve helped build [`vtki`](http://docs.vtki.org/en/latest/) which aims to make VTK accessible to a wide audience and incredibly intuitive to use.

---

<div class="post-metadata">

### Author: ![singularity](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/898d66/32.png) [@singularity](https://discourse.vtk.org/u/singularity)
#### Post date: [March 3, 2019, 1:53am UTC](https://discourse.vtk.org/t/strange-behavior-if-camera-is-far-away-vtk-only-renders-upon-clicking-on-the-render-window/327/6 "2019-03-03T01:53:06Z")

</div>

Hi, Bill. Thanks for the response. Yes, I have been going through the user-guide, VTK textbook, and VTK Examples website. I have finally managed to write a complete volume rendering example for myself. I am a physics student and so not the most competent person with computers, which is why I am missing small but important things.

---

<div class="post-metadata">

### Author: ![banesullivan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/banesullivan/32/7143_2.png) [@banesullivan](https://discourse.vtk.org/u/banesullivan)
#### Post date: [March 3, 2019, 3:27am UTC](https://discourse.vtk.org/t/strange-behavior-if-camera-is-far-away-vtk-only-renders-upon-clicking-on-the-render-window/327/7 "2019-03-03T03:27:56Z")

</div>

> [@singularity](#):
>
> I am a physics student … which is why I am missing small but important things.

Awesome! I would love to see the types of data you are visualizing!

_One final solicitation:_ [`vtki`](http://docs.vtki.org/en/latest/) was built for people in your situation! I’m a geophysics researcher and helped build up `vtki` to make 3D visualization more accessible to researchers in my domain (and non-computer scientists across the board). It helps you focus on your data and the underlying science rather than the nuances of common tasks in 3D viz.

---

<div class="post-metadata">

### Author: ![singularity](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/898d66/32.png) [@singularity](https://discourse.vtk.org/u/singularity)
#### Post date: [March 3, 2019, 3:46am UTC](https://discourse.vtk.org/t/strange-behavior-if-camera-is-far-away-vtk-only-renders-upon-clicking-on-the-render-window/327/8 "2019-03-03T03:46:01Z")

</div>

I would certainly look into vtki. I will have to learn python a bit before I can do that. I do cosmology/particle physics and have been looking for an efficient rendering tool. I was using mathematica for 3d plots but it is extremely slow. During my test, yesterday, VTK seemed many many times faster than mathematica.

---

<div class="post-metadata">

### Author: ![banesullivan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/banesullivan/32/7143_2.png) [@banesullivan](https://discourse.vtk.org/u/banesullivan)
#### Post date: [March 3, 2019, 3:47am UTC](https://discourse.vtk.org/t/strange-behavior-if-camera-is-far-away-vtk-only-renders-upon-clicking-on-the-render-window/327/9 "2019-03-03T03:47:34Z")

</div>

> [@singularity](#):
>
> VTK seemed many many times faster than mathematica.

Oh yes! VTK is super fast and scalable! In `vtki` we maintain that speed by wrapping common tasks in VTK with VTK’s python bindings
