Entries from 2017-01-01 to 1 year

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

Modified so that the front-sides are directed in their normals. (faces's normal. not vertex's normal) import bpy def cross(u, v): return [u[1]*v[2]-u[2]*v[1], u[2]*v[0]-u[0]*v[2], u[1]*v[2]-u[2]*v[1]] def dot(u, v): return u[0]*v[0]+u[1]*v…

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

If you prefer vertices/normals separated style, this is for you. import bpy ao = bpy.context.active_object lineNum = 0 f = open("Obj.cpp", "w") # vertices lineNum = 0 i = 0 l = [] f.write("GLfloat Obj::vtx_src[] = {\n") for v in ao.data.ve…

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 = …

get edges for each MeshPolygon

ao = bpy.context.active_object for p in ao.data.polygons: p for ek in p.edge_keys: ek This results like py.data.meshes['Plane'].polygons[0] (2, 3) (1, 3) (0, 1) (0, 2) bpy.data.meshes['Plane'].polygons[1] (0, 1) (1, 5) (4, 5) (0, 4) ... No…

simple text exporter of vertices for Blender Python for CPP

a small modification of the last snippet for C++. import bpy import bmesh def up(lineNum, v, f): for e in v.link_edges: ov = e.other_vert(v) if ov not in verts: verts.append(ov) lineNum = up(lineNum, ov, f) if lineNum%10 == 0: f.write("// …

simple text exporter of vertices for Blender Python

After executing main(), you can easily make use of the output on gnuplot. e.g. gnuplot> splot "file.dat" import bpy import bmesh def up(v, f): for e in v.link_edges: ov = e.other_vert(v) if ov not in verts: verts.append(ov) up(ov, f) f.wri…