Update exporter for b28

This commit is contained in:
unknown 2018-08-14 19:18:25 +02:00
parent 04b72dff34
commit 91b2735130
5 changed files with 30 additions and 23 deletions

View file

@ -29,7 +29,7 @@ import arm.material.cycles as cycles
NodeTypeNode = 0
NodeTypeBone = 1
NodeTypeMesh = 2
NodeTypeLamp = 3
NodeTypeLight = 3
NodeTypeCamera = 4
NodeTypeSpeaker = 5
NodeTypeDecal = 6
@ -120,8 +120,8 @@ class ArmoryExporter:
return NodeTypeMesh
elif bobject.type == "META": # Metaball
return NodeTypeMesh
elif bobject.type == "LAMP":
return NodeTypeLamp
elif bobject.type == "LIGHT" or bobject.type == "LAMP": # TODO: LAMP is deprecated
return NodeTypeLight
elif bobject.type == "CAMERA":
return NodeTypeCamera
elif bobject.type == "SPEAKER":
@ -972,12 +972,12 @@ class ArmoryExporter:
#if shapeKeys:
# self.ExportMorphWeights(bobject, shapeKeys, scene, o)
elif type == NodeTypeLamp:
if not objref in self.lampArray:
self.lampArray[objref] = {"structName" : objname, "objectTable" : [bobject]}
elif type == NodeTypeLight:
if not objref in self.lightArray:
self.lightArray[objref] = {"structName" : objname, "objectTable" : [bobject]}
else:
self.lampArray[objref]["objectTable"].append(bobject)
o['data_ref'] = self.lampArray[objref]["structName"]
self.lightArray[objref]["objectTable"].append(bobject)
o['data_ref'] = self.lightArray[objref]["structName"]
elif type == NodeTypeCamera:
if 'spawn' in o and o['spawn'] == False:
@ -1697,8 +1697,8 @@ class ArmoryExporter:
self.write_mesh(bobject, fp, o)
def export_lamp(self, objectRef):
# This function exports a single lamp object
def export_light(self, objectRef):
# This function exports a single light object
o = {}
o['name'] = objectRef[1]["structName"]
objref = objectRef[0]
@ -1757,14 +1757,14 @@ class ArmoryExporter:
col = n.inputs[0].default_value
o['color'] = [col[0], col[1], col[2]]
o['strength'] = n.inputs[1].default_value
# Normalize lamp strength
# Normalize light strength
if o['type'] == 'point' or o['type'] == 'spot':
o['strength'] *= 0.026
elif o['type'] == 'area':
o['strength'] *= 0.26
elif o['type'] == 'sun':
o['strength'] *= 0.325
# TODO: Lamp texture test..
# TODO: Light texture test..
if n.inputs[0].is_linked:
color_node = n.inputs[0].links[0].from_node
if color_node.type == 'TEX_IMAGE':
@ -1782,7 +1782,7 @@ class ArmoryExporter:
return [0.051, 0.051, 0.051, 1.0]
if self.scene.world.node_tree == None:
c = self.scene.world.horizon_color
c = self.scene.world.color if bpy.app.version >= (2, 80, 1) else self.scene.world.horizon_color
return [c[0], c[1], c[2], 1.0]
if 'Background' in self.scene.world.node_tree.nodes:
@ -2140,8 +2140,8 @@ class ArmoryExporter:
self.output['lamp_datas'] = []
self.output['camera_datas'] = []
self.output['speaker_datas'] = []
for objectRef in self.lampArray.items():
self.export_lamp(objectRef)
for objectRef in self.lightArray.items():
self.export_light(objectRef)
for objectRef in self.cameraArray.items():
self.export_camera(objectRef)
# Keep sounds with fake user
@ -2170,7 +2170,7 @@ class ArmoryExporter:
self.bobjectArray = {}
self.bobjectBoneArray = {}
self.meshArray = {}
self.lampArray = {}
self.lightArray = {}
self.cameraArray = {}
self.camera_spawned = False
self.speakerArray = {}

View file

@ -115,7 +115,8 @@ def add_world_defs():
wrd.world_defs += '_Legacy'
# Area lamps
for lamp in bpy.data.lamps:
lamps = bpy.data.lights if bpy.app.version >= (2, 80, 1) else bpy.data.lamps
for lamp in lamps:
if lamp.type == 'AREA':
wrd.world_defs += '_LTC'
assets.add_khafile_def('arm_ltc')

View file

@ -33,7 +33,7 @@ def build_node_tree(world):
solid_mat = rpdat.arm_material_model == 'Solid'
if rpdat.arm_irradiance and not solid_mat:
wrd.world_defs += '_Irr'
c = world.horizon_color
c = world.color if bpy.app.version >= (2, 80, 1) else world.horizon_color
world.arm_envtex_color = [c[0], c[1], c[2], 1.0]
world.arm_envtex_strength = 1.0

View file

@ -338,10 +338,16 @@ def init_properties():
# bpy.types.Scene.arm_gp_export = BoolProperty(name="Export GP", description="Export grease pencil data", default=True)
bpy.types.Scene.arm_compress = BoolProperty(name="Compress", description="Pack data into zip file", default=False)
# For lamp
bpy.types.Lamp.arm_clip_start = FloatProperty(name="Clip Start", default=0.1)
bpy.types.Lamp.arm_clip_end = FloatProperty(name="Clip End", default=50.0)
bpy.types.Lamp.arm_fov = FloatProperty(name="Field of View", default=0.84)
bpy.types.Lamp.arm_shadows_bias = FloatProperty(name="Bias", description="Depth offset to fight shadow acne", default=1.0)
if bpy.app.version >= (2, 80, 1):
bpy.types.Light.arm_clip_start = FloatProperty(name="Clip Start", default=0.1)
bpy.types.Light.arm_clip_end = FloatProperty(name="Clip End", default=50.0)
bpy.types.Light.arm_fov = FloatProperty(name="Field of View", default=0.84)
bpy.types.Light.arm_shadows_bias = FloatProperty(name="Bias", description="Depth offset to fight shadow acne", default=1.0)
else:
bpy.types.Lamp.arm_clip_start = FloatProperty(name="Clip Start", default=0.1)
bpy.types.Lamp.arm_clip_end = FloatProperty(name="Clip End", default=50.0)
bpy.types.Lamp.arm_fov = FloatProperty(name="Field of View", default=0.84)
bpy.types.Lamp.arm_shadows_bias = FloatProperty(name="Bias", description="Depth offset to fight shadow acne", default=1.0)
bpy.types.World.arm_lamp_texture = StringProperty(name="Mask Texture", default="")
bpy.types.World.arm_lamp_ies_texture = StringProperty(name="IES Texture", default="")
bpy.types.World.arm_lamp_clouds_texture = StringProperty(name="Clouds Texture", default="")

View file

@ -152,7 +152,7 @@ class DataPropsPanel(bpy.types.Panel):
# if obj.type == 'MESH':
# layout.prop(obj.data, 'arm_sdfgen')
layout.operator("arm.invalidate_cache")
elif obj.type == 'LAMP':
elif obj.type == 'LIGHT' or obj.type == 'LAMP': # TODO: LAMP is deprecated
row = layout.row(align=True)
col = row.column()
col.prop(obj.data, 'arm_clip_start')