当前位置: 首页>>代码示例>>C++>>正文


C++ AssetPtr类代码示例

本文整理汇总了C++中AssetPtr的典型用法代码示例。如果您正苦于以下问题:C++ AssetPtr类的具体用法?C++ AssetPtr怎么用?C++ AssetPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AssetPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AssetItem

void AssetsWindow::AddAsset(AssetPtr asset)
{
    ///\todo Check that the asset doesn't already exists
    AssetItem *item = new AssetItem(asset);
    AddChildren(asset, item);

    connect(asset.get(), SIGNAL(Loaded(AssetPtr)), SLOT(HandleAssetLoaded(AssetPtr)));
    connect(asset.get(), SIGNAL(Unloaded(IAsset *)), SLOT(HandleAssetUnloaded(IAsset *)));

    bool storageFound = false;
    AssetStoragePtr storage = asset->GetAssetStorage();
    if (storage)
        for(int i = 0; i < treeWidget->topLevelItemCount(); ++i)
        {
            QTreeWidgetItem *storageItem = treeWidget->topLevelItem(i);
            if (storageItem->text(0) == storage->ToString())
            {
                storageItem->addChild(item);
                storageFound = true;
                break;
            }
        }

    if (!storageFound)
        noProviderItem->addChild(item);

    noProviderItem->setHidden(noProviderItem->childCount() == 0);
}
开发者ID:Ilikia,项目名称:naali,代码行数:28,代码来源:AssetsWindow.cpp

示例2: OnMaterialAssetLoaded

void EC_Mesh::OnMaterialAssetLoaded(AssetPtr asset)
{
    OgreMaterialAsset *ogreMaterial = dynamic_cast<OgreMaterialAsset*>(asset.get());
    if (!ogreMaterial)
    {
        LogError("OnMaterialAssetLoaded: Material asset load finished for asset \"" +
            asset->Name().toStdString() + "\", but downloaded asset was not of type OgreMaterialAsset!");
        return;
    }

    Ogre::MaterialPtr material = ogreMaterial->ogreMaterial;
    bool assetUsed = false;

    AssetReferenceList materialList = meshMaterial.Get();
    for(int i = 0; i < materialList.Size(); ++i)
        if (materialList[i].ref == ogreMaterial->Name() ||
            framework_->Asset()->LookupAssetRefToStorage(materialList[i].ref) == ogreMaterial->Name()) ///<///\todo The design of whether the LookupAssetRefToStorage should occur here, or internal to Asset API needs to be revisited.
        {
            SetMaterial(i, ogreMaterial->Name());
            assetUsed = true;
        }

    if (!assetUsed)
    {
        LogWarning("OnMaterialAssetLoaded: Trying to apply material \"" + ogreMaterial->Name().toStdString() + "\" to mesh " +
            meshRef.Get().ref.toStdString() + ", but no submesh refers to the given material! The references are: ");
        for(int i = 0; i < materialList.Size(); ++i)
            LogWarning(QString::number(i).toStdString() + ": " + materialList[i].ref.toStdString());
    }
}
开发者ID:A-K,项目名称:naali,代码行数:30,代码来源:EC_Mesh.cpp

示例3: IAssetTransfer_Asset

