VTK例子22-设置观察交互模式
设置观察交互模式#include "stdafx.h"//VTK 对场景中的多个对象设置不同的交互方式方式//#if 1#include "vtkconesource.h"#include "vtkpolydatamapper.h"#include "vtkactor.h"#include "vtkrenderer.h"#include "vtkrenderwindow.h"#include "vtkRenderWindowInteractor.h"#include "vtkInteractorStyleTrackballCamera.h"#include "vtkInteractorStyleTrackballActor.h" int main(int argc, char* argv[]){//建立模型vtkConeSource *cone=vtkConeSource::New();cone->SetHeight(5);cone->SetCenter(0,0,0);cone->SetRadius(2);cone->SetResolution(100); vtkPolyDataMapper * map=vtkPolyDataMapper::New();map->SetInput(cone->GetOutput()); vtkActor *actor=vtkActor::New();actor->SetMapper(map); //建立模型vtkConeSource *cone1=vtkConeSource::New();cone1->SetHeight(5);cone1->SetCenter(10,0,0);cone1->SetRadius(2);cone1->SetResolution(100); vtkPolyDataMapper * map1=vtkPolyDataMapper::New();map1->SetInput(cone1->GetOutput()); vtkActor *actor1=vtkActor::New();actor1->SetMapper(map1); //建立模型vtkConeSource *cone2=vtkConeSource::New();cone2->SetHeight(5);cone2->SetCenter(20,0,0);cone2->SetRadius(2);cone2->SetResolution(100); vtkPolyDataMapper * map2=vtkPolyDataMapper::New();map2->SetInput(cone2->GetOutput()); vtkActor *actor2=vtkActor::New();actor2->SetMapper(map2); //设置rendervtkRenderer * ren=vtkRenderer::New();ren->AddActor(actor);ren->AddActor(actor1);ren->AddActor(actor2);ren->SetBackground(.9,.5,.4); vtkRenderWindow* win=vtkRenderWindow::New();win->AddRenderer(ren);win->SetSize(600,480); vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();iren->SetRenderWindow(win);iren->Initialize(); //设置观察交互模式//vtkInteractorStyleTrackballCamera *pvtkInteractorStyleTrackballCamera=vtkInteractorStyleTrackballCamera::New();//iren->SetInteractorStyle(pvtkInteractorStyleTrackballCamera); //对所有actor使用相同的交互 vtkInteractorStyleTrackballActor *pvtkInteractorStyleTrackballActor=vtkInteractorStyleTrackballActor::New();iren->SetInteractorStyle(pvtkInteractorStyleTrackballActor); //对每个不同的actor使用不同的交互 win->Render(); //开始交互iren->Start(); return 0;} LZ高人啊,我来学习了 顶!!!!!!!!! 顶 一直在寻找这个,多谢了 zhichizhichi
页:
[1]