diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2017-01-11 14:10:24 +0200 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2017-01-18 13:10:28 +0000 |
commit | cef6d5406267787d22deee75600ee9d3653a3109 (patch) | |
tree | 8e03434b1556ab642133b0a6ba85cce0e012f97f /src/plugins/sceneparsers/gltfexport/gltfexporter.cpp | |
parent | d7fb7425775d4e9191626fcf62f4198c84843090 (diff) |
GLTF Export QCamera properly
QCamera position, upVector, and viewCenter properties were not properly
preserved when doing GLTF export/import.
Change-Id: I6d81633cf29d6e347935c56605b46923d3e1aa03
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Diffstat (limited to 'src/plugins/sceneparsers/gltfexport/gltfexporter.cpp')
-rw-r--r-- | src/plugins/sceneparsers/gltfexport/gltfexporter.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp index befe7770d..7332fa6b5 100644 --- a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp +++ b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp @@ -961,6 +961,7 @@ void GLTFExporter::parseCameras() { qCDebug(GLTFExporterLog, "Parsing cameras..."); int cameraCount = 0; + for (auto it = m_cameraMap.constBegin(); it != m_cameraMap.constEnd(); ++it) { QCameraLens *camera = it.value(); CameraInfo c; @@ -984,7 +985,12 @@ void GLTFExporter::parseCameras() c.zfar = camera->farPlane(); // GLTF cameras point in -Z by default, the rest is in the - // node matrix, so no separate look-at params given here. + // node matrix, so no separate look-at params given here, unless it's actually QCamera. + QCamera *cameraEntity = nullptr; + const QVector<QEntity *> entities = camera->entities(); + if (entities.size() == 1) + cameraEntity = qobject_cast<QCamera *>(entities.at(0)); + c.cameraEntity = cameraEntity; m_cameraInfo.insert(camera, c); if (GLTFExporterLog().isDebugEnabled()) { @@ -1259,6 +1265,11 @@ bool GLTFExporter::saveScene() camera["type"] = QStringLiteral("orthographic"); camera["orthographic"] = proj; } + if (camInfo.cameraEntity) { + camera["position"] = vec2jsvec(camInfo.cameraEntity->position()); + camera["upVector"] = vec2jsvec(camInfo.cameraEntity->upVector()); + camera["viewCenter"] = vec2jsvec(camInfo.cameraEntity->viewCenter()); + } camera["name"] = camInfo.originalName; cameras[camInfo.name] = camera; } |