X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=blender%2Fio_mspgl%2Fexport_light.py;h=2fc8c8dd02bd3dbccec4b0204dd75ed0930c378e;hb=adc26a2e141a2853b6c5025130c46a46cece4b84;hp=cfa4a19dadef5e2d859233dd1db477b054e46e61;hpb=7ae4af705535271ad84dbfe2b5a24bc9c546ae01;p=libs%2Fgl.git diff --git a/blender/io_mspgl/export_light.py b/blender/io_mspgl/export_light.py index cfa4a19d..2fc8c8dd 100644 --- a/blender/io_mspgl/export_light.py +++ b/blender/io_mspgl/export_light.py @@ -3,20 +3,23 @@ import mathutils class LightExporter: def export_light(self, obj): if obj.type!='LIGHT': - raise ValueError("Object is not a light") + raise ValueError("Object {} is not a light".format(obj.name)) light = obj.data - from .datafile import Resource, Statement + from .datafile import Resource, Statement, Token light_res = Resource(light.name+".light", "light") if light.type=='SUN': - pos = obj.matrix_world@mathutils.Vector((0.0, 0.0, 1.0, 0.0)) - else: + light_res.statements.append(Statement("type", Token("directional"))) + light_res.statements.append(Statement("direction", *(-obj.matrix_world.col[2])[0:3])) + elif light.type=='POINT': + light_res.statements.append(Statement("type", Token("point"))) pos = obj.matrix_world@mathutils.Vector((0.0, 0.0, 0.0, 1.0)) + light_res.statements.append(Statement("position", *obj.matrix_world.col[3][0:3])) + else: + raise Exception("Can't export light {} of unknown type {}".format(light.name, light.type)) - light_res.statements.append(Statement("position", *tuple(pos))) - c = light.color - e = light.energy - light_res.statements.append(Statement("color", c.r*e, c.g*e, c.b*e)) + c = light.color*light.energy + light_res.statements.append(Statement("color", *tuple(c))) return light_res