############################################################# ############################################################# ## ## CELLNOISE ## _ Jimmy Haze ## _ 9/2003 ############################################################# ## # CELLNOISE adapted to dynoise.py by JMS (28/09) # tested with blender2.28a # how to: # 1/ open dynoise.py on a blender/python script window # 2/ open cellnoise.py on a second blender/python script window # 3/ alt-p on the cellnoise script # ## import Blender from Blender import * from Blender.Draw import * from Blender.BGL import * from math import * from whrandom import * # ## import noise import dynoise # ############################################################# # ############################################################# xres=Create(32) yres=Create(32) cellf =Create(2) cex =Create(1.0) cey =Create(1.0) cez =Create(0) cezz =Create(0) offz =Create(0) offx =Create(0.0) offy =Create(0.0) offz1 =Create(1) offz2 =Create(1) rx=Create(0.0) ry=Create(0.0) rz=Create(0) ############################################################# # ############################################################# def Cell(): global cex, cey, cez, cezz, offx, offy, offz1, offz2 global xres, yres, cellf, rx, ry, rz, offz, noiseg #### me=NMesh.GetRaw() #### i=0.0 j=0.0 x=0.0 y=0.0 z=0.0 xmax = xres.val ymax = yres.val ######## for i in range(0, xmax, 1): for j in range(0, ymax, 1): # xv = (i-xmax/2.0)/10.0 yv = (j-ymax/2.0)/10.0 # xn=(xv/2)*cex.val*cellf.val+offx.val xn+=0.25*rx.val*random() yn=(yv/2)*cey.val*cellf.val+offy.val yn+=0.25*ry.val*random() # xm=(xv/2)*cez.val*0.5*cellf.val+offz.val xm+=0.25*rx.val*random() ym=(yv/2)*cezz.val*0.5*cellf.val+offz.val ym+=0.25*ry.val*random() ##------------------- modified : 28/09 #vn= noise.cellnoise(xn,yn) pos=[xn,yn,0.0] vn=dynoise.NG.FNoise(pos) #vm= noise.cellnoise(xm,ym) pos=[xm,ym,0.0] vm=dynoise.NG.FNoise(pos) #vo= noise.noise(xm,yn) pos=[xm,yn,0.0] vo=dynoise.NG.FNoise(pos) ##------------------- modified : 28/09 # z = vn *offz1.val z +=vm *offz2.val z +=0.2*rz.val*sin(vn/vm*rz.val=",2,20,80,65,25,offx.val,-96.0,96.0,"cell X offset") offy=Number("=",2,92.5,80,65,25,offy.val,-96.0,96.0,"cell Y offset") offz1=Number("Z1=",2,20,45,137.5,25,offz1.val,-32.0,32.0) offz2=Number("Z2=",2,165,45,85,25,offz2.val,-32.0,32.0) cellf=Number("frequency =",2,20,110,137.5,25,cellf.val,0.0,64.0,"freq.") xres=Number("X Size =",2,20, 10, 110, 25, xres.val, 2, 128) yres=Number("Y Size =",2,140, 10, 110, 25, yres.val, 2, 128) # Button("Exit ", 1, 165, 200, 85, 25) ### def event(evt, val): if (evt== QKEY and not val): Exit() def bevent(evt): if (evt== 1): Exit() elif (evt== 2): Cell() Draw() elif (evt== 3): Cell() Redraw() Cell() Register(draw, event, bevent) Blender.Redraw()