<p>I've found <a href="https://www.vtk.org" rel="nofollow noreferrer">VTK</a> library and used bindings to Python  3 available from different Anaconda organizations: <a href="https://anaconda.org/anaconda/vtk" rel="nofollow noreferrer">anaconda</a> itself, <a href="https://anaconda.org/conda-forge/vtk" rel="nofollow noreferrer">conda-forge</a>, <a href="https://anaconda.org/clinicalgraphics/vtk" rel="nofollow noreferrer">clinicalgraphics</a> and <a href="https://anaconda.org/menpo/vtk" rel="nofollow noreferrer">menpo</a>.
Also it can be compiled from sources.</p>

<p>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.</p>

<p><a href="http://www.menpo.org" rel="nofollow noreferrer">menpo</a> has its own wrapper for VTK and <a href="http://code.enthought.com/projects/mayavi/" rel="nofollow noreferrer">mayavi</a> called <a href="http://www.menpo.org/menpo3d/" rel="nofollow noreferrer">menpo3d</a>.
I have not tried it yet, but examples look very simple.</p>

CC BY-SA 3.0
2017-11-01T18:50:48.140Z
2017-11-01T18:50:48.140Z
Charlie
<p>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).</p>

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

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

CC BY-SA 3.0
2016-02-27T09:49:06.657Z
What do you consider ligtweight and why not use opengl or matplotlib?
joojaa
CC BY-SA 3.0
2016-02-29T17:09:13.360Z
@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
CC BY-SA 3.0
2016-03-24T22:51:04.317Z
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
CC BY-SA 3.0
2016-03-26T06:35:48.780Z
@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
<3d><raster-image><render>
Triangulated model rasterization: light-weight Python library
Charlie
# Triangulated model rasterization: light-weight Python library

(Asked by: username_0 on 2016-02-25)

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

**Tags:** 3d, raster-image, render

> **Comments:**
> **username_1**: What do you consider ligtweight and why not use opengl or matplotlib?  
> **username_0**: @username_1 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.  
> **username_2**: Can i ask you how you defined colors for each triangle when you have already a variable defined in 3D-space ? Cheers, Aurel  
> **username_0**: @username_2 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  

---

## 1 answers

### Answer by username_0 on 2017-11-01. Score: 0 | Accepted answer

I've found [VTK](https://www.vtk.org) library and used bindings to Python 3 available from different Anaconda organizations: [anaconda](https://anaconda.org/anaconda/vtk) itself, [conda-forge](https://anaconda.org/conda-forge/vtk), [clinicalgraphics](https://anaconda.org/clinicalgraphics/vtk) and [menpo](https://anaconda.org/menpo/vtk).
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](http://www.menpo.org) has its own wrapper for VTK and [mayavi](http://code.enthought.com/projects/mayavi/) called [menpo3d](http://www.menpo.org/menpo3d/).
I have not tried it yet, but examples look very simple.


---

