def set_models(ob, name):
# If possible, attach child mesh objects (requires models to be available, io_scene_bfres and no existing children).
if name in _empty_models or not addon_utils.check("io_scene_bfres")[1] or len(ob.children):
return
# Get the model or load it if it does not exist yet.
model_ob = bpy.data.objects.get("MK8.{}".format(name))
if not model_ob:
model_ob = _load_model(name)
if not model_ob:
log(0, "Warning: No model found for '{}'.".format(name))
_empty_models.append(name)
return
model_ob.name = "MK8.{}".format(name)
# Link-clone the child objects and attach them to the given parent.
for child in model_ob.children:
child_ob = bpy.data.objects.new(child.name, child.data)
child_ob.mk8.object_type = "ADDON_VISUALIZER"
child_ob.parent = ob
child_ob.lock_location = [True] * 3
child_ob.lock_rotation = [True] * 3
child_ob.lock_scale = [True] * 3
bpy.context.scene.objects.link(child_ob)
bpy.context.scene.update() # Required to find the children at the parent's transform eventually.
评论列表
文章目录