How to fix the vtkCamera inverted y axis

 Go back to the basics, it is actually quite simple.
    There is a right-handed coordinate system,
    the same in ITK and VTK.

    You must put your camera in a location in space,
    (defined in term of that coordinate system)
    aim the camera to a point in space
    (defined in term of that coordinate system)
    orient the camera to have a vertical direction
    (defined in term of that coordinate system)


    Then you can start populating your scene.
 
 
    this->m_viewer2 = vtkSmartPointer<vtkImageViewer2>::New();
 
  
    this->m_viewer2->SetInput(vtkReader->GetOutput());
    this->m_viewer2->SetSliceOrientationToXY();
 
  
    // Fixed invert y axis
 
  
    double pos[2], foc[2];
    this->m_viewer2->GetRenderer()->GetActiveCamera()->GetPosition(pos);
    this->m_viewer2->GetRenderer()->GetActiveCamera()->GetFocalPoint(foc);
    pos[2] = -1;
    this->m_viewer2->GetRenderer()->GetActiveCamera()->SetPosition(pos);
    //    std::cout<<pos[0]<<pos[1]<<pos[2]<<std::endl<<foc[0]<<foc[1]<<foc[2]<<std::endl;
 
  
    this->m_viewer2->GetRenderer()->GetActiveCamera()->SetViewUp(0, -1, 0);
    this->m_viewer2->GetRenderer()->ResetCamera();
    this->m_viewer2->UpdateDisplayExtent();

你可能感兴趣的:(How to fix the vtkCamera inverted y axis)