码迷,mamicode.com
首页 > 其他好文 > 详细

纹理贴图

时间:2016-06-17 16:51:04      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:

vtkNew<vtkPoints> points;
        points->SetNumberOfPoints(4);
        points->SetPoint(0, 0, 0, 0);
        points->SetPoint(1, 1, 0, 0);
        points->SetPoint(2, 1, 1, 0);
        points->SetPoint(3, 0, 1, 0);

        vtkNew<vtkCellArray> polygons;
        polygons->InsertNextCell(4);
        polygons->InsertCellPoint(0);
        polygons->InsertCellPoint(1);
        polygons->InsertCellPoint(2);
        polygons->InsertCellPoint(3);

        vtkNew<vtkFloatArray> texcoord;
        texcoord->SetNumberOfComponents(3);
        double t0[] = {0, 0, 0};
        double t1[] = {1, 0, 0};
        double t2[] = {1, 1, 0};
        double t3[] = {0, 1, 0};

        texcoord->InsertNextTuple(t0);
        texcoord->InsertNextTuple(t1);
        texcoord->InsertNextTuple(t2);
        texcoord->InsertNextTuple(t3);

        vtkNew<vtkPolyData> polydata;
        polydata->SetPoints(points.GetPointer());
        polydata->SetPolys(polygons.GetPointer());
        polydata->GetPointData()->SetTCoords(texcoord.GetPointer());

        vtkNew<vtkPolyDataMapper> mapper;
        mapper->SetInputData(polydata.GetPointer());

        vtkNew<vtkPNGReader> png;
        png->SetFileName("/home/cc/1.png");

        vtkNew<vtkTexture> texture;
        texture->SetInputConnection(png->GetOutputPort());

        vtkNew<vtkActor> actor;
        actor->RotateX(90);

        actor->SetMapper(mapper.GetPointer());
        actor->SetTexture(texture.GetPointer());

 

纹理贴图

标签:

原文地址:http://www.cnblogs.com/nmgxbc/p/5594213.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!