mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 08:23:04 +02:00
Add exporting by entity ID to Application
This commit is contained in:
parent
71768ef275
commit
6848025504
4 changed files with 44 additions and 3 deletions
|
@ -1633,6 +1633,47 @@ void Application::setActiveFaceTracker() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Application::exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs) {
|
||||||
|
QVector<EntityItem*> entities;
|
||||||
|
|
||||||
|
auto entityTree = _entities.getTree();
|
||||||
|
EntityTree exportTree;
|
||||||
|
|
||||||
|
glm::vec3 root(TREE_SCALE, TREE_SCALE, TREE_SCALE);
|
||||||
|
for (auto entityID : entityIDs) {
|
||||||
|
auto entityItem = entityTree->findEntityByEntityItemID(entityID);
|
||||||
|
if (!entityItem) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto properties = entityItem->getProperties();
|
||||||
|
auto position = properties.getPosition();
|
||||||
|
|
||||||
|
root.x = glm::min(root.x, position.x);
|
||||||
|
root.y = glm::min(root.y, position.y);
|
||||||
|
root.z = glm::min(root.z, position.z);
|
||||||
|
|
||||||
|
entities << entityItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entities.size() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto entityItem : entities) {
|
||||||
|
auto properties = entityItem->getProperties();
|
||||||
|
|
||||||
|
properties.setPosition(properties.getPosition() - root);
|
||||||
|
exportTree.addEntity(entityItem->getEntityItemID(), properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
exportTree.writeToSVOFile(filename.toLocal8Bit().constData());
|
||||||
|
|
||||||
|
// restore the main window's active state
|
||||||
|
_window->activateWindow();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Application::exportEntities(const QString& filename, float x, float y, float z, float scale) {
|
bool Application::exportEntities(const QString& filename, float x, float y, float z, float scale) {
|
||||||
QVector<EntityItem*> entities;
|
QVector<EntityItem*> entities;
|
||||||
_entities.getTree()->findEntities(AACube(glm::vec3(x / (float)TREE_SCALE,
|
_entities.getTree()->findEntities(AACube(glm::vec3(x / (float)TREE_SCALE,
|
||||||
|
|
|
@ -324,7 +324,7 @@ public slots:
|
||||||
void packetSent(quint64 length);
|
void packetSent(quint64 length);
|
||||||
|
|
||||||
QVector<EntityItemID> pasteEntities(float x, float y, float z);
|
QVector<EntityItemID> pasteEntities(float x, float y, float z);
|
||||||
bool exportEntities(const QString& filename, const QStringList& entityIDs);
|
bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs);
|
||||||
bool exportEntities(const QString& filename, float x, float y, float z, float scale);
|
bool exportEntities(const QString& filename, float x, float y, float z, float scale);
|
||||||
bool importEntities(const QString& filename);
|
bool importEntities(const QString& filename);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
ClipboardScriptingInterface::ClipboardScriptingInterface() {
|
ClipboardScriptingInterface::ClipboardScriptingInterface() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClipboardScriptingInterface::exportEntities(const QString& filename, QStringList entityIDs) {
|
bool ClipboardScriptingInterface::exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs) {
|
||||||
return Application::getInstance()->exportEntities(filename, entityIDs);
|
return Application::getInstance()->exportEntities(filename, entityIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool importEntities(const QString& filename);
|
bool importEntities(const QString& filename);
|
||||||
bool exportEntities(const QString& filename, QStringList entityIDs);
|
bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs);
|
||||||
bool exportEntities(const QString& filename, float x, float y, float z, float s);
|
bool exportEntities(const QString& filename, float x, float y, float z, float s);
|
||||||
QVector<EntityItemID> pasteEntities(float x, float y, float z, float s);
|
QVector<EntityItemID> pasteEntities(float x, float y, float z, float s);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue