All pastes #765816 Raw Edit

Stuff

public text v1 · immutable
·published 2007-11-08 11:29 UTC
rendered paste body
#TypeError: unsupported operand type(s) for -: 'int' and 'Button'


#!BPY

import Blender, math
from Blender import Scene, Mesh, Draw, BGL
from math import *

umin = 0
umax = 2
vmin = 0
vmax = 2

ustep = 32
vstep = 32

points = []
faces = []

def makeparam():
	scn = Scene.GetCurrent()
	uverstep = (umax - umin) / float(ustep)
	vverstep = (vmax - vmin) / float(vstep)
	me = Mesh.New()
	for u1 in range(ustep):
		u = umin + uverstep * u1
		for v1 in range(vstep):
	 		v = vmin + vverstep * v1
			x = cos(u*pi)*sin(v*pi)
			y = sin(u*pi)*sin(v*pi)
			z = cos(pi*v)
			points.append([x,y,z])
	
	me.verts.extend(points)
	
	for uf in range(ustep-1):
		for vf in range(vstep-1):
			f1 = uf + ustep * vf
			f2 = f1 + 1
			f3 = (f1 + 1) + ustep
			f4 = f1 + ustep
			
			faces.append([f1,f2,f3,f4])
			
	me.faces.extend(faces)
	ob = scn.objects.new(me,"Grid")
	ob.select(1)
	Blender.Redraw()

GEN = 1
QUIT = 2
	
def draw_gui():
	global umin
	BGL.glRasterPos2i(5, 275)
	Draw.Text("Stuf")
	umin = Draw.Number("U min: ", 3, 5, 40, 100, 25, 0, -99999, 99999, "sdf")
	Draw.PushButton("Create", GEN, 5, 5, 60, 25, "sf")
	Draw.PushButton("Quit", QUIT, 80, 5, 60, 25, "dfs")

def event(event, val):
	if event == Draw.ESCKEY:
		Draw.Exit()
	
def button_event(evt):
	if evt == GEN :
		makeparam()
	elif evt == QUIT :
		Draw.Exit()
		
Draw.Register(draw_gui, event, button_event)