mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 19:41:20 +02:00
Add cubemap output format
This commit is contained in:
parent
900486ed01
commit
c3d3cdca3d
8 changed files with 64 additions and 17 deletions
|
@ -7350,9 +7350,9 @@ void Application::takeSecondaryCameraSnapshot(const QString& filename) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::takeSecondaryCamera360Snapshot(const glm::vec3& cameraPosition, const QString& filename) {
|
void Application::takeSecondaryCamera360Snapshot(const glm::vec3& cameraPosition, const bool& cubemapOutputFormat, const QString& filename) {
|
||||||
postLambdaEvent([filename, cameraPosition, this] {
|
postLambdaEvent([filename, cubemapOutputFormat, cameraPosition, this] {
|
||||||
Snapshot::save360Snapshot(cameraPosition, filename);
|
Snapshot::save360Snapshot(cameraPosition, cubemapOutputFormat, filename);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,7 @@ public:
|
||||||
|
|
||||||
void takeSnapshot(bool notify, bool includeAnimated = false, float aspectRatio = 0.0f, const QString& filename = QString());
|
void takeSnapshot(bool notify, bool includeAnimated = false, float aspectRatio = 0.0f, const QString& filename = QString());
|
||||||
void takeSecondaryCameraSnapshot(const QString& filename = QString());
|
void takeSecondaryCameraSnapshot(const QString& filename = QString());
|
||||||
void takeSecondaryCamera360Snapshot(const glm::vec3& cameraPosition, const QString& filename = QString());
|
void takeSecondaryCamera360Snapshot(const glm::vec3& cameraPosition, const bool& cubemapOutputFormat, const QString& filename = QString());
|
||||||
|
|
||||||
void shareSnapshot(const QString& filename, const QUrl& href = QUrl(""));
|
void shareSnapshot(const QString& filename, const QUrl& href = QUrl(""));
|
||||||
|
|
||||||
|
|
|
@ -431,8 +431,8 @@ void WindowScriptingInterface::takeSecondaryCameraSnapshot(const QString& filena
|
||||||
qApp->takeSecondaryCameraSnapshot(filename);
|
qApp->takeSecondaryCameraSnapshot(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowScriptingInterface::takeSecondaryCamera360Snapshot(const glm::vec3& cameraPosition, const QString& filename) {
|
void WindowScriptingInterface::takeSecondaryCamera360Snapshot(const glm::vec3& cameraPosition, const bool& cubemapOutputFormat, const QString& filename) {
|
||||||
qApp->takeSecondaryCamera360Snapshot(cameraPosition, filename);
|
qApp->takeSecondaryCamera360Snapshot(cameraPosition, cubemapOutputFormat, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowScriptingInterface::shareSnapshot(const QString& path, const QUrl& href) {
|
void WindowScriptingInterface::shareSnapshot(const QString& path, const QUrl& href) {
|
||||||
|
|
|
@ -376,7 +376,7 @@ public slots:
|
||||||
*
|
*
|
||||||
* var filename = QString();
|
* var filename = QString();
|
||||||
*/
|
*/
|
||||||
void takeSecondaryCamera360Snapshot(const glm::vec3& cameraPosition, const QString& filename = QString());
|
void takeSecondaryCamera360Snapshot(const glm::vec3& cameraPosition, const bool& cubemapOutputFormat = false, const QString& filename = QString());
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Emit a {@link Window.connectionAdded|connectionAdded} or a {@link Window.connectionError|connectionError} signal that
|
* Emit a {@link Window.connectionAdded|connectionAdded} or a {@link Window.connectionError|connectionError} signal that
|
||||||
|
@ -588,13 +588,13 @@ signals:
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Triggered when a still equirectangular snapshot has been taken by calling {@link Window.takeSecondaryCamera360Snapshot|takeSecondaryCamera360Snapshot}
|
* Triggered when a still equirectangular snapshot has been taken by calling {@link Window.takeSecondaryCamera360Snapshot|takeSecondaryCamera360Snapshot}
|
||||||
* @function Window.equirectangularSnapshotTaken
|
* @function Window.snapshot360Taken
|
||||||
* @param {string} pathStillSnapshot - The path and name of the snapshot image file.
|
* @param {string} pathStillSnapshot - The path and name of the snapshot image file.
|
||||||
* @param {boolean} notify - The value of the <code>notify</code> parameter that {@link Window.takeSecondaryCamera360Snapshot|takeSecondaryCamera360Snapshot}
|
* @param {boolean} notify - The value of the <code>notify</code> parameter that {@link Window.takeSecondaryCamera360Snapshot|takeSecondaryCamera360Snapshot}
|
||||||
* was called with.
|
* was called with.
|
||||||
* @returns {Signal}
|
* @returns {Signal}
|
||||||
*/
|
*/
|
||||||
void equirectangularSnapshotTaken(const QString& pathEquirectangularSnapshot, bool notify);
|
void snapshot360Taken(const QString& path360Snapshot, bool notify);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Triggered when a snapshot submitted via {@link Window.shareSnapshot|shareSnapshot} is ready for sharing. The snapshot
|
* Triggered when a snapshot submitted via {@link Window.shareSnapshot|shareSnapshot} is ready for sharing. The snapshot
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <QtCore/QJsonArray>
|
#include <QtCore/QJsonArray>
|
||||||
#include <QtNetwork/QHttpMultiPart>
|
#include <QtNetwork/QHttpMultiPart>
|
||||||
#include <QtGui/QImage>
|
#include <QtGui/QImage>
|
||||||
|
#include <QPainter>
|
||||||
#include <QtConcurrent/QtConcurrentRun>
|
#include <QtConcurrent/QtConcurrentRun>
|
||||||
|
|
||||||
#include <AccountManager.h>
|
#include <AccountManager.h>
|
||||||
|
@ -102,6 +103,7 @@ QString Snapshot::saveSnapshot(QImage image, const QString& filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Snapshot::snapshotFilename;
|
QString Snapshot::snapshotFilename;
|
||||||
|
bool Snapshot::cubemapOutputFormat;
|
||||||
qint16 Snapshot::snapshotIndex = 0;
|
qint16 Snapshot::snapshotIndex = 0;
|
||||||
bool Snapshot::oldEnabled = false;
|
bool Snapshot::oldEnabled = false;
|
||||||
QVariant Snapshot::oldAttachedEntityId = 0;
|
QVariant Snapshot::oldAttachedEntityId = 0;
|
||||||
|
@ -110,8 +112,9 @@ QVariant Snapshot::oldvFoV = 0;
|
||||||
QVariant Snapshot::oldNearClipPlaneDistance = 0;
|
QVariant Snapshot::oldNearClipPlaneDistance = 0;
|
||||||
QVariant Snapshot::oldFarClipPlaneDistance = 0;
|
QVariant Snapshot::oldFarClipPlaneDistance = 0;
|
||||||
static const float CUBEMAP_SIDE_PIXEL_DIMENSION = 2048.0f;
|
static const float CUBEMAP_SIDE_PIXEL_DIMENSION = 2048.0f;
|
||||||
void Snapshot::save360Snapshot(const glm::vec3& cameraPosition, const QString& filename) {
|
void Snapshot::save360Snapshot(const glm::vec3& cameraPosition, const bool& cubemapOutputFormat, const QString& filename) {
|
||||||
Snapshot::snapshotFilename = filename;
|
Snapshot::snapshotFilename = filename;
|
||||||
|
Snapshot::cubemapOutputFormat = cubemapOutputFormat;
|
||||||
SecondaryCameraJobConfig* secondaryCameraRenderConfig = static_cast<SecondaryCameraJobConfig*>(qApp->getRenderEngine()->getConfiguration()->getConfig("SecondaryCamera"));
|
SecondaryCameraJobConfig* secondaryCameraRenderConfig = static_cast<SecondaryCameraJobConfig*>(qApp->getRenderEngine()->getConfiguration()->getConfig("SecondaryCamera"));
|
||||||
|
|
||||||
// Save initial values of secondary camera render config
|
// Save initial values of secondary camera render config
|
||||||
|
@ -191,12 +194,54 @@ void Snapshot::takeNextSnapshot() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process six QImages
|
// Process six QImages
|
||||||
QtConcurrent::run(Snapshot::convertToEquirectangular);
|
if (Snapshot::cubemapOutputFormat) {
|
||||||
|
QtConcurrent::run(Snapshot::convertToCubemap);
|
||||||
|
} else {
|
||||||
|
QtConcurrent::run(Snapshot::convertToEquirectangular);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Snapshot::snapshotIndex++;
|
Snapshot::snapshotIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Snapshot::convertToCubemap() {
|
||||||
|
float outputImageHeight = CUBEMAP_SIDE_PIXEL_DIMENSION * 3.0f;
|
||||||
|
float outputImageWidth = CUBEMAP_SIDE_PIXEL_DIMENSION * 4.0f;
|
||||||
|
|
||||||
|
QImage outputImage(outputImageWidth, outputImageHeight, QImage::Format_RGB32);
|
||||||
|
|
||||||
|
QPainter painter(&outputImage);
|
||||||
|
QPoint destPos;
|
||||||
|
|
||||||
|
// Paint DownImage
|
||||||
|
destPos = QPoint(CUBEMAP_SIDE_PIXEL_DIMENSION, CUBEMAP_SIDE_PIXEL_DIMENSION * 2.0f);
|
||||||
|
painter.drawImage(destPos, Snapshot::imageArray[0]);
|
||||||
|
|
||||||
|
// Paint FrontImage
|
||||||
|
destPos = QPoint(CUBEMAP_SIDE_PIXEL_DIMENSION, CUBEMAP_SIDE_PIXEL_DIMENSION);
|
||||||
|
painter.drawImage(destPos, Snapshot::imageArray[1]);
|
||||||
|
|
||||||
|
// Paint LeftImage
|
||||||
|
destPos = QPoint(0, CUBEMAP_SIDE_PIXEL_DIMENSION);
|
||||||
|
painter.drawImage(destPos, Snapshot::imageArray[2]);
|
||||||
|
|
||||||
|
// Paint BackImage
|
||||||
|
destPos = QPoint(CUBEMAP_SIDE_PIXEL_DIMENSION * 3.0f, CUBEMAP_SIDE_PIXEL_DIMENSION);
|
||||||
|
painter.drawImage(destPos, Snapshot::imageArray[3]);
|
||||||
|
|
||||||
|
// Paint RightImage
|
||||||
|
destPos = QPoint(CUBEMAP_SIDE_PIXEL_DIMENSION * 2.0f, CUBEMAP_SIDE_PIXEL_DIMENSION);
|
||||||
|
painter.drawImage(destPos, Snapshot::imageArray[4]);
|
||||||
|
|
||||||
|
// Paint UpImage
|
||||||
|
destPos = QPoint(CUBEMAP_SIDE_PIXEL_DIMENSION, 0);
|
||||||
|
painter.drawImage(destPos, Snapshot::imageArray[5]);
|
||||||
|
|
||||||
|
painter.end();
|
||||||
|
|
||||||
|
emit DependencyManager::get<WindowScriptingInterface>()->snapshot360Taken(saveSnapshot(outputImage, Snapshot::snapshotFilename), true);
|
||||||
|
}
|
||||||
|
|
||||||
void Snapshot::convertToEquirectangular() {
|
void Snapshot::convertToEquirectangular() {
|
||||||
// I got help from StackOverflow while writing this code:
|
// I got help from StackOverflow while writing this code:
|
||||||
// https://stackoverflow.com/questions/34250742/converting-a-cubemap-into-equirectangular-panorama
|
// https://stackoverflow.com/questions/34250742/converting-a-cubemap-into-equirectangular-panorama
|
||||||
|
@ -278,7 +323,7 @@ void Snapshot::convertToEquirectangular() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit DependencyManager::get<WindowScriptingInterface>()->equirectangularSnapshotTaken(saveSnapshot(outputImage, Snapshot::snapshotFilename), true);
|
emit DependencyManager::get<WindowScriptingInterface>()->snapshot360Taken(saveSnapshot(outputImage, Snapshot::snapshotFilename), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTemporaryFile* Snapshot::saveTempSnapshot(QImage image) {
|
QTemporaryFile* Snapshot::saveTempSnapshot(QImage image) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
Snapshot();
|
Snapshot();
|
||||||
|
|
||||||
static QString saveSnapshot(QImage image, const QString& filename);
|
static QString saveSnapshot(QImage image, const QString& filename);
|
||||||
static void save360Snapshot(const glm::vec3& cameraPosition, const QString& filename);
|
static void save360Snapshot(const glm::vec3& cameraPosition, const bool& cubemapOutputFormat, const QString& filename);
|
||||||
static QTemporaryFile* saveTempSnapshot(QImage image);
|
static QTemporaryFile* saveTempSnapshot(QImage image);
|
||||||
static SnapshotMetaData* parseSnapshotData(QString snapshotPath);
|
static SnapshotMetaData* parseSnapshotData(QString snapshotPath);
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ private:
|
||||||
static QFile* savedFileForSnapshot(QImage & image, bool isTemporary, const QString& userSelectedFilename = QString());
|
static QFile* savedFileForSnapshot(QImage & image, bool isTemporary, const QString& userSelectedFilename = QString());
|
||||||
|
|
||||||
static QString snapshotFilename;
|
static QString snapshotFilename;
|
||||||
|
static bool cubemapOutputFormat;
|
||||||
static QTimer snapshotTimer;
|
static QTimer snapshotTimer;
|
||||||
static qint16 snapshotIndex;
|
static qint16 snapshotIndex;
|
||||||
static bool oldEnabled;
|
static bool oldEnabled;
|
||||||
|
@ -70,6 +71,7 @@ private:
|
||||||
static QVariant oldNearClipPlaneDistance;
|
static QVariant oldNearClipPlaneDistance;
|
||||||
static QVariant oldFarClipPlaneDistance;
|
static QVariant oldFarClipPlaneDistance;
|
||||||
static QImage imageArray[6];
|
static QImage imageArray[6];
|
||||||
|
static void convertToCubemap();
|
||||||
static void convertToEquirectangular();
|
static void convertToEquirectangular();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -672,7 +672,7 @@
|
||||||
Menu.menuItemEvent.connect(menuItemEvent);
|
Menu.menuItemEvent.connect(menuItemEvent);
|
||||||
Window.domainConnectionRefused.connect(onDomainConnectionRefused);
|
Window.domainConnectionRefused.connect(onDomainConnectionRefused);
|
||||||
Window.stillSnapshotTaken.connect(onSnapshotTaken);
|
Window.stillSnapshotTaken.connect(onSnapshotTaken);
|
||||||
Window.equirectangularSnapshotTaken.connect(onSnapshotTaken);
|
Window.snapshot360Taken.connect(onSnapshotTaken);
|
||||||
Window.processingGifStarted.connect(processingGif);
|
Window.processingGifStarted.connect(processingGif);
|
||||||
Window.connectionAdded.connect(connectionAdded);
|
Window.connectionAdded.connect(connectionAdded);
|
||||||
Window.connectionError.connect(connectionError);
|
Window.connectionError.connect(connectionError);
|
||||||
|
|
|
@ -194,7 +194,7 @@
|
||||||
Window.domainChanged.connect(onDomainChanged);
|
Window.domainChanged.connect(onDomainChanged);
|
||||||
Window.geometryChanged.connect(resizeViewFinderOverlay);
|
Window.geometryChanged.connect(resizeViewFinderOverlay);
|
||||||
Window.stillSnapshotTaken.connect(onStillSnapshotTaken);
|
Window.stillSnapshotTaken.connect(onStillSnapshotTaken);
|
||||||
Window.equirectangularSnapshotTaken.connect(onEquirectangularSnapshotTaken);
|
Window.snapshot360Taken.connect(on360SnapshotTaken);
|
||||||
Controller.keyPressEvent.connect(keyPressEvent);
|
Controller.keyPressEvent.connect(keyPressEvent);
|
||||||
HMD.displayModeChanged.connect(onHMDChanged);
|
HMD.displayModeChanged.connect(onHMDChanged);
|
||||||
viewFinderOverlay = false;
|
viewFinderOverlay = false;
|
||||||
|
@ -407,7 +407,7 @@
|
||||||
}, 250);
|
}, 250);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function onEquirectangularSnapshotTaken() {
|
function on360SnapshotTaken() {
|
||||||
if (monitorShowsCameraView) {
|
if (monitorShowsCameraView) {
|
||||||
setDisplay(true);
|
setDisplay(true);
|
||||||
}
|
}
|
||||||
|
@ -606,7 +606,7 @@
|
||||||
Window.domainChanged.disconnect(onDomainChanged);
|
Window.domainChanged.disconnect(onDomainChanged);
|
||||||
Window.geometryChanged.disconnect(resizeViewFinderOverlay);
|
Window.geometryChanged.disconnect(resizeViewFinderOverlay);
|
||||||
Window.stillSnapshotTaken.disconnect(onStillSnapshotTaken);
|
Window.stillSnapshotTaken.disconnect(onStillSnapshotTaken);
|
||||||
Window.equirectangularSnapshotTaken.disconnect(onEquirectangularSnapshotTaken);
|
Window.snapshot360Taken.disconnect(on360SnapshotTaken);
|
||||||
addOrRemoveButton(true);
|
addOrRemoveButton(true);
|
||||||
if (tablet) {
|
if (tablet) {
|
||||||
tablet.screenChanged.disconnect(onTabletScreenChanged);
|
tablet.screenChanged.disconnect(onTabletScreenChanged);
|
||||||
|
|
Loading…
Reference in a new issue