mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 07:33:51 +02:00
Move definition of supported file types into ModelLoader
This commit is contained in:
parent
98853b5d1d
commit
d1f8bfe48b
3 changed files with 24 additions and 19 deletions
libraries/model-networking/src/model-networking
|
@ -12,9 +12,6 @@
|
|||
#include "ModelCache.h"
|
||||
#include <Finally.h>
|
||||
#include <FSTReader.h>
|
||||
#include "FBXSerializer.h"
|
||||
#include "OBJSerializer.h"
|
||||
#include "GLTFSerializer.h"
|
||||
|
||||
#include <gpu/Batch.h>
|
||||
#include <gpu/Stream.h>
|
||||
|
@ -311,22 +308,6 @@ ModelCache::ModelCache() {
|
|||
const qint64 GEOMETRY_DEFAULT_UNUSED_MAX_SIZE = DEFAULT_UNUSED_MAX_SIZE;
|
||||
setUnusedResourceCacheSize(GEOMETRY_DEFAULT_UNUSED_MAX_SIZE);
|
||||
setObjectName("ModelCache");
|
||||
|
||||
// Add supported model formats
|
||||
|
||||
ModelLoader::MIMEType fbxMIMEType("fbx");
|
||||
fbxMIMEType.extensions.push_back("fbx");
|
||||
fbxMIMEType.fileSignatures.emplace_back("Kaydara FBX Binary \x00", 0);
|
||||
_modelLoader.addSupportedFormat<FBXSerializer>(fbxMIMEType);
|
||||
|
||||
ModelLoader::MIMEType objMIMEType("obj");
|
||||
objMIMEType.extensions.push_back("obj");
|
||||
_modelLoader.addSupportedFormat<OBJSerializer>(objMIMEType);
|
||||
|
||||
ModelLoader::MIMEType gltfMIMEType("gltf");
|
||||
gltfMIMEType.extensions.push_back("gltf");
|
||||
gltfMIMEType.webMediaTypes.push_back("model/gltf+json");
|
||||
_modelLoader.addSupportedFormat<GLTFSerializer>(gltfMIMEType);
|
||||
}
|
||||
|
||||
QSharedPointer<Resource> ModelCache::createResource(const QUrl& url, const QSharedPointer<Resource>& fallback,
|
||||
|
|
|
@ -11,6 +11,28 @@
|
|||
|
||||
#include "ModelLoader.h"
|
||||
|
||||
#include "FBXSerializer.h"
|
||||
#include "OBJSerializer.h"
|
||||
#include "GLTFSerializer.h"
|
||||
|
||||
ModelLoader::ModelLoader() {
|
||||
// Add supported model formats
|
||||
|
||||
MIMEType fbxMIMEType("fbx");
|
||||
fbxMIMEType.extensions.push_back("fbx");
|
||||
fbxMIMEType.fileSignatures.emplace_back("Kaydara FBX Binary \x00", 0);
|
||||
addSupportedFormat<FBXSerializer>(fbxMIMEType);
|
||||
|
||||
MIMEType objMIMEType("obj");
|
||||
objMIMEType.extensions.push_back("obj");
|
||||
addSupportedFormat<OBJSerializer>(objMIMEType);
|
||||
|
||||
MIMEType gltfMIMEType("gltf");
|
||||
gltfMIMEType.extensions.push_back("gltf");
|
||||
gltfMIMEType.webMediaTypes.push_back("model/gltf+json");
|
||||
addSupportedFormat<GLTFSerializer>(gltfMIMEType);
|
||||
}
|
||||
|
||||
hfm::Model::Pointer ModelLoader::load(const hifi::ByteArray& data, const hifi::VariantHash& mapping, const hifi::URL& url, const std::string& webMediaType) const {
|
||||
// Check file contents
|
||||
for (auto& supportedFormat : supportedFormats) {
|
||||
|
|
|
@ -47,6 +47,8 @@ public:
|
|||
std::vector<FileSignature> fileSignatures;
|
||||
};
|
||||
|
||||
ModelLoader();
|
||||
|
||||
// T is a subclass of hfm::Serializer
|
||||
template <typename T>
|
||||
void addSupportedFormat(const MIMEType& mimeType) {
|
||||
|
|
Loading…
Reference in a new issue