mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 16:02:58 +02:00
Add ModelFormatRegistry for handling model loading on the application side
This commit is contained in:
parent
74015a1a5e
commit
243a1d6598
3 changed files with 72 additions and 0 deletions
|
@ -101,6 +101,7 @@
|
||||||
#include <MainWindow.h>
|
#include <MainWindow.h>
|
||||||
#include <MappingRequest.h>
|
#include <MappingRequest.h>
|
||||||
#include <MessagesClient.h>
|
#include <MessagesClient.h>
|
||||||
|
#include <model-networking/ModelFormatRegistry.h>
|
||||||
#include <model-networking/ModelCacheScriptingInterface.h>
|
#include <model-networking/ModelCacheScriptingInterface.h>
|
||||||
#include <model-networking/TextureCacheScriptingInterface.h>
|
#include <model-networking/TextureCacheScriptingInterface.h>
|
||||||
#include <ModelEntityItem.h>
|
#include <ModelEntityItem.h>
|
||||||
|
@ -883,6 +884,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
|
||||||
DependencyManager::set<NodeList>(NodeType::Agent, listenPort);
|
DependencyManager::set<NodeList>(NodeType::Agent, listenPort);
|
||||||
DependencyManager::set<recording::ClipCache>();
|
DependencyManager::set<recording::ClipCache>();
|
||||||
DependencyManager::set<GeometryCache>();
|
DependencyManager::set<GeometryCache>();
|
||||||
|
DependencyManager::set<ModelFormatRegistry>();
|
||||||
DependencyManager::set<ModelCache>();
|
DependencyManager::set<ModelCache>();
|
||||||
DependencyManager::set<ModelCacheScriptingInterface>();
|
DependencyManager::set<ModelCacheScriptingInterface>();
|
||||||
DependencyManager::set<ScriptCache>();
|
DependencyManager::set<ScriptCache>();
|
||||||
|
@ -2745,6 +2747,7 @@ Application::~Application() {
|
||||||
DependencyManager::destroy<FramebufferCache>();
|
DependencyManager::destroy<FramebufferCache>();
|
||||||
DependencyManager::destroy<TextureCacheScriptingInterface>();
|
DependencyManager::destroy<TextureCacheScriptingInterface>();
|
||||||
DependencyManager::destroy<TextureCache>();
|
DependencyManager::destroy<TextureCache>();
|
||||||
|
DependencyManager::destroy<ModelFormatRegistry>();
|
||||||
DependencyManager::destroy<ModelCacheScriptingInterface>();
|
DependencyManager::destroy<ModelCacheScriptingInterface>();
|
||||||
DependencyManager::destroy<ModelCache>();
|
DependencyManager::destroy<ModelCache>();
|
||||||
DependencyManager::destroy<ScriptCache>();
|
DependencyManager::destroy<ScriptCache>();
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
//
|
||||||
|
// ModelFormatRegistry.cpp
|
||||||
|
// libraries/model-networking/src/model-networking
|
||||||
|
//
|
||||||
|
// Created by Sabrina Shanman on 2018/11/30.
|
||||||
|
// Copyright 2018 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "ModelFormatRegistry.h"
|
||||||
|
|
||||||
|
#include "FBXSerializer.h"
|
||||||
|
#include "OBJSerializer.h"
|
||||||
|
#include "GLTFSerializer.h"
|
||||||
|
|
||||||
|
ModelFormatRegistry::ModelFormatRegistry() : hfm::FormatRegistry() {
|
||||||
|
addDefaultFormats();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelFormatRegistry::addDefaultFormats() {
|
||||||
|
addFormat(std::make_shared<FBXFormat>());
|
||||||
|
addFormat(std::make_shared<OBJFormat>());
|
||||||
|
addFormat(std::make_shared<GLTFFormat>());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelFormatRegistry::addFormat(const std::shared_ptr<hfm::Format>& format) {
|
||||||
|
format->registerFormat(*this);
|
||||||
|
withWriteLock([&](){
|
||||||
|
formats.push_back(format);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ModelFormatRegistry::~ModelFormatRegistry() {
|
||||||
|
for (auto& format : formats) {
|
||||||
|
format->unregisterFormat(*this);
|
||||||
|
}
|
||||||
|
formats.clear();
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
//
|
||||||
|
// ModelFormatRegistry.h
|
||||||
|
// libraries/model-networking/src/model-networking
|
||||||
|
//
|
||||||
|
// Created by Sabrina Shanman on 2018/11/30.
|
||||||
|
// Copyright 2018 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_ModelFormatRegistry_h
|
||||||
|
#define hifi_ModelFormatRegistry_h
|
||||||
|
|
||||||
|
#include <hfm/HFMFormat.h>
|
||||||
|
#include <hfm/HFMFormatRegistry.h>
|
||||||
|
|
||||||
|
class ModelFormatRegistry : public hfm::FormatRegistry {
|
||||||
|
public:
|
||||||
|
ModelFormatRegistry();
|
||||||
|
~ModelFormatRegistry();
|
||||||
|
void addFormat(const std::shared_ptr<hfm::Format>& format);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void addDefaultFormats();
|
||||||
|
std::vector<std::shared_ptr<hfm::Format>> formats;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_ModelFormatRegistry_h
|
Loading…
Reference in a new issue