def UrhoGatherInstances(obj):
# Compute transforms and append instance to the list of models to process
def UrhoDupliTransforms(dupli, root, parent = None):
if dupli.matrix_local.to_euler() != Euler((0.0, 0.0, 0.0)):
log.warning('You should apply rotation to object {:s}'.format(dupli.name))
if dupli.matrix_local.to_scale() != Vector((1.0, 1.0, 1.0)):
log.warning('You should apply scale to object {:s}'.format(dupli.name))
instance = UrhoInstance()
instance.name = dupli.name
instance.matrix = root.matrix_world
instance.objectName = obj.name
if parent:
instance.matrix = instance.matrix * parent.matrix_world
# Parent-child relationship inside a group object
if dupli.children:
instance.objectName += dupli.name # Make parent name unic for parent-child relationship
if dupli.parent and dupli.parent.type != 'ARMATURE':
instance.parentName = obj.name + dupli.parent.name # See parent naming above
instance.matrix = dupli.matrix_local
instances.append(instance)
if obj.hide:
return
if obj.type == 'EMPTY' and obj.dupli_group: # Look for instances
for dupli in obj.dupli_group.objects: # Find members for this group
if dupli.hide or dupli.type == 'ARMATURE': continue
if dupli.type == 'EMPTY' and dupli.dupli_group: # Bunch of instances found
for subDupli in dupli.dupli_group.objects:
UrhoDupliTransforms(subDupli, obj, dupli)
else:
UrhoDupliTransforms(dupli, obj)
elif obj.type == 'MESH': # Look for mesh objects
instance = UrhoInstance()
instance.name = obj.data.name # Use mesh name instead of object name
instance.matrix = obj.matrix_world
instance.objectName = obj.name
if obj.parent and obj.parent.type == 'MESH':
instance.parentName = obj.parent.name
instance.matrix = obj.matrix_local
instances.append(instance)
#------------------------
# Export scene prefab
#------------------------
评论列表
文章目录