本文整理汇总了C++中ModelLoader::load方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelLoader::load方法的具体用法?C++ ModelLoader::load怎么用?C++ ModelLoader::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelLoader
的用法示例。
在下文中一共展示了ModelLoader::load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeScene
Scene* makeScene(){
ModelLoader loader;
Object* o = loader.load("teapot.obj", true);
o->setDrawMode( GL_TRIANGLES );// Render mode: triangluar mesh
o->glSetTexture(0, "test0.png");// Texture
o->glSetTexture(1, pSkyTech->getTexture() ); // Environment map.
o->glSetTexture(2, pShadowTarget->getColorTexture() ); // Blurred shadows-only image. for soft-shadows.
o->glSetTexture(3, pShadowsHV->getColorTexture() );
o->glSetTexture(0, new Texture( GL_TEXTURE_2D, pCube->getTexture() ) );
Scene* sc = new Scene();
sc->addObject(o);
return sc;
}
示例2: run
void GeometryReader::run() {
DependencyManager::get<StatTracker>()->decrementStat("PendingProcessing");
CounterStat counter("Processing");
PROFILE_RANGE_EX(resource_parse_geometry, "GeometryReader::run", 0xFF00FF00, 0, { { "url", _url.toString() } });
auto originalPriority = QThread::currentThread()->priority();
if (originalPriority == QThread::InheritPriority) {
originalPriority = QThread::NormalPriority;
}
QThread::currentThread()->setPriority(QThread::LowPriority);
Finally setPriorityBackToNormal([originalPriority]() {
QThread::currentThread()->setPriority(originalPriority);
});
if (!_resource.data()) {
return;
}
try {
if (_data.isEmpty()) {
throw QString("reply is NULL");
}
// Ensure the resource has not been deleted
auto resource = _resource.toStrongRef();
if (!resource) {
qCWarning(modelnetworking) << "Abandoning load of" << _url << "; could not get strong ref";
return;
}
if (_url.path().isEmpty()) {
throw QString("url is invalid");
}
HFMModel::Pointer hfmModel;
QVariantHash serializerMapping = _mapping.second;
serializerMapping["combineParts"] = _combineParts;
serializerMapping["deduplicateIndices"] = true;
if (_url.path().toLower().endsWith(".gz")) {
QByteArray uncompressedData;
if (!gunzip(_data, uncompressedData)) {
throw QString("failed to decompress .gz model");
}
// Strip the compression extension from the path, so the loader can infer the file type from what remains.
// This is okay because we don't expect the serializer to be able to read the contents of a compressed model file.
auto strippedUrl = _url;
strippedUrl.setPath(_url.path().left(_url.path().size() - 3));
hfmModel = _modelLoader.load(uncompressedData, serializerMapping, strippedUrl, "");
} else {
hfmModel = _modelLoader.load(_data, serializerMapping, _url, _webMediaType.toStdString());
}
if (!hfmModel) {
throw QString("unsupported format");
}
if (hfmModel->meshes.empty() || hfmModel->joints.empty()) {
throw QString("empty geometry, possibly due to an unsupported model version");
}
// Add scripts to hfmModel
if (!serializerMapping.value(SCRIPT_FIELD).isNull()) {
QVariantList scripts = serializerMapping.values(SCRIPT_FIELD);
for (auto &script : scripts) {
hfmModel->scripts.push_back(script.toString());
}
}
// Do processing on the model
baker::Baker modelBaker(hfmModel, _mapping.second, _mapping.first);
modelBaker.run();
auto processedHFMModel = modelBaker.getHFMModel();
auto materialMapping = modelBaker.getMaterialMapping();
QMetaObject::invokeMethod(resource.data(), "setGeometryDefinition",
Q_ARG(HFMModel::Pointer, processedHFMModel), Q_ARG(MaterialMapping, materialMapping));
} catch (const std::exception&) {
auto resource = _resource.toStrongRef();
if (resource) {
QMetaObject::invokeMethod(resource.data(), "finishedLoading",
Q_ARG(bool, false));
}
} catch (QString& e) {
qCWarning(modelnetworking) << "Exception while loading model --" << e;
auto resource = _resource.toStrongRef();
if (resource) {
QMetaObject::invokeMethod(resource.data(), "finishedLoading",
Q_ARG(bool, false));
}
}
}