本文整理汇总了C++中IResource类的典型用法代码示例。如果您正苦于以下问题:C++ IResource类的具体用法?C++ IResource怎么用?C++ IResource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void IResourceMgr::Update(void)
{
for(auto& pTask : m_lTaskPool)
{
if(pTask.second->Get_Status() == IParser::E_DONE_STATUS)
{
pTask.second->Commit();
if(m_lContainer.find(pTask.first) != m_lContainer.end())
{
IResource* pResource = m_lContainer[pTask.first];
pResource->Set_SourceData(pTask.second->Get_SourceData());
SAFE_DELETE(pTask.second);
m_lTaskPool.erase(pTask.first);
pResource->DispatchEvent();
return;
}
}
else
{
if(pTask.second->Get_Status() == IParser::E_ERROR_STATUS)
{
SAFE_DELETE(pTask.second);
m_lTaskPool.erase(pTask.first);
return;
}
}
}
}
示例2: GetResource
Core::SCOM::ComPtr<IResource> CFileSystem::GetResource(const std::string& path, bool searchArchives)
{
Core::SCOM::ComPtr<IResource> pResource;
bfs::path search = bfs::system_complete(bfs::path(path));
bfs::path root = search.root_path();
GetResource(search, pResource.wrapped());
if(!pResource && searchArchives)
{
// Find archive
bfs::path current = search.parent_path();
while(current != root)
{
if(bfs::is_regular_file(current) && bfs::exists(current))
break;
current = current.parent_path();
}
// Create CArchive and get child
if(current.extension() == ".zip")
{
SCOM::ComPtr<IArchive> arch;
IResource* pRes;
GetResource(current, &pRes);
arch = pRes;
pRes->Release();
pResource = arch->FindItem(search.string().substr(current.string().size() + 1));
}
}
return pResource;
}
示例3: CHECK
IResource *ResourceSet::GetInternalArrayResource(vm::Object *obj) {
CHECK(vm::ArrayWrapper::IsIntArray(obj));
auto it = array_resources_.find(obj);
if (it != array_resources_.end()) {
return it->second;
}
vm::IntArray *memory = vm::ArrayWrapper::GetIntArray(obj);
int address_bits;
for (address_bits = 0; (1 << address_bits) < (int)memory->GetLength();
++address_bits) {
// do nothing here.
}
int data_bits = numeric::Width::GetWidth(memory->GetWidth());
IResource *res =
DesignTool::CreateArrayResource(tab_, address_bits, data_bits, false, true);
if (memory->GetLength() > 0) {
IDesign *design = tab_->GetModule()->GetDesign();
IArrayImage *image = new IArrayImage(design);
design->array_images_.push_back(image);
for (int i = 0; i < memory->GetLength(); ++i) {
image->values_.push_back(numeric::Numeric::GetInt(memory->Read(i)));
}
res->GetArray()->SetArrayImage(image);
}
array_resources_[obj] = res;
return res;
}
示例4: LogTrace
CFileSystem::~CFileSystem()
{
LogTrace("[Shutdown] Shutting down file system");
// Zero out all non-archives
for (TResourceMap::iterator it = mResourceMap.begin();
it != mResourceMap.end() ; ++it)
{
IArchive* pArch;
interface_cast<IArchive>(it->second, &pArch);
if(pArch)
pArch->Release();
else
it->second = 0;
}
TResourceMap::iterator it = mResourceMap.begin();
while(it != mResourceMap.end())
{
if(it->second)
{
IResource *arch = it->second;
it->second = 0;
LogWarningAlways("Releasing cached archive: %s", arch->FullPath().c_str());
arch->Release();
// iterator now invalid - start over
it = mResourceMap.begin();
continue;
}
++it;
}
}
示例5:
Core::SCOM::ComPtr<IFolder> CFileSystem::CurrentFolder()
{
IResource* res;
GetResource(bfs::current_path(), &res);
Core::SCOM::ComPtr<IFolder> ret = (IFolder*)res;
res->Release();
return ret;
}
示例6: FileOpen
FMOD_RESULT F_CALLBACK SoundSystem::FileOpen( const char* name, int unicode, unsigned int* filesize, void** handle, void** userdata )
{
IResource* resource = Management::Get( )->GetResourceManager( )->GetResource( name );
resource->AddReference( );
*handle = resource;
*filesize = resource->GetFileBuffer( )->fileLength;
return FMOD_OK;
}
示例7: CreateResource
const IResource* ResourceManager::GetResource(const std::string &fileName, eResType resType)
{
ResourceMap::const_iterator i = m_resources.find(fileName);
if(i != m_resources.end())
return i->second;
IResource* pResource = CreateResource(fileName, resType);
if(!pResource || !pResource->VLoad())
return NULL;
m_resources.insert(std::make_pair(fileName, pResource));
return pResource;
}
示例8: getTexture
ITexture* MinimapTile::getTexture()
{
if(!m_handle || !isValidHandle(m_handle))return 0;
IResourceNode* node = (IResourceNode*)getHandleData(m_handle);
if (node)
{
IResource* res = node->getResource();
if (res)
{
return (ITexture*)res->getInnerData();
}
}
return 0;
}
示例9: update
void ChangePartManager::update()
{
if( isValidHandle(m_handle) && !m_bLoaded ) //句柄有效,且没有加载
{
IResourceNode* node = (IResourceNode*)getHandleData(m_handle);
if( node)
{
IResource * res = node->getResource();
if( res)
{
ModelNode * n = (ModelNode *)res->getInnerData();
if( n )
{
onResLoad(n);
}
}
}
}
}
示例10:
IResource *ResourceSet::GetImportedResource(vm::Method *method) {
synth::ResourceParams *dparams =
method->parse_tree_->imported_resource_;
string name = dparams->GetResourceName();
for (IResource *res : imported_resources_) {
iroha::ResourceParams *iparams = res->GetParams();
if (iparams->GetEmbeddedModuleName() == name) {
return res;
}
}
string fn = dparams->GetCopyFileName();
IResource *res =
DesignTool::CreateEmbedResource(tab_, name, fn);
iroha::ResourceParams *iparams = res->GetParams();
vector<string> args;
fe::VarDeclSet *a = method->parse_tree_->args_;
if (a) {
for (fe::VarDecl *vd : a->decls) {
args.push_back(sym_cstr(vd->name_expr->sym_));
IValueType vt;
if (vd->type == sym_bool) {
vt.SetWidth(0);
} else {
vt.SetWidth(numeric::Width::GetWidth(vd->width));
}
res->input_types_.push_back(vt);
}
}
iparams->SetValues(resource::kEmbeddedModuleArgs, args);
args.clear();
args.push_back("req");
iparams->SetValues(resource::kEmbeddedModuleReq, args);
string ack = dparams->GetAckPinName();
if (!ack.empty()) {
args.clear();
args.push_back(ack);
iparams->SetValues(resource::kEmbeddedModuleAck, args);
}
return res;
}
示例11: ScriptEvent
void XMLSerializer::Load( const std::string& levelPath )
{
if ( !Management::Get( )->GetFileManager( )->FileExists( levelPath ) )
{
std::stringstream logMessage;
logMessage << "Unable to locate level file at path: " << levelPath;
Logger::Get( )->Warn( logMessage.str( ) );
return;
}
_loadProgress = 0;
_loadTotal = 0;
Management::Get( )->GetEventManager( )->QueueEvent( new ScriptEvent( "WORLD_LOADING_STARTED", levelPath ) );
IResource* resource = Management::Get( )->GetResourceManager( )->GetResource( levelPath );
Document levelFile( resource->GetFileBuffer()->fileBytes );
this->LoadElement( levelFile.FirstChildElement( ) );
}
示例12: LoadEntity
void XMLSerializer::LoadEntity( ticpp::Element* element )
{
std::string name;
element->GetAttribute( "name", &name );
IWorldEntity* entity = _world->CreateEntity( name );
std::string src;
element->GetAttribute( "src", &src, false );
NodePtrMap components;
if ( !src.empty( ) )
{
IResource* resource = Management::Get( )->GetResourceManager( )->GetResource( src );
Document externalFile( resource->GetFileBuffer( )->fileBytes );
for( Iterator< Element > child = externalFile.FirstChildElement( false ); child != child.end( ); child++ )
{
this->LoadEntityComponents( &*child, components );
}
}
this->LoadEntityComponents( element, components );
for( NodePtrMap::iterator i = components.begin( ); i != components.end( ); ++i )
{
if ( Management::Get( )->GetSystemManager( )->HasSystem( ( *i ).first ) )
{
IComponentSerializer* serializer = ComponentSerializerFactory::Create( ( *i ).first );
ISystemComponent* component = serializer->DeSerialize( name, ( *i ).second->ToElement( ), _world->GetSystemScenes( ) );
entity->AddComponent( component );
delete serializer;
}
delete ( *i ).second;
}
entity->Initialize( );
}
示例13: LoadScript
void ScriptComponent::LoadScript( const std::string& scriptPath )
{
IResource* resource = Management::Get( )->GetResourceManager( )->GetResource( scriptPath );
int result = luaL_loadbuffer( m_state, resource->GetFileBuffer( )->fileBytes, resource->GetFileBuffer( )->fileLength, resource->GetFileBuffer( )->filePath.c_str( ) );
if ( LUA_ERRSYNTAX == result )
{
std::stringstream errorMessage;
errorMessage << lua_tostring( m_state, -1 );
Logger::Get( )->Warn( errorMessage.str( ) );
lua_pop( m_state, 1 );
}
if ( LUA_ERRMEM == result )
{
ScriptException memE( "Script::Initialize - There is memory allocation error within the Script" );
Logger::Get( )->Fatal( memE.what( ) );
throw memE;
}
}
示例14: LoadHelper
void FResourceLoader::LoadHelper(FResourceManager::ResourceHeader* _resourceHeader)
{
IResource* currentResource;
unsigned char* resourceData;
std::ifstream::pos_type fileSize;
FFileIO dataIO;
// Check if this resource is local
if (_resourceHeader->isLocal)
{
// Get the current resource
currentResource = m_CurrentLocalResource;
// Pre-Open the resource data
dataIO.PreOpen(_resourceHeader->resourceName);
// Get the file size
fileSize = dataIO.FileSize();
// Alloc space for the resource data
resourceData = new unsigned char[fileSize];
// Open the resource data
if (!dataIO.Open(FFileIO::OpenMode::ReadMode))
{
// ASSERT
return;
}
// Get the data
if (!dataIO.Read(fileSize, resourceData))
{
// ASSERT
return;
}
// Close the file
if (!dataIO.Close())
{
// ASSERT
return;
}
}
else
{
// Get the current resource
IResource* currentResource = m_ResourceData[_resourceHeader->dataIndex].currentResource;
// Get the resource size
fileSize = _resourceHeader->resourceCompressedSize ? _resourceHeader->resourceCompressedSize : _resourceHeader->resourceSize;
// Alloc space for the resource data
resourceData = new unsigned char[fileSize];
// Get the data IO for this thread
dataIO = m_ResourceData[_resourceHeader->dataIndex].dataIO;
// Seek to the data position inside the file
dataIO.Seek(_resourceHeader->dataPosition);
// Read the resource data
dataIO.Read(fileSize, resourceData);
}
// Check if we need to decompress the data
if (_resourceHeader->resourceCompressedSize)
{
// Decompress the data
// ...
// Call the resource load function
// ...
// Delete the temproary decompressed data
// ...
}
else
{
// Call the resource load function
currentResource->Load(resourceData);
}
// Delete the temporary resource data
delete [] resourceData;
}
示例15: Actor
Forest::Forest(Actor* parent, ForestDesc* desc) : Actor( parent )
{
assert( desc );
assert( desc->surface );
assert( desc->assetName.length() );
assert( desc->cache.length() );
// copy descriptor
_desc = *desc;
// load asset
_asset = Gameplay::iEngine->createAsset( engine::atBinary, _desc.assetName.c_str() );
// enumerate clumps
callback::ClumpL clumps;
_asset->forAllClumps( callback::enumerateClumps, &clumps );
assert( clumps.size() );
// fill batch schemes
Matrix4f clumpM;
MatrixConversion trunkConversion;
MatrixConversion canopyConversion;
_canopyScheme.numLods = _trunkScheme.numLods = clumps.size();
for( callback::ClumpI clumpI = clumps.begin(); clumpI != clumps.end(); clumpI++ )
{
// determine lod Id and check for consistency
unsigned int lodId = getClumpLodId( *clumpI );
if( _trunkScheme.lodGeometry[lodId] )
{
throw Exception( "Clump \"%s\" is a duplication of existing LOD!", (*clumpI)->getName() );
}
// fill schemes
engine::IAtomic* trunkAtomic = Gameplay::iEngine->getAtomic( *clumpI, Gameplay::iEngine->findFrame( (*clumpI)->getFrame(), "Trunk" ) ); assert( trunkAtomic );
engine::IAtomic* canopyAtomic = Gameplay::iEngine->getAtomic( *clumpI, Gameplay::iEngine->findFrame( (*clumpI)->getFrame(), "Canopy" ) ); assert( canopyAtomic );
_trunkScheme.lodGeometry[lodId] = trunkAtomic->getGeometry();
_canopyScheme.lodGeometry[lodId] = canopyAtomic->getGeometry();
_trunkScheme.lodDistance[lodId] = _canopyScheme.lodDistance[lodId] = _desc.lodDistance[lodId];
// calculate conversions for nearest LOD
if( lodId == 0 )
{
clumpM = (*clumpI)->getFrame()->getLTM();
trunkConversion.setup( clumpM, trunkAtomic->getFrame()->getLTM() );
canopyConversion.setup( clumpM, canopyAtomic->getFrame()->getLTM() );
}
}
_trunkScheme.flags = _canopyScheme.flags = 0;
// check schemes
assert( _trunkScheme.isValid() );
assert( _canopyScheme.isValid() );
// create full cache names
std::string instanceCache = _desc.cache; instanceCache += ".matrices";
std::string trunkBspCache = _desc.cache; trunkBspCache += ".trunk";
std::string canopyBspCache = _desc.cache; canopyBspCache += ".canopy";
// try to load forest from cache
IResource* resource = getCore()->getResource( instanceCache.c_str(), "rb" );
if( resource )
{
unsigned int numTrees;
fread( &numTrees, sizeof(unsigned int), 1, resource->getFile() );
_treeMatrix.resize( numTrees );
fread( &_treeMatrix[0], sizeof(Matrix4f), numTrees, resource->getFile() );
resource->release();
}
else
{
// obtain surface properties
Matrix4f ltm = _desc.surface->getFrame()->getLTM();
engine::IGeometry* geometry = _desc.surface->getGeometry();
engine::Mesh* mesh = geometry->createMesh();
float preservedDistance = _desc.collScale * ( geometry->getAABBSup() - geometry->getAABBInf() ).length();
// iterate surface triangles
Vector3f vertex[3];
Vector3f edge[3];
Vector3f edgeN[2];
Vector3f normal;
Vector3f pos;
float cosA, sinA, angle, square, probability, scale;
unsigned int i,j,numTreesInTriangle;
Matrix4f instanceM;
for( i=0; i<mesh->numTriangles; i++ )
{
// transform triangle vertices to world space
vertex[0] = Gameplay::iEngine->transformCoord( mesh->vertices[mesh->triangles[i].vertexId[0]], ltm );
vertex[1] = Gameplay::iEngine->transformCoord( mesh->vertices[mesh->triangles[i].vertexId[1]], ltm );
vertex[2] = Gameplay::iEngine->transformCoord( mesh->vertices[mesh->triangles[i].vertexId[2]], ltm );
// calculate triangle square value...
edge[0] = vertex[1] - vertex[0];
edge[1] = vertex[2] - vertex[0];
edge[2] = vertex[2] - vertex[1];
edgeN[0] = edge[0]; edgeN[0].normalize();
edgeN[1] = edge[1]; edgeN[1].normalize();
normal.cross( edgeN[0], edgeN[1] );
cosA = Vector3f::dot( edgeN[0], edgeN[1] );
if( cosA > 1.0f ) angle = 0.0f;
//.........这里部分代码省略.........