MeshNode

The libavg mesh node is a generic way to display a 2D polygon mesh on the screen and is fairly low-level. It works like this:

1mesh = avg.MeshNode(texhref="rgb24-64x64.png", 
2        vertexcoords=((0,0), (64,0), (0,64), (64, 64), (32, 32)),
3        texcoords=((0,0), (1,0), (0,1), (1,1), (0.5,0.5)),
4        triangles=((0,1,4), (1,3,4), (3,2,4), (2,0,4)))

The vertexcoords attribute specifies the positions of the triangle points. The triangles attribute tells libavg which points to connect to triangles. So in the example, the first triangle - (0,1,4) - has the coordinates (0,0), (64,0) and (32,32).

These triangles are textured using the image given in the texhref attribute. The image is mapped using texture coordinates. These coordinates run from 0 to 1 in both image dimensions and specify which positions on the image correspond to the different vertexes. The image is warped so the texture coordinates fit.