We need to have an asset system. Coming up with an API on how we may want developers to use our API's. Considering many flaws in our own design.
API Structure Ideas
When looking into this design I was considering we'd have an AssetObject POD or class, AssetManager, and AssetStream.
AssetObject is when going to be our representation of a type of asset that we load into engine3d.
AssetManager is essentially going to be our asset system that may be used to help manage our assets, including synchronization, attaching textures if models have textures, etc.
AssetStream streams data to help reduce loading time, such as if we have loaded our asset in cache, we do not need to load in that same asset again.
Functionality
Assets should be loaded and updated
Enabling to deploy to other entities and notify the entities when their asset has been changed
Modify the entities assets who use that same asset.
When an update has been made to the asset, entities should notify to developers when an asset has been loaded successfully or not.
Enabling hot-reloading with assets
Content browser panels should be able to reload when a new directory has been added into current project directory or to engine3d.
Loading assets through editor's runtime.
Synchronization
Here is an overview of std::future and async. std::future
Using asynchronization with std::future, for enabling assets to load while Engine3D is performing other tasks that may need to be done
Usage is also when loading in thumbnails for the content browser panels.
Asset Loading Examples
AssetObject* model = AssetModel::Load("backpack.obj");
if(!model.IsLoaded()){
static_assert(false);
}
// Example API of potentially rendering our some asset into our world/screen
Renderer::RenderAsset(pos, model);
With std::future Async
Not a perfect example, but just an idea of potentially using std::future for loading a texture or a 3D model.
// Loading a texture from our assets
std::future<Ref> thumbnail = std::async(std::launch::async, [&]{
return AssetManager::GetTexture(handler);
}
// Loading in a 3D model or some kind of in-game asset object
std::future thumbnail = std::async(std::launch::async, [&]{
return AssetManager::Get(handler);
}
We need to have an asset system. Coming up with an API on how we may want developers to use our API's. Considering many flaws in our own design.
API Structure Ideas
AssetObject
is when going to be our representation of a type of asset that we load into engine3d.AssetManager
is essentially going to be our asset system that may be used to help manage our assets, including synchronization, attaching textures if models have textures, etc.AssetStream
streams data to help reduce loading time, such as if we have loaded our asset in cache, we do not need to load in that same asset again.Functionality
Synchronization
std::future
std::future
, for enabling assets to load while Engine3D is performing other tasks that may need to be doneAsset Loading Examples
With std::future Async
// Loading a texture from our assets std::future<Ref> thumbnail = std::async(std::launch::async, [&]{
return AssetManager::GetTexture(handler);
}
// Loading in a 3D model or some kind of in-game asset object std::future thumbnail = std::async(std::launch::async, [&]{
return AssetManager::Get(handler);
}