Skip to content

Commit

Permalink
Rename HDR skybox to panoramic skybox
Browse files Browse the repository at this point in the history
  • Loading branch information
NEDJIMAbelgacem committed Aug 6, 2020
1 parent d7787f2 commit 7a022c6
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 47 deletions.
4 changes: 2 additions & 2 deletions src/3d/qgs3dmapscene.cpp
Expand Up @@ -881,8 +881,8 @@ void Qgs3DMapScene::onSkyboxSettingsChanged()
this
);
break;
case QgsSkyboxEntity::HDRSkybox:
mSkybox = new QgsHDRSkyboxEntity( skyboxSettings.hdrTexturePath(), this );
case QgsSkyboxEntity::PanoramicSkybox:
mSkybox = new QgsPanoramicSkyboxEntity( skyboxSettings.panoramicTexturePath(), this );
break;
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/3d/qgsskyboxentity.cpp
Expand Up @@ -41,6 +41,7 @@

#include "qgsimagecache.h"
#include "qgsimagetexture.h"
#include "qgsproject.h"

QgsSkyboxEntity::QgsSkyboxEntity( QNode *parent )
: Qt3DCore::QEntity( parent )
Expand Down Expand Up @@ -96,11 +97,11 @@ QgsSkyboxEntity::QgsSkyboxEntity( QNode *parent )
addComponent( mMaterial );
}

// HDR skybox
// Panoramic skybox

QgsHDRSkyboxEntity::QgsHDRSkyboxEntity( const QString &hdrTexturePath, QNode *parent )
QgsPanoramicSkyboxEntity::QgsPanoramicSkyboxEntity( const QString &texturePath, QNode *parent )
: QgsSkyboxEntity( parent )
, mHDRTexturePath( hdrTexturePath )
, mTexturePath( texturePath )
, mLoadedTexture( new Qt3DRender::QTextureLoader( parent ) )
, mGlShader( new Qt3DRender::QShaderProgram( this ) )
{
Expand All @@ -115,9 +116,9 @@ QgsHDRSkyboxEntity::QgsHDRSkyboxEntity( const QString &hdrTexturePath, QNode *pa
reloadTexture();
}

void QgsHDRSkyboxEntity::reloadTexture()
void QgsPanoramicSkyboxEntity::reloadTexture()
{
mLoadedTexture->setSource( QUrl::fromUserInput( mHDRTexturePath ) );
mLoadedTexture->setSource( QUrl::fromUserInput( mTexturePath ) );
}

// 6 faces skybox
Expand Down Expand Up @@ -192,7 +193,7 @@ void QgsCubeFacesSkyboxEntity::reloadTexture()
Qt3DRender::QTextureImage *image = new Qt3DRender::QTextureImage( this );
image->setFace( face );
image->setMirrored( false );
image->setSource( QUrl::fromUserInput( mCubeFacesPaths[ it.key() ] ) );
image->setSource( QUrl::fromUserInput( texturePath ) );
mCubeMap->addTextureImage( image );
mFacesTextureImages.push_back( image );
}
Expand Down
16 changes: 8 additions & 8 deletions src/3d/qgsskyboxentity.h
Expand Up @@ -47,7 +47,7 @@ class _3D_EXPORT QgsSkyboxEntity : public Qt3DCore::QEntity
//! Skybox type enumeration
enum SkyboxType
{
HDRSkybox,
PanoramicSkybox,
TexturesCollectionSkybox,
DistinctTexturesSkybox
};
Expand All @@ -70,25 +70,25 @@ class _3D_EXPORT QgsSkyboxEntity : public Qt3DCore::QEntity
};

