Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Import of initial work on QGIS 3D framework from wonder-sk/qgis3d
- Loading branch information
Showing
with
8,413 additions
and 1 deletion.
- +9 −0 CMakeLists.txt
- +1 −1 scripts/prepare-commit.sh
- +176 −0 src/3d/CMakeLists.txt
- +103 −0 src/3d/aabb.h
- +228 −0 src/3d/cameracontroller.cpp
- +112 −0 src/3d/cameracontroller.h
- +366 −0 src/3d/chunkedentity.cpp
- +109 −0 src/3d/chunkedentity.h
- +103 −0 src/3d/chunklist.cpp
- +54 −0 src/3d/chunklist.h
- +9 −0 src/3d/chunkloader.cpp
- +44 −0 src/3d/chunkloader.h
- +128 −0 src/3d/chunknode.cpp
- +70 −0 src/3d/chunknode.h
- +309 −0 src/3d/demterraingenerator.cpp
- +109 −0 src/3d/demterraingenerator.h
- +284 −0 src/3d/demterraintilegeometry.cpp
- +56 −0 src/3d/demterraintilegeometry.h
- +153 −0 src/3d/flatterraingenerator.cpp
- +45 −0 src/3d/flatterraingenerator.h
- +77 −0 src/3d/lineentity.cpp
- +19 −0 src/3d/lineentity.h
- +488 −0 src/3d/map3d.cpp
- +197 −0 src/3d/map3d.h
- +113 −0 src/3d/maptexturegenerator.cpp
- +60 −0 src/3d/maptexturegenerator.h
- +90 −0 src/3d/maptextureimage.cpp
- +38 −0 src/3d/maptextureimage.h
- +235 −0 src/3d/pointentity.cpp
- +15 −0 src/3d/pointentity.h
- +365 −0 src/3d/poly2tri/common/shapes.cc
- +323 −0 src/3d/poly2tri/common/shapes.h
- +127 −0 src/3d/poly2tri/common/utils.h
- +38 −0 src/3d/poly2tri/poly2tri.h
- +108 −0 src/3d/poly2tri/sweep/advancing_front.cc
- +118 −0 src/3d/poly2tri/sweep/advancing_front.h
- +71 −0 src/3d/poly2tri/sweep/cdt.cc
- +105 −0 src/3d/poly2tri/sweep/cdt.h
- +793 −0 src/3d/poly2tri/sweep/sweep.cc
- +285 −0 src/3d/poly2tri/sweep/sweep.h
- +211 −0 src/3d/poly2tri/sweep/sweep_context.cc
- +186 −0 src/3d/poly2tri/sweep/sweep_context.h
- +75 −0 src/3d/polygonentity.cpp
- +23 −0 src/3d/polygonentity.h
- +83 −0 src/3d/polygongeometry.cpp
- +32 −0 src/3d/polygongeometry.h
- +367 −0 src/3d/quantizedmeshgeometry.cpp
- +73 −0 src/3d/quantizedmeshgeometry.h
- +143 −0 src/3d/quantizedmeshterraingenerator.cpp
- +27 −0 src/3d/quantizedmeshterraingenerator.h
- +176 −0 src/3d/scene.cpp
- +51 −0 src/3d/scene.h
- +28 −0 src/3d/terrain.cpp
- +34 −0 src/3d/terrain.h
- +122 −0 src/3d/terrainboundsentity.cpp
- +21 −0 src/3d/terrainboundsentity.h
- +70 −0 src/3d/terrainchunkloader.cpp
- +30 −0 src/3d/terrainchunkloader.h
- +56 −0 src/3d/terraingenerator.cpp
- +75 −0 src/3d/terraingenerator.h
- +171 −0 src/3d/tessellator.cpp
- +29 −0 src/3d/tessellator.h
- +73 −0 src/3d/tilingscheme.cpp
- +37 −0 src/3d/tilingscheme.h
- +65 −0 src/3d/utils.cpp
- +18 −0 src/3d/utils.h
- +4 −0 src/CMakeLists.txt
@@ -0,0 +1,176 @@ | ||
############################################################# | ||
# sources | ||
|
||
SET(QGIS_3D_SRCS | ||
cameracontroller.cpp | ||
chunkedentity.cpp | ||
chunklist.cpp | ||
chunkloader.cpp | ||
chunknode.cpp | ||
demterraingenerator.cpp | ||
demterraintilegeometry.cpp | ||
flatterraingenerator.cpp | ||
lineentity.cpp | ||
map3d.cpp | ||
maptexturegenerator.cpp | ||
maptextureimage.cpp | ||
pointentity.cpp | ||
polygonentity.cpp | ||
polygongeometry.cpp | ||
#quantizedmeshgeometry.cpp | ||
#quantizedmeshterraingenerator.cpp | ||
scene.cpp | ||
terrain.cpp | ||
terrainboundsentity.cpp | ||
terrainchunkloader.cpp | ||
terraingenerator.cpp | ||
tessellator.cpp | ||
tilingscheme.cpp | ||
utils.cpp | ||
|
||
poly2tri/common/shapes.cc | ||
poly2tri/sweep/advancing_front.cc | ||
poly2tri/sweep/cdt.cc | ||
poly2tri/sweep/sweep_context.cc | ||
poly2tri/sweep/sweep.cc | ||
) | ||
|
||
SET(QGIS_3D_MOC_HDRS | ||
cameracontroller.h | ||
chunkedentity.h | ||
demterraingenerator.h | ||
demterraintilegeometry.h | ||
maptexturegenerator.h | ||
maptextureimage.h | ||
scene.h | ||
terrain.h | ||
) | ||
|
||
QT5_WRAP_CPP(QGIS_3D_MOC_SRCS ${QGIS_3D_MOC_HDRS}) | ||
|
||
# install headers | ||
|
||
SET(QGIS_3D_HDRS | ||
aabb.h | ||
cameracontroller.h | ||
chunkedentity.h | ||
chunklist.h | ||
chunkloader.h | ||
chunknode.h | ||
demterraingenerator.h | ||
demterraintilegeometry.h | ||
flatterraingenerator.h | ||
lineentity.h | ||
map3d.h | ||
maptexturegenerator.h | ||
maptextureimage.h | ||
pointentity.h | ||
polygonentity.h | ||
polygongeometry.h | ||
#quantizedmeshgeometry.h | ||
#quantizedmeshterraingenerator.h | ||
scene.h | ||
terrain.h | ||
terrainboundsentity.h | ||
terrainchunkloader.h | ||
terraingenerator.h | ||
tessellator.h | ||
tilingscheme.h | ||
utils.h | ||
) | ||
|
||
INCLUDE_DIRECTORIES( | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
${CMAKE_SOURCE_DIR}/src/core/ | ||
${CMAKE_SOURCE_DIR}/src/core/geometry | ||
${CMAKE_SOURCE_DIR}/src/core/raster | ||
${CMAKE_SOURCE_DIR}/src/core/symbology-ng | ||
${CMAKE_SOURCE_DIR}/src/core/metadata | ||
${CMAKE_SOURCE_DIR}/src/core/expression | ||
${CMAKE_BINARY_DIR}/src/core | ||
${CMAKE_BINARY_DIR}/src/3d | ||
) | ||
INCLUDE_DIRECTORIES(SYSTEM | ||
${PROJ_INCLUDE_DIR} | ||
${GEOS_INCLUDE_DIR} | ||
${GDAL_INCLUDE_DIR} | ||
${SQLITE3_INCLUDE_DIR} | ||
) | ||
|
||
############################################################# | ||
# qgis_3d library | ||
|
||
ADD_LIBRARY(qgis_3d SHARED ${QGIS_3D_SRCS} ${QGIS_3D_MOC_SRCS} ${QGIS_3D_HDRS}) | ||
|
||
qt5_use_modules(qgis_3d 3DCore 3DRender 3DInput 3DLogic 3DExtras) | ||
|
||
GENERATE_EXPORT_HEADER( | ||
qgis_3d | ||
BASE_NAME 3D | ||
EXPORT_FILE_NAME qgis_3d.h | ||
) | ||
IF(MSVC) | ||
SET_TARGET_PROPERTIES(qgis_3d PROPERTIES LINK_FLAGS "/FORCE:MULTIPLE") | ||
ENDIF(MSVC) | ||
|
||
SET(QGIS_3D_HDRS ${QGIS_3D_HDRS} ${CMAKE_CURRENT_BINARY_DIR}/qgis_3d.h) | ||
|
||
IF(NOT APPLE) | ||
INSTALL(FILES ${QGIS_3D_HDRS} DESTINATION ${QGIS_INCLUDE_DIR}) | ||
ELSE(NOT APPLE) | ||
SET_TARGET_PROPERTIES(qgis_3d PROPERTIES | ||
# no moc headers, messes up PROPERTIES syntax | ||
CLEAN_DIRECT_OUTPUT 1 | ||
FRAMEWORK 1 | ||
FRAMEWORK_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}" | ||
MACOSX_FRAMEWORK_INFO_PLIST "${CMAKE_SOURCE_DIR}/mac/framework.info.plist.in" | ||
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${COMPLETE_VERSION} | ||
MACOSX_FRAMEWORK_IDENTIFIER org.qgis.qgis3_3d | ||
BUILD_WITH_INSTALL_RPATH TRUE | ||
PUBLIC_HEADER "${QGIS_3D_HDRS}" | ||
LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}" | ||
) | ||
# generated export header does not get copied with PUBLIC_HEADER files | ||
ADD_CUSTOM_COMMAND(TARGET qgis_3d | ||
POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy qgis_3d.h | ||
"${QGIS_OUTPUT_DIRECTORY}/${QGIS_LIB_SUBDIR}/qgis_3d.framework/Headers" | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
DEPENDS qgis_3d.h | ||
) | ||
ENDIF(NOT APPLE) | ||
|
||
#generate unversioned libs for android | ||
IF (NOT ANDROID) | ||
SET_TARGET_PROPERTIES(qgis_3d PROPERTIES | ||
VERSION ${COMPLETE_VERSION} | ||
SOVERSION ${COMPLETE_VERSION} | ||
) | ||
ENDIF (NOT ANDROID) | ||
|
||
TARGET_LINK_LIBRARIES(qgis_3d qgis_core) | ||
|
||
# clang-tidy | ||
IF(CLANG_TIDY_EXE) | ||
SET_TARGET_PROPERTIES( | ||
qgis_3d PROPERTIES | ||
CXX_CLANG_TIDY "${DO_CLANG_TIDY}" | ||
) | ||
ENDIF(CLANG_TIDY_EXE) | ||
|
||
# install | ||
|
||
INSTALL(TARGETS qgis_3d | ||
RUNTIME DESTINATION ${QGIS_BIN_DIR} | ||
LIBRARY DESTINATION ${QGIS_LIB_DIR} | ||
ARCHIVE DESTINATION ${QGIS_LIB_DIR} | ||
FRAMEWORK DESTINATION ${QGIS_FW_SUBDIR} | ||
PUBLIC_HEADER DESTINATION ${QGIS_INCLUDE_DIR}) | ||
|
||
# Mac dev frameworks | ||
|
||
IF (APPLE AND QGIS_MACAPP_INSTALL_DEV) | ||
INSTALL(TARGETS qgis_3d FRAMEWORK DESTINATION ${QGIS_MACAPP_DEV_PREFIX}) | ||
INSTALL(CODE "EXECUTE_PROCESS(COMMAND install_name_tool -id \"${QGIS_MACAPP_DEV_PREFIX}/qgis_3d.framework/Versions/${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}/qgis_3d\" \"$ENV{DESTDIR}${QGIS_MACAPP_DEV_PREFIX}/qgis_3d.framework/qgis_3d\")") | ||
INSTALL(CODE "EXECUTE_PROCESS(COMMAND install_name_tool -change \"${CMAKE_INSTALL_NAME_DIR}/qgis_core.framework/Versions/${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}/qgis_core\" \"${QGIS_MACAPP_DEV_PREFIX}/qgis_core.framework/Versions/${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}/qgis_core\" \"$ENV{DESTDIR}${QGIS_MACAPP_DEV_PREFIX}/qgis_3d.framework/qgis_3d\")") | ||
ENDIF (APPLE AND QGIS_MACAPP_INSTALL_DEV) |
@@ -0,0 +1,103 @@ | ||
#ifndef AABB_H | ||
#define AABB_H | ||
|
||
#include <math.h> | ||
#include <QList> | ||
#include <QVector3D> | ||
|
||
//! axis-aligned bounding box - in world coords | ||
class AABB | ||
{ | ||
public: | ||
AABB() | ||
: xMin( 0 ), yMin( 0 ), zMin( 0 ), xMax( 0 ), yMax( 0 ), zMax( 0 ) | ||
{ | ||
} | ||
|
||
AABB( float xMin, float yMin, float zMin, float xMax, float yMax, float zMax ) | ||
: xMin( xMin ), yMin( yMin ), zMin( zMin ), xMax( xMax ), yMax( yMax ), zMax( zMax ) | ||
{ | ||
// normalize coords | ||
if ( this->xMax < this->xMin ) | ||
qSwap( this->xMin, this->xMax ); | ||
if ( this->yMax < this->yMin ) | ||
qSwap( this->yMin, this->yMax ); | ||
if ( this->zMax < this->zMin ) | ||
qSwap( this->zMin, this->zMax ); | ||
} | ||
|
||
float xExtent() const { return xMax - xMin; } | ||
float yExtent() const { return yMax - yMin; } | ||
float zExtent() const { return zMax - zMin; } | ||
|
||
float xCenter() const { return ( xMax + xMin ) / 2; } | ||
float yCenter() const { return ( yMax + yMin ) / 2; } | ||
float zCenter() const { return ( zMax + zMin ) / 2; } | ||
|
||
QVector3D center() const { return QVector3D( xCenter(), yCenter(), zCenter() ); } | ||
|
||
bool intersects( const AABB &other ) const | ||
{ | ||
return xMin < other.xMax && other.xMin < xMax && | ||
yMin < other.yMax && other.yMin < yMax && | ||
zMin < other.zMax && other.zMin < zMax; | ||
} | ||
|
||
bool intersects( float x, float y, float z ) const | ||
{ | ||
return xMin <= x && xMax >= x && | ||
yMin <= y && yMax >= y && | ||
zMin <= z && zMax >= z; | ||
} | ||
|
||
float distanceFromPoint( float x, float y, float z ) const | ||
{ | ||
float dx = qMax( xMin - x, qMax( 0.f, x - xMax ) ); | ||
float dy = qMax( yMin - y, qMax( 0.f, y - yMax ) ); | ||
float dz = qMax( zMin - z, qMax( 0.f, z - zMax ) ); | ||
return sqrt( dx * dx + dy * dy + dz * dz ); | ||
} | ||
|
||
float distanceFromPoint( const QVector3D &v ) const | ||
{ | ||
return distanceFromPoint( v.x(), v.y(), v.z() ); | ||
} | ||
|
||
QList<QVector3D> verticesForLines() const | ||
{ | ||
QList<QVector3D> vertices; | ||
for ( int i = 0; i < 2; ++i ) | ||
{ | ||
float x = i ? xMax : xMin; | ||
for ( int j = 0; j < 2; ++j ) | ||
{ | ||
float y = j ? yMax : yMin; | ||
for ( int k = 0; k < 2; ++k ) | ||
{ | ||
float z = k ? zMax : zMin; | ||
if ( i == 0 ) | ||
{ | ||
vertices.append( QVector3D( xMin, y, z ) ); | ||
vertices.append( QVector3D( xMax, y, z ) ); | ||
} | ||
if ( j == 0 ) | ||
{ | ||
vertices.append( QVector3D( x, yMin, z ) ); | ||
vertices.append( QVector3D( x, yMax, z ) ); | ||
} | ||
if ( k == 0 ) | ||
{ | ||
vertices.append( QVector3D( x, y, zMin ) ); | ||
vertices.append( QVector3D( x, y, zMax ) ); | ||
} | ||
} | ||
} | ||
} | ||
return vertices; | ||
} | ||
|
||
float xMin, yMin, zMin; | ||
float xMax, yMax, zMax; | ||
}; | ||
|
||
#endif // AABB_H |
Oops, something went wrong.