## HDRI lights for Curious Labs Poser ## (c) 2003 Stefan Werner stew@keindesign.de import poser, re, string, math import tkFileDialog import Tkinter class App: def __init__(self, master, textMessage): self.master = master scene = poser.Scene() try: textfile = open (tkFileDialog.askopenfilename(),"r") except: raise "file not found." line = "" while 1: line = textfile.readline() if not line: break line = string.replace (line, ":", "") if (string.find(line, "Light") == -1): continue else: name = line line = textfile.readline() if not line: break color = string.split (line) if (color[0] != "Color:"): continue else: r = float (color[1]) * 2 g = float (color[2]) * 2 b = float (color[3]) * 2 line = textfile.readline() if not line: break color = string.split (line) if (color[0] != "Direction:"): continue else: x = float (color[1]) y = float (color[2]) z = -float (color[3]) m = math.sqrt(x*x + y*y + z*z) if (m == 0): continue if (x != 0): a1 = math.atan((z/x)/m)/math.pi*180 if (x < 0): a1 = 180 - a1 else: if (z < 0): a1 = -90 else: a1 = 90 a1 = a1 - 90 a2 = math.acos(y/m)/math.pi*180.0 -90 scene.CreateLight() light = scene.CurrentActor() light.SetName(name) light.SetLightType(poser.kLightCodeINFINITE) light.ParameterByCode(poser.kParmCodeXROT).SetValue(-a2) light.ParameterByCode(poser.kParmCodeYROT).SetValue(a1) light.ParameterByCode(poser.kParmCodeZROT).SetValue(0) light.ParameterByCode(poser.kParmCodeKDRED).SetValue(r) light.ParameterByCode(poser.kParmCodeKDGREEN).SetValue(g) light.ParameterByCode(poser.kParmCodeKDBLUE).SetValue(b) textfile.close() self.master.destroy() self.master.quit() root = Tkinter.Tk() app = App(root, "") root.mainloop()