[vtkusers] mapping texture on spehere: deata mirrored
Sidney Cadot
sidney at v2e.nl
Mon Feb 4 06:13:32 EST 2002
Hi all,
I have to map a 2D in-memory array of shorts onto a sphere; the 2D data is
layed out as such:
array[ 0 ][ 0 ] --> top left
array[HOR-1][ 0 ] --> top right
array[ 0 ][VER-1] --> bottom left
array[HOR-1][VER-1] --> bottom right
when I draw a simple in-memory texture saying "HELLO" and map this onto a
sphere, I get a mirror-image (see code snippet below). It seems that the
TexturedSphereSource is programmed in such a way that it maps as if the
viewer is on the "inside" rather than on the "outside". Please check
http://www.v2e.nl/~sidney/hello.jpg
...to see what I mean.
Now of course I can do mirroring using a filter, but I would very much
prefer if I could get the picture right without requiring extra memory for
another image, for example by setting some flag for the
vtkTexturedSphereSource (there seems to be none) or the vtkTexture (I'm
not sure).
Does anybody know a good way of doing this?
Best regards,
Sidney Cadot
===== code snippet
vtkShortArray *array = vtkShortArray::New();
array->SetVoidArray(dmap, HOR*VER, 1);
vtkImageData *imageData = vtkImageData::New();
imageData->SetDimensions(HOR,VER,1);
imageData->SetScalarTypeToShort();
imageData->GetPointData()->SetScalars(array);
vtkTexturedSphereSource *tss = vtkTexturedSphereSource::New();
tss->SetRadius(1.000);
tss->SetThetaResolution(36);
tss->SetPhiResolution(18);
vtkPolyDataMapper *pictureLayerMapper = vtkPolyDataMapper::New();
pictureLayerMapper->SetInput(tss->GetOutput());
vtkTexture *pictureTexture = vtkTexture::New();
pictureTexture->SetInput(imageData);
vtkActor *pictureLayerActor = vtkActor::New();
pictureLayerActor->SetMapper(pictureLayerMapper);
pictureLayerActor->SetTexture(pictureTexture);
vtkRenderer *renderer = vtkRenderer::New();
renderer->AddActor(pictureLayerActor);
vtkRenderWindow *renderWindow = vtkRenderWindow::New();
renderWindow->AddRenderer(renderer);
iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renderWindow);
renderWindow->Render();
iren->Start();
===== end of code snippet
More information about the vtkusers
mailing list