from Blender import *
import math, random, sys
radius = 100.0
height = .033
size = .033
max_alt = .02
print
offset = 0.0
loops = 50
maxangle = 4.0
scene = Scene.GetCurrent()
editmode = Window.EditMode()
if editmode : Window.EditMode(0)
material_on = Material.New("On")
material_off = Material.New("Off")
coords = []
faces = []
sys.exit()
for l in range(loops) :
erase = False
if random.random()<.5 :
erase = not erase
fragments = int(maxangle/(math.atan((size/2)/(radius+height))*180/math.pi*2))
divide = maxangle / fragments
radius_increment = height/fragments
for i in range(fragments) :
if random.random()<.1 :
radius += radius_increment
offset += max_alt/fragments
continue
if random.random()<.01 :
erase = not erase
coords = []
angleA = ((i * divide) + (divide / 75)) / 180 * math.pi
angleB = (((i+1) * divide) - (divide / 75)) / 180 * math.pi
altitude = max_alt
if erase : altitude = random.random()*max_alt
for i in range(2) :
coords.append([])
coords[0+(i*4)].append(math.cos(angleA)*radius)
coords[0+(i*4)].append(math.sin(angleA)*radius)
coords[0+(i*4)].append(i*altitude+offset)
coords.append([])
coords[1+(i*4)].append(math.cos(angleA)*(radius+height))
coords[1+(i*4)].append(math.sin(angleA)*(radius+height))
coords[1+(i*4)].append(i*altitude+offset)
coords.append([])
coords[2+(i*4)].append(math.cos(angleB)*(radius+height+radius_increment))
coords[2+(i*4)].append(math.sin(angleB)*(radius+height+radius_increment))
coords[2+(i*4)].append(i*altitude+offset)
coords.append([])
coords[3+(i*4)].append(math.cos(angleB)*(radius+radius_increment))
coords[3+(i*4)].append(math.sin(angleB)*(radius+radius_increment))
coords[3+(i*4)].append(i*altitude+offset)
faces = [[3,2,1,0],[4,5,6,7],[0,1,5,4],[1,2,6,5],[2,3,7,6],[3,0,4,7]]
mesh = Mesh.New("fragment_mesh")
mesh.verts.extend(coords)
mesh.faces.extend(faces)
mesh.vertexColors = 1
mesh.faces[0].col[0].r = 255
mesh.faces[0].col[1].g = 255
mesh.faces[0].col[2].b = 255
object = scene.objects.new(mesh, "fragment")
object.setMaterials([material_on])
if erase : object.setMaterials([material_off])
object.colbits = (1<<0)
radius += radius_increment
offset += max_alt/fragments
umxprime wrote:Everything (modelling, positionning, yafaray materials) except camera position : made with python scripting.
Users browsing this forum: No registered users and 0 guests