VTK/Examples/Broken/Interaction/Flight
From KitwarePublic
This example is currently broken. The sphere disappears if you click the left mouse button. The arrow keys do nothing.
Left mouse button press produces forward motion. Right mouse button press produces reverse motion. Moving mouse during motion steers user in desired direction. Keyboard controls are: Left/Right/Up/Down Arrows for steering direction 'A' forward, 'Z' reverse motion Ctrl Key causes sidestep instead of steering in mouse and key modes Shift key is accelerator in mouse and key modes Ctrl and Shift together causes Roll in mouse and key modes
Flight.cxx
#include <vtkSmartPointer.h> #include <vtkPolyDataMapper.h> #include <vtkActor.h> #include <vtkRenderWindow.h> #include <vtkRenderer.h> #include <vtkRenderWindowInteractor.h> #include <vtkPolyData.h> #include <vtkSphereSource.h> #include <vtkInteractorStyleFlight.h> int main (int argc, char *argv[]) { vtkSmartPointer<vtkSphereSource> sphereSource = vtkSmartPointer<vtkSphereSource>::New(); //create a mapper and actor vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); mapper->SetInputConnection(sphereSource->GetOutputPort()); vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); actor->SetMapper(mapper); // a renderer and render window vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New(); vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New(); renderWindow->AddRenderer(renderer); // an interactor vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New(); renderWindowInteractor->SetRenderWindow(renderWindow); // add the actors to the scene renderer->AddActor(actor); renderer->SetBackground(1,1,1); // Background color white // render an image (lights and cameras are created automatically) renderWindow->Render(); vtkSmartPointer<vtkInteractorStyleFlight> style = vtkSmartPointer<vtkInteractorStyleFlight>::New(); //like paraview renderWindowInteractor->SetInteractorStyle( style ); // begin mouse interaction renderWindowInteractor->Start(); return EXIT_SUCCESS; }
CMakeLists.txt
cmake_minimum_required(VERSION 2.6) PROJECT(Flight) FIND_PACKAGE(VTK REQUIRED) INCLUDE(${VTK_USE_FILE}) ADD_EXECUTABLE(Flight Flight.cxx) TARGET_LINK_LIBRARIES(Flight vtkHybrid)