I have a 3D model, which consists of ~50 thousand vertices and 100 thousand triangles. Format is: there's array of vertices' coordinates and array of triangles, which has numbers of vertices (e.g., [1, 2, 5] -- triangle, which consists of first, second and fifth vertex from vertices' array).

I calculate color of each triangle and rotate the model by myself. Also I "render" it manually, putting vertices as pixels on PIL image, but matrix with colors is enough for my purpose (I need only the matrix).

I don't know, whether I will implement robust and correct rendering function, but I cannot find light-weight library as well. All I need is to display the set of triangles with specified colors and background image fast (far less than for a second).

  • $\begingroup$ What do you consider ligtweight and why not use opengl or matplotlib? $\endgroup$ – joojaa Feb 27 '16 at 9:49
  • $\begingroup$ @joojaa Saying "lightweight", I mean not a game framework, because I don't need a lot of features just to visualize models. Matplotlib took several seconds to render the model; mayavi does it fast, but I don't need a frame with image on it -- I need just a matrix with colors. I started meeting with PyOpenGL and didn't find, how to render triangulated model and get buffer as a matrix instead of displaying it. $\endgroup$ – Charlie Feb 29 '16 at 17:09
  • $\begingroup$ Can i ask you how you defined colors for each triangle when you have already a variable defined in 3D-space ? Cheers, Aurel $\endgroup$ – Aurelien Sanchez Mar 24 '16 at 22:51
  • $\begingroup$ @AurelienSanchez sure. I want to use normal map as a color of pixels, and it's another problem -- to find normal vectors fast. Now I use glfw to render the model and planning to use glReadPixels to achieve matrix with pixels, and calculating normal vectors by myself $\endgroup$ – Charlie Mar 26 '16 at 6:35

I've found VTK library and used bindings to Python 3 available from different Anaconda organizations: anaconda itself, conda-forge, clinicalgraphics and menpo. Also it can be compiled from sources.

Works fast (I've rendered a mesh with half a million vertices without any problems) and easier in use than low-level OpenGL shaders with GLUT.

menpo has its own wrapper for VTK and mayavi called menpo3d. I have not tried it yet, but examples look very simple.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.