From 4b5242104a3051d43375d76abff7777dc9cd872b Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 30 Aug 2012 17:34:05 +0900 Subject: [PATCH] Add lights from the map to the scene. Only the very basics are done at this stage, but things look reasonable. The lamp energy might need tweaking. --- tools/io_qfmap/import_map.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tools/io_qfmap/import_map.py b/tools/io_qfmap/import_map.py index ff09cd970..ab69d6738 100644 --- a/tools/io_qfmap/import_map.py +++ b/tools/io_qfmap/import_map.py @@ -25,11 +25,27 @@ from mathutils import Vector,Matrix from .map import parse_map, MapError +def parse_vector(vstr): + v = vstr.split() + for i in range(len(v)): + v[i] = float(v[i]) + return Vector(v) + def process_entity(ent): + if "targetname" in ent.d: + name = ent.d["targetname"] + else: + name = ent.d["classname"] if "classname" in ent.d and ent.d["classname"][:5] == "light": - pass + light = bpy.data.lamps.new("light", 'POINT') + light.distance = 300.0 + light.falloff_type = 'CUSTOM_CURVE' + obj = bpy.data.objects.new(name, light) + obj.location = parse_vector (ent.d["origin"]) + bpy.context.scene.objects.link(obj) + bpy.context.scene.objects.active=obj + obj.select = True elif ent.b: - name = "brush" verts = [] faces = [] for bverts, bfaces in ent.b: