All pastes #413409 Raw Edit

jesterKing

public python v1 · immutable
#413409 ·published 2007-03-28 12:11 UTC
rendered paste body
#!/usr/bin/env python# GRID nodeimport Blenderimport bpyimport Blender.Nodeimport mathclass Grid(Blender.Node.node):	def __init__(self, indef, outdef):		"""		The Grid node takes three inputs, and gives one output		in:		gap = gap width		slab = slab width		line = color of slabs		color = the input color		out:		color = the output color		"""		strength=(Blender.Node.VALUE, 1.0, 1.0, 1.0, 1.0, 0.0, 100.0)		color=(Blender.Node.RGBA, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0)				indef.definitions = {	'gap':strength,								'slab':strength,								'line':color,								'color':color,								'debug':strength							}		outdef.definitions = {'color':color}	def __call__(self, shi, ins, outs):		"""		the exec func		"""		texcoord = shi.tex_coord		col= ins['color']		if ins['debug']>5.0:			print			print "texture coord", texcoord			print "color", col		else:			pass		mortar=ins['slab']		brick=ins['gap']		cube = brick+mortar		c = int(texcoord[0]/cube), int(texcoord[1]/cube), int(texcoord[2]/cube)		pos = math.fabs(texcoord[0] - (c[0]*cube)), math.fabs(texcoord[1] - (c[1]*cube)), math.fabs(texcoord[2] - (c[2]*cube))		if pos[0] <= mortar: # or pos[1] <= mortar or pos[2] <= mortar:			outs['color'] = ins['line']		else:			outs['color'] = col