#!BPY """ Name: 'ClothGen' Blender: 237 Group: 'Mesh' Tip: 'Creates cloth reminiscent of curtains' """ from Blender import * import math import sys rnd = Mathutils.Rand gridX = 45 gridY = 15 scaleX= 0.5 scaleY = -4 depth = 4 mesh = NMesh.New() for x in range(gridX): new = NMesh.Vert(x * scaleX, rnd() * depth, 0) mesh.verts.append(new) for y in range(1,gridY): for x in range(gridX): new = NMesh.Vert(x * scaleX,(rnd() * depth + mesh.verts[(y-1) * gridY + x][1] * 2) / 3,y * scaleY) mesh.verts.append(new) for y in range(1,gridY): for x in range(1,gridX-1): a = mesh.verts[y * gridX + x][1] b = mesh.verts[y * gridX + x - 1][1] c = mesh.verts[y * gridX + x + 1][1] d = (a + b + c) / 3 mesh.verts[x][1] = d for y in range(gridY-1): for x in range(gridX-1): a = mesh.verts[y * gridX + x] b = mesh.verts[y * gridX + x + 1] c = mesh.verts[(y + 1) * gridX + x] d = mesh.verts[(y + 1) * gridX + x + 1] new = NMesh.Face([a,b,d,c]) mesh.faces.append(new) objName = Draw.PupStrInput("Obj Name:","cloth",20) obj = Object.New("Mesh", objName) obj.link(mesh) Scene.GetCurrent().link(obj) Redraw()