mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 09:24:00 +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
|
||||
}
|
||||
|
||||
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) {
|
||||
QVector<EntityItem*> entities;
|
||||
_entities.getTree()->findEntities(AACube(glm::vec3(x / (float)TREE_SCALE,
|
||||
|
|
|
@ -324,7 +324,7 @@ public slots:
|
|||
void packetSent(quint64 length);
|
||||
|
||||
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 importEntities(const QString& filename);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ signals:
|
|||
|
||||
public slots:
|
||||
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);
|
||||
QVector<EntityItemID> pasteEntities(float x, float y, float z, float s);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue