本文整理汇总了C++中AnimatedModel::GetModel方法的典型用法代码示例。如果您正苦于以下问题:C++ AnimatedModel::GetModel方法的具体用法?C++ AnimatedModel::GetModel怎么用?C++ AnimatedModel::GetModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnimatedModel
的用法示例。
在下文中一共展示了AnimatedModel::GetModel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ImportAnimation
bool ModelImporter::ImportAnimation(const String& filename, const String& name, float startTime, float endTime)
{
SharedPtr<OpenAssetImporter> importer(new OpenAssetImporter(context_));
//importer->SetVerboseLog(true);
importer->SetScale(scale_);
importer->SetExportAnimations(true);
importer->SetStartTime(startTime);
importer->SetEndTime(endTime);
if (importer->Load(filename))
{
importer->ExportModel(asset_->GetCachePath(), name, true);
const Vector<OpenAssetImporter::AnimationInfo>& infos = importer->GetAnimationInfos();
for (unsigned i = 0; i < infos.Size(); i++)
{
const OpenAssetImporter::AnimationInfo& info = infos.At(i);
String pathName, fileName, extension;
SplitPath(info.cacheFilename_, pathName, fileName, extension);
ResourceCache* cache = GetSubsystem<ResourceCache>();
AnimatedModel* animatedModel = importNode_->GetComponent<AnimatedModel>();
if (animatedModel)
{
Model* model = animatedModel->GetModel();
if (model)
{
SharedPtr<Animation> animation = cache->GetTempResource<Animation>(fileName + extension);
if (animation)
model->AddAnimationResource(animation);
}
}
LOGINFOF("Import Info: %s : %s", info.name_.CString(), fileName.CString());
}
return true;
}
return false;
}
示例2: Import
bool ModelImporter::Import()
{
String ext = asset_->GetExtension();
String modelAssetFilename = asset_->GetPath();
importNode_ = new Node(context_);
if (ext == ".mdl")
{
FileSystem* fs = GetSubsystem<FileSystem>();
ResourceCache* cache = GetSubsystem<ResourceCache>();
// mdl files are native file format that doesn't need to be converted
// doesn't allow scale, animations legacy primarily for ToonTown
if (!fs->Copy(asset_->GetPath(), asset_->GetCachePath() + ".mdl"))
{
importNode_= 0;
return false;
}
Model* mdl = cache->GetResource<Model>( asset_->GetCachePath() + ".mdl");
if (!mdl)
{
importNode_= 0;
return false;
}
// Force a reload, though file watchers will catch this delayed and load again
cache->ReloadResource(mdl);
importNode_->CreateComponent<StaticModel>()->SetModel(mdl);
}
else
{
// skip external animations, they will be brought in when importing their
// corresponding model
if (!modelAssetFilename.Contains("@"))
{
ImportModel();
if (importAnimations_)
{
ImportAnimations();
}
AnimatedModel* animatedModel = importNode_->GetComponent<AnimatedModel>();
if (animatedModel)
{
Model* model = animatedModel->GetModel();
if (model && model->GetAnimationCount())
{
// resave with animation info
File mdlFile(context_);
if (!mdlFile.Open(asset_->GetCachePath() + ".mdl", FILE_WRITE))
{
ErrorExit("Could not open output file " + asset_->GetCachePath() + ".mdl");
return false;
}
model->Save(mdlFile);
}
}
}
}
File outFile(context_);
if (!outFile.Open(asset_->GetCachePath(), FILE_WRITE))
ErrorExit("Could not open output file " + asset_->GetCachePath());
importNode_->SaveXML(outFile);
importNode_ = 0;
return true;
}