blender to C++ exporter for vertices and normals of triangulated mesh

Use in vnvnvn way with OpenGL.

import bpy
ao = bpy.context.active_object

lineNum = 0
f = open("Obj.cpp", "w")

# vertices and normals
lineNum = 0
i = 0
l = []
f.write("GLfloat Obj::vtxnml_src[] = {\n")
for v in ao.data.vertices:
    i += 1
    n = v.normal
    f.write("%f, %f, %f, \t%f, %f, %f,\n"% (v.co.x, v.co.y, v.co.z, n.x, n.y, n.z))
    if i%10 == 0:
        f.write("// line %d\n" %i)
        
f.write("};\n\n")

#indices
lineNum = 0
i = 0
f.write("GLushort Obj::idx_src[] = {\n")
for p in ao.data.polygons:
    l = []
    for ek in p.edge_keys:
        for v in ek:
            if v.numerator not in l:
                i += 1
                l.append(v.numerator)
                f.write("%d, "% v.numerator)
                if i%3 == 0:
                    f.write("\t") 
                    if i%12 == 0:
                        f.write("\n") 
                        lineNum += 1
                        if lineNum%10 == 0:
                            f.write("// line %d\n" %lineNum)
        
f.write("};\n")

f.close()