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


C++ AssetPtr::SerializeTo方法代码示例

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


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

示例1: ConfigLoadSucceeded

void EC_Hydrax::ConfigLoadSucceeded(AssetPtr asset)
{
    PROFILE(EC_Hydrax_ConfigLoadSucceeded);
    // If we haven't yet initialized, do a full init.
    if (!impl || !impl->hydrax || !impl->module)
        Create();

    if (!impl || !impl->hydrax || !impl->module)
    {
        LogError("EC_Hydrax: Could not apply Hydrax config \"" + asset->Name() + "\", Hydrax could not be initialized!");
        return;
    }

    std::vector<u8> rawData;
    asset->SerializeTo(rawData);
    QString configData = QString::fromAscii((const char*)&rawData[0], (int)rawData.size());

    if (configData.isEmpty())
    {
        LogInfo("EC_Hydrax: Downloaded config is empty!");
        return;
    }

    try
    {
        // Update the noise module
        if (configData.contains("noise=fft", Qt::CaseInsensitive))
        {
            /// \note Using the FFT noise plugin seems to crash somewhere after we leave this function.
            /// FFT looks better so would be nice to investigate further!
            if (impl->module->getNoise()->getName() != "FFT")
                impl->module->setNoise(new Hydrax::Noise::FFT());
        }
        else if (configData.contains("noise=perlin", Qt::CaseInsensitive))
        {
            if (impl->module->getNoise()->getName() != "Perlin")
                impl->module->setNoise(new Hydrax::Noise::Perlin());
        }
        else
        {
            LogError("EC_Hydrax: Unknown noise param in loaded config, acceptable = FFT/Perlin.");
            SAFE_DELETE(impl);
            return;
        }

        // Load config from the asset data string.
        impl->hydrax->remove();
        impl->hydrax->loadCfgString(configData.toStdString());
        
        // Override the shader mode specified in the config - OpenGL should always use GLSL, D3D HLSL.
        // (Cg is never used, for compatibility, since it requires an extra install and some Linux systems don't always have it enabled)
        if (QString(Ogre::Root::getSingleton().getRenderSystem()->getName().c_str()).contains("OpenGL"))
            impl->hydrax->setShaderMode(Hydrax::MaterialManager::SM_GLSL);
        else
            impl->hydrax->setShaderMode(Hydrax::MaterialManager::SM_HLSL);
        impl->hydrax->create();

        // The position attribute is always authoritative from the component attribute.
        if (visible.Get())
            impl->hydrax->setPosition(position.Get());
    }
    catch (const Ogre::Exception &e)
    {
        LogError(std::string("EC_Hydrax: Ogre threw exception while loading new config: ") + e.what());
        if (impl && impl->hydrax)
            impl->hydrax->remove();
        SAFE_DELETE(impl);
    }
}
开发者ID:Pouique,项目名称:naali,代码行数:69,代码来源:EC_Hydrax.cpp

示例2: StoreAsset

QString AssetCache::StoreAsset(AssetPtr asset)
{
    std::vector<u8> data;
    asset->SerializeTo(data);
    return StoreAsset(&data[0], data.size(), asset->Name());
}
开发者ID:360degrees-fi,项目名称:tundra,代码行数:6,代码来源:AssetCache.cpp


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