Lysa Nodes  0.0
Lysa Nodes — Scene Graph for the Lysa Engine
Loader Class Reference

Detailed Description

Centralized loader for scene trees and external resources.

The Loader resolves a file path from an URI and builds a tree of Node instances from supported formats:

  • JSON scene descriptions
  • Lysa AssetPacks

The loader optionally caches root nodes to allow fast re-use across the application lifetime. Access is thread-safe via an internal mutex.

Classes

struct  SceneNode
 

Static Public Member Functions

template<typename T = Node>
static std::shared_ptr< T > load (const std::string &uri, const bool useCache=false)
 
template<typename T = Node>
static std::shared_ptr< T > load (const VirtualFS &fs, const std::string &uri, const bool useCache=false)
 
template<typename T = Node>
static void loadAsync (const std::string &URI, LoaderHandlerCallback callback, const bool useCache=false)
 
template<typename T = Node>
static void loadAsync (const VirtualFS &fs, const std::string &URI, LoaderHandlerCallback callback, const bool useCache=false)
 
static std::string getAssetPackURI (const JsonValue &root)
 
template<typename T = Node>
static std::shared_ptr< T > loadScene (const std::string &uri)
 
template<typename T = Node>
static std::shared_ptr< T > loadScene (const VirtualFS &fs, const std::string &uri)
 
static void clearCache ()
 
static std::string resourceID (const std::string &catalogURI, const std::string &localID)
 
static void save (const VirtualFS &fs, const std::string &uri, const std::shared_ptr< Node > &root, const std::string &jsonURI="")
 

Member Function Documentation

static void clearCache ( )
static

Clears the global resources cache.

All previously cached root nodes become eligible for destruction once no other shared references exist.

static std::string getAssetPackURI ( const JsonValue &  root)
inlinestatic

Returns the binary pack URI

static std::shared_ptr<T> load ( const std::string &  uri,
const bool  useCache = false 
)
inlinestatic

Loads a JSON Scene or an AssetPack and returns the constructed node tree.

Template Parameters
TNode subtype to cast the root to (defaults to Node).
Parameters
uriURI to the JSON/glTF/ZRes file
useCacheWhen true, store and re-use the loaded root from a global cache.
Returns
Shared pointer to the loaded root node or nullptr if no scene (possibly from cache).
static std::shared_ptr<T> load ( const VirtualFS &  fs,
const std::string &  uri,
const bool  useCache = false 
)
inlinestatic

Loads a JSON Scene or an AssetPack of a given virtual file system and returns the constructed node tree.

Template Parameters
TNode subtype to cast the root to (defaults to Node).
Parameters
fsVirtual file system resolving the URI & the URIs it references.
uriURI to the JSON/glTF/ZRes file
useCacheWhen true, store and re-use the loaded root from a global cache.
Returns
Shared pointer to the loaded root node or nullptr if no scene (possibly from cache).
static void loadAsync ( const std::string &  URI,
LoaderHandlerCallback  callback,
const bool  useCache = false 
)
inlinestatic

Loads an assets pack from a URI in a background thread

Parameters
URIThe URI of the node to load
callbackcallback called at the start of the frame following the loading
useCacheWhen true, store and re-use the loaded root from a global cache.
static void loadAsync ( const VirtualFS &  fs,
const std::string &  URI,
LoaderHandlerCallback  callback,
const bool  useCache = false 
)
inlinestatic

Loads an assets pack of a given virtual file system from a URI in a background thread

Parameters
fsVirtual file system resolving the URI & the URIs it references
URIThe URI of the node to load
callbackcallback called at the start of the frame following the loading
useCacheWhen true, store and re-use the loaded root from a global cache.
static std::shared_ptr<T> loadScene ( const std::string &  uri)
inlinestatic

Loads a JSON Scene and returns the constructed node tree.

Parameters
uriURI to the JSON scene
static std::shared_ptr<T> loadScene ( const VirtualFS &  fs,
const std::string &  uri 
)
inlinestatic

Loads a JSON Scene of a given virtual file system and returns the constructed node tree.

Parameters
fsVirtual file system resolving the URI & the URIs it references
uriURI to the JSON scene
static std::string resourceID ( const std::string &  catalogURI,
const std::string &  localID 
)
inlinestatic
static void save ( const VirtualFS &  fs,
const std::string &  uri,
const std::shared_ptr< Node > &  root,
const std::string &  jsonURI = "" 
)
static