提交 ac6b89b9 编写于 作者: M Mr.doob

Merge pull request #7403 from bhouston/blender_export_bugfixes

Blender export bugfixes
......@@ -338,6 +338,7 @@ INTENSITY = 'intensity'
DISTANCE = 'distance'
ASPECT = 'aspect'
ANGLE = 'angle'
DECAY = 'decayExponent'
FOV = 'fov'
ASPECT = 'aspect'
......
......@@ -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
......
......@@ -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]
......@@ -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:
......
......@@ -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:
......
......@@ -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"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册