Blender-Pipeline/wiki/docs/LinkingAssets.md

6 KiB

Linking Assets

It's important to be able to link assets into animation files. You can still do that from the Blender's UI it self. But it requires knowing the folder structure of the VCStudio project. It's way easier to do so if a system of linking would be available based on assets them selves.

Chapters:

Configuring Assets

In order to link the assets with the VCStudio link system you need to configure those assets first. So let's go over the configuration of assets.

There is button for configuration above the main progress bar in the asset manager.

The configuration is broken up to 3 steps.

Make the asset

Of course before the asset is link-able it has to be finished first. So the configuartion window will check the checklist of the asset and see whether you are done or not. You need to have done the checklist in order to go to the next step.

Copy the ast blend file

There is a specific folder for final blend files. /ast/ folder. And the linker will refer to it when linking. Actually if you place the blend file there manually. You can bypass the Making the asset step. If there is a file, the progress becomes 100% by default. Ignoring the checklist.

During this step the configuration window will ask you to select which file to make the final /ast/ file. This is important to select the right file. So be careful. To revert the change you will need to go to the /ast/ folder manually.

Choosing Collections and a Rig

When I make rigs there is usually hell of a lot of not needed collections. Stuff like rig elements. Trash objects that used to build the asset. This is not a part of the rig. So in this window you can select your collections that you would like to be linked. And deselect those not to link.

And since we are doing proxies or library overrides we want to know what objects to proxy. Or in other words, which object is your rig.

Actually I made it so if you call the collection exactly as the asset. Then it's selected by default. And for every armature it activates Proxies by default.

Asset Linking

In order to link an asset into an animation file. You need to click the button on the animation file. Note: Linking is implemented only for the animation files. Not asset files. And not sequence files.

You will be presented with a following window.

In here you may add those assets that you want to link into the scene. You are linking assets. Under the hood it will find the /ast/ files and link them. But for you as a user. You link the assets.

While linking you can choose from 3 modes of linking:

is only linking object. No proxy or library overrides will be done to anything.

is to add library overrides to the linked objects. It might be buggy since it's a new feature of Blender.

is to make proxy to the rig. And any object that was configured to be made proxy.

Also with you can automatically add the assets marked in the text of the scene. And with you can configure any asset on the spot.

Source Code

The best documentation is to read the code of the software directly. For the linking assets I recommend:

How does it link?

When you press okay in the conformation window it launches blender -b ( in the background ) and makes it launch the studio/bpy_do_linking.py script. Which is parsing a file called autolink.data where it finds which assets it needs to link. And what mode we are in. And so I'm using standard blender bpy functions to do the linking and proxies. By the end it just saves the file and quits.

All the output of this script is piped into the studio/studio_shot_linkLayer.py using what's called subprocess.Popen() and reading it I can estimate the percentage of the linking operation. And show a progress bar.

How does it know what collections and what objects are in the file?

Similarly as in the previous thing. But this time we are running the studio/bpy_get_blend_content.py and piping this. The script basically just outputs the list of collections and the list of objects / object types it finds in every collection. All using standard bpy commands.