| Code: |
|
from Blender import * from math import * from Blender.Mathutils import * omega = 1.618 dia = 0.025 floor_width = 1 floor_height = 2 pillar_rows = 2 pillar_cols = 2 rad = pi / 180 def create_bow(sc, ri, deg, num): c = (float(dia) * pi) / float(12) a = (c * omega) / 2 b = omega * a * 2 n = 0 t1 = Mesh.New("Bow_Mash") r = sqrt(ri * ri * 2) / 2 - dia / 2 for s in range(num): LocX = (r * sin(((deg * rad) / (num - 1)) * n))# + (2 * a + c) LocY = (r * cos(((deg * rad) / (num - 1)) * n))# + b bX = (b * sin(((deg * rad) / (num - 1)) * n)) bY = (b * cos(((deg * rad) / (num - 1)) * n)) points = [[0, LocY + bY, LocX + bX], [a, LocY, LocX], [a + c, LocY, LocX], [(2 * a + c), LocY + bY, LocX + bX]] t1.verts.extend(points) edge = [[n * 4 + 0, n * 4 + 1], [n * 4 + 1, n * 4 + 2], [n * 4 + 2, n * 4 + 3]] t1.edges.extend(edge) if(n > 0): t1.edges.extend([[old[0][0], edge[0][0]], [old[0][1], edge[0][1]], [old[1][1], edge[1][1]], [old[2][1], edge[2][1]]]) old = edge n = n + 1 Mesh.Mode(Mesh.SelectModes['VERTEX']) for v in t1.verts: v.sel = 1 ob = Object.New("Mesh", "Bow") ob.link(t1) sc.link(ob) t1.fill() return(ob, a, c) def make_cross(sc, ob, a, c): Window.EditMode(0) for o in Object.GetSelected(): o.sel = 0 ob.sel = 1 Object.Duplicate(1) aob = sc.getActiveObject() aob.RotZ = 90 * rad ob.LocX = -((2 * a + c) / 2) aob.LocY = -((2 * a + c) / 2) ob.join([aob]) ob.setEuler([0.0, 0.0, 45.0 * rad]) ob.LocX = 0.5 ob.makeDisplayList() Window.RedrawAll() sc.unlink(aob) print "Dom-Script started..." sc = Scene.GetCurrent() (ob, a, c) = create_bow(sc, floor_width, 180, 16) make_cross(sc, ob, a, c) Window.RedrawAll() print "Dom-Script finished" |