There are two projection methods for camera setting, orthographic (paraller) projection and perspective projection, they have different view styles.


The light of sight in orthographic (paraller) projection is just like the light of sun. So the segment length keeps same at far and near position.
The model’s size is is related to the distance from eye to far view plane.

    \[y_s = \frac{d}{z}y\]

Here is a demo about parallel projection and perspective projection for vtkCamera object.

#include <iostream>
#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
#include <vtkActor.h>
#include <vtkCylinderSource.h>
#include <vtkCubeSource.h>
#include <vtkCamera.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderWindowInteractor.h>

#define vtkSPtr vtkSmartPointer
#define vtkSPtrNew(Var, Type) vtkSPtr<Type> Var = vtkSPtr<Type>::New();

using namespace std;


int main()
{
    vtkSPtrNew( source, vtkCylinderSource );
    source->SetHeight(10);

    vtkSPtrNew( mapper, vtkPolyDataMapper );
    mapper->SetInputConnection( source->GetOutputPort() );

    vtkSPtrNew( actor, vtkActor );
    actor->SetMapper( mapper );

    vtkSPtrNew( renderer, vtkRenderer );
    renderer->AddActor(actor);
    renderer->SetBackground( 0, 0, 0 );

    vtkSPtrNew( renderWindow, vtkRenderWindow );
    renderWindow->AddRenderer( renderer );

    vtkSPtrNew( renderWindowInteractor, vtkRenderWindowInteractor );
    renderWindowInteractor->SetRenderWindow( renderWindow );

    vtkSPtrNew( camera, vtkCamera );
    camera->ParallelProjectionOn();
    renderer->SetActiveCamera( camera );
    renderer->ResetCamera();
    renderWindow->Render();
    renderWindowInteractor->Start();
    return 0;
}

Let’s change it to perspective projection.

camera->ParallelProjectionOff();

Categories: VTK

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

Tex To PDF
: convert the Latex file which suffix is tex to a PDF file

X
0
Would love your thoughts, please comment.x
()
x