/**
* \brief a skybox constructed from a 360 HDR image
* \brief a skybox constructed from a panoramic image
* \ingroup 3d
* \since QGIS 3.16
*/
class _3D_EXPORT QgsHDRSkyboxEntity : public QgsSkyboxEntity
class _3D_EXPORT QgsPanoramicSkyboxEntity : public QgsSkyboxEntity
{
public:
//! Construct a skybox from a high resolution 360 image
QgsHDRSkyboxEntity( const QString &hdrTexturePath, Qt3DCore::QNode *parent = nullptr );
//! Construct a skybox from a panoramic 360 image
QgsPanoramicSkyboxEntity( const QString &texturePath, Qt3DCore::QNode *parent = nullptr );

//! Returns the path of the current texture in use
QString hdrTexturePath() const { return mHDRTexturePath; }
QString texturePath() const { return mTexturePath; }
//! Returns the type of the current skybox
SkyboxType type() const override { return SkyboxType::HDRSkybox; }
SkyboxType type() const override { return SkyboxType::PanoramicSkybox; }

private:
void reloadTexture();
private:
QString mHDRTexturePath;
QString mTexturePath;
Qt3DRender::QTextureLoader *mLoadedTexture = nullptr;
Qt3DRender::QShaderProgram *mGlShader = nullptr;
};
Expand Down
24 changes: 12 additions & 12 deletions src/3d/qgsskyboxsettings.cpp
Expand Up @@ -29,18 +29,18 @@ void QgsSkyboxSettings::readXml( const QDomElement &element, const QgsReadWriteC
mSkyboxType = QgsSkyboxEntity::TexturesCollectionSkybox;
else if ( skyboxTypeStr == QStringLiteral( "Distinct Faces" ) )
mSkyboxType = QgsSkyboxEntity::DistinctTexturesSkybox;
else if ( skyboxTypeStr == QStringLiteral( "HDR texture" ) )
mSkyboxType = QgsSkyboxEntity::HDRSkybox;
else if ( skyboxTypeStr == QStringLiteral( "Panoramic texture" ) )
mSkyboxType = QgsSkyboxEntity::PanoramicSkybox;
mSkyboxBaseName = element.attribute( QStringLiteral( "base-name" ) );
mSkyboxExt = element.attribute( QStringLiteral( "extension" ) );
mHDRTexturePath = element.attribute( pathResolver.readPath( QStringLiteral( "HDR-texture-path" ) ) );
mPanoramicTexturePath = pathResolver.readPath( element.attribute( QStringLiteral( "panoramic-texture-path" ) ) );
mCubeMapFacesPaths.clear();
mCubeMapFacesPaths[ QStringLiteral( "posX" ) ] = element.attribute( pathResolver.readPath( QStringLiteral( "posX-texture-path" ) ) );
mCubeMapFacesPaths[ QStringLiteral( "posY" ) ] = element.attribute( pathResolver.readPath( QStringLiteral( "posY-texture-path" ) ) );
mCubeMapFacesPaths[ QStringLiteral( "posZ" ) ] = element.attribute( pathResolver.readPath( QStringLiteral( "posZ-texture-path" ) ) );
mCubeMapFacesPaths[ QStringLiteral( "negX" ) ] = element.attribute( pathResolver.readPath( QStringLiteral( "negX-texture-path" ) ) );
mCubeMapFacesPaths[ QStringLiteral( "negY" ) ] = element.attribute( pathResolver.readPath( QStringLiteral( "negY-texture-path" ) ) );
mCubeMapFacesPaths[ QStringLiteral( "negZ" ) ] = element.attribute( pathResolver.readPath( QStringLiteral( "negZ-texture-path" ) ) );
mCubeMapFacesPaths[ QStringLiteral( "posX" ) ] = pathResolver.readPath( element.attribute( QStringLiteral( "posX-texture-path" ) ) );
mCubeMapFacesPaths[ QStringLiteral( "posY" ) ] = pathResolver.readPath( element.attribute( QStringLiteral( "posY-texture-path" ) ) );
mCubeMapFacesPaths[ QStringLiteral( "posZ" ) ] = pathResolver.readPath( element.attribute( QStringLiteral( "posZ-texture-path" ) ) );
mCubeMapFacesPaths[ QStringLiteral( "negX" ) ] = pathResolver.readPath( element.attribute( QStringLiteral( "negX-texture-path" ) ) );
mCubeMapFacesPaths[ QStringLiteral( "negY" ) ] = pathResolver.readPath( element.attribute( QStringLiteral( "negY-texture-path" ) ) );
mCubeMapFacesPaths[ QStringLiteral( "negZ" ) ] = pathResolver.readPath( element.attribute( QStringLiteral( "negZ-texture-path" ) ) );
}

