Add "hand crafted" resource to resource manager/saving them?


#1

I’m importing some custom formats from an old game “by hand”, so basically I read the data from the old game archive and put together the meshes and textures manually.

Since bs:f does not yet support loading resources from archives, it seems like I can’t use the resource manager, which prevents loading the same resource twice. Is there any way to register my resources inside the manager or that I can search them by name without putting them into a map myself?

Also, I understand I would need a resource manifest if I want to save an object which combines those resources. Is there some example code on how to generate one?


#2

I do suggest converting your resources into bsf format so you can use the resource manager directly. But if you wanted to proceed with your approach I believe it can be done, but note the system wasn’t really built for it.

If you ensure all your resources are loaded in-memory, then register them with a resource manifest using some custom names, you should be able to retrieve those resources by calling gResources().load(name). Note this will only work if resources are loaded in memory already as the load method expects a file path at which to find a resource at. If it can’t find the resource already loaded in memory it will try to load from that path, and in your case fail since it’s just a name.

This is why I suggest just converting and saving your resources. Later when resource packages are supported those paths will be allowed to be virtual, loading transparently from a package.

Regarding resource manifest, you can take a look at how the examples do it: https://github.com/GameFoundry/bsfExamples/blob/master/Source/Common/BsExampleFramework.h . There’s also this section in the manual: http://docs.bsframework.io/latest/saving_scene.html.


#3

Converting and saving the resources works fine, thanks you!