Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3D] add support for gl_clipdistance + scene rotation (part 2) #58051

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
268e2f9
qgsabstractmaterialsettings: Add mapSettings parameter to toMaterial
ptitjano May 23, 2024
bc19fab
qgsphongmaterialsettings: Use default vertex for the constant case
ptitjano May 28, 2024
7ea241f
qgsmetalroughmaterial: Move add addDefinesToShaderCode to Qgs3DUtils
ptitjano May 17, 2024
87dad15
qgsphongmaterialsettings: Merge datadefined and constant cases
ptitjano May 27, 2024
e6d7379
qgsgoochmaterialsettings: Merge datadefined and constant cases
ptitjano May 27, 2024
e51eb79
qgsphongtexturedmaterialsettings: Use default.vert vertex
ptitjano Jun 24, 2024
c1d16c1
qgsmetalroughmaterial: Add qgs3dmapsettings parameter
ptitjano May 27, 2024
34e88e8
3d: Introduce QgsTextureMaterial
ptitjano Mar 19, 2024
4be6e52
3d: Introduce QgsDiffuseSpecularMaterial
ptitjano Mar 19, 2024
f48b6b4
terrain: use QgsTextureMaterial and QgsDiffuseSpecularMaterial
ptitjano Jun 24, 2024
e0b0c65
qgsframegraph: Add clip planes
ptitjano Jun 7, 2024
7c161d8
3d: Add support for gl_ClipDistance in the default vertex shader file
ptitjano Jun 7, 2024
d29b940
qgsdemterraintileloader: Simplify createTextureComponent signature
ptitjano Jun 24, 2024
f39e189
qgsdiffusespecularmaterial: Add support for gl_ClipDistance
ptitjano Jun 24, 2024
d54610c
qgstexturematerial: Add support for gl_ClipDistance
ptitjano Jun 24, 2024
403762f
phongDataDefined: Add support for gl_ClipDistance
ptitjano Jun 24, 2024
9f933b4
goochDataDefined: Add support for gl_ClipDistance
ptitjano Jun 24, 2024
f0b289f
qgssimplelinematerialsettings: Add support for gl_ClipDistance
ptitjano May 27, 2024
3ca8205
qgsinstancedpoint3d: Add support for gl_ClipDistance
ptitjano Jun 24, 2024
e58c189
qgspointcloud3dsymbol: Add support for gl_ClipDistance
ptitjano Jun 24, 2024
0bb1e81
qgsmesh3dmaterial: Add support for gl_ClipDistance
ptitjano Jun 24, 2024
aac7640
qgs3dmapconfigwidget: Use settings extent to compute the zoom level
ptitjano Jul 10, 2024
92f14f8
qgs3dmapsettings: Regroup logic to update terrain generator extent
ptitjano May 23, 2024
49950c2
qgs3dmapsettings: Introduce default min/max depth parameter
ptitjano Jul 5, 2024
6f6a711
qgsmatrix4x4: Add support for rotation
ptitjano Jul 2, 2024
ebf7807
qgsvector3d: Add support for minus operator
ptitjano Jul 2, 2024
c75dab2
qgsorientedbox3d: Add a method to compute rotation angles
ptitjano Jul 3, 2024
849ce7e
qgs3dmapsettings: Store scene extent in an oriented box
ptitjano Mar 10, 2023
02e4298
qgs3dmapcanvaswidget: Add support for box in onExtentChanged
ptitjano Jul 10, 2024
fe52b6a
qgs3dutils: Add support for box in addBoundingBoxParametersToEffect
ptitjano Jun 7, 2024
dae2a8e
3d: Use a new widget for extent definition
ptitjano Aug 17, 2023
478a64e
qgs3dutils: Factor out logic to compute rotated oriented box
ptitjano Jul 5, 2024
b124157
qgs3dmapconfigwidget: Add support for z rotation
ptitjano Mar 10, 2023
7cf3747
testqgs3drendering: Add unit test for flat terrain with scene rotation
ptitjano Jul 6, 2024
823c488
testqgs3drendering: Add unit test for vector data with scene rotation
ptitjano Jul 4, 2024
ee748dc
testqgspointcloud3drendering: Add a unit test with scene rotation
ptitjano Jul 4, 2024
5e0133e
testqgsmesh3drendering: Add a unit test with scene rotation
ptitjano Jul 6, 2024
de942d9
qgs3dmapcanvaswidget: Give a proper name to Qgs3DMapConfigWidget var
ptitjano Aug 18, 2023
0cc4d6e
qgs3dmapconfigwidget: Factor out logic to update the terrain from apply
ptitjano Jul 5, 2024
583ead4
qgs3dmapconfigwidget: Live extent change
ptitjano Aug 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions python/3d/auto_generated/qgs3dmapsettings.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Resolves references to other objects (map layers) after the call to :py:func:`~Q

QgsRectangle extent() const;
%Docstring
Returns the 3D scene's 2D extent in the 3D scene's CRS
Returns the 3D scene's 2D bounding box of the extent in the 3D scene's CRS.

.. seealso:: :py:func:`crs`

Expand All @@ -57,13 +57,10 @@ Returns the 3D scene's 2D extent in the 3D scene's CRS

void setExtent( const QgsRectangle &extent );
%Docstring
Sets the 3D scene's 2D ``extent`` in the 3D scene's CRS, while also setting the scene's origin to the extent's center
This needs to be called during initialization, as terrain will only be generated
within this extent and layer 3D data will only be loaded within this extent too.
Sets the 3D scene's 2D ``extent`` in the 3D scene's CRS
This calls setBox to set 3D scene box.

.. seealso:: :py:func:`setOrigin`

.. seealso:: :py:func:`setCrs`
.. seealso:: :py:func:`setBox`

.. versionadded:: 3.30
%End
Expand All @@ -83,6 +80,26 @@ to improve the precision.
QgsVector3D origin() const;
%Docstring
Returns coordinates in map CRS at which 3D scene has origin (0,0,0)
%End

void setBox( const QgsOrientedBox3D &box );
%Docstring
Sets the 3D scene's ``box`` in the 3D scene's CRS, while also setting the scene's origin to the box's center
This needs to be called during initialization, as terrain will only be generated
within this extent and layer 3D data will only be loaded within this extent too.

.. seealso:: :py:func:`setOrigin`

.. seealso:: :py:func:`setCrs`

.. versionadded:: 3.40
%End

QgsOrientedBox3D box() const;
%Docstring
Returns the 3D scene's box in the 3D scene's CRS.

.. versionadded:: 3.40
%End

QgsVector3D mapToWorldCoordinates( const QgsVector3D &mapCoords ) const;
Expand Down Expand Up @@ -934,9 +951,9 @@ Emitted when the debug overaly is enabled or disabled

void extentChanged();
%Docstring
Emitted when the 3d view's 2d extent has changed
Emitted when the 3d view's extent has changed

.. seealso:: :py:func:`setExtent`
.. seealso:: :py:func:`setBox`

.. versionadded:: 3.30
%End
Expand Down
35 changes: 26 additions & 9 deletions python/PyQt6/3d/auto_generated/qgs3dmapsettings.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Resolves references to other objects (map layers) after the call to :py:func:`~Q

