在VC6.0上进行开发,用到的是VTK,按网上提供的教程VTK需要用5.0版本(额,这个好老,费了很大劲终于找到了)
相关配置方法可以参考下面的博客:
http://blog.sina.com.cn/s/blog_4cee400e0100b0rd.html
·
直接复制粘贴地址可能不行需要手打一遍(这是我遇到的);
我的Additional include directories为:
directoriesJ:\vtk5.0\vtk\Rendering,J:\vtk5.0\vtkbin,J:\vtk5.0\vtk\Graphics,J:\vtk5.0\vtk\Filtering,J:\vtk5.0\vtk\Common
J:\vtk5.0\vtkbin\bin\Debug
我的Object/library modules为:
opengl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib vtkCommon.lib vtkDICOMParser.lib vtkexoIIc.lib vtkexpat.lib vtkFiltering.lib vtkfreetype.lib vtkftgl.lib vtkGenericFiltering.lib vtkGraphics.lib vtkHybrid.lib vtkImaging.lib vtkIO.lib vtkjpeg.lib vtkNetCDF.lib vtkpng.lib vtkRendering.lib vtksys.lib vtktiff.lib vtkVolumeRendering.lib vtkWidgets.lib vtkzlib.lib
最终将示例代码打进去后终于出来结果:
#include "vtkConeSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkCamera.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkProperty.h"
int main()
{
vtkConeSource *cone = vtkConeSource::New();
cone->SetHeight( 3.0 );
cone->SetRadius( 1.0 );
cone->SetResolution( 10 );
vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
coneMapper->SetInputConnection( cone->GetOutputPort() );
vtkActor *coneActor = vtkActor::New();
coneActor->SetMapper( coneMapper );
vtkRenderer *ren1= vtkRenderer::New();
ren1->AddActor( coneActor );
ren1->SetBackground( 0.1, 0.2, 0.4 );
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer( ren1 );
renWin->SetSize( 300, 300 );
int i;
for (i = 0; i < 360; ++i)
...{
renWin->Render();
ren1->GetActiveCamera()->Azimuth( i );
}
cone->Delete();
coneMapper->Delete();
coneActor->Delete();
ren1->Delete();
renWin->Delete();
return 0;
}
结果: