本文整理汇总了C++中AssetLoader类的典型用法代码示例。如果您正苦于以下问题:C++ AssetLoader类的具体用法?C++ AssetLoader怎么用?C++ AssetLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AssetLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doAssetLoadTests
inline void doAssetLoadTests(size_t &passCounter, size_t &failCounter)
{
AssetLoader loader;
int length = 0;
char *data = nullptr;
std::cout << "Loading the readme" << std::endl;
size_t loopCount = 0;
while(true) {
data = loader.requestData("README.org", 100, &length);
if(data) {
break;
}
// Show a progress bar thingy.
if(loopCount % 70 == 0 && loopCount) {
std::cout << std::endl;
}
std::cout << ".oO0Oo"[loopCount % 6];
loopCount++;
}
std::cout << std::endl;
EXPOP_TEST_VALUE(!!data, true);
EXPOP_TEST_VALUE(std::string(data, length), FileSystem::loadFileString("README.org"));
}
示例2: initFile
void Sound::initFile(const std::string &name) {
SLresult result;
std::string filename = name + ".mp3";
// use asset manager to open asset by filename
AssetLoader *loader = AssetLoader::instance();
AAsset *asset = loader->open(filename);
// the asset might not be found
if (NULL == asset) {
LOGI("Asset not found: %s", name.c_str());
return;
}
// open asset as file descriptor
off_t start, length;
int fd = AAsset_openFileDescriptor(asset, &start, &length);
assert(0 <= fd);
AAsset_close(asset);
// configure audio source
SLDataLocator_AndroidFD loc_fd = {SL_DATALOCATOR_ANDROIDFD, fd, start, length};
SLDataFormat_MIME format_mime = {SL_DATAFORMAT_MIME, NULL, SL_CONTAINERTYPE_UNSPECIFIED};
SLDataSource audioSrc = {&loc_fd, &format_mime};
// configure audio sink
SLDataLocator_OutputMix loc_outmix = {SL_DATALOCATOR_OUTPUTMIX, pd->outputMixObject};
SLDataSink audioSnk = {&loc_outmix, NULL};
// create audio player
PrivateImplData::SoundPlayer soundPlayer;
const SLInterfaceID ids[1] = {SL_IID_SEEK};
const SLboolean req[1] = {SL_BOOLEAN_TRUE};
result = (*pd->engineEngine)->CreateAudioPlayer(pd->engineEngine, &soundPlayer.fdPlayerObject, &audioSrc, &audioSnk,
1, ids, req);
assert(SL_RESULT_SUCCESS == result);
// realize the player
result = (*soundPlayer.fdPlayerObject)->Realize(soundPlayer.fdPlayerObject, SL_BOOLEAN_FALSE);
assert(SL_RESULT_SUCCESS == result);
// get the play interface
result = (*soundPlayer.fdPlayerObject)->GetInterface(soundPlayer.fdPlayerObject, SL_IID_PLAY, &soundPlayer.fdPlayerPlay);
assert(SL_RESULT_SUCCESS == result);
// get the seek interface
result = (*soundPlayer.fdPlayerObject)->GetInterface(soundPlayer.fdPlayerObject, SL_IID_SEEK, &soundPlayer.fdPlayerSeek);
assert(SL_RESULT_SUCCESS == result);
pd->soundPlayers[name] = soundPlayer;
}
示例3: Load
void SoundBank::Load(const AssetLoader &loader, const ResourceIndex &index) {
sounds.clear();
sounds.resize(index.Size());
for (const auto &entry : index.Entries()) {
sounds[entry.second] = loader.LoadSound(entry.first);
}
}
示例4: deserialized
Scene Scene::deserialized(io::ReaderRef reader, AssetLoader<StaticMesh>& mesh_loader, const AssetPtr<Material>& default_material) {
y_profile();
struct Header {
u32 magic;
AssetType type;
u32 version;
u32 statics;
u32 lights;
bool is_valid() const {
return magic == fs::magic_number &&
type == AssetType::Scene &&
version == 2;
}
};
auto header = reader->read_one<Header>();
if(!header.is_valid()) {
y_throw("Invalid header.");
}
Scene scene;
scene.static_meshes().set_min_capacity(header.statics);
scene.lights().set_min_capacity(header.lights);
{
for(u32 i = 0; i != header.statics; ++i) {
auto id = reader->read_one<AssetId>();
auto transform = reader->read_one<math::Transform<>>();
if(id == AssetId::invalid_id()) {
log_msg("Skipping asset with invalid id.", Log::Warning);
continue;
}
try {
auto mesh = mesh_loader.load(id);
auto inst = std::make_unique<StaticMeshInstance>(mesh, default_material);
inst->transform() = transform;
scene.static_meshes().emplace_back(std::move(inst));
} catch(std::exception& e) {
log_msg(fmt("Unable to load asset: %, Skipping.", e.what()), Log::Warning);
continue;
}
}
}
{
for(u32 i = 0; i != header.lights; ++i) {
// load as point, then read on top. Maybe change this ?
auto light = std::make_unique<Light>(Light::Point);
reader->read_one(*light);
scene.lights().emplace_back(std::move(light));
}
}
return scene;
}
示例5: loadMaterialTestModel
//////////////////////////////////////////
// Standard Material Test Models
//////////////////////////////////////////
std::shared_ptr<TriangleMesh> loadMaterialTestModel( AssetLoader & loader )
{
std::string modelBasePath = "models";
//auto mesh = loader.load( modelBasePath + "/dacunni/material_test1.obj" );
//auto mesh = loader.load( modelBasePath + "/dacunni/material_test1.stl" );
auto mesh = loader.load( modelBasePath + "/tf3dm.com/soccerball/untitled.ply" );
//auto mesh = loader.load( modelBasePath + "/uvsphere.ply" );
//auto mesh = loader.loadMultiPartMerged( modelBasePath + "/test_objects/mori/testObj.obj" );
#if 0
auto mesh = loader.loadMultiPartMerged( modelBasePath + "/test_objects/mitsuba/mitsuba.obj" );
#endif
#if 0
mesh->makeCanonical();
#endif
#if 1
mesh->accelerator = new TMOctreeAccelerator( *mesh );
mesh->accelerator->build();
#endif
return mesh;
}
示例6: loadLuaScript
std::string ResourceLoader::loadLuaScript(const std::string &scriptname) {
const std::string &filename = scriptname + ".lua";
AssetLoader *loader = AssetLoader::instance();
AAsset *asset = loader->open(filename);
// the asset might not be found
if (NULL == asset) {
DEBUGLOG("Asset not found: %s", filename.c_str());
return NULL;
}
size_t length = AAsset_getLength(asset);
const char *buffer = (char *)AAsset_getBuffer(asset);
std::string script(buffer, length);
if (buffer = NULL) {
DEBUGLOG("Buffer is empty");
}
AAsset_close(asset);
return script;
}
示例7: HELIUM_TRACE
//.........这里部分代码省略.........
return Invalid< size_t >();
}
#ifndef NDEBUG
size_t loadRequestSize = m_loadRequests.GetSize();
for( size_t loadRequestIndex = 0; loadRequestIndex < loadRequestSize; ++loadRequestIndex )
{
if( !m_loadRequests.IsElementValid( loadRequestIndex ) )
{
continue;
}
LoadRequest* pRequest = m_loadRequests[ loadRequestIndex ];
HELIUM_ASSERT( pRequest );
HELIUM_ASSERT( pRequest->index != objectIndex );
if( pRequest->index == objectIndex )
{
return Invalid< size_t >();
}
}
#endif
LoadRequest* pRequest = m_loadRequestPool.Allocate();
HELIUM_ASSERT( pRequest );
HELIUM_ASSERT( !pRequest->spObject );
pRequest->index = objectIndex;
pRequest->spType = pType;
HELIUM_ASSERT( !pRequest->spTemplate );
HELIUM_ASSERT( !pRequest->spOwner );
SetInvalid( pRequest->templateLoadId );
SetInvalid( pRequest->ownerLoadId );
SetInvalid( pRequest->persistentResourceDataLoadId );
pRequest->pCachedObjectDataBuffer = NULL;
pRequest->cachedObjectDataBufferSize = 0;
SetInvalid( pRequest->asyncFileLoadId );
pRequest->pAsyncFileLoadBuffer = NULL;
pRequest->asyncFileLoadBufferSize = 0;
pRequest->pResolver = pResolver;
pRequest->forceReload = forceReload;
pRequest->flags = 0;
// If a fully-loaded object already exists with the same name, do not attempt to re-load the object (just mark
// the request as complete).
if ( !forceReload )
{
pRequest->spObject = Asset::FindObject( path );
}
Asset* pObject = pRequest->spObject;
if( pObject && pObject->IsFullyLoaded() )
{
pRequest->flags = LOAD_FLAG_PRELOADED;
}
else
{
HELIUM_ASSERT( !pObject || !pObject->GetAnyFlagSet( Asset::FLAG_LOADED | Asset::FLAG_LINKED ) );
// Begin loading the template and owner objects. Note that there isn't much reason to check for failure
// until we tick this request, as we need to make sure any other load requests for the template/owner that
// did succeed are properly synced anyway.
AssetLoader* pAssetLoader = AssetLoader::GetStaticInstance();
HELIUM_ASSERT( pAssetLoader );
if( rObjectData.templatePath.IsEmpty() )
{
// Make sure the template is fully loaded.
Asset* pTemplate = pType->GetTemplate();
rObjectData.templatePath = pTemplate->GetPath();
if( pTemplate->IsFullyLoaded() )
{
pRequest->spTemplate = pTemplate;
}
else
{
pRequest->templateLoadId = pAssetLoader->BeginLoadObject( rObjectData.templatePath );
}
}
else
{
pRequest->templateLoadId = pAssetLoader->BeginLoadObject( rObjectData.templatePath );
}
AssetPath ownerPath = path.GetParent();
if( ownerPath == m_packagePath )
{
// Easy check: if the owner is this package (which is likely), we don't need to load it.
pRequest->spOwner = m_spPackage.Ptr();
}
else if( !ownerPath.IsEmpty() )
{
pRequest->ownerLoadId = pAssetLoader->BeginLoadObject( ownerPath );
}
}
size_t requestId = m_loadRequests.Add( pRequest );
return requestId;
}
示例8: HELIUM_ASSERT
/// Begin asynchronous pre-loading of package information.
///
/// @see TryFinishPreload()
bool LoosePackageLoader::BeginPreload()
{
HELIUM_ASSERT( !m_startPreloadCounter );
HELIUM_ASSERT( !m_preloadedCounter );
HELIUM_ASSERT( IsInvalid( m_parentPackageLoadId ) );
// Load the parent package if we need to create the current package.
if( !m_spPackage )
{
AssetPath parentPackagePath = m_packagePath.GetParent();
if( !parentPackagePath.IsEmpty() )
{
AssetLoader* pAssetLoader = AssetLoader::GetStaticInstance();
HELIUM_ASSERT( pAssetLoader );
m_parentPackageLoadId = pAssetLoader->BeginLoadObject( parentPackagePath );
HELIUM_ASSERT( IsValid( m_parentPackageLoadId ) );
}
}
AsyncLoader &rAsyncLoader = AsyncLoader::GetStaticInstance();
if ( !m_packageDirPath.Exists() )
{
HELIUM_TRACE(
TraceLevels::Warning,
"LoosePackageLoader::BeginPreload - Package physical path '%s' does not exist\n",
m_packageDirPath.c_str());
}
else if ( !m_packageDirPath.IsDirectory() )
{
HELIUM_TRACE(
TraceLevels::Warning,
"LoosePackageLoader::BeginPreload - Package physical path '%s' is not a directory\n",
m_packageDirPath.c_str());
}
else
{
DirectoryIterator packageDirectory( m_packageDirPath );
HELIUM_TRACE( TraceLevels::Info, TXT(" LoosePackageLoader::BeginPreload - Issuing read requests for all files in %s\n"), m_packageDirPath.c_str() );
for( ; !packageDirectory.IsDone(); packageDirectory.Next() )
{
const DirectoryIteratorItem& item = packageDirectory.GetItem();
#if HELIUM_TOOLS
if ( item.m_Path.IsDirectory() )
{
AssetPath packagePath;
std::string name = item.m_Path.DirectoryAsVector().back();
packagePath.Set( Name( name.c_str() ), true, m_packagePath );
m_childPackagePaths.Add( packagePath );
HELIUM_TRACE( TraceLevels::Info, TXT("- Skipping directory [%s]\n"), item.m_Path.c_str(), item.m_Path.Extension().c_str() );
}
else
#endif
if ( item.m_Path.Extension() == Persist::ArchiveExtensions[ Persist::ArchiveTypes::Json ] )
{
HELIUM_TRACE( TraceLevels::Info, TXT("- Reading file [%s]\n"), item.m_Path.c_str() );
FileReadRequest *request = m_fileReadRequests.New();
request->expectedSize = item.m_Size;
HELIUM_ASSERT( item.m_Size < UINT32_MAX );
// Create a buffer for the file to be read into temporarily
request->pLoadBuffer = DefaultAllocator().Allocate( static_cast< size_t > ( item.m_Size ) + 1 );
static_cast< char* >( request->pLoadBuffer )[ static_cast< size_t > ( item.m_Size ) ] = '\0'; // for efficiency parsing text files
HELIUM_ASSERT( request->pLoadBuffer );
// Queue up the read
request->asyncLoadId = rAsyncLoader.QueueRequest( request->pLoadBuffer, String( item.m_Path.c_str() ), 0, static_cast< size_t >( item.m_Size ) );
HELIUM_ASSERT( IsValid( request->asyncLoadId ) );
request->filePath = item.m_Path;
request->fileTimestamp = item.m_ModTime;
}
else
{
HELIUM_TRACE( TraceLevels::Info, TXT("- Skipping file [%s] (Extension is %s)\n"), item.m_Path.c_str(), item.m_Path.Extension().c_str() );
}
}
}
AtomicExchangeRelease( m_startPreloadCounter, 1 );
return true;
}
示例9: HELIUM_ASSERT
void ForciblyFullyLoadedPackageManager::Tick()
{
AssetLoader *pAssetLoader = AssetLoader::GetStaticInstance();
// For each editable package
for ( DynamicArray< ForciblyFullyLoadedPackage >::Iterator packageIter = m_ForciblyFullyLoadedPackages.Begin();
packageIter != m_ForciblyFullyLoadedPackages.End(); ++packageIter)
{
ForciblyFullyLoadedPackage &package = *packageIter;
// Load the package if we need to
if ( Helium::IsValid< size_t >( package.m_PackageLoadId ) )
{
HELIUM_ASSERT( package.m_Assets.IsEmpty() );
HELIUM_ASSERT( package.m_AssetLoadIds.IsEmpty() );
HELIUM_ASSERT( package.m_AssetPaths.IsEmpty() );
HELIUM_ASSERT( !package.m_Package );
AssetPtr packagePtr;
if ( pAssetLoader->TryFinishLoad( package.m_PackageLoadId, packagePtr ) )
{
// Load request is finished.
package.m_PackageLoadId = Helium::Invalid< size_t >();
package.m_Package = Reflect::AssertCast<Package>(packagePtr);
if ( package.m_Package )
{
if ( !package.m_Package->GetAllFlagsSet( Asset::FLAG_EDITOR_FORCIBLY_LOADED ) )
{
// Package loaded successfully, queue load requests for all children
package.m_Package->SetFlags( Asset::FLAG_EDITOR_FORCIBLY_LOADED );
e_AssetForciblyLoadedEvent.Raise( AssetEventArgs( package.m_Package ) );
}
PackageLoader *pLoader = package.m_Package->GetLoader();
pLoader->EnumerateChildren( package.m_AssetPaths );
package.m_Assets.Resize( package.m_AssetPaths.GetSize() );
package.m_AssetLoadIds.Resize( package.m_AssetPaths.GetSize() );
DynamicArray< AssetPath >::Iterator assetPathIter = package.m_AssetPaths.Begin();
DynamicArray< size_t >::Iterator assetLoadIdIter = package.m_AssetLoadIds.Begin();
int i = 0;
for ( ; assetPathIter != package.m_AssetPaths.End(); ++assetPathIter, ++assetLoadIdIter )
{
*assetLoadIdIter = pAssetLoader->BeginLoadObject( *assetPathIter );
HELIUM_ASSERT( !package.m_Assets[i++] );
}
}
else
{
HELIUM_TRACE(
TraceLevels::Warning,
"Failed to load package '%s' for editor.",
*package.m_PackagePath.ToString());
}
}
}
}
// For each editable package
for ( DynamicArray< ForciblyFullyLoadedPackage >::Iterator packageIter = m_ForciblyFullyLoadedPackages.Begin();
packageIter != m_ForciblyFullyLoadedPackages.End(); ++packageIter)
{
ForciblyFullyLoadedPackage &package = *packageIter;
// If the package is loaded
if ( package.m_Package )
{
// Load the child assets if we need to
for ( int i = 0; i < package.m_AssetPaths.GetSize(); ++i )
{
if ( Helium::IsValid<size_t>( package.m_AssetLoadIds[i] ) )
{
HELIUM_ASSERT( !package.m_Assets[i] );
if ( pAssetLoader->TryFinishLoad( package.m_AssetLoadIds[i], package.m_Assets[i] ) )
{
package.m_AssetLoadIds[i] = Invalid< size_t >();
if ( package.m_Assets[i] )
{
// Asset loaded successfully
if ( !package.m_Assets[i]->IsPackage() && !package.m_Assets[i]->GetAllFlagsSet( Asset::FLAG_EDITOR_FORCIBLY_LOADED ) )
{
package.m_Assets[i]->SetFlags( Asset::FLAG_EDITOR_FORCIBLY_LOADED );
e_AssetForciblyLoadedEvent.Raise( AssetEventArgs( package.m_Assets[i] ) );
}
}
else
{
HELIUM_TRACE(
TraceLevels::Warning,
"Failed to asset '%s' for editor.",
*package.m_PackagePath.ToString());
}
}
else
{
HELIUM_ASSERT( !package.m_Assets[i] );
//.........这里部分代码省略.........
示例10: main
int main( int argc, const char* argv[] )
#endif
{
HELIUM_TRACE_SET_LEVEL( TraceLevels::Debug );
Helium::GetComponentsDefaultHeap();
Helium::GetBulletDefaultHeap();
#if HELIUM_TOOLS
Helium::GetEditorSupportDefaultHeap();
#endif
int32_t result = 0;
{
// Initialize a GameSystem instance.
CommandLineInitializationImpl commandLineInitialization;
MemoryHeapPreInitializationImpl memoryHeapPreInitialization;
AssetLoaderInitializationImpl assetLoaderInitialization;
ConfigInitializationImpl configInitialization;
#if HELIUM_DIRECT3D
WindowManagerInitializationImpl windowManagerInitialization( hInstance, nCmdShow );
#else
WindowManagerInitializationImpl windowManagerInitialization;
#endif
RendererInitializationImpl rendererInitialization;
//NullRendererInitialization rendererInitialization;
AssetPath systemDefinitionPath( "/ExampleGames/PhysicsDemo:System" );
GameSystem* pGameSystem = GameSystem::CreateStaticInstance();
HELIUM_ASSERT( pGameSystem );
bool bSystemInitSuccess = pGameSystem->Initialize(
commandLineInitialization,
memoryHeapPreInitialization,
assetLoaderInitialization,
configInitialization,
windowManagerInitialization,
rendererInitialization,
systemDefinitionPath);
if( bSystemInitSuccess )
{
World *pWorld = NULL;
{
AssetLoader *pAssetLoader = AssetLoader::GetStaticInstance();
SceneDefinitionPtr spSceneDefinition;
AssetPath scenePath( TXT( "/ExampleGames/PhysicsDemo/Scenes/TestScene:SceneDefinition" ) );
pAssetLoader->LoadObject(scenePath, spSceneDefinition );
HELIUM_ASSERT( !spSceneDefinition->GetAllFlagsSet( Asset::FLAG_BROKEN ) );
pWorld = pGameSystem->LoadScene(spSceneDefinition.Get());
}
HELIUM_ASSERT( pWorld );
if ( pWorld )
{
AssetLoader *pAssetLoader = AssetLoader::GetStaticInstance();
EntityDefinitionPtr spCubeDefinition;
EntityDefinitionPtr spSphereDefinition;
AssetPath spCubePath( TXT( "/ExampleGames/PhysicsDemo:Cube" ) );
AssetPath spSpherePath( TXT( "/ExampleGames/PhysicsDemo:Sphere" ) );
pAssetLoader->LoadObject(spCubePath, spCubeDefinition );
pAssetLoader->LoadObject(spSpherePath, spSphereDefinition );
Helium::StrongPtr< ParameterSet_InitLocated > locatedParamSet( new ParameterSet_InitLocated() );
locatedParamSet->m_Position = Simd::Vector3::Zero;
locatedParamSet->m_Rotation = Simd::Quat::IDENTITY;
Simd::Vector3 &position = locatedParamSet->m_Position;
Simd::Quat &rotation = locatedParamSet->m_Rotation;
for (int i = 0; i < 25; ++i)
{
position = Simd::Vector3(
50.0f * static_cast<float>(i / 5) - 100.0f + Helium::Ran(-10.0f, 10.0f),
Helium::Ran(150.0f, 200.0f),
50.0f * static_cast<float>(i % 5) - 100.0f + Helium::Ran(-10.0f, 10.0f));
pWorld->GetRootSlice()->CreateEntity(spCubeDefinition, locatedParamSet.Get());
}
for (int i = 0; i < 25; ++i)
{
position = Simd::Vector3(
50.0f * static_cast<float>(i / 5) - 100.0f + Helium::Ran(-10.0f, 10.0f),
Helium::Ran(250.0f, 300.0f),
50.0f * static_cast<float>(i % 5) - 100.0f + Helium::Ran(-10.0f, 10.0f));
pWorld->GetRootSlice()->CreateEntity(spSphereDefinition, locatedParamSet.Get());
}
for (int i = 0; i < 25; ++i)
{
position = Simd::Vector3(
50.0f * static_cast<float>(i / 5) - 100.0f + Helium::Ran(-10.0f, 10.0f),
//.........这里部分代码省略.........
示例11: HELIUM_ASSERT
/// @copydoc PackageLoader::TryFinishLoadObject()
bool CachePackageLoader::TryFinishLoadObject( size_t requestId, AssetPtr& rspObject )
{
HELIUM_ASSERT( requestId < m_loadRequests.GetSize() );
HELIUM_ASSERT( m_loadRequests.IsElementValid( requestId ) );
LoadRequest* pRequest = m_loadRequests[ requestId ];
HELIUM_ASSERT( pRequest );
if( !( pRequest->flags & LOAD_FLAG_PRELOADED ) )
{
return false;
}
// Sync on template and owner dependencies.
AssetLoader* pAssetLoader = AssetLoader::GetInstance();
HELIUM_ASSERT( pAssetLoader );
if( IsValid( pRequest->ownerLoadIndex ) )
{
size_t linkLoadId = pRequest->ownerLoadIndex;
if( IsValid( linkLoadId ) && !pAssetLoader->TryFinishLoad( linkLoadId, pRequest->spOwner ) )
{
return false;
}
SetInvalid( pRequest->ownerLoadIndex );
}
rspObject = pRequest->spObject;
Asset* pObject = rspObject;
if( pObject && ( pRequest->flags & LOAD_FLAG_ERROR ) )
{
pObject->SetFlags( Asset::FLAG_BROKEN );
}
if ( pObject->IsPackage() )
{
Package *pPackage = Reflect::AssertCast<Package>( pObject );
pPackage->SetLoader( this );
}
pRequest->spObject.Release();
HELIUM_ASSERT( IsInvalid( pRequest->asyncLoadId ) );
HELIUM_ASSERT( !pRequest->pAsyncLoadBuffer );
//pRequest->spTemplate.Release();
pRequest->spOwner.Release();
HELIUM_ASSERT( IsInvalid( pRequest->ownerLoadIndex ) );
//HELIUM_ASSERT( IsInvalid( pRequest->templateLoadIndex ) );
HELIUM_ASSERT( pObject || pRequest->pEntry );
HELIUM_TRACE(
TraceLevels::Debug,
"CachePackageLoader::TryFinishLoadObject(): Load request for \"%s\" (ID: %" PRIuSZ ") synced.\n",
*( pObject ? pObject->GetPath() : pRequest->pEntry->path ).ToString(),
requestId );
m_loadRequests.Remove( requestId );
m_loadRequestPool.Release( pRequest );
return true;
}
示例12: CloseProject
bool ProjectViewModel::OpenProject( const FilePath& project )
{
if ( !m_CurrentProject.Empty() )
{
CloseProject();
}
m_CurrentProject = project;
FileLocations::SetBaseDirectory( project );
// Make sure various module-specific heaps are initialized from the main thread before use.
InitEngineJobsDefaultHeap();
InitGraphicsJobsDefaultHeap();
// Register shutdown for general systems.
m_InitializerStack.Push( FileLocations::Shutdown );
m_InitializerStack.Push( Name::Shutdown );
m_InitializerStack.Push( AssetPath::Shutdown );
m_InitializerStack.Push( AsyncLoader::Startup, AsyncLoader::Shutdown );
// Asset cache management.
m_InitializerStack.Push( CacheManager::Startup, CacheManager::Shutdown );
m_InitializerStack.Push( Reflect::ObjectRefCountSupport::Shutdown );
m_InitializerStack.Push( Asset::Shutdown );
m_InitializerStack.Push( AssetType::Shutdown );
m_InitializerStack.Push( Reflect::Startup, Reflect::Shutdown );
m_InitializerStack.Push( Persist::Startup, Persist::Shutdown );
m_InitializerStack.Push( LooseAssetLoader::Startup, LooseAssetLoader::Shutdown );
m_InitializerStack.Push( AssetPreprocessor::Startup, AssetPreprocessor::Shutdown );
AssetPreprocessor* pAssetPreprocessor = AssetPreprocessor::GetInstance();
HELIUM_ASSERT( pAssetPreprocessor );
PlatformPreprocessor* pPlatformPreprocessor = new PcPreprocessor;
HELIUM_ASSERT( pPlatformPreprocessor );
pAssetPreprocessor->SetPlatformPreprocessor( Cache::PLATFORM_PC, pPlatformPreprocessor );
m_InitializerStack.Push( AssetTracker::Startup, AssetTracker::Shutdown );
m_InitializerStack.Push( ThreadSafeAssetTrackerListener::Startup, ThreadSafeAssetTrackerListener::Shutdown );
ThreadSafeAssetTrackerListener::GetInstance()->e_AssetLoaded.AddMethod( this, &ProjectViewModel::OnAssetLoaded );
ThreadSafeAssetTrackerListener::GetInstance()->e_AssetChanged.AddMethod( this, &ProjectViewModel::OnAssetChanged );
m_InitializerStack.Push( Config::Startup, Config::Shutdown );
HELIUM_ASSERT( AssetLoader::GetInstance() );
AssetLoader::GetInstance()->LoadObject<SystemDefinition>( "/Editor:System", m_pEditorSystemDefinition );
if ( HELIUM_VERIFY( m_pEditorSystemDefinition ) )
{
m_pEditorSystemDefinition->Initialize();
}
else
{
HELIUM_TRACE( TraceLevels::Error, "InitializeEditorSystem(): Could not find SystemDefinition. LoadObject on '/Editor:System' failed.\n" );
}
Components::Startup( m_pEditorSystemDefinition.Get() );
// Engine configuration.
Config* pConfig = Config::GetInstance();
HELIUM_ASSERT( pConfig );
AssetLoader* pAssetLoader = AssetLoader::GetInstance();
HELIUM_ASSERT( pAssetLoader );
pConfig->BeginLoad();
while( !pConfig->TryFinishLoad() )
{
pAssetLoader->Tick();
}
ConfigPc::SaveUserConfig();
#if HELIUM_OS_WIN
m_Engine.Initialize( &wxGetApp().GetFrame()->GetSceneManager(), GetHwndOf( wxGetApp().GetFrame() ) );
#else
m_Engine.Initialize( &wxGetApp().GetFrame()->GetSceneManager(), NULL );
#endif
ForciblyFullyLoadedPackageManager::GetInstance()->e_AssetForciblyLoadedEvent.AddMethod( this, &ProjectViewModel::OnAssetEditable );
return true;
}
示例13: paintWrapper
static void paintWrapper() {
// clear the palette
newCubes.clear();
lostCubes.clear();
reconnectedCubes.clear();
dirtyCubes.clear();
// fire events
System::paint();
// dynamically load assets just-in-time
if (!(newCubes | reconnectedCubes).empty()) {
loader.start(config);
while(!loader.isComplete()) {
for(CubeID cid : (newCubes | reconnectedCubes)) {
vbuf[cid].bg0rom.hBargraph(
vec(0, 4), loader.cubeProgress(cid, 128), BG0ROMDrawable::ORANGE, 8
);
}
// fire events while we wait
System::paint();
}
loader.finish();
}
// repaint cubes
for(CubeID cid : dirtyCubes) {
activateCube(cid, taskCubes[cid].task);
}
// also, handle lost cubes, if you so desire :)
}
示例14: onConnect
void onConnect(void *x, unsigned int cube)
{
loader.start(assetConfig);
loader.finish();
auto &vid = gVideo[cube];
vid.initMode(BG0);
vid.attach(cube);
vid.bg0.erase(StripeTile);
}
示例15: main
void main() {
blicketCubes.mark(blicket1);
blicketCubes.mark(blicket2);
nonBlicketCubes.mark(nonBlicket1);
nonBlicketCubes.mark(nonBlicket2);
// Initialize asset configuration and loader
config.append(gMainSlot, BootstrapAssets);
loader.init();
// Subscribe to events (See pubsub design pattern)
Events::cubeConnect.set(onCubeConnect);
Events::cubeDisconnect.set(onCubeDisconnect);
Events::cubeRefresh.set(onCubeRefresh);
Events::neighborAdd.set(onNeighborAdd);
Events::neighborRemove.set(onNeighborRemove);
// Events::cubeTouch.set(onCubeTouch);
Events::cubeTouch.set(onTouch);
// Initialize cubes
for(CubeID cid : CubeSet::connected()) {
vbuf[cid].attach(cid);
activateCube(cid);
}
// Run loop
for(;;) {
paintWrapper();
}
}