-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExportModule.cpp
40 lines (30 loc) · 1005 Bytes
/
ExportModule.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "ExportModule.hpp"
#include "ExportFormatOBJ.hpp"
#include <Qt3DCore/QEntity>
#include "Model.hpp"
#include <Qt3DRender/QGeometryRenderer>
#include <thread>
using Qt3DRender::QGeometryRenderer;
using Qt3DCore::QEntity;
ExportModule::ExportModule() : Module(), exports({}) {
this->registerExportFormat<ExportFormatOBJ>("obj");
}
ExportModule::~ExportModule() {
for (ExportFormat* temp : this->exports) {
delete temp;
temp = nullptr;
}
}
void ExportModule::actionOnModuleEmitting(Actions) {
}
void ExportModule::exportTo(const QString& str) {
QEntity* model = Model::getInstance()->getModelEntity();
QGeometryRenderer* renderer = model->componentsOfType<QGeometryRenderer>().first();
if (renderer == nullptr) {
return;
}
if (QString extension = str.split(".").last(); exports.contains(extension)) {
exports[extension]->fillExportFormat(renderer->geometry());
}
emit Module::emitting(Actions::ExportedAssetAction);
}