佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1969|回复: 0

vtk 高手求救

[复制链接]
发表于 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?

回复

使用道具 举报

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

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 26-4-2024 03:12 PM , Processed in 0.058299 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表