[vtkusers] Can't view texture after mapping on .obj file

Joachim Pouderoux joachim.pouderoux at kitware.com
Mon Nov 26 03:37:12 EST 2012


Hi Judith,

Does your obj file contains texture coordinates?
They are a basic requirement if you want to apply a texture on an object,
if you do not provide them, it is impossible for a graphic renderer to know
how to apply the texture on the object.
You may have to use a modelling tool to create those coordinates or if your
object is simple you can try to compute them by yourself (manually or by
using some VTK filters like vtkTextureMapToSphere).

Regards,

2012/11/26 Judith Tony <contactjudith at yahoo.co.in>

> Dear all,
>
> I've tried to texture map an .obj file using the PNG file.
> But I could not see the texture after rendering.Here is my code:
> *************************************************
> from vtk import *
> object = vtkOBJReader()
> object.SetFileName('aa.obj')
> objectMapper = vtkPolyDataMapper()
> objectMapper.SetInputConnection(object.GetOutputPort())
> objectActor=vtkActor()
> objectActor.SetMapper(objectMapper)
> # Read the image data from a file
> pngreader = vtkPNGReader()
> pngreader.SetFileName('aa.png')
> pngreader.Update()
>
> # Create texture object
> texture = vtkTexture()
> texture.SetInputConnection(pngreader.GetOutputPort())
> texture.InterpolateOn()
> objectActor.SetTexture(texture)
> ren = vtkRenderer()
> ren.AddActor(objectActor)
> .
> .
> .
> ***********************************
> How can I view the texture on the top of the .obj file.Pls throw light on
> this
> Thank you
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>


-- 
*Joachim Pouderoux*

*PhD, R&D Enginee*r
*Kitware SAS <http://www.kitware.fr>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121126/ee19f382/attachment.htm>


More information about the vtkusers mailing list