tak jsem dodelal rozhozeni cihel nahoru a dolu a aby nezacinala rada cihel v jedne rovine i kdyz nenavazuje na konec
Kód:
#!BPY
#********Importovani Knihoven****
import whrandom
import math
import Blender
from Blender import NMesh
from Blender.BGL import *
from Blender.Draw import *
#Events
EVENT_NOEVENT=1
EVENT_DRAW=2
EVENT_EXIT=3
#promenne pro slidery
cihel_x2= Create(15)
cihel_y2= Create(20)
xx_ofset2 = Create(0.1)
yy_ofset2 = Create(1.25)
faktor_x2 = Create(2.0)
faktor_y2 = Create(0.1)
cihla_vel_y2= Create(1.0)
cihla_vel_x2= Create(1.0)
pole_krok_z= Create(2.5)
pole_scale_z= Create(1.0)
pole_rot_z= Create(0)
pole_krok_rand_z= Create(0.0)
pole_scale_min_z= Create(1.0)
pole_scale_max_z= Create(1.0)
pole_rot_min_z= Create(0)
pole_rot_max_z= Create(0)
rankrokz = Create(0)
def cihly(cihel_x,cihel_y,yy_ofset,cihla_vel_y,cihla_vel_x,faktor_x,xx_ofset,faktor_y):
me = NMesh.GetRaw()
lastvelx=0
for i2 in range(cihel_y):
lastvelx=(whrandom.random()*faktor_x+cihla_vel_x)
for i in range(cihel_x):
randx=whrandom.random()
finishvelx=randx*faktor_x+cihla_vel_x
randy=whrandom.random()*faktor_y
randy2=whrandom.random()*faktor_y
v=NMesh.Vert(lastvelx,i2*yy_ofset+randy-randy2,0.0)
me.verts.append(v)
v=NMesh.Vert(lastvelx+finishvelx,cihla_vel_y+(i2*yy_ofset)+randy-randy2,0.0)
me.verts.append(v)
v=NMesh.Vert(lastvelx,cihla_vel_y+(i2*yy_ofset)+randy-randy2,0.0)
me.verts.append(v)
v=NMesh.Vert(lastvelx+finishvelx,i2*yy_ofset+randy-randy2,0.0)
me.verts.append(v)
lastvelx=lastvelx+finishvelx+xx_ofset
lastvelx=0
for i in range(cihel_x*cihel_y):
f=NMesh.Face()
f.v.append(me.verts[0+i*4])
f.v.append(me.verts[3+i*4])
f.v.append(me.verts[1+i*4])
f.v.append(me.verts[2+i*4])
me.faces.append(f)
NMesh.PutRaw(me,"test",1)
Blender.Redraw
def draw():
####Promenne pro offset tlacitek
tlac_y=-100
####promenne pro slidery
global cihel_x2,cihel_y2,yy_ofset2,faktor_x2,cihla_vel_y2,cihla_vel_x2,xx_ofset2,faktor_y2
####Popisky
glClear(GL_COLOR_BUFFER_BIT)
###Parametry GUI tlacitek
# glRasterPos2d(15,360+tlac_y)
# Text("Text")
cihel_x2= Number("Pocet cihel x:",EVENT_NOEVENT,10,295+tlac_y+60,120,18,cihel_x2.val,0,1000,"Pocet cihel na ose x");
cihel_y2= Number("Pocet cihel y:",EVENT_NOEVENT,10,295+tlac_y+30,120,18,cihel_y2.val,0,1000,"Pocet cihel na ose y");
cihla_vel_x2= Number("Velikost cihly na ose x:",EVENT_NOEVENT,10,295+tlac_y-90,220,18,cihla_vel_x2.val,0,10,"Velikost cihly na ose x")
cihla_vel_y2 = Number("Velikost cihly na ose y:",EVENT_NOEVENT,10,295+tlac_y-120,220,18,cihla_vel_y2.val,0,10,"Velikost cihly na ose y");
faktor_x2=Number("Faktor nahody pro osu X:",EVENT_NOEVENT,10,295+tlac_y-30,220,18,faktor_x2.val,0,10,"Faktor nahody pro velikost cihly na ose x");
faktor_y2=Number("Faktor nahody pro osu Y:",EVENT_NOEVENT,10,295+tlac_y-60,220,18,faktor_y2.val,0,10,"Faktor nahody pro velikost cihly na ose y");
xx_ofset2= Number("Offset na ose x:",EVENT_NOEVENT,150,295+tlac_y+60,150,18,xx_ofset2.val,0,200,"Offset na ose x");
yy_ofset2= Number("Offset na ose y:",EVENT_NOEVENT,150,295+tlac_y+30,150,18,yy_ofset2.val,0,200,"Offset na ose y");
# *****Tlacitka pro randomize
###Nakreslit tlacitka
Button("Make Wall",EVENT_DRAW,20,10,80,18)
Button("Exit",EVENT_EXIT,270,10,80,18)
def event(evt,val):
if(evt == QKEY and not val):
Exit()
def bevent(evt):
###Ovladani GUI soucasti
if(evt== EVENT_EXIT):
Exit()
if (evt==EVENT_DRAW):
cihly(cihel_x2.val,cihel_y2.val,yy_ofset2.val,cihla_vel_y2.val,cihla_vel_x2.val,faktor_x2.val,xx_ofset2.val,faktor_y2.val)
Blender.Redraw
Register(draw,event,bevent)