mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 12:54:30 +02:00
Update exportModels implementation
This commit is contained in:
parent
6ecc12cdea
commit
a39a7e2356
2 changed files with 18 additions and 6 deletions
|
@ -1506,19 +1506,31 @@ struct SendVoxelsOperationArgs {
|
||||||
const unsigned char* newBaseOctCode;
|
const unsigned char* newBaseOctCode;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Application::exportModels(const QString& filename, float x, float y, float z, float scale) {
|
bool Application::exportModels(const QString& filename, float x, float y, float z, float scale) {
|
||||||
ModelTreeElement* selectedNode = _models.getTree()->getModelAt(x, y, z, scale);
|
QVector<ModelItem*> models;
|
||||||
if (selectedNode) {
|
_models.getTree()->findModelsInCube(AACube(glm::vec3(x / (float)TREE_SCALE, y / (float)TREE_SCALE, z / (float)TREE_SCALE), scale / (float)TREE_SCALE), models);
|
||||||
qDebug() << "Exporting models doing it!" << filename;
|
if (models.size() > 0) {
|
||||||
|
glm::vec3 root(x, y, z);
|
||||||
ModelTree exportTree;
|
ModelTree exportTree;
|
||||||
_models.getTree()->copySubTreeIntoNewTree(selectedNode, &exportTree, true);
|
|
||||||
|
for (int i = 0; i < models.size(); i++) {
|
||||||
|
ModelItemProperties properties;
|
||||||
|
ModelItemID id = models.at(i)->getModelItemID();
|
||||||
|
id.isKnownID = false;
|
||||||
|
properties.copyFromModelItem(*models.at(i));
|
||||||
|
properties.setPosition(properties.getPosition() - root);
|
||||||
|
exportTree.addModel(id, properties);
|
||||||
|
}
|
||||||
|
|
||||||
exportTree.writeToSVOFile(filename.toLocal8Bit().constData());
|
exportTree.writeToSVOFile(filename.toLocal8Bit().constData());
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "No models were selected";
|
qDebug() << "No models were selected";
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore the main window's active state
|
// restore the main window's active state
|
||||||
_window->activateWindow();
|
_window->activateWindow();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::sendVoxelsOperation(OctreeElement* element, void* extraData) {
|
bool Application::sendVoxelsOperation(OctreeElement* element, void* extraData) {
|
||||||
|
|
|
@ -316,7 +316,7 @@ public slots:
|
||||||
void packetSent(quint64 length);
|
void packetSent(quint64 length);
|
||||||
|
|
||||||
void pasteModels(float x, float y, float z);
|
void pasteModels(float x, float y, float z);
|
||||||
void exportModels(const QString& filename, float x, float y, float z, float scale);
|
bool exportModels(const QString& filename, float x, float y, float z, float scale);
|
||||||
void importModels(const QString& filename);
|
void importModels(const QString& filename);
|
||||||
|
|
||||||
void importVoxels(); // doesn't include source voxel because it goes to clipboard
|
void importVoxels(); // doesn't include source voxel because it goes to clipboard
|
||||||
|
|
Loading…
Reference in a new issue