Is it possible for the engine to load resources asynchronously

I created an object that I displayed to engine-world using IStatObj and IRenderNode.

But When I use ’gEnv->p3DEngine->LoadStatObj(mv_geometryFile);‘ to loading model, the whole engine will be stuck until the resource file was loaded.

This is very embarrassed because I would load hundreds or thousands of large models at the same time.

So, Is there a way to make CryEngine can load assets asynchronously?

Re: Is it possible for the engine to load resources asynchronously

Ok, I found a solution to async Loading model files. :)

USE CObjManager::LoadStatObjAsync AND class IStatObjFoundCallback.

Code: Select all

class CObjManager { // ... void LoadStatObjAsync(const char* szFileName, const char* szGeomName, bool useStreaming, uint32 loadingFlags, IStatObjFoundCallback* pCallback = nullptr); }

Code: Select all

class IStatObjFoundCallback { public: virtual ~IStatObjFoundCallback() = default; //! Gets called once loading is finished. //! Will be called directly from the thread invoking LoadStatObjAsync or later from the main thread. //! \param pObject can be null in case of a loading error. //! \param pSubObject may point to a named sub-object, if a geometryName was requested and found virtual void OnFound(CStatObj* pObject, IStatObj::SSubObject* pSubObject) = 0; };

Who is online

Users browsing this forum: No registered users and 1 guest