QgsRectangle extent() const;
%Docstring
Returns the 3D scene's 2D extent in the 3D scene's CRS
Returns the 3D scene's 2D bounding box of the extent in the 3D scene's CRS.

.. seealso:: :py:func:`crs`

Expand All @@ -57,13 +57,10 @@ Returns the 3D scene's 2D extent in the 3D scene's CRS

void setExtent( const QgsRectangle &extent );
%Docstring
Sets the 3D scene's 2D ``extent`` in the 3D scene's CRS, while also setting the scene's origin to the extent's center
This needs to be called during initialization, as terrain will only be generated
within this extent and layer 3D data will only be loaded within this extent too.
Sets the 3D scene's 2D ``extent`` in the 3D scene's CRS
This calls setBox to set 3D scene box.

.. seealso:: :py:func:`setOrigin`

.. seealso:: :py:func:`setCrs`
.. seealso:: :py:func:`setBox`

.. versionadded:: 3.30
%End
Expand All @@ -83,6 +80,26 @@ to improve the precision.
QgsVector3D origin() const;
%Docstring
Returns coordinates in map CRS at which 3D scene has origin (0,0,0)
%End

void setBox( const QgsOrientedBox3D &box );
%Docstring
Sets the 3D scene's ``box`` in the 3D scene's CRS, while also setting the scene's origin to the box's center
This needs to be called during initialization, as terrain will only be generated
within this extent and layer 3D data will only be loaded within this extent too.

.. seealso:: :py:func:`setOrigin`

.. seealso:: :py:func:`setCrs`

.. versionadded:: 3.40
%End

QgsOrientedBox3D box() const;
%Docstring
Returns the 3D scene's box in the 3D scene's CRS.

.. versionadded:: 3.40
%End

QgsVector3D mapToWorldCoordinates( const QgsVector3D &mapCoords ) const;
Expand Down Expand Up @@ -934,9 +951,9 @@ Emitted when the debug overaly is enabled or disabled

void extentChanged();
%Docstring
Emitted when the 3d view's 2d extent has changed
Emitted when the 3d view's extent has changed

.. seealso:: :py:func:`setExtent`
.. seealso:: :py:func:`setBox`

.. versionadded:: 3.30
%End
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ Returns box transformed by a 4x4 matrix.
Returns ``True`` if the box intersects the ``other`` box.
%End


QgsVector3D eulerAngles() const /HoldGIL/;
%Docstring
Calculates roll, pitch, and yaw Euler angles (in degrees) that corresponds to the rotation of the box

.. versionadded:: 3.40
%End

SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsOrientedBox3D([%1, %2, %3], [%4, %5, %6, %7, %8, %9, %10, %11, %12])>" )
Expand Down
8 changes: 8 additions & 0 deletions python/PyQt6/core/auto_generated/qgsmatrix4x4.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ Returns matrix data (in column-major order)
Multiplies this matrix by another that translates coordinates by the components of a ``vector``.
%End


