本文整理汇总了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);
}
}
示例2: StoreAsset
QString AssetCache::StoreAsset(AssetPtr asset)
{
std::vector<u8> data;
asset->SerializeTo(data);
return StoreAsset(&data[0], data.size(), asset->Name());
}