]> git.tdb.fi Git - libs/gl.git/blob - blender/io_mspgl/export_light.py
Add a Blender operator to export the entire project at once
[libs/gl.git] / blender / io_mspgl / export_light.py
1 import mathutils
2
3 class LightExporter:
4         def export_light(self, obj):
5                 if obj.type!='LIGHT':
6                         raise ValueError("Object is not a light")
7                 light = obj.data
8
9                 from .datafile import Resource, Statement
10                 light_res = Resource(light.name+".light", "light")
11
12                 if light.type=='SUN':
13                         pos = obj.matrix_world@mathutils.Vector((0.0, 0.0, 1.0, 0.0))
14                 else:
15                         pos = obj.matrix_world@mathutils.Vector((0.0, 0.0, 0.0, 1.0))
16
17                 light_res.statements.append(Statement("position", *tuple(pos)))
18                 c = light.color
19                 e = light.energy
20                 light_res.statements.append(Statement("color", c.r*e, c.g*e, c.b*e))
21
22                 return light_res