在VTK中,actor经常会组织成一定的层次结构,以便一个actor的运动可以带动或影响其他actor的位置。比如,例如,一个机械手臂可能由上臂、前臂、手腕和末端等部分通过关节(joints)连接起来。
通过参考作者的python 代码 ,http://www.cnblogs.com/21207-iHome/p/6534929.html 写了c++ demo ,记录分享一下。
//#vtkassembly arm
#include <vtkSmartPointer.h>
#include <vtkTransform.h>
#include <vtkCubeSource.h>
#include <vtkProperty.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkAssembly.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPolyData.h>
#include <vtkSphereSource.h>
#include <vtkOrientationMarkerWidget.h>
#include <vtkAxesActor.h>
#include <vtkPropAssembly.h>
#include <vtkSTLReader.h>
#include <iostream>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkObjectFactory.h>
#include <vtkActor.h>
#include <vtkImageViewer2.h>
#include <vtkDICOMImageReader.h>
#include <vtkInteractorStyleImage.h>
#include <vtkActor2D.h>
#include <vtkTextProperty.h>
#include <vtkTextMapper.h>
#include <sstream>
#include <vtkSetGet.h>
#include <vtkLODA