Blender-Pipeline/wiki/docs/LinkingAssets.md

89 lines
6 KiB
Markdown
Raw Normal View History

2021-05-10 21:48:23 +02:00
# 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.
![](https://notabug.org/jyamihud/update_manager/raw/master/vcstudio/32.png)
### Chapters:
- [Configuring Assets](#configuring-assets)
- [Asset Linking](#asset-linking)
- [Source Code](#source-code)
# 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 ![](../../settings/themes/OldSchool/icons/link_configure.png) button for configuration above the main progress bar in the [asset manager.](../../wiki/docs/Assets.md)
The configuration is broken up to 3 steps.
![](https://notabug.org/jyamihud/update_manager/raw/master/vcstudio/34.png)
**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.
![](https://notabug.org/jyamihud/update_manager/raw/master/vcstudio/35.png)
**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.
![](https://notabug.org/jyamihud/update_manager/raw/master/vcstudio/36.png)
**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.
![](https://notabug.org/jyamihud/update_manager/raw/master/vcstudio/37.png)
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
![](https://notabug.org/jyamihud/update_manager/raw/master/vcstudio/38.png)
In order to link an asset into an animation file. You need to click the ![](../../settings/themes/OldSchool/icons/obj_link.png) 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.
![](https://notabug.org/jyamihud/update_manager/raw/master/vcstudio/32.png)
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:
![](../../settings/themes/OldSchool/icons/link.png) is only linking object. No proxy or library overrides will be done to anything.
![](../../settings/themes/OldSchool/icons/override.png) is to add library overrides to the linked objects. It might be buggy since it's a new feature of Blender.
![](../../settings/themes/OldSchool/icons/proxy.png) is to make proxy to the rig. And any object that was configured to be made proxy.
Also with ![](../../settings/themes/OldSchool/icons/scene_new.png) you can automatically add the assets marked in the text of the scene. And with ![](../../settings/themes/OldSchool/icons/link_configure.png) 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:
- [studio/studio_scriptLayer.py](../../studio/studio_scriptLayer.py) It's the UI of the Script Writer that has the initial Link Asset button.
- [studio/studio_shot_linkLayer.py](../../studio/studio_shot_linkLayer.py) It's the UI of the conformation.
- [studio/bpy_do_linking.py](../../studio/bpy_do_linking.py) This is the `bpy` script that runs inside blender to do that linking of the assets.
- [studio/studio_assetLayer.py](../../studio/studio_assetLayer.py) This is UI of the Asset Manager where you can find the configure asset button.
- [studio/studio_asset_configureLayer.py](../../studio/studio_asset_configureLayer.py) The configuration UI
- [studio/bpy_get_blend_content.py](../../studio/bpy_get_blend_content.py) This is the `bpy` script that runs inside blender to get collections and list of objects.
**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](../../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](../../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](../../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.