diff --git a/utils/exporters/blender/addons/io_three/constants.py b/utils/exporters/blender/addons/io_three/constants.py index 2a8d676abe9c06bc9ae885f33db912065944d46d..77177250f70f3a60249963640da67f94cf59cd1b 100644 --- a/utils/exporters/blender/addons/io_three/constants.py +++ b/utils/exporters/blender/addons/io_three/constants.py @@ -338,6 +338,7 @@ INTENSITY = 'intensity' DISTANCE = 'distance' ASPECT = 'aspect' ANGLE = 'angle' +DECAY = 'decayExponent' FOV = 'fov' ASPECT = 'aspect' diff --git a/utils/exporters/blender/addons/io_three/exporter/api/animation.py b/utils/exporters/blender/addons/io_three/exporter/api/animation.py index 1445daf2979b4b92b4c33a28f1bb2fb0cd78ec9e..d18e396a6385a41b221bb26978bac8aebb947b3c 100644 --- a/utils/exporters/blender/addons/io_three/exporter/api/animation.py +++ b/utils/exporters/blender/addons/io_three/exporter/api/animation.py @@ -7,7 +7,6 @@ import mathutils from bpy import data, context, ops from .. import constants, logger - def pose_animation(armature, options): """Query armature animation using pose bones @@ -47,9 +46,10 @@ def _parse_action(func, armature, options): animations = [] logger.info("Parsing %d actions", len(data.actions)) for action in data.actions: - logger.info("Parsing action %s", action.name) - animation = func(action, armature, options) - animations.append(animation) + if action == armature.animation_data.action: + logger.info("Parsing action %s", action.name) + animation = func(action, armature, options) + animations.append(animation) return animations diff --git a/utils/exporters/blender/addons/io_three/exporter/api/light.py b/utils/exporters/blender/addons/io_three/exporter/api/light.py index 33c5fa86dd89b3c33b364471bb2675a996f6ab03..25a8cc48da1aecd12425c40034030ba715ddd4b1 100644 --- a/utils/exporters/blender/addons/io_three/exporter/api/light.py +++ b/utils/exporters/blender/addons/io_three/exporter/api/light.py @@ -75,3 +75,23 @@ def intensity(lamp): """ logger.debug("light.intensity(%s)", lamp) return round(lamp.energy, 2) + +# mapping enum values to decay exponent +__FALLOFF_TO_EXP = { + 'CONSTANT': 0, + 'INVERSE_LINEAR': 1, + 'INVERSE_SQUARE': 2, + 'CUSTOM_CURVE': 0, + 'LINEAR_QUADRATIC_WEIGHTED': 2 +} + +@_lamp +def falloff(lamp): + """ + + :param lamp: + :rtype: float + + """ + logger.debug("light.falloff(%s)", lamp) + return __FALLOFF_TO_EXP[lamp.falloff_type] diff --git a/utils/exporters/blender/addons/io_three/exporter/api/mesh.py b/utils/exporters/blender/addons/io_three/exporter/api/mesh.py index fa942b2b7cd4c9e19f3b47f727314db085ebd3a6..d7cc5d6c7fbc8ee6e5d4ac54444666e401f161f4 100644 --- a/utils/exporters/blender/addons/io_three/exporter/api/mesh.py +++ b/utils/exporters/blender/addons/io_three/exporter/api/mesh.py @@ -342,9 +342,9 @@ def faces(mesh, options, material_list=None): face_data.append(mat_index) break else: - error = ("Could not map the material index " + logger.warning("Could not map the material index " "for face %d" % face.index) - raise exceptions.MaterialError(error) + face_data.append(0) # default to index zero if there's a bad material if uv_indices: for index, uv_layer in enumerate(uv_indices): @@ -465,6 +465,11 @@ def animated_blend_shapes(mesh, name, options): :param options: """ + + # let filter the name to only keep the node's name + # the two cases are '%sGeometry' and '%sGeometry.%d', and we want %s + name = re.search("^(.*)Geometry(\..*)?$", name).group(1) + logger.debug("mesh.animated_blend_shapes(%s, %s)", mesh, options) tracks = [] shp = mesh.shape_keys @@ -520,6 +525,9 @@ def materials(mesh, options): logger.info("Vertex colours set to %s", use_colors) for mat, index in material_sets: + if mat == None: # undefined material for a specific index is skipped + continue + try: dbg_color = constants.DBG_COLORS[index] except IndexError: diff --git a/utils/exporters/blender/addons/io_three/exporter/geometry.py b/utils/exporters/blender/addons/io_three/exporter/geometry.py index 0e2cc502d2a19516d07878843d3f2213d96c01bd..389bdf266c596e698d91463e3f4a932aefdebb1f 100644 --- a/utils/exporters/blender/addons/io_three/exporter/geometry.py +++ b/utils/exporters/blender/addons/io_three/exporter/geometry.py @@ -568,7 +568,6 @@ class Geometry(base_classes.BaseNode): mt = api.mesh.blend_shapes(self.node, self.options) or [] self[constants.MORPH_TARGETS] = mt if len(mt) > 0 and self._scene: # there's blend shapes, let check for animation - #self[constants.CLIPS] = api.mesh.animated_blend_shapes(self.node, self.options) or [] tracks = api.mesh.animated_blend_shapes(self.node, self[constants.NAME], self.options) or [] merge = self._scene[constants.ANIMATION][0][constants.KEYFRAMES] for track in tracks: diff --git a/utils/exporters/blender/addons/io_three/exporter/object.py b/utils/exporters/blender/addons/io_three/exporter/object.py index d6309017f5ac8cc3a78c76c61d8714d9ecb969d3..0a5ddfc53644d2ee3ba177bc569931a5397f5875 100644 --- a/utils/exporters/blender/addons/io_three/exporter/object.py +++ b/utils/exporters/blender/addons/io_three/exporter/object.py @@ -51,8 +51,12 @@ class Object(base_classes.BaseNode): # self[constants.DISTANCE] = api.light.distance(self.data) self[constants.DISTANCE] = 0; - if self[constants.TYPE] == constants.SPOT_LIGHT: + lightType = self[constants.TYPE] + if lightType == constants.SPOT_LIGHT: self[constants.ANGLE] = api.light.angle(self.data) + self[constants.DECAY] = api.light.falloff(self.data) + elif lightType == constants.POINT_LIGHT: + self[constants.DECAY] = api.light.falloff(self.data) def _init_mesh(self): """Initialize mesh attributes"""