void rotate( double angle, const QgsVector3D &vector );
%Docstring
Multiples this matrix by another that rotates coordinates through ``angle`` degrees about ``vector``.

.. versionadded:: 3.40
%End

QgsVector3D map( const QgsVector3D &vector ) const /HoldGIL/;
%Docstring
Matrix-vector multiplication (vector is converted to homogeneous coordinates [X,Y,Z,1] and back)
Expand Down
2 changes: 2 additions & 0 deletions python/PyQt6/core/auto_generated/qgsvector3d.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Sets vector coordinates

QgsVector3D operator-( const QgsVector3D &other ) const /HoldGIL/;

const QgsVector3D operator-() const /HoldGIL/;

QgsVector3D operator *( const double factor ) const /HoldGIL/;

QgsVector3D operator /( const double factor ) const /HoldGIL/;
Expand Down
8 changes: 8 additions & 0 deletions python/core/auto_generated/geometry/qgsorientedbox3d.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ Returns box transformed by a 4x4 matrix.
Returns ``True`` if the box intersects the ``other`` box.
%End


QgsVector3D eulerAngles() const /HoldGIL/;
%Docstring
Calculates roll, pitch, and yaw Euler angles (in degrees) that corresponds to the rotation of the box

.. versionadded:: 3.40
%End

SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsOrientedBox3D([%1, %2, %3], [%4, %5, %6, %7, %8, %9, %10, %11, %12])>" )
Expand Down
8 changes: 8 additions & 0 deletions python/core/auto_generated/qgsmatrix4x4.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ Returns matrix data (in column-major order)
Multiplies this matrix by another that translates coordinates by the components of a ``vector``.
%End


void rotate( double angle, const QgsVector3D &vector );
%Docstring
Multiples this matrix by another that rotates coordinates through ``angle`` degrees about ``vector``.

.. versionadded:: 3.40
%End

QgsVector3D map( const QgsVector3D &vector ) const /HoldGIL/;
%Docstring
Matrix-vector multiplication (vector is converted to homogeneous coordinates [X,Y,Z,1] and back)
Expand Down
2 changes: 2 additions & 0 deletions python/core/auto_generated/qgsvector3d.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Sets vector coordinates

QgsVector3D operator-( const QgsVector3D &other ) const /HoldGIL/;

const QgsVector3D operator-() const /HoldGIL/;

QgsVector3D operator *( const double factor ) const /HoldGIL/;

QgsVector3D operator /( const double factor ) const /HoldGIL/;
Expand Down
4 changes: 4 additions & 0 deletions src/3d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ set(QGIS_3D_SRCS
lights/qgspointlightsettings.cpp

materials/qgsabstractmaterialsettings.cpp
materials/qgsdiffusespecularmaterial.cpp
materials/qgsgoochmaterialsettings.cpp
materials/qgsmaterialregistry.cpp
materials/qgsmetalroughmaterial.cpp
Expand All @@ -73,6 +74,7 @@ set(QGIS_3D_SRCS
materials/qgsphongmaterialsettings.cpp
materials/qgsphongtexturedmaterialsettings.cpp
materials/qgssimplelinematerialsettings.cpp
materials/qgstexturematerial.cpp

processing/qgs3dalgorithms.cpp
processing/qgsalgorithmtessellate.cpp
Expand Down Expand Up @@ -157,6 +159,7 @@ set(QGIS_3D_HDRS
lights/qgspointlightsettings.h

materials/qgsabstractmaterialsettings.h
materials/qgsdiffusespecularmaterial.h
materials/qgsgoochmaterialsettings.h
materials/qgsmaterialregistry.h
materials/qgsmetalroughmaterial.h
Expand All @@ -165,6 +168,7 @@ set(QGIS_3D_HDRS
materials/qgsphongmaterialsettings.h
materials/qgsphongtexturedmaterialsettings.h
materials/qgssimplelinematerialsettings.h
materials/qgstexturematerial.h

symbols/qgsbillboardgeometry.h
symbols/qgsline3dsymbol.h
Expand Down
3 changes: 2 additions & 1 deletion src/3d/materials/qgsabstractmaterialsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class QDomElement;
class QgsReadWriteContext;
class QgsLineMaterial;
class QgsExpressionContext;
class Qgs3DMapSettings;

#ifndef SIP_RUN
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Expand Down Expand Up @@ -179,7 +180,7 @@ class _3D_EXPORT QgsAbstractMaterialSettings SIP_ABSTRACT
* The \a technique argument specifies the rendering technique which will be used with the returned
* material.
*/
virtual Qt3DRender::QMaterial *toMaterial( QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context ) const = 0 SIP_FACTORY;
virtual Qt3DRender::QMaterial *toMaterial( const Qgs3DMapSettings &mapSettings, QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context ) const = 0 SIP_FACTORY;

/**
* Returns the parameters to be exported to .mtl file
Expand Down
Loading