[vtkusers] Texture mapping on multiple planes?

Karl Beal KBeal at HNTB.com
Wed Aug 17 17:10:55 EDT 2005


I need to map a texture to a 3D polygon.  Using vtkTextureMapToPlane I
only see a way to properly map to one plane.  What is the best way to do
this?  
My example below shows a cube but I need to do this with varying shapes.

Here is a summary of the pipeline
vtkPolyData->vtkTextureMapToPlane->vtkPolyDataMapper->vtkActor

--------------------------------------------------
vtkPolyData *cube = vtkPolyData::New();
vtkPoints *points = vtkPoints::New();
vtkCellArray *polys = vtkCellArray::New();

for (i=0; i<8; i++) points->InsertPoint(i,x[i]);
for (i=0; i<6; i++) polys->InsertNextCell(4,pts[i]);

cube->SetPoints(points);
points->Delete();
cube->SetPolys(polys);
polys->Delete();

vtkTextureMapToPlane *planeMap = vtkTextureMapToPlane::New();
planeMap->AutomaticPlaneGenerationOff();
planeMap->SetOrigin(0.0, 0.0, 0.0);       // Define plane to map on
planeMap->SetPoint1( 0, 1.0, 0.0 );
planeMap->SetPoint2( 0,0, 1.0 );

planeMap->SetInput(cube);

vtkPolyDataMapper *cubeMapper = vtkPolyDataMapper::New();
cubeMapper->SetInput(planeMap->GetPolyDataOutput());

vtkJPEGReader* pBmpReader = vtkJPEGReader::New();
pBmpReader->SetFileName("metal.jpg");

vtkTexture* pPolyTex = vtkTexture::New();
pPolyTex->SetInput( pBmpReader->GetOutput() );
pPolyTex->InterpolateOn();

vtkActor *cubeActor = vtkActor::New();
cubeActor->SetMapper(cubeMapper);
cubeActor->SetTexture(pPolyTex);



This e-mail and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed. If you are NOT the intended recipient or the person responsible for delivering the e-mail to the intended recipient, be advised that you have received this e-mail in error and that any use, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited.. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050817/ff283e3d/attachment.htm>


More information about the vtkusers mailing list