urho_scene_prefab.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:Urho3D-Blender-Mod 作者: Mike3D 项目源码 文件源码
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
#------------------------
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号