Malay
颜色选择
阳光橙
深夜黑
天空蓝
葡萄紫
薄荷绿
深海蓝
首页
论坛
佳礼报道
新闻
专栏
搜索
1897
查看
0
回复

vtk 高手求救

[复制链接]

楼主: wsmong2       显示全部楼层   阅读模式

楼主
发表于 16-4-2015 07:21 PM | 显示全部楼层 |阅读模式
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkOutlineFilter.h>
#include <vtkCamera.h>
#include <vtkProperty.h>
#include <vtkPolyDataNormals.h>
#include <vtkSmartPointer.h>
#include"project_config.h"
#include<vtkJPEGReader.h>
#include<vtkMarchingCubes.h>
#include<vtkStripper.h>
#include <vtkCommand.h>
#include <vtkPlaneSource.h>
#include<vtkTextureMapToPlane.h>
#include<vtkTextProperty.h>
#include<vtkTextMapper.h>
int main()
{

       
        int b[3]={1,2,3};
         vtkSmartPointer<vtkJPEGReader> jPEGReader =
    vtkSmartPointer<vtkJPEGReader>::New();
         //Read only one file
jPEGReader->SetFileName ("C:/test/img0.jpg"  );
for( int a=0;a<3;a++)
{
//create a plane
vtkSmartPointer<vtkPlaneSource> plane1 =
  vtkSmartPointer<vtkPlaneSource>::New();
//plane1->SetOrigin(0,0,0);
//plane1->SetXResolution(1.0);
//plane1->SetYResolution(1.0);
//translates the center of the plane to the specified center point.
  plane1->SetCenter(0.0+b[a], 1.0+b[a], 1.0+b[a]);
  //to rotate the plane around the center of the plane, aligning the plane normal with the specified normal
  plane1->SetNormal(1.0,1.0, 1.0);

// plane1->SetPoint1(width,0,0);
  //plane1->SetPoint2(0,height,0);

   //Apply the texture
  vtkSmartPointer<vtkTexture> texture =
    vtkSmartPointer<vtkTexture>::New();
  texture->SetInputConnection(jPEGReader->GetOutputPort());

  vtkSmartPointer<vtkTextureMapToPlane> texturePlane =
    vtkSmartPointer<vtkTextureMapToPlane>::New();
  texturePlane->SetInputConnection(plane1->GetOutputPort());

  vtkSmartPointer<vtkPolyDataMapper> planeMapper =
    vtkSmartPointer<vtkPolyDataMapper>::New();
  planeMapper->SetInputConnection(texturePlane->GetOutputPort());

  vtkSmartPointer<vtkActor> texturedPlane =
    vtkSmartPointer<vtkActor>::New();
  texturedPlane->SetMapper(planeMapper);
  texturedPlane->SetTexture(texture);
  //set opacity
texturedPlane->GetProperty()->SetOpacity(0.2);

  // Visualize the textured plane
  vtkSmartPointer<vtkRenderer> renderer =
    vtkSmartPointer<vtkRenderer>::New();
  renderer->AddActor(texturedPlane);
  renderer->SetBackground(.1, .2, .3);// Background color dark blue
  renderer->ResetCamera();

  vtkSmartPointer<vtkRenderWindow> renderWindow =
    vtkSmartPointer<vtkRenderWindow>::New();
  renderWindow->AddRenderer(renderer);

  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
    vtkSmartPointer<vtkRenderWindowInteractor>::New();
  renderWindowInteractor->SetRenderWindow(renderWindow);

  renderWindow->Render();

  renderWindowInteractor->Start();


  return 0;
}
}

我想要创建很多个plane然后把texture放进plane里面。想问为什么只有一个plane出来,要怎样弄很多plane?

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册 | 登入

本版积分规则

 WeChat
 CARI App
Get it FREE Apple App Store
Get it FREE Google play
 Instagram
cari_malaysia
FOLLOW
- 版权所有 © 1996-2017 Cari Internet Sdn Bhd 佳礼网络有限公司 (483575-W) -
0.353149s Gzip On
快速回复 返回顶部 返回列表