MayaVI Texture Map

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

MayaVI Texture Map

Dimagiba, Lorenzo
Hi,

so I saw this post: http://en.usenet.digipedia.org/thread/15952/3032/

I'm interested in doing something very similar, trying to texture map onto a triangulated surface. I believe I have set the texture coordinates properly, but when I try to apply a texture, nothing appears. Here is the code I am using so far.

v = mlab.figure()

vertex = np.zeros((4,3))

vertex[1,:] = [5, 1, 0]
vertex[2,:] = [1, 5, 0]
vertex[3,:] = [6, 8, 2]

tri = np.zeros((2,3))
tri[0,:] = [0,1,2]
tri[1,:] = [1,2,3]

texture = np.zeros((4,2))
texture[1, :] = [0 , 1]
texture[2, :] = [1, 1]
texture[3, :] = [1, 0]

s = mlab.triangular_mesh(vertex[:,0],vertex[:,1],vertex[:,2],tri)

s.mlab_source.dataset.point_data.t_coords = texture
ary = np.zeros((4,4))
s.mlab_source.texture = ary

mlab.show()


I'm trying to apply like a unicolor texture (ie. my array)

Any help would be appreciated.

Regards,

Lorenzo


This e-mail may contain confidential and/or privileged information for the sole use of the intended recipient.
Any review or distribution by anyone other than the person for whom it was originally intended is strictly prohibited.
If you have received this e-mail in error, please contact the sender and delete all copies.
Opinions, conclusions or other information contained in this e-mail may not be that of the organization.

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: MayaVI Texture Map

Eric Carlson
The following works for me to texture map to PolyData objects (stl objects or meshes here) . There may be easier/better ways, and I have another example that uses tvtk and allows definition of texture coordinates at the cost of not seeing the object in the MayaVi pipeline:

from enthought.tvtk.api import tvtk
from enthought.mayavi import mlab as p3d
from enthought.mayavi.sources.vtk_data_source import VTKDataSource

the_engine=p3d.get_engine()
my_scene=the_engine.new_scene()

##my_stl=tvtk.STLReader()
##my_stl.file_name="Disk_fin.stl" #any stl file
##my_stl.update()
##src2 = VTKDataSource(data = my_stl.get_output())

oct_vertices=import_table("""[1 0 0;-1 0 0;0 1 0;
              0 -1 0; 0 0 1; 0 0 -1]""",3)
oct_faces=import_table("""[1 3 5; 3 2 5; 2 4 5; 4 1 5; 1 6 3; 3 6 2; 2 6 4; 4 6 1]""",3)-1
temp=array([1.0,1.5,3.0,3.5,5.5,6.0])
mesh = tvtk.PolyData(points=oct_vertices, polys=oct_faces)
src2 = VTKDataSource(data = mesh)

bmp1 = tvtk.JPEGReader()
bmp1.file_name="IMG_5225.JPG" #any jpeg file

my_texture=tvtk.Texture()
my_texture.interpolate=0
my_texture.set_input(0,bmp1.get_output())

the_engine.add_source(src2)
asurf=p3d.pipeline.surface(src2,opacity=1.0)
asurf.actor.actor.mapper.scalar_visibility=False
asurf.actor.enable_texture=True
asurf.actor.tcoord_generator_mode='sphere' #'plane' or 'sphere' or 'cylinder'
asurf.actor.actor.texture=my_texture
p3d.show()



-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Dimagiba, Lorenzo
Sent: Friday, January 18, 2013 9:42 AM
To: [hidden email]
Subject: [Enthought-Dev] MayaVI Texture Map

Hi,

so I saw this post: http://en.usenet.digipedia.org/thread/15952/3032/

I'm interested in doing something very similar, trying to texture map onto a triangulated surface. I believe I have set the texture coordinates properly, but when I try to apply a texture, nothing appears. Here is the code I am using so far.

v = mlab.figure()

vertex = np.zeros((4,3))

vertex[1,:] = [5, 1, 0]
vertex[2,:] = [1, 5, 0]
vertex[3,:] = [6, 8, 2]

tri = np.zeros((2,3))
tri[0,:] = [0,1,2]
tri[1,:] = [1,2,3]

texture = np.zeros((4,2))
texture[1, :] = [0 , 1]
texture[2, :] = [1, 1]
texture[3, :] = [1, 0]

s = mlab.triangular_mesh(vertex[:,0],vertex[:,1],vertex[:,2],tri)

s.mlab_source.dataset.point_data.t_coords = texture
ary = np.zeros((4,4))
s.mlab_source.texture = ary

mlab.show()


I'm trying to apply like a unicolor texture (ie. my array)

Any help would be appreciated.

Regards,

Lorenzo


This e-mail may contain confidential and/or privileged information for the sole use of the intended recipient.
Any review or distribution by anyone other than the person for whom it was originally intended is strictly prohibited.
If you have received this e-mail in error, please contact the sender and delete all copies.
Opinions, conclusions or other information contained in this e-mail may not be that of the organization.

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev