Normal specification with Mayavi

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

Normal specification with Mayavi

Eric Larson
Hello,

I have a 3D mesh defined by a set of vertices and connecting triangles. Plotting them is easy in Mayavi. However, I also know the associated set of vertex normals, but I cannot figure out how to pass them to Mayavi for plotting, which is important for the surface to render properly. Currently this is the (simple) code I use to plot:

from mayavi import mlab

mesh = mlab.pipeline.triangular_mesh_source(x, y, z, tris)

surf = mlab.pipeline.surface(mesh)


I have tried using the "mlab.pipeline.poly_data_normals" functionality, but can't seem to find documentation on how to use it (or anything else) to either a) do decent automatic vertex normal estimation, or even better b) allow me to manually pass in the vertex normals, since I know what the true values are. Has anyone else tried to do this?


Cheers,

Eric



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

Re: Normal specification with Mayavi

Eelco Hoogendoorn

mesh.data.point_data.normals = your_normal_data_here_as_Nx3_array
mesh.data.cell_data.normals = None

That does the trick for me. Also took me a while to figure out.


On Thu, Dec 19, 2013 at 8:07 PM, Eric Larson <[hidden email]> wrote:
Hello,

I have a 3D mesh defined by a set of vertices and connecting triangles. Plotting them is easy in Mayavi. However, I also know the associated set of vertex normals, but I cannot figure out how to pass them to Mayavi for plotting, which is important for the surface to render properly. Currently this is the (simple) code I use to plot:

from mayavi import mlab

mesh = mlab.pipeline.triangular_mesh_source(x, y, z, tris)

surf = mlab.pipeline.surface(mesh)


I have tried using the "mlab.pipeline.poly_data_normals" functionality, but can't seem to find documentation on how to use it (or anything else) to either a) do decent automatic vertex normal estimation, or even better b) allow me to manually pass in the vertex normals, since I know what the true values are. Has anyone else tried to do this?


Cheers,

Eric



_______________________________________________
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