mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-19 00:57:35 +02:00
Copy pre-parsed node from FBXSerializer for baking
This commit is contained in:
parent
3aaa18f529
commit
cb1f42afe5
3 changed files with 23 additions and 30 deletions
|
@ -50,35 +50,7 @@ FBXBaker::FBXBaker(const QUrl& inputModelURL, TextureBakerThreadGetter inputText
|
|||
|
||||
void FBXBaker::bakeProcessedSource(const hfm::Model::Pointer& hfmModel, const std::vector<hifi::ByteArray>& dracoMeshes, const std::vector<std::vector<hifi::ByteArray>>& dracoMaterialLists) {
|
||||
_hfmModel = hfmModel;
|
||||
// Load the root node from the FBX file
|
||||
importScene();
|
||||
|
||||
if (shouldStop()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// enumerate the models and textures found in the scene and start a bake for them
|
||||
rewriteAndBakeSceneTextures();
|
||||
|
||||
if (shouldStop()) {
|
||||
return;
|
||||
}
|
||||
|
||||
rewriteAndBakeSceneModels(hfmModel->meshes, dracoMeshes, dracoMaterialLists);
|
||||
}
|
||||
|
||||
void FBXBaker::importScene() {
|
||||
qDebug() << "file path: " << _originalModelFilePath.toLocal8Bit().data() << QDir(_originalModelFilePath).exists();
|
||||
|
||||
QFile fbxFile(_originalModelFilePath);
|
||||
if (!fbxFile.open(QIODevice::ReadOnly)) {
|
||||
handleError("Error opening " + _originalModelFilePath + " for reading");
|
||||
return;
|
||||
}
|
||||
|
||||
qCDebug(model_baking) << "Parsing" << _modelURL;
|
||||
_rootNode = FBXSerializer().parseFBX(&fbxFile);
|
||||
|
||||
|
||||
#ifdef HIFI_DUMP_FBX
|
||||
{
|
||||
FBXToJSON fbxToJSON;
|
||||
|
@ -92,6 +64,19 @@ void FBXBaker::importScene() {
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (shouldStop()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// enumerate the models and textures found in the scene and start a bake for them
|
||||
rewriteAndBakeSceneTextures();
|
||||
|
||||
if (shouldStop()) {
|
||||
return;
|
||||
}
|
||||
|
||||
rewriteAndBakeSceneModels(hfmModel->meshes, dracoMeshes, dracoMaterialLists);
|
||||
}
|
||||
|
||||
void FBXBaker::replaceMeshNodeWithDraco(FBXNode& meshNode, const QByteArray& dracoMeshBytes, const std::vector<hifi::ByteArray>& dracoMaterialList) {
|
||||
|
|
|
@ -38,7 +38,6 @@ protected:
|
|||
virtual void bakeProcessedSource(const hfm::Model::Pointer& hfmModel, const std::vector<hifi::ByteArray>& dracoMeshes, const std::vector<std::vector<hifi::ByteArray>>& dracoMaterialLists) override;
|
||||
|
||||
private:
|
||||
void importScene();
|
||||
void rewriteAndBakeSceneModels(const QVector<hfm::Mesh>& meshes, const std::vector<hifi::ByteArray>& dracoMeshes, const std::vector<std::vector<hifi::ByteArray>>& dracoMaterialLists);
|
||||
void rewriteAndBakeSceneTextures();
|
||||
void replaceMeshNodeWithDraco(FBXNode& meshNode, const QByteArray& dracoMeshBytes, const std::vector<hifi::ByteArray>& dracoMaterialList);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <DependencyManager.h>
|
||||
#include <hfm/ModelFormatRegistry.h>
|
||||
#include <FBXSerializer.h>
|
||||
|
||||
#include <model-baker/Baker.h>
|
||||
#include <model-baker/PrepareJointsTask.h>
|
||||
|
@ -250,6 +251,14 @@ void ModelBaker::bakeSourceCopy() {
|
|||
serializerMapping["deduplicateIndices"] = true; // Draco compression also deduplicates, but we might as well shave it off to save on some earlier processing (currently FBXSerializer only)
|
||||
hfm::Model::Pointer loadedModel = serializer->read(modelData, serializerMapping, _modelURL);
|
||||
|
||||
// Temporarily support copying the pre-parsed node from FBXSerializer, for better performance in FBXBaker
|
||||
// TODO: Pure HFM baking
|
||||
std::shared_ptr<FBXSerializer> fbxSerializer = std::dynamic_pointer_cast<FBXSerializer>(serializer);
|
||||
if (fbxSerializer) {
|
||||
qCDebug(model_baking) << "Parsing" << _modelURL;
|
||||
_rootNode = fbxSerializer->_rootNode;
|
||||
}
|
||||
|
||||
baker::Baker baker(loadedModel, serializerMapping, _mappingURL);
|
||||
auto config = baker.getConfiguration();
|
||||
// Enable compressed draco mesh generation
|
||||
|
|
Loading…
Reference in a new issue