[vtkusers] Problem setting texture coordinates via SetTCoords...
Terry J. Ligocki
tjligocki at lbl.gov
Fri Feb 13 02:27:12 EST 2004
The follow message was posted on February 5th by Ted Sternberg:
> SetTCoords() seems to have no effect. I'm working with VTK checked out
> from your CVS repository -- tag release-4-4.
>
> Consider the program included below [see bottom of this message]. This
> is your triangularTexture.py from the VTK 3.2 distribution, modified
> by me to run under VTK 4.x as well (vtkTCoords becomes vtkFloatArray,
> etc).
>
> Run this against VTK 3.2 ("python triangularTexture.py") and you get
> something that looks like a diamond with some decorative cutouts
> (which are the texture). Run it against VTK 4.4 ("vtkpython
> triangularTexture.py") and you don't see the cutouts. Run it against
> VTK 3.2 again -- this time commenting out the two places where
> SetTCoords() gets invoked -- and it looks like it does under VTK 4.4,
> i.e. no texture.
Apparently, there have been no responses to this e-mail. I am very
surprised and a bit dismayed. Is no one using SetTCoords() under VTK
4.x? Does it work for everyone else? From C++? From Python? Why no
comments? If it doesn't work, why no comments?
Usually this list is very responsive and informative. Also, if the
people using VTK don't have much information, the developers provide
some guidance or commentary. Someone, at least, says something, :-).
There may just be a simple correction necessary or something could be
broken. Any insight would be very helpful!
Ted has found a torturous work around by including 2-3 addition filters
downstream which do various unpleasant transformations to achieve what
"SetTCoords" was doing for him upstream. It is not a very satisfactory
solution.
Thank-you for your time and help with this. Please direct any followups
to the VTK list, or Ted, tdsternberg at lbl.gov, and I, tjligocki at lbl.gov,
(and we will summarize to the VTK list!)...
Terry J. (Ligocki, tjligocki at lbl.gov)
Applied Numerical Algorithms Group
Lawrence Berkeley National Laboratory
>#======================== program begins here =======================
>
>use_tcoords = 1
>
>import os
>
>from libVTKCommonPython import *
>from libVTKGraphicsPython import *
>
>try:
> foo = vtkTCoords()
> vtk_version = 3
>except:
> vtk_version = 4
>
>
>#
># create a triangular texture and save it as a ppm
>#
>ren = vtkRenderer()
>renWin = vtkRenderWindow()
>renWin.AddRenderer(ren)
>renWin.SetSize(400,400)
>iren = vtkRenderWindowInteractor()
>iren.SetRenderWindow(renWin)
>
>
>aTriangularTexture = vtkTriangularTexture()
>aTriangularTexture.SetTexturePattern(1)
>aTriangularTexture.SetXSize(32)
>aTriangularTexture.SetYSize(32)
>
>
>points = vtkPoints()
>points.InsertPoint(0,0.0,0.0,0.0)
>points.InsertPoint(1,1.0,0.0,0.0)
>points.InsertPoint(2,.5,1.0,0.0)
>points.InsertPoint(3,1.0,0.0,0.0)
>points.InsertPoint(4,0.0,0.0,0.0)
>points.InsertPoint(5,.5,-1.0,.5)
>
>if vtk_version == 3:
> tCoords = vtkTCoords()
> insert_func = tCoords.InsertTCoord
>elif vtk_version == 4:
> tCoords = vtkFloatArray()
> tCoords.SetNumberOfComponents(3)
> insert_func = tCoords.InsertTuple3
>apply(insert_func, (0,0.0,0.0,0.0))
>apply(insert_func, (1,1.0,0.0,0.0))
>apply(insert_func, (2,.5,.86602540378443864676,0.0))
>apply(insert_func, (3,0.0,0.0,0.0))
>apply(insert_func, (4,1.0,0.0,0.0))
>apply(insert_func, (5,.5,.86602540378443864676,0.0))
>
>pointData = vtkPointData()
>if use_tcoords:
> pointData.SetTCoords(tCoords)
>
>triangles = vtkCellArray()
>triangles.InsertNextCell(3)
>triangles.InsertCellPoint(0)
>triangles.InsertCellPoint(1)
>triangles.InsertCellPoint(2)
>triangles.InsertNextCell(3)
>triangles.InsertCellPoint(3)
>triangles.InsertCellPoint(4)
>triangles.InsertCellPoint(5)
>
>triangle = vtkPolyData()
>triangle.SetPolys(triangles)
>triangle.SetPoints(points)
>if use_tcoords:
> triangle.GetPointData().SetTCoords(tCoords)
>
>triangleMapper = vtkPolyDataMapper()
>triangleMapper.SetInput(triangle)
>
>aTexture = vtkTexture()
>aTexture.SetInput(aTriangularTexture.GetOutput())
>
>triangleActor = vtkActor()
>triangleActor.SetMapper(triangleMapper)
>triangleActor.SetTexture(aTexture)
>
>ren.SetBackground(.3,.7,.2)
>ren.AddActor(triangleActor)
>ren.GetActiveCamera().Zoom(1.5)
>
># render the image
>#
>iren.Initialize()
>
>iren.Start()
>#======================== program ends here =======================
>
>
More information about the vtkusers
mailing list