本文整理汇总了C++中Any::source方法的典型用法代码示例。如果您正苦于以下问题:C++ Any::source方法的具体用法?C++ Any::source怎么用?C++ Any::source使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Any
的用法示例。
在下文中一共展示了Any::source方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: r
shared_ptr<SpriteSheet> SpriteSheet::create(const Any& a, Table<ModelID, shared_ptr<Model> >& modelTable) {
a.verifyName("SpriteSheet");
const shared_ptr<SpriteSheet>& s = shared_ptr<SpriteSheet>(new SpriteSheet());
s->m_source = a.source();
AnyTableReader r(a);
// Read the textures
Texture::Specification spec;
if (r.getIfPresent("emissive", spec)) {
spec.generateMipMaps = false;
spec.encoding.format = ImageFormat::RGBA_DXT5();
s->m_emissive = Texture::create(spec);
} else {
s->m_emissive = Texture::opaqueBlack();
}
if (r.getIfPresent("color", spec)) {
spec.generateMipMaps = false;
spec.encoding.format = ImageFormat::RGBA_DXT5();
s->m_color = Texture::create(spec);
} else {
s->m_color = Texture::createColor(Color4unorm8(Color4::zero()));
}
String bumpFilename;
spec = Texture::Specification("<white>");
if (r.getFilenameIfPresent("bump", bumpFilename)) {
spec.filename = bumpFilename;
}
spec.generateMipMaps = false;
spec.preprocess = Texture::Preprocess::normalMap();
spec.encoding.format = ImageFormat::RGBA8();
spec.encoding.readMultiplyFirst = Color3(2.0f);
spec.encoding.readAddSecond = Color3(-1.0f);
s->m_normal = Texture::create(spec);
// Read the animation table
Table<String, Any> tbl;
r.getIfPresent("modelTable", tbl);
for (Table<String, Any>::Iterator it = tbl.begin(); it.hasMore(); ++it) {
if (modelTable.containsKey(it.key())) {
String msg = format("Two models with the same name, '%s': ", it.key().c_str());
msg += format("the first %s:%d and ", modelTable[it.key()]->source().filename.c_str(), modelTable[it.key()]->source().line);
msg += format("and the second from %s:%d.", it.value().source().filename.c_str(), it.value().source().line);
report(msg, ReportLevel::ERROR);
} else {
modelTable.set(it.key(), Model::create(s, it.key(), it.value()));
}
}
r.verifyDone();
return s;
}
示例2: saveScene
void App::saveScene() {
// Called when the "save" button is pressed
if (m_scene.notNull()) {
Any a = m_scene->toAny();
const std::string& filename = a.source().filename;
if (filename != "") {
a.save(filename);
debugPrintf("Saved %s\n", filename.c_str());
} else {
debugPrintf("Could not save: empty filename");
}
}
}