All pastes #822141 Raw Edit

SF_shader-002.py

public python v1 · immutable
·published 2007-12-18 15:38 UTC
rendered paste body
#!BPY"""Name: 'SF Shader exporter'Blender: 245Group: 'Export'Tooltip: 'Prototype for ID Properties based SF shader system'"""# License: Copyright Olivier Saraja (c) 2007 and GPL v2.0import Blenderfrom Blender import Object, Material, Draw, BGL## global vars ##global FILEFILENAME = Blender.Get('filename').replace(".blend", ".sc")##Default values for buttons##SHADERNAME=Draw.Create("sfdif")SHADERTYPE=Draw.Create(1)DIFFR=Draw.Create(1.000)DIFFG=Draw.Create(1.000)DIFFB=Draw.Create(1.000)REFL=Draw.Create(1.000)BRIGHTR=Draw.Create(1.000)BRIGHTG=Draw.Create(1.000)BRIGHTB=Draw.Create(1.000)DARKR=Draw.Create(1.000)DARKG=Draw.Create(1.000)DARKB=Draw.Create(1.000)SAMPLESAO=Draw.Create(100)DIST=Draw.Create(100.0)SPECR=Draw.Create(1.000)SPECG=Draw.Create(1.000)SPECB=Draw.Create(1.000)HARD=Draw.Create(100)SAMPLES=Draw.Create(100)ROUGHX=Draw.Create(10.000)ROUGHY=Draw.Create(10.000)REFLR=Draw.Create(1.000)REFLG=Draw.Create(1.000)REFLB=Draw.Create(1.000)TETA=Draw.Create(10.000)COLR=Draw.Create(1.000)COLG=Draw.Create(1.000)COLB=Draw.Create(1.000)ABSORPTIONDIST=Draw.Create(100.0)ABSCOLR=Draw.Create(1.000)ABSCOLG=Draw.Create(1.000)ABSCOLB=Draw.Create(1.000)##Buttons Events##EV_SHADERNAME=1EV_SHADERTYPE=2EV_DIFFR=3EV_DIFFG=4EV_DIFFB=5EV_REFL=6EV_BRIGHTR=7EV_BRIGHTG=8EV_BRIGHTB=9EV_DARKR=10EV_DARKG=11EV_DARKB=12EV_SAMPLESAO=13EV_DIST=14EV_SPECR=15EV_SPECG=16EV_SPECB=17EV_HARD=18EV_SAMPLES=19EV_ROUGHX=20EV_ROUGHY=21EV_REFLR=22EV_REFLG=23EV_REFLB=24EV_COLR=25EV_COLG=26EV_COLB=27EV_TETA=28EV_ABSORPTIONDIST=29EV_ABSCOLR=30EV_ABSCOLG=31EV_ABSCOLB=32EV_SAVEID=33EV_SHADREDRAW=34EV_EXPSHAD=35def translate_shaders():	ob=Blender.Object.GetSelected()	obj=ob[0]	material=obj.getData(mesh=1).materials	for mat in material:		if mat.name.startswith("sfdif"):			mat.properties['Type']="diffuse"		elif mat.name.startswith("sfshi"):			mat.properties['Type']="shiny"		elif mat.name.startswith("sfamb"):			mat.properties['Type']="amb-occ"		elif mat.name.startswith("sfpho"):			mat.properties['Type']="phong"		elif mat.name.startswith("sfwar"):			mat.properties['Type']="ward"		elif mat.name.startswith("sfmir"):			mat.properties['Type']="mirror"		elif mat.name.startswith("sfgla"):			mat.properties['Type']="glass"		elif mat.name.startswith("sfshi"):			mat.properties['Type']="shiny"		elif mat.name.startswith("sfcon"):			mat.properties['Type']="constant"		elif mat.name.startswith("sfsss"):			mat.properties['Type']="sss"		elif mat.name.startswith("sfube"):			mat.properties['Type']="uber"		else:			mat.properties['Type']="diffuse"			mat.properties['Shader Name']=mat.name		diff=mat.getRGBCol()		#Diffuse for Uber, Diffuse, Shiny, Phong, Ward, SSS		mat.properties['Diff R']=diff[0]		mat.properties['Diff G']=diff[1]		mat.properties['Diff B']=diff[2]		#Color for Constant, Glass		mat.properties['Col R']=diff[0]		mat.properties['Col G']=diff[1]		mat.properties['Col B']=diff[2]		#Bright for AMb-Occ		mat.properties['Bright R']=diff[0]		mat.properties['Bright G']=diff[1]		mat.properties['Bright B']=diff[2]			speccol=mat.getSpecCol()		#Spec for Phong, Ward		mat.properties['Spec R']=speccol[0]		mat.properties['Spec G']=speccol[1]		mat.properties['Spec B']=speccol[2]		#Specular for SSS		mat.properties['Specular R']=speccol[0]		mat.properties['Specular G']=speccol[1]		mat.properties['Specular B']=speccol[2]		#absorption.color for Glass		mat.properties['Absorption Color R']=speccol[0]		mat.properties['Absorption Color G']=speccol[1]		mat.properties['Absorption Color B']=speccol[2]		#Dark for Amb-Occ		mat.properties['Dark R']=speccol[0]		mat.properties['Dark G']=speccol[1]		mat.properties['Dark B']=speccol[2]			textures=mat.getTextures()			reflShiny=mat.getRayMirr()		#Refl for Shiny		mat.properties['Refl Shiny']=reflShiny			hardPhong=mat.hard		#hard for Phong		mat.properties['Hard']=hardPhong			refMirror=mat.getRGBCol()		#Refl for Mirror		mat.properties['Refl R']=diff[0]		mat.properties['Refl G']=diff[1]		mat.properties['Refl B']=diff[2]				teta=mat.getIOR()		#teta for Glass		mat.properties['Teta']=teta			#Samples for Amb-Occ		mat.properties['Samples AO']=32			#Dist for Amb-Occ		mat.properties['Dist']=3.0				#Rough for Ward		mat.properties['Rough X']=0.2		mat.properties['Rough Y']=0.01		#Samples for Phong, Ward		mat.properties['Samples']=4				#Absorption Distance for Glass, SSS		mat.properties['Absorption Distance']=5.0				#Absoprtion Power for SSS		mat.properties['Absorption Power']=1.0				#sssRays for SSS		mat.properties['SSS Rays']=4				#Phong Rays for SSS		mat.properties['Phong Rays']=6				#thickness for SSS		mat.properties['thickness']=0.125	def export_shaders(filename):	FILE=open(filename,"w")	ob=Blender.Object.GetSelected()	obj=ob[0]	material=obj.getData(mesh=1).materials	for mat in material:		print "  o exporting diffuse shader "+mat.name+"..."		FILE.write("\n\nshader {\n")		FILE.write("\tname \""+mat.name+".shader\"\n")		FILE.write("\ttype %s \n" % (mat.properties['Type']))		if mat.properties['Type']=="diffuse":				FILE.write("\tdiff { \"sRGB nonlinear\" %.3f %.3f %.3f }\n" % (mat.properties['Diff R'], mat.properties['Diff G'], mat.properties['Diff B']))		elif mat.properties['Type']=="shiny":			FILE.write("\tdiff { \"sRGB nonlinear\" %.3f %.3f %.3f }\n" % (mat.properties['Diff R'], mat.properties['Diff G'], mat.properties['Diff B']))			FILE.write("\trefl %.2f\n" % mat.properties['Refl Shiny'])		elif mat.properties['Type']=="amb-occ":			FILE.write("\tbright %.3f %.3f %.3f\n" % (mat.properties['Bright R'], mat.properties['Bright G'], mat.properties['Bright B']))			FILE.write("\tdark %.3f %.3f %.3f\n" % (mat.properties['Dark R'], mat.properties['Dark G'], mat.properties['Dark B']))			FILE.write("\tsamples %i \n" % mat.properties['Samples AO'])			FILE.write("\tdist %i \n" % mat.properties['Dist'])		elif mat.properties['Type']=="phong":			FILE.write("\tdiff { \"sRGB nonlinear\" %.3f %.3f %.3f }\n" % (mat.properties['Diff R'], mat.properties['Diff G'], mat.properties['Diff B']))			FILE.write("\tspec { \"sRGB nonlinear\" %.3f %.3f %.3f } %i\n" %(mat.properties['Spec R'], mat.properties['Spec G'], mat.properties['Spec B'], mat.properties['Hard']))			FILE.write("\tsamples %i\n" % mat.properties['Samples'])		elif mat.properties['Type']=="ward":			FILE.write("\tdiff { \"sRGB nonlinear\" %.3f %.3f %.3f }\n" % (mat.properties['Diff R'], mat.properties['Diff G'], mat.properties['Diff B']))			FILE.write("\tspec { \"sRGB nonlinear\" %.3f %.3f %.3f } \n" %(mat.properties['Spec R'], mat.properties['Spec G'], mat.properties['Spec B']))			FILE.write("\trough %.3f %.3f1\n" % (mat.properties['Rough X'],mat.properties['Rough Y']))			FILE.write("\tsamples %i\n" % mat.properties['Samples'])		elif mat.properties['Type']=="mirror":			FILE.write("\trefl { \"sRGB nonlinear\" %.3f %.3f %.3f }\n" %(mat.properties['Refl R'], mat.properties['Refl G'], mat.properties['Refl B']))		elif mat.properties['Type']=="glass":			FILE.write("\teta %.3f \n" % mat.properties['Teta'])			FILE.write("\tcolor { \"sRGB nonlinear\" %.3f %.3f %.3f }\n" %(mat.properties['Col R'],mat.properties['Col G'],mat.properties['Col B']))			FILE.write("\tabsorbtion.distance %.3f \n" % mat.properties['Absorption Distance'])			FILE.write("\tabsorbtion.color { \"sRGB nonlinear\" %.3f %.3f %.3f }\n" %(mat.properties['Absorption Color R'], mat.properties['Absorption Color G'], mat.properties['Absorption Color B']))		elif mat.properties['Type']=="constant":			FILE.write("\tcolor { \"sRGB nonlinear\" %.3f %.3f %.3f }\n" %(mat.properties['Col R'],mat.properties['Col G'],mat.properties['Col B']))		#elif mat.properties['Type']="sss":		#	...		#elif mat.properties['Type']="uber":		#	...		else:			FILE.write("\tdiff { \"sRGB nonlinear\" %.3f %.3f %.3f }\n" % (mat.properties['Diff R'], mat.properties['Diff G'], mat.properties['Diff B']))		FILE.write("\t}")	FILE.close	return()def checkID():	if id_exists == 1:		print "ID properties already exist, go to editing..."		drawGUI()	elif id_exists ==0:		print "ID properties don't exist, automatically generate defaults..."		translate_shaders()		drawGUI()		def initGUI():		SHADERNAME.val=mat.properties['Shader Name']		if mat.properties['Type']=="diffuse":			SHADERTYPE.val=1		elif mat.properties['Type']=="shiny":			SHADERTYPE.val=2		elif mat.properties['Type']=="amb-occ":			SHADERTYPE.val=3		elif mat.properties['Type']=="phong":			SHADERTYPE.val=4		elif mat.properties['Type']=="ward":			SHADERTYPE.val=5		elif mat.properties['Type']=="mirror":			SHADERTYPE.val=6		elif mat.properties['Type']=="glass":			SHADERTYPE.val=7		elif mat.properties['Type']=="constant":			SHADERTYPE.val=8		else:			SHADERTYPE.val=1		print SHADERTYPE.val		DIFFR.val=mat.properties['Diff R']		DIFFG.val=mat.properties['Diff G']		DIFFB.val=mat.properties['Diff B']		REFL.val=mat.properties['Refl Shiny']		BRIGHTR.val=mat.properties['Bright R']		BRIGHTG.val=mat.properties['Bright G']		BRIGHTB.val=mat.properties['Bright B']		DARKR.val=mat.properties['Dark R']		DARKG.val=mat.properties['Dark G']		DARKB.val=mat.properties['Dark B']		SAMPLESAO.val=mat.properties['Samples AO']		DIST.val=mat.properties['Dist']		SPECR.val=mat.properties['Spec R']		SPECG.val=mat.properties['Spec G']		SPECB.val=mat.properties['Spec B']		HARD.val=mat.properties['Hard']		SAMPLES.val=mat.properties['Samples']		ROUGHX.val=mat.properties['Rough X']		ROUGHY.val=mat.properties['Rough Y']		REFLR.val=mat.properties['Refl R']		REFLG.val=mat.properties['Refl G']		REFLB.val=mat.properties['Refl B']		TETA.val=mat.properties['Teta']		COLR.val=mat.properties['Col R']		COLG.val=mat.properties['Col G']		COLB.val=mat.properties['Col B']		ABSORPTIONDIST.val=mat.properties['Absorption Distance']		ABSCOLR.val=mat.properties['Absorption Color R']		ABSCOLG.val=mat.properties['Absorption Color G']		ABSCOLB.val=mat.properties['Absorption Color B']		def saveID():		mat.properties['Shader Name']=SHADERNAME.val		if SHADERTYPE.val==1:			mat.properties['Type']="diffuse"		elif SHADERTYPE.val==2:			mat.properties['Type']="shiny"		elif SHADERTYPE.val==3:			mat.properties['Type']="amb-occ"		elif SHADERTYPE.val==4:			mat.properties['Type']="phong"		elif SHADERTYPE.val==5:			mat.properties['Type']="ward"		elif SHADERTYPE.val==6:			mat.properties['Type']="mirror"		elif SHADERTYPE.val==7:			mat.properties['Type']="glass"		elif SHADERTYPE.val==8:			mat.properties['Type']="constant"		else:			mat.properties['Type']="diffuse"		mat.properties['Diff R']=DIFFR.val		mat.properties['Diff G']=DIFFG.val		mat.properties['Diff B']=DIFFB.val		mat.properties['Refl Shiny']=REFL.val		mat.properties['Bright R']=BRIGHTR.val		mat.properties['Bright G']=BRIGHTG.val		mat.properties['Bright B']=BRIGHTB.val		mat.properties['Dark R']=DARKR.val		mat.properties['Dark G']=DARKG.val		mat.properties['Dark B']=DARKB.val		mat.properties['Samples AO']=SAMPLESAO.val		mat.properties['Dist']=DIST.val		mat.properties['Spec R']=SPECR.val		mat.properties['Spec G']=SPECG.val		mat.properties['Spec B']=SPECB.val		mat.properties['Hard']=HARD.val		mat.properties['Samples']=SAMPLES.val		mat.properties['Rough X']=ROUGHX.val		mat.properties['Rough Y']=ROUGHY.val		mat.properties['Refl R']=REFLR.val		mat.properties['Refl G']=REFLG.val		mat.properties['Refl B']=REFLB.val		mat.properties['Teta']=TETA.val		mat.properties['Col R']=COLR.val		mat.properties['Col G']=COLG.val		mat.properties['Col B']=COLB.val		mat.properties['Absorption Distance']=ABSORPTIONDIST.val		mat.properties['Absorption Color R']=ABSCOLR.val		mat.properties['Absorption Color G']=ABSCOLG.val		mat.properties['Absorption Color B']=ABSCOLB.val	def drawGUI():		global SHADERNAME, SHADERTYPE, DIFFR, DIFFG, DIFFB, REFL, BRIGHTR, BRIGHTG, BRIGHTB, DARKR, DARKG, DARKB, SAMPLESAO, DIST, SPECR, SPECG, SPECB, HARD, SAMPLES		global ROUGHX, ROUGHY, REFLR, REFLG, REFLB, COLR, COLG,COLB, TETA, ABSORPTIONDIST, ABSCOLR, ABSCOLG, ABSCOLB		col=10; line=450;BGL.glRasterPos2i(col, line); SHADERNAME=Draw.String("Shader's name: ", EV_SHADERNAME, col, line, 200, 25, SHADERNAME.val,80, "Name of the shader")		col=10; line=410;BGL.glRasterPos2i(col, line); SHADERTYPE=Draw.Menu("%tShader type|diffuse|shiny|amb-occ|phong|ward|mirror|glass|constant",EV_SHADERTYPE, col, line, 100, 25, SHADERTYPE.val)		col=125; line=410;BGL.glRasterPos2i(col, line); SHADREDRAW=Draw.PushButton("Redraw", EV_SHADREDRAW,col,line,150,25,"Redraw GUI after shader type change")		col=10; line=330;BGL.glRasterPos2i(col, line); SAVEID=Draw.PushButton("Save changes", EV_SAVEID,col,line,100,65,"Save ID Properties to Material")		col=10; line=250;BGL.glRasterPos2i(col, line); EXPSHAD=Draw.PushButton("Export all shaders", EV_EXPSHAD,col,line,100,65,"Export shaders to .sc file")		if mat.properties['Type']=="diffuse":			col=125;line=370;BGL.glRasterPos2i(col, line); DIFFR=Draw.Slider("Diff R: ", EV_DIFFR, col,line, 150, 25, DIFFR.val, 0.000, 1.000, 1, "Diffuse color component R")			col=290;line=370;BGL.glRasterPos2i(col, line); DIFFG=Draw.Slider("Diff G: ", EV_DIFFG, col,line, 150, 25, DIFFG.val, 0.000, 1.000, 1, "Diffuse color component G")			col=455;line=370;BGL.glRasterPos2i(col, line); DIFFB=Draw.Slider("Diff B: ", EV_DIFFB, col,line, 150, 25, DIFFB.val, 0.000, 1.000, 1, "Diffuse color component B")		elif mat.properties['Type']=="shiny":			col=125;line=370;BGL.glRasterPos2i(col, line); DIFFR=Draw.Slider("Diff R: ", EV_DIFFR, col,line, 150, 25, DIFFR.val, 0.000, 1.000, 1, "Diffuse color component R")			col=290;line=370;BGL.glRasterPos2i(col, line); DIFFG=Draw.Slider("Diff G: ", EV_DIFFG, col,line, 150, 25, DIFFG.val, 0.000, 1.000, 1, "Diffuse color component G")			col=455;line=370;BGL.glRasterPos2i(col, line); DIFFB=Draw.Slider("Diff B: ", EV_DIFFB, col,line, 150, 25, DIFFB.val, 0.000, 1.000, 1, "Diffuse color component B")			col=125;line=330;BGL.glRasterPos2i(col, line); REFL=Draw.Number("Refl: ", EV_REFL, col,line, 150, 25, REFL.val, 0.000, 1.000, "Reflection value")		elif mat.properties['Type']=="amb-occ":			col=125;line=370;BGL.glRasterPos2i(col, line); BRIGHTR=Draw.Slider("Bright R: ", EV_BRIGHTR, col,line, 150, 25, BRIGHTR.val, 0.000, 1.000, 1, "Brightness color component R")			col=290;line=370;BGL.glRasterPos2i(col, line); BRIGHTG=Draw.Slider("Bright G: ", EV_BRIGHTG, col,line, 150, 25, BRIGHTG.val, 0.000, 1.000, 1, "Brightness color component G")			col=455;line=370;BGL.glRasterPos2i(col, line); BRIGHTB=Draw.Slider("Bright B: ", EV_BRIGHTB, col,line, 150, 25, BRIGHTB.val, 0.000, 1.000, 1, "Brightness color component B")			col=125;line=330;BGL.glRasterPos2i(col, line); DARKR=Draw.Slider("Dark R: ", EV_DARKR, col,line, 150, 25, DARKR.val, 0.000, 1.000, 1, "Darkness color component R")			col=290;line=330;BGL.glRasterPos2i(col, line); DARKG=Draw.Slider("Dark G: ", EV_DARKG, col,line, 150, 25, DARKG.val, 0.000, 1.000, 1, "Darkness color component G")			col=455;line=330;BGL.glRasterPos2i(col, line); DARKB=Draw.Slider("Dark B: ", EV_DARKB, col,line, 150, 25, DARKB.val, 0.000, 1.000, 1, "Darkness color component B")			col=125;line=290;BGL.glRasterPos2i(col, line); SAMPLESAO=Draw.Number("Samples AO: ", EV_SAMPLESAO, col,line, 150, 25, SAMPLESAO.val, 0.000, 1.000, "Ambiant Occlusion Samples")			col=290;line=290;BGL.glRasterPos2i(col, line); DIST=Draw.Number("Dist: ", EV_DIST, col,line, 150, 25, DIST.val, 0.000, 1.000, "Ambiant Occlusion Distance")		elif mat.properties['Type']=="phong":			col=125;line=370;BGL.glRasterPos2i(col, line); DIFFR=Draw.Slider("Diff R: ", EV_DIFFR, col,line, 150, 25, DIFFR.val, 0.000, 1.000, 1, "Diffuse color component R")			col=290;line=370;BGL.glRasterPos2i(col, line); DIFFG=Draw.Slider("Diff G: ", EV_DIFFG, col,line, 150, 25, DIFFG.val, 0.000, 1.000, 1, "Diffuse color component G")			col=455;line=370;BGL.glRasterPos2i(col, line); DIFFB=Draw.Slider("Diff B: ", EV_DIFFB, col,line, 150, 25, DIFFB.val, 0.000, 1.000, 1, "Diffuse color component B")			col=125;line=330;BGL.glRasterPos2i(col, line); SPECR=Draw.Slider("Spec R: ", EV_SPECR, col,line, 150, 25, SPECR.val, 0.000, 1.000, 1, "Specular color component R")			col=290;line=330;BGL.glRasterPos2i(col, line); SPECG=Draw.Slider("Spec G: ", EV_SPECG, col,line, 150, 25, SPECG.val, 0.000, 1.000, 1, "Specular color component G")			col=455;line=330;BGL.glRasterPos2i(col, line); SPECB=Draw.Slider("Spec B: ", EV_SPECB, col,line, 150, 25, SPECB.val, 0.000, 1.000, 1, "Specular color component B")			col=125;line=290;BGL.glRasterPos2i(col, line); HARD=Draw.Number("Hard: ", EV_HARD, col,line, 150, 25, HARD.val, 0.000, 1.000, "Hardness of the specular")			col=125;line=240;BGL.glRasterPos2i(col, line); SAMPLES=Draw.Number("Samples: ", EV_SAMPLES, col,line, 150, 25, SAMPLES.val, 0.000, 1.000, "Samples of the specular")		elif mat.properties['Type']=="ward":			col=125;line=370;BGL.glRasterPos2i(col, line); DIFFR=Draw.Slider("Diff R: ", EV_DIFFR, col,line, 150, 25, DIFFR.val, 0.000, 1.000, 1, "Diffuse color component R")			col=290;line=370;BGL.glRasterPos2i(col, line); DIFFG=Draw.Slider("Diff G: ", EV_DIFFG, col,line, 150, 25, DIFFG.val, 0.000, 1.000, 1, "Diffuse color component G")			col=455;line=370;BGL.glRasterPos2i(col, line); DIFFB=Draw.Slider("Diff B: ", EV_DIFFB, col,line, 150, 25, DIFFB.val, 0.000, 1.000, 1, "Diffuse color component B")			col=125;line=330;BGL.glRasterPos2i(col, line); SPECR=Draw.Slider("Spec R: ", EV_SPECR, col,line, 150, 25, SPECR.val, 0.000, 1.000, 1, "Specular color component R")			col=290;line=330;BGL.glRasterPos2i(col, line); SPECG=Draw.Slider("Spec G: ", EV_SPECG, col,line, 150, 25, SPECG.val, 0.000, 1.000, 1, "Specular color component G")			col=455;line=330;BGL.glRasterPos2i(col, line); SPECB=Draw.Slider("Spec B: ", EV_SPECB, col,line, 150, 25, SPECB.val, 0.000, 1.000, 1, "Specular color component B")			col=125;line=290;BGL.glRasterPos2i(col, line); ROUGHX=Draw.Number("Rough X: ", EV_ROUGHX, col,line, 150, 25, ROUGHX.val, 0.000, 1.000, "Roughness in the X direction")			col=290;line=290;BGL.glRasterPos2i(col, line); ROUGHY=Draw.Number("Rough Y: ", EV_ROUGHY, col,line, 150, 25, ROUGHY.val, 0.000, 1.000, "Roughness in the Y direction")			col=125;line=250;BGL.glRasterPos2i(col, line); SAMPLES=Draw.Number("Samples: ", EV_SAMPLES, col,line, 150, 25, SAMPLES.val, 0.000, 1.000, "Samples")		elif mat.properties['Type']=="mirror":			col=125;line=370;BGL.glRasterPos2i(col, line); REFLR=Draw.Slider("Refl R: ", EV_REFLR, col,line, 150, 25, REFLR.val, 0.000, 1.000, 1, "Reflection color component R")			col=290;line=370;BGL.glRasterPos2i(col, line); REFLG=Draw.Slider("Refl G: ", EV_REFLG, col,line, 150, 25, REFLG.val, 0.000, 1.000, 1, "Reflection color component G")			col=455;line=370;BGL.glRasterPos2i(col, line); REFLB=Draw.Slider("Refl B: ", EV_REFLB, col,line, 150, 25, REFLB.val, 0.000, 1.000, 1, "Reflection color component B")		elif mat.properties['Type']=="glass":			col=125;line=370;BGL.glRasterPos2i(col, line); COLR=Draw.Slider("Col R: ", EV_COLR, col,line, 150, 25, COLR.val, 0.000, 1.000, 1, "Color component R")			col=290;line=370;BGL.glRasterPos2i(col, line); COLG=Draw.Slider("Col G: ", EV_COLG, col,line, 150, 25, COLG.val, 0.000, 1.000, 1, "Color component G")			col=455;line=370;BGL.glRasterPos2i(col, line); COLB=Draw.Slider("Col B: ", EV_COLB, col,line, 150, 25, COLB.val, 0.000, 1.000, 1, "Color component B")			col=125;line=330;BGL.glRasterPos2i(col, line); TETA=Draw.Number("Teta: ", EV_TETA, col,line, 150, 25, TETA.val, 0.000, 1.000, "Index of refraction")			col=125;line=290;BGL.glRasterPos2i(col, line); ABSORPTIONDIST=Draw.Number("Absorption Distance: ", EV_ABSORPTIONDIST, col,line, 150, 25, ABSORPTIONDIST.val, 0.000, 1.000, "Absorption distance of light")			col=125;line=250;BGL.glRasterPos2i(col, line); ABSCOLR=Draw.Slider("Absorption Color R: ", EV_ABSCOLR, col,line, 150, 25, ABSCOLR.val, 0.000, 1.000, 1, "Absorption Color component R")			col=290;line=250;BGL.glRasterPos2i(col, line); ABSCOLG=Draw.Slider("Absorption Color G: ", EV_ABSCOLG, col,line, 150, 25, ABSCOLG.val, 0.000, 1.000, 1, "Absorption Color component G")			col=455;line=250;BGL.glRasterPos2i(col, line); ABSCOLB=Draw.Slider("Absorption Color B: ", EV_ABSCOLB, col,line, 150, 25, ABSCOLB.val, 0.000, 1.000, 1, "Absorption Color component B")		elif mat.properties['Type']=="constant":			col=125;line=370;BGL.glRasterPos2i(col, line); COLR=Draw.Slider("Col R: ", EV_COLR, col,line, 150, 25, COLR.val, 0.000, 1.000, 1, "Color component R")			col=290;line=370;BGL.glRasterPos2i(col, line); COLG=Draw.Slider("Col G: ", EV_COLG, col,line, 150, 25, COLG.val, 0.000, 1.000, 1, "Color component G")			col=455;line=370;BGL.glRasterPos2i(col, line); COLB=Draw.Slider("Col B: ", EV_COLB, col,line, 150, 25, COLB.val, 0.000, 1.000, 1, "Color component B")ob=Blender.Object.GetSelected()print "Selected Objects:"for o in ob:	print "- "+o.nameif ob==[]:	print "Warning: no object selected!"else:	obj=ob[0]	print "Active object: "+obj.name	matlist=obj.getData(mesh=1).materials	if matlist==[]:		print "No material for "+obj.name	else:		mat=matlist[0]try:	print mat.properties['Shader Name']	id_exists=1	print "ID Properties already set"except KeyError:	id_exists=0	print "No ID Properties set"checkID()initGUI()drawGUI()def event(evt, val):	if evt == Draw.ESCKEY:		print "quitting exporter..."		Draw.Exit()def buttonEvent(evt):	if evt == EV_SAVEID:		saveID()	if evt == EV_SHADREDRAW:		drawGUI()	if evt == EV_EXPSHAD:		export_shaders("test.sc")Draw.Register(drawGUI,event,buttonEvent)