static duk_ret_t IAssetTransfer_Asset(duk_context* ctx)
{
    IAssetTransfer* thisObj = GetThisWeakObject<IAssetTransfer>(ctx);
    AssetPtr ret = thisObj->Asset();
    PushWeakObject(ctx, ret.Get());
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:IAssetTransferBindings.cpp

示例4: HELIUM_ASSERT

/// Recursive function for resolving a package request.
///
/// @param[out] rspPackage   Resolved package.
/// @param[in]  packagePath  Package object path.
void CachePackageLoader::ResolvePackage( AssetPtr& rspPackage, AssetPath packagePath )
{
	HELIUM_ASSERT( !packagePath.IsEmpty() );

	rspPackage = Asset::FindObject( packagePath );
	if( !rspPackage )
	{
		AssetPtr spParent;
		AssetPath parentPath = packagePath.GetParent();
		if( !parentPath.IsEmpty() )
		{
			ResolvePackage( spParent, parentPath );
			HELIUM_ASSERT( spParent );
		}

		HELIUM_VERIFY( Asset::CreateObject(
			rspPackage,
			Package::GetStaticType(),
			packagePath.GetName(),
			spParent ) );
		HELIUM_ASSERT( rspPackage );
		HELIUM_ASSERT( rspPackage->IsA( Package::GetStaticType()->GetMetaClass() ) );
	}

	rspPackage->SetFlags( Asset::FLAG_PRELOADED | Asset::FLAG_LINKED | Asset::FLAG_LOADED );
}
开发者ID:HeliumProject,项目名称:Helium,代码行数:30,代码来源:CachePackageLoader.cpp

示例5: IAsset_Clone_String

static duk_ret_t IAsset_Clone_String(duk_context* ctx)
{
    IAsset* thisObj = GetThisWeakObject<IAsset>(ctx);
    String newAssetName = duk_require_string(ctx, 0);
    AssetPtr ret = thisObj->Clone(newAssetName);
    PushWeakObject(ctx, ret.Get());
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:8,代码来源:IAssetBindings.cpp

示例6: lock

std::string Agent::handleAssets (std::ostream &        aOut,
                                 const key_value_map & aQueries,
                                 const std::string &   aList)
{
    using namespace dlib;
    vector<AssetPtr> assets;

    if ( !aList.empty( ) )
    {
        auto_mutex         lock(*mAssetLock);
        istringstream      str(aList);
        tokenizer_kernel_1 tok;
        tok.set_stream(str);
        tok.set_identifier_token(tok.lowercase_letters( ) + tok.uppercase_letters( )
                                 + tok.numbers( ) + "[email protected]$%&^:+-_=",
                                 tok.lowercase_letters( ) + tok.uppercase_letters( )
                                 + tok.numbers( ) + "[email protected]$%&^:+-_=");

        int    type;
        string token;

        for ( tok.get_token(type, token); type != tok.END_OF_FILE; tok.get_token(type, token) )
        {
            if ( type == tok.IDENTIFIER )
            {
                AssetPtr ptr = mAssetMap[token];

                if ( ptr.getObject( ) == NULL )
                {
                    return XmlPrinter::printError(mInstanceId, 0, 0, "ASSET_NOT_FOUND",
                                                  (string) "Could not find asset: " + token);
                }
                assets.push_back(ptr);
            }
        }
    }
    else
    {
        auto_mutex lock(*mAssetLock);

        // Return all asssets, first check if there is a type attribute

        string type = aQueries["type"];

        list<AssetPtr>::iterator iter;

        for ( iter = mAssets.begin( ); iter != mAssets.end( ); ++iter )
        {
            if ( type.empty( ) || ( type == ( *iter )->getType( ) ) )
            {
                assets.push_back(*iter);
            }
        }
    }

    return XmlPrinter::printAssets(mInstanceId, mMaxAssets, mAssets.size( ), assets);
}
开发者ID:johnmichaloski,项目名称:MTConnectToolbox,代码行数:57,代码来源:agent.cpp

示例7: TryFinishLoad

/// Test whether an object load request has completed, getting the result object if so.
///
/// Note that after a load request has completed (this function returns true), the request ID should no longer be
/// considered valid.
///
/// @param[in]  id         Load request ID.
/// @param[out] rspObject  Smart pointer set to the loaded object if loading has completed.  Note that this will be
///                        set to the object instance even if the object isn't finished loading (i.e. still being
///                        linked, etc.).
///
/// @return  True if the load request has completed, false if it is still being processed.
///
/// @see FinishLoad(), BeginLoadObject()
bool AssetLoader::TryFinishLoad( size_t id, AssetPtr& rspObject )
{
	HELIUM_ASSERT( IsValid( id ) );

	// Retrieve the load request and test whether it has completed.
	LoadRequest* pRequest = m_loadRequestPool.GetObject( id );
	HELIUM_ASSERT( pRequest );

	if( ( pRequest->stateFlags & LOAD_FLAG_FULLY_LOADED ) != LOAD_FLAG_FULLY_LOADED )
	{
		return false;
	}

	HELIUM_TRACE(
		TraceLevels::Debug,
		"AssetLoader::TryFinishLoad - Completed load for asset %s\n",
		*pRequest->path.ToString());

	HELIUM_ASSERT(  !pRequest->spObject.Get() || pRequest->spObject->IsFullyLoaded() || ( pRequest->spObject->GetFlags() & Asset::FLAG_BROKEN ) );

	rspObject = pRequest->spObject;

	// Acquire an exclusive lock to the request entry.
	AssetPath objectPath = pRequest->path;

	ConcurrentHashMap< AssetPath, LoadRequest* >::Accessor requestAccessor;
	HELIUM_VERIFY( m_loadRequestMap.Find( requestAccessor, objectPath ) );
	HELIUM_ASSERT( requestAccessor->Second() == pRequest );


	// Decrement the reference count on the load request, releasing it if the reference count reaches zero.
	int32_t newRequestCount = AtomicDecrementRelease( pRequest->requestCount );
	if( newRequestCount == 0 )
	{
		pRequest->spObject.Release();
		pRequest->resolver.Clear();

		m_loadRequestMap.Remove( requestAccessor );
		m_loadRequestPool.Release( pRequest );
	}

	requestAccessor.Release();

#if HELIUM_TOOLS
	if (rspObject)
	{
		if ( !(rspObject->SetFlags(Asset::FLAG_LOAD_EVENT_FIRED) & Asset::FLAG_LOAD_EVENT_FIRED) )
		{
			AssetTracker::GetStaticInstance()->NotifyAssetLoaded( rspObject.Get() );
		}
	}
#endif

	return true;
}
开发者ID:justinliew,项目名称:Helium,代码行数:68,代码来源:AssetLoader.cpp

示例8: dataStream

QWidget *UiAPI::LoadFromFile(const QString &filePath, bool addToScene, QWidget *parent)
{
    QWidget *widget = 0;

    if (AssetAPI::ParseAssetRefType(filePath) != AssetAPI::AssetRefLocalPath)
    {
        AssetPtr asset = owner->Asset()->GetAsset(filePath);
        if (!asset)
        {
            LogError(("LoadFromFile: Asset \"" + filePath + "\" is not loaded to the asset system. Call RequestAsset prior to use!").toStdString());
            return 0;
        }

        QtUiAsset *uiAsset = dynamic_cast<QtUiAsset*>(asset.get());
        if (!uiAsset)
        {
            LogError(("LoadFromFile: Asset \"" + filePath + "\" is not of type QtUiFile!").toStdString());
            return 0;
        }
        if (!uiAsset->IsLoaded())
        {
            LogError(("LoadFromFile: Asset \"" + filePath + "\" data is not valid!").toStdString());
            return 0;
        }

        // Get the asset data with the assetrefs replaced to point to the disk sources on the current local system.
        QByteArray data = uiAsset->GetRefReplacedAssetData();
        
        QUiLoader loader;
        QDataStream dataStream(&data, QIODevice::ReadOnly);
        widget = loader.load(dataStream.device(), parent);
    }
    else // The file is from absolute source location.
    {
        QFile file(filePath);
        QUiLoader loader;
        file.open(QFile::ReadOnly);
        widget = loader.load(&file, parent);
    }

    if (!widget)
    {
        LogError(("LoadFromFile: Failed to load widget from file \"" + filePath + "\"!").toStdString());
        return 0;
    }

    if (addToScene && widget)
        AddWidgetToScene(widget);

    return widget;
}
开发者ID:A-K,项目名称:naali,代码行数:51,代码来源:UiAPI.cpp

示例9: OnTextureAssetLoaded

void EC_Sky::OnTextureAssetLoaded(AssetPtr tex)
{
    std::vector<std::string> texture_names;
    texture_names.reserve(cSkyBoxTextureCount);
    
    AssetReferenceList textureList = textureRefs.Get();

    const char * const defaultSkyTextures[cSkyBoxTextureCount] =
    {   "rex_sky_front.dds",
        "rex_sky_back.dds",
        "rex_sky_left.dds",
        "rex_sky_right.dds",
        "rex_sky_top.dds",
        "rex_sky_bot.dds"
    };

    for(size_t i = 0; i < textureAssets.size() || i < cSkyBoxTextureCount; ++i)
        if (i < textureAssets.size() && textureAssets[i])
        {
            AssetPtr asset = textureAssets[i]->Asset();
            TextureAsset *textureAsset = dynamic_cast<TextureAsset*>(asset.get());
            if (textureAsset)
                texture_names.push_back(textureAsset->ogreAssetName.toStdString());
            else
                texture_names.push_back(defaultSkyTextures[i]);
        }
        else
            texture_names.push_back(defaultSkyTextures[i]);

    assert(texture_names.size() == cSkyBoxTextureCount);

    ///\todo Use AssetAPI for the material.
    Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(materialRef.Get().ref.toStdString().c_str());
    if (materialPtr.isNull())
    {
        LogError("EC_Sky::OnTextureAssetLoaded: Cannot find Ogre material \"" + materialRef.Get().ref.toStdString() + "\"!");
        return;
    }
    if (materialPtr->getNumTechniques() == 0 || materialPtr->getTechnique(0) == 0 ||
        materialPtr->getTechnique(0)->getNumPasses() == 0 || materialPtr->getTechnique(0)->getPass(0) == 0 ||
        materialPtr->getTechnique(0)->getPass(0)->getNumTextureUnitStates() == 0 ||
        materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0) == 0)
    {
        LogError("EC_Sky::OnTextureAssetLoaded: Cannot use material \"" + materialRef.Get().ref.toStdString() + "\" as Skybox material: It has 0 techniques, passes or texture unit states!");
        return;
    }

    materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setCubicTextureName(&texture_names[0], false);
    
    CreateSky();    
}
开发者ID:Ilikia,项目名称:naali,代码行数:51,代码来源:EC_Sky.cpp

示例10: getFile

void XmlPrinterTest::testPrintRemovedCuttingTool()
{
  vector<AssetPtr> assets;
  
  string document = getFile("asset1.xml");
  AssetPtr asset = config->parseAsset("KSSP300R4SD43L240.1", "CuttingTool", document);
  asset->setRemoved(true);
  CuttingToolPtr tool = (CuttingTool*) asset.getObject();
  
  
  assets.push_back(asset);
  
  {
    PARSE_XML(XmlPrinter::printAssets(123, 4, 2, assets));
    CPPUNITTEST_ASSERT_XML_PATH_EQUAL(doc, "//m:Assets//m:[email protected]", "true");
  }
}
开发者ID:TCSmaint,项目名称:cppagent,代码行数:17,代码来源:xml_printer_test.cpp

示例11: OnMeshAssetLoaded

void EC_Mesh::OnMeshAssetLoaded(AssetPtr asset)
{
    OgreMeshAsset *mesh = dynamic_cast<OgreMeshAsset*>(asset.get());
    if (!mesh)
    {
        LogError("OnMeshAssetLoaded: Mesh asset load finished for asset \"" + asset->Name().toStdString() + "\", but downloaded asset was not of type OgreMeshAsset!");
        return;
    }

    QString ogreMeshName = mesh->Name();
    if (mesh)
    {
        if (mesh->ogreMesh.get())
        {
            ogreMeshName = QString::fromStdString(mesh->ogreMesh->getName()).trimmed();

            // Do not reload if all of the following are met
            // 1. Ogre::Entity and Ogre::Mesh are valid (aka this is not the first load for this EC_Mesh) 
            // 2. Mesh name is same (aka asset reference with ogre sanitations)
            // 3. Content hash has not changed (aka data has not changed)
            if (entity_ && entity_->getMesh().get())
            {
                QString currentMeshName = QString::fromStdString(entity_->getMesh()->getName()).trimmed();
                if (currentMeshName == ogreMeshName && mesh->ContentHashChanged() == false)
                    return;
            }
        }
        else
            LogError("OnMeshAssetLoaded: Mesh asset load finished for asset \"" + asset->Name().toStdString() + "\", but Ogre::Mesh pointer was null!");
    }

    SetMesh(ogreMeshName);

    // Force a re-application of the skeleton on this mesh. ///\todo This path should be re-evaluated to see if we have potential performance issues here. -jj.
    if (skeletonAsset->Asset())
        OnSkeletonAssetLoaded(skeletonAsset->Asset());

    // Apply pending materials, these were tried to be applied before the mesh was loaded
    if (!pendingMaterialApplies.empty())
    {
        for(int idx = 0; idx < pendingMaterialApplies.size(); ++idx)
            SetMaterial(idx, pendingMaterialApplies[idx]);
        pendingMaterialApplies.clear();
    }
}
开发者ID:A-K,项目名称:naali,代码行数:45,代码来源:EC_Mesh.cpp

示例12: assert

AssetPtr IAsset::Clone(QString newAssetName) const
{
    assert(assetAPI);
    if (!IsLoaded())
        return AssetPtr();

    AssetPtr existing = assetAPI->GetAsset(newAssetName);
    if (existing)
    {
        LogError("Cannot Clone() asset \"" + Name() + "\" to a new asset \"" + newAssetName + "\": An asset with that name already exists!");
        return AssetPtr();
    }

    std::vector<u8> data;
    bool success = SerializeTo(data);
    if (!success)
    {
        LogError("Cannot Clone() asset \"" + Name() + "\" to a new asset \"" + newAssetName + "\": Serializing the asset failed!");
        return AssetPtr();
    }
    if (data.size() == 0)
    {
        LogError("Cannot Clone() asset \"" + Name() + "\" to a new asset \"" + newAssetName + "\": Asset serialization succeeded with zero size!");
        return AssetPtr();
    }

    AssetPtr newAsset = assetAPI->CreateNewAsset(this->Type(), newAssetName);
    if (!newAsset)
    {
        LogError("Cannot Clone() asset \"" + Name() + "\" to a new asset \"" + newAssetName + "\": AssetAPI::CreateNewAsset failed!");
        return AssetPtr();
    }

    // Do not allow asynchronous loading due the caller of this 
    // expects the asset to be usable when this function returns.
    success = newAsset->LoadFromFileInMemory(&data[0], data.size(), false);
    if (!success)
    {
        LogError("Cannot Clone() asset \"" + Name() + "\" to a new asset \"" + newAssetName + "\": Deserializing the new asset from bytes failed!");
        assetAPI->ForgetAsset(newAsset, false);
        return AssetPtr();
    }

    return newAsset;
}
开发者ID:katik,项目名称:naali,代码行数:45,代码来源:IAsset.cpp

示例13: OnAssetCreated

void AssetRefListener::OnAssetCreated(AssetPtr assetData)
{
    if (assetData.Get() && !currentWaitingRef.Empty() && currentWaitingRef == assetData->Name())
    {
        /// @todo Remove this logic once a EC_Material + EC_Mesh behaves correctly without failed requests, see generated:// logic in HandleAssetRefChange.
        /** Log the same message as before for non generated:// refs. This is good to do
            because AssetAPI has now said the request failed, so user might be confused when it still works. */
        if (!currentWaitingRef.ToLower().StartsWith("generated://"))
            LogInfo("AssetRefListener: Asset \"" + assetData->Name() + "\" was created, applying after it loads.");

        // The asset we are waiting for has been created, hook to the IAsset::Loaded signal.
        currentWaitingRef = "";
        asset = assetData;
        assetData->Loaded.Connect(this, &AssetRefListener::OnAssetLoaded);
        if (myAssetAPI)
            myAssetAPI->AssetCreated.Disconnect(this, &AssetRefListener::OnAssetCreated);
    }
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:18,代码来源:AssetRefListener.cpp

示例14: FindAsset

	AssetPtr AssetManager::LoadAsset(const boost::filesystem::path& file)
	{
		AssetPtr pAsset = FindAsset(file);
		if(pAsset)
		{
			pAsset->IncRef();
			return pAsset;
		}

		AssetLoader loader = FindLoader(file);
		if(loader)
		{
			return AssetPtr();
		}
		pAsset = loader(file);

		m_assets[file.string()] = pAsset;
		return pAsset;
	}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例15: OnSkeletonAssetLoaded

void EC_Mesh::OnSkeletonAssetLoaded(AssetPtr asset)
{
    OgreSkeletonAsset *skeletonAsset = dynamic_cast<OgreSkeletonAsset*>(asset.get());
    if (!skeletonAsset)
    {
        LogError("OnSkeletonAssetLoaded: Skeleton asset load finished for asset \"" +
            asset->Name().toStdString() + "\", but downloaded asset was not of type OgreSkeletonAsset!");
        return;
    }

    Ogre::SkeletonPtr skeleton = skeletonAsset->ogreSkeleton;
    if (skeleton.isNull())
    {
        LogError("OnSkeletonAssetLoaded: Skeleton asset load finished for asset \"" +
            asset->Name().toStdString() + "\", but Ogre::Skeleton pointer was null!");
        return;
    }

    if(!entity_)
    {
        LogDebug("Could not set skeleton yet because entity is not yet created");
        return;
    }

    try
    {
        // If old skeleton is same as a new one no need to replace it.
        if (entity_->getSkeleton() && entity_->getSkeleton()->getName() == skeleton->getName())
            return;
        
        entity_->getMesh()->_notifySkeleton(skeleton);
        
//        LogDebug("Set skeleton " + skeleton->getName() + " to mesh " + entity_->getName());
        emit SkeletonChanged(QString::fromStdString(skeleton->getName()));
    }
    catch (...)
    {
        LogError("Exception while setting skeleton to mesh" + entity_->getName());
    }

    // Now we have to recreate the entity to get proper animations etc.
    SetMesh(entity_->getMesh()->getName().c_str(), false);
}
开发者ID:A-K,项目名称:naali,代码行数:43,代码来源:EC_Mesh.cpp


注:本文中的AssetPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。