[vtkusers] Texture problem - is it a BUG?

Martin Petrek Petrek at kmlinux.fjfi.cvut.cz
Thu Apr 10 03:26:36 EDT 2003


Hi, I've problem with mapping texture 
onto the surface made of triangles. I've texture Image 't.ppm' (256x256) 
and  i like to map it on surface. I've defined  2 triangles and texture 
coordinates (see code). The corners of the texture corespondentwith the 
right points. But the result is quite strange. Can anybody tell me what  
I'm doing wrong?  Please help.

					Martin

#!/usr/bin/vtk
package require vtk
package require vtkinteraction


vtkPolyData triang
vtkPoints points
vtkCellArray polys

vtkPolyDataMapper triangMapper
vtkActor triangActor

points InsertPoint 0 0 0 0
points InsertPoint 1 1 0 0 
points InsertPoint 2 1 1 0
points InsertPoint 3 0 1 0

polys InsertNextCell 3
polys InsertCellPoint 0
polys InsertCellPoint 1
polys InsertCellPoint 2

polys InsertNextCell 3
polys InsertCellPoint 2
polys InsertCellPoint 3
polys InsertCellPoint 0


triang SetPoints points
triang SetPolys polys

		     
vtkFloatArray tc
 tc SetNumberOfComponents 2

 tc SetNumberOfTuples 6
  tc SetTuple2 0 0 0
  tc SetTuple2 1 1 0 
  tc SetTuple2 2 1 1
  tc SetTuple2 3 1 1
  tc SetTuple2 4 0 1
  tc SetTuple2 5 0 0


  [triang GetPointData] SetTCoords tc

  
vtkPNMReader pnmReader
  pnmReader SetFileName "t.ppm"
vtkTexture atext
  atext SetInput [pnmReader GetOutput]
  atext InterpolateOn

  triangMapper SetInput triang

  triangActor SetMapper triangMapper
  triangActor SetTexture atext

vtkRenderer ren1
vtkRenderWindow renWin
    renWin AddRenderer ren1
vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin

ren1 SetBackground 0.1 0.2 0.4
ren1 AddActor triangActor
renWin SetSize 500 500

# render the image
iren AddObserver UserEvent {wm deiconify .vtkInteract}
renWin Render

ren1 ResetCameraClippingRange
renWin Render

# prevent the tk window from showing up then start the event loop
wm withdraw .



-- 
***********************************************************
* -----------------------+               \'/     F J F I  *
*  Martin Petrek         |                O      C V U T  *
*  5. rocnik  FJFI CVUT  |             \'/ \'/    PRAHA   *
* -----------------------+                                *
*                                                         *
* Fakulta jaderna a fyzikalne inzenyrska                  *
* Faculty of Nuclear sciences and Physical engineering    *
* ======================================================= *
* email : petrek at newton.fjfi.cvut.cz                      *
* www   : http://www-troja.fjfi.cvut.cz/~petrek           *
*         http://bimbo.fjfi.cvut.cz/~petrek               *
* ICQ   : 52725854   nyni opet v akci                     *
*                                                         *
***********************************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.ppm
Type: image/x-portable-pixmap
Size: 65596 bytes
Desc: 
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030410/b5be8e19/attachment.ppm>


More information about the vtkusers mailing list