# Triangulated model rasterization: light-weight Python library

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).

• What do you consider ligtweight and why not use opengl or matplotlib? – joojaa Feb 27 '16 at 9:49
• @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. – Charlie Feb 29 '16 at 17:09
• Can i ask you how you defined colors for each triangle when you have already a variable defined in 3D-space ? Cheers, Aurel – Aurelien Sanchez Mar 24 '16 at 22:51
• @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 – Charlie Mar 26 '16 at 6:35