void QgsSkyboxSettings::writeXml( QDomElement &element, const QgsReadWriteContext &context ) const
Expand All @@ -54,15 +54,15 @@ void QgsSkyboxSettings::writeXml( QDomElement &element, const QgsReadWriteContex
case QgsSkyboxEntity::DistinctTexturesSkybox:
element.setAttribute( QStringLiteral( "skybox-type" ), QStringLiteral( "Distinct Faces" ) );
break;
case QgsSkyboxEntity::HDRSkybox:
element.setAttribute( QStringLiteral( "skybox-type" ), QStringLiteral( "HDR texture" ) );
case QgsSkyboxEntity::PanoramicSkybox:
element.setAttribute( QStringLiteral( "skybox-type" ), QStringLiteral( "Panoramic texture" ) );
break;
}

const QgsPathResolver &pathResolver = context.pathResolver();
element.setAttribute( QStringLiteral( "base-name" ), mSkyboxBaseName );
element.setAttribute( QStringLiteral( "extension" ), mSkyboxExt );
element.setAttribute( QStringLiteral( "HDR-texture-path" ), pathResolver.writePath( mHDRTexturePath ) );
element.setAttribute( QStringLiteral( "panoramic-texture-path" ), pathResolver.writePath( mPanoramicTexturePath ) );
element.setAttribute( QStringLiteral( "posX-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[ QStringLiteral( "posX" ) ] ) );
element.setAttribute( QStringLiteral( "posY-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[ QStringLiteral( "posY" ) ] ) );
element.setAttribute( QStringLiteral( "posZ-texture-path" ), pathResolver.writePath( mCubeMapFacesPaths[ QStringLiteral( "posZ" ) ] ) );
Expand Down
10 changes: 5 additions & 5 deletions src/3d/qgsskyboxsettings.h
Expand Up @@ -61,10 +61,10 @@ class _3D_EXPORT QgsSkyboxSettings
//! Sets the extension of a skybox of type "Textures collection"
void setSkyboxExtension( const QString &extension ) { mSkyboxExt = extension; }

//! Returns the HDR texture path of a skybox of type "HDR texture"
QString hdrTexturePath() const { return mHDRTexturePath; }
//! Sets the HDR texture path of a skybox of type "HDR texture"
void setHdrTexturePath( const QString &texturePath ) { mHDRTexturePath = texturePath; }
//! Returns the panoramic texture path of a skybox of type "Panormaic skybox"
QString panoramicTexturePath() const { return mPanoramicTexturePath; }
//! Sets the panoramic texture path of a skybox of type "Panoramic skybox"
void setPanoramicTexturePath( const QString &texturePath ) { mPanoramicTexturePath = texturePath; }

/**
* Returns a map containing the path of each texture specified by the user.
Expand All @@ -85,7 +85,7 @@ class _3D_EXPORT QgsSkyboxSettings
QString mSkyboxBaseName;
QString mSkyboxExt;
//
QString mHDRTexturePath;
QString mPanoramicTexturePath;
//
QMap<QString, QString> mCubeMapFacesPaths;
};
Expand Down
20 changes: 10 additions & 10 deletions src/app/3d/qgsskyboxrenderingsettingswidget.cpp
Expand Up @@ -25,20 +25,20 @@ QgsSkyboxRenderingSettingsWidget::QgsSkyboxRenderingSettingsWidget( QWidget *par
setupUi( this );

layoutGroupBoxes.push_back( textureCollectionGroupBox );
layoutGroupBoxes.push_back( hdrTextureGroupBox );
layoutGroupBoxes.push_back( panoramicTextureGroupBox );
layoutGroupBoxes.push_back( faceTexturesGroupBox );

skyboxTypeComboBox->addItem( QStringLiteral( "Textures collection" ) );
skyboxTypeComboBox->addItem( QStringLiteral( "HDR texture" ) );
skyboxTypeComboBox->addItem( QStringLiteral( "Panoramic texture" ) );
skyboxTypeComboBox->addItem( QStringLiteral( "Distinct Faces" ) );
connect( skyboxTypeComboBox, &QComboBox::currentTextChanged, [&]( const QString & skyboxType )
{
for ( QGroupBox *groupBox : layoutGroupBoxes )
groupBox->setVisible( false );
if ( skyboxType == QStringLiteral( "Textures collection" ) )
textureCollectionGroupBox->setVisible( true );
if ( skyboxType == QStringLiteral( "HDR texture" ) )
hdrTextureGroupBox->setVisible( true );
if ( skyboxType == QStringLiteral( "Panoramic texture" ) )
panoramicTextureGroupBox->setVisible( true );
if ( skyboxType == QStringLiteral( "Distinct Faces" ) )
faceTexturesGroupBox->setVisible( true );
} );
Expand All @@ -57,14 +57,14 @@ void QgsSkyboxRenderingSettingsWidget::setSkyboxSettings( const QgsSkyboxSetting
case QgsSkyboxEntity::DistinctTexturesSkybox:
skyboxTypeComboBox->setCurrentText( QStringLiteral( "Distinct Faces" ) );
break;
case QgsSkyboxEntity::HDRSkybox:
skyboxTypeComboBox->setCurrentText( QStringLiteral( "HDR texture" ) );
case QgsSkyboxEntity::PanoramicSkybox:
skyboxTypeComboBox->setCurrentText( QStringLiteral( "Panoramic texture" ) );
break;
}

skyboxBaseNameLineEdit->setText( skyboxSettings.skyboxBaseName() );
skyboxExtensionLineEdit->setText( skyboxSettings.skyboxExtension() );
hdrTextureImageSource->setSource( skyboxSettings.hdrTexturePath() );
panoramicTextureImageSource->setSource( skyboxSettings.panoramicTexturePath() );
QMap<QString, QString> cubeMapFaces = skyboxSettings.cubeMapFacesPaths();
posXImageSource->setSource( cubeMapFaces[ QStringLiteral( "posX" ) ] );
posYImageSource->setSource( cubeMapFaces[ QStringLiteral( "posY" ) ] );
Expand All @@ -83,12 +83,12 @@ QgsSkyboxSettings QgsSkyboxRenderingSettingsWidget::toSkyboxSettings()
settings.setSkyboxType( QgsSkyboxEntity::TexturesCollectionSkybox );
else if ( skyboxTypeComboBox->currentText() == QStringLiteral( "Distinct Faces" ) )
settings.setSkyboxType( QgsSkyboxEntity::DistinctTexturesSkybox );
else if ( skyboxTypeComboBox->currentText() == QStringLiteral( "HDR texture" ) )
settings.setSkyboxType( QgsSkyboxEntity::HDRSkybox );
else if ( skyboxTypeComboBox->currentText() == QStringLiteral( "Panoramic texture" ) )
settings.setSkyboxType( QgsSkyboxEntity::PanoramicSkybox );

settings.setSkyboxBaseName( skyboxBaseNameLineEdit->text() );
settings.setSkyboxExtension( skyboxExtensionLineEdit->text() );
settings.setHdrTexturePath( hdrTextureImageSource->source() );
settings.setPanoramicTexturePath( panoramicTextureImageSource->source() );
settings.setCubeMapFace( QStringLiteral( "posX" ), posXImageSource->source() );
settings.setCubeMapFace( QStringLiteral( "posY" ), posYImageSource->source() );
settings.setCubeMapFace( QStringLiteral( "posZ" ), posZImageSource->source() );
Expand Down
8 changes: 4 additions & 4 deletions src/ui/3d/skyboxrenderingsettingswidget.ui
Expand Up @@ -12,22 +12,22 @@
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QGroupBox" name="hdrTextureGroupBox">
<widget class="QGroupBox" name="panoramicTextureGroupBox">
<property name="title">
<string>360 image:</string>
<string>Panoramic image:</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<layout class="QGridLayout" name="hdrTextureLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>HDR Texture File:</string>
<string>Panoramic Texture File:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QgsImageSourceLineEdit" name="hdrTextureImageSource" native="true"/>
<widget class="QgsImageSourceLineEdit" name="panoramicTextureImageSource" native="true"/>
</item>
</layout>
</item>
Expand Down

0 comments on commit 7a022c6

Please sign in to comment.