[vtkusers] mapping texture on spehere: deata mirrored
Robert Belleman
robbel at science.uva.nl
Mon Feb 4 08:53:40 EST 2002
Hi Sidney,
Here's a way to get the image appear right:
pictureLayerActor->GetProperty()->BackfaceCullingOff();
pictureLayerActor->GetProperty()->FrontfaceCullingOn();
But I'm pretty sure you're not going to like the side effects... ;-)
Seriously though; I don't think this is a problem of
vtkTexturedSphereSource (see for example
examples/contrib/examplesTcl/earth.tcl which takes the texture from
VTK_DATA/earth.ppm, which is not mirrored).
I'm afraid you will have to remap you array.
Best,
-- Rob
[] Robert Belleman X Section Computational Science []
[] robbel at science.uva.nl |X| University of Amsterdam, the Netherlands []
[] tel: (+31) 20 525 7510 X http://www.science.uva.nl/~robbel/ []
On Mon, Feb 04, 2002 at 12:13:32PM +0100, Sidney Cadot wrote:
>
> 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
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list