How to apply different textures to each face of a tetrahedron

Here is my code example.(only can use one actor!)
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2)
VTK_MODULE_INIT(vtkInteractionStyle)
#include <vtkPoints.h>
#include <vtkPolygon.h>
#include <vtkCellArray.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkTexture.h>
int main()
{
float pts[4][3] = { {0,0,0},{1,0,0},{0,1,0},{0,0,1} };
vtkIdType ids[4][3] = { {0,2,1},{0,3,2},{0,1,3},{1,2,3} };
vtkSmartPointer vtkPts = vtkSmartPointer::New();
for (int i = 0; i < 4; i++)
vtkPts->InsertPoint(i, pts[i]);
vtkSmartPointer polys = vtkSmartPointer::New();
for (int i = 0; i < 4; i++)
{
//I have four textures here for each face of tetrahedron
//how can i achieve this function?
vtkSmartPointer poly = vtkSmartPointer::New();
poly->GetPointIds()->SetNumberOfIds(3);
for (int j = 0; j < 3; j++)
poly->GetPointIds()->SetId(j, ids[i][j]);
polys->InsertNextCell(poly);
}
vtkSmartPointer polydata = vtkSmartPointer::New();
polydata->SetPoints(vtkPts);
polydata->SetPolys(polys);
vtkSmartPointer mapper = vtkSmartPointer::New();
mapper->SetInputData(polydata);
vtkSmartPointer actor = vtkSmartPointer::New();
actor->SetMapper(mapper);
vtkSmartPointer render = vtkSmartPointer::New();
render->AddActor(actor);
vtkSmartPointer renWin = vtkSmartPointer::New();
vtkSmartPointer Iren = vtkSmartPointer::New();
renWin->AddRenderer(render);
renWin->SetInteractor(Iren);
renWin->Render();
Iren->Start();
return 1;
}

Hello, Cheng. I’m assuming this:

Means this:

vtkSmartPointer<vtkMapper> mapper = vtkTexture<vtkMapper>::New();

Tip: use the code markdown syntax :wink:.

Answering your question: No, from the design of vtkActor class.

However, you can achieve the same effect of “multiple textures” by tiling your four textures in a single larger image like this:

image

Then you assign different texture coordinates (2D UV coordinates) to each vertex (3D XYZ coordinates) of your actor to match each tile in your texture image to a face of your model. VTK has some ready-to-use texture mappers to save you the trouble of computing UV coordinates by hand (specially handy when it comes to curved surfaces). I suggest you to study the vtkTexture class and googling for vtkTextureMapTo* classes and their examples.

Texture mapping can be visualized as unfolding a 3D polyhedron into the 2D plane of the texture image:

image
(made with Blender)

Here’s an example of someone trying to map an image into a cube (the closest thing to your problem): c++ - Apply an image on cube faces - VTK - Stack Overflow . It’s in Pyton, but the API is the same.

all the best

Thanks for your suggestions.The code error may have occurred during the paste process,next time I will check the code carefully. I will try the method you said.