Compare commits
30 Commits
main
...
8d60355ccf
| Author | SHA1 | Date | |
|---|---|---|---|
| 8d60355ccf | |||
| 0551b4f91f | |||
| ecae09f82d | |||
| e68d384340 | |||
| e2c7f5ba75 | |||
| f1d9a07940 | |||
| f5a38892b1 | |||
| d230662924 | |||
| 97bf086a87 | |||
| e97ccd8195 | |||
| 728710ece2 | |||
| 40119856de | |||
| de9ef4c948 | |||
| b252922b0a | |||
| 12883e8c20 | |||
| bdd178d0f2 | |||
| 9bd09b2bb0 | |||
| 0d2a73a35f | |||
| ea25ba312a | |||
| 78639cf1c2 | |||
| 941f2d228c | |||
| 16baf6cdaf | |||
| c86a7744b3 | |||
| 7fac6bafb4 | |||
| 1bed9545c9 | |||
| 32641acd8d | |||
| 68bfff7bcd | |||
| 92e5937cc7 | |||
| 1e1c328a5a | |||
| dcbeb26738 |
24
.github/workflows/build.yml
vendored
@@ -43,16 +43,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
version: ${{ env.QT_VERSION }}
|
version: ${{ env.QT_VERSION }}
|
||||||
|
|
||||||
- name: Install pkgconfiglite
|
# Windows
|
||||||
|
|
||||||
|
- name: Chocolatey Action
|
||||||
if: matrix.os == 'windows-latest'
|
if: matrix.os == 'windows-latest'
|
||||||
uses: crazy-max/ghaction-chocolatey@v2
|
uses: crazy-max/ghaction-chocolatey@v2
|
||||||
with:
|
with:
|
||||||
args: install pkgconfiglite --checksum e87b5ea3c9142256af60f2d5b917aa63b571e6a0 --checksum-type sha1
|
args: install pkgconfiglite --checksum e87b5ea3c9142256af60f2d5b917aa63b571e6a0 --checksum-type sha1
|
||||||
- name: Install nsis
|
|
||||||
if: matrix.os == 'windows-latest'
|
|
||||||
uses: crazy-max/ghaction-chocolatey@v2
|
|
||||||
with:
|
|
||||||
args: install nsis
|
|
||||||
|
|
||||||
- name: Install Debian packaging dependencies
|
- name: Install Debian packaging dependencies
|
||||||
if: matrix.os == 'ubuntu-latest'
|
if: matrix.os == 'ubuntu-latest'
|
||||||
@@ -194,11 +191,6 @@ jobs:
|
|||||||
uses: crazy-max/ghaction-chocolatey@v2
|
uses: crazy-max/ghaction-chocolatey@v2
|
||||||
with:
|
with:
|
||||||
args: install pkgconfiglite --checksum e87b5ea3c9142256af60f2d5b917aa63b571e6a0 --checksum-type sha1
|
args: install pkgconfiglite --checksum e87b5ea3c9142256af60f2d5b917aa63b571e6a0 --checksum-type sha1
|
||||||
- name: Install nsis
|
|
||||||
if: matrix.os == 'windows-latest'
|
|
||||||
uses: crazy-max/ghaction-chocolatey@v2
|
|
||||||
with:
|
|
||||||
args: install nsis
|
|
||||||
|
|
||||||
- name: Configure Qtk Library
|
- name: Configure Qtk Library
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -206,13 +198,13 @@ jobs:
|
|||||||
|
|
||||||
- name: Build Qtk Library
|
- name: Build Qtk Library
|
||||||
shell: bash
|
shell: bash
|
||||||
run: cmake --build build/ --config Release --target qtk -- ${{ matrix.flags }}
|
run: cmake --build build/ --config Release --target qtk_library -- ${{ matrix.flags }}
|
||||||
|
|
||||||
# Packaging
|
# Packaging
|
||||||
|
|
||||||
- name: Install Qtk Library
|
- name: Install Qtk Library
|
||||||
shell: bash
|
shell: bash
|
||||||
run: cmake --install build/ --config Release --prefix=$(pwd)/install --component qtk
|
run: cmake --install build/ --config Release --prefix=$(pwd)/install --component qtk_library
|
||||||
|
|
||||||
- name: Package Qtk Library
|
- name: Package Qtk Library
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -371,12 +363,13 @@ jobs:
|
|||||||
|
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.event.workflow_run.head_branch, 'v')
|
||||||
needs: [Qtk, Qtk-Library, Qtk-Plugins]
|
needs: [Qtk, Qtk-Library, Qtk-Plugins]
|
||||||
steps:
|
steps:
|
||||||
- name: Download Installer Artifact
|
- name: Download Installer Artifact
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
name: Qtk Packages
|
||||||
path: |
|
path: |
|
||||||
build/packages/*
|
build/packages/*
|
||||||
install/*
|
install/*
|
||||||
@@ -385,7 +378,8 @@ jobs:
|
|||||||
id: create_release
|
id: create_release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
name: Qtk ${{ github.ref_name }}
|
tag_name: ${{ github.event.workflow_run.head_branch }}
|
||||||
|
name: Qtk ${{ github.event.workflow_run.head_branch }}
|
||||||
draft: true
|
draft: true
|
||||||
prerelease: false
|
prerelease: false
|
||||||
generate_release_notes: true
|
generate_release_notes: true
|
||||||
|
|||||||
14
.github/workflows/linting.yml
vendored
@@ -39,7 +39,7 @@ jobs:
|
|||||||
# Check the entire repo for source files to tidy
|
# Check the entire repo for source files to tidy
|
||||||
files-changed-only: false
|
files-changed-only: false
|
||||||
# Ignore qtk build and external assimp directories
|
# Ignore qtk build and external assimp directories
|
||||||
ignore: '.github|build|extern'
|
ignore: '.github|build|extern/assimp/assimp'
|
||||||
# Point to compile_commands.json produced by build
|
# Point to compile_commands.json produced by build
|
||||||
database: 'build'
|
database: 'build'
|
||||||
# Use thread comments as feedback
|
# Use thread comments as feedback
|
||||||
@@ -61,12 +61,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: cpp-linter/cpp-linter-action@v2
|
- name: clang-format Check
|
||||||
|
uses: jidicula/clang-format-action@v4.9.0
|
||||||
with:
|
with:
|
||||||
version: '18'
|
clang-format-version: '18'
|
||||||
style: 'file'
|
check-path: ${{ matrix.path }}
|
||||||
tidy-checks: ''
|
|
||||||
files-changed-only: false
|
|
||||||
ignore: '.github|build|extern'
|
|
||||||
extensions: 'cpp,h'
|
|
||||||
files: ${{ matrix.path }}
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
## Project for working with OpenGL and Qt6 widgets ##
|
## Project for working with OpenGL and Qt6 widgets ##
|
||||||
## ##
|
## ##
|
||||||
## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ##
|
## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ##
|
||||||
## All Content (c) 2025 Shaun Reed, all rights reserved ##
|
## All Content (c) 2023 Shaun Reed, all rights reserved ##
|
||||||
################################################################################
|
################################################################################
|
||||||
cmake_minimum_required(VERSION 3.28)
|
cmake_minimum_required(VERSION 3.23)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Constants
|
# Constants
|
||||||
@@ -18,7 +18,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
set(CMAKE_MACOSX_BUNDLE ON)
|
set(CMAKE_MACOSX_BUNDLE ON)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
set(CMAKE_AUTORCC_OPTIONS --binary)
|
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)
|
set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)
|
||||||
@@ -31,7 +30,7 @@ add_compile_options(-fPIC)
|
|||||||
################################################################################
|
################################################################################
|
||||||
project(
|
project(
|
||||||
#[[NAME]] Qtk
|
#[[NAME]] Qtk
|
||||||
VERSION 0.3
|
VERSION 0.2
|
||||||
DESCRIPTION "Qt OpenGL library and desktop application."
|
DESCRIPTION "Qt OpenGL library and desktop application."
|
||||||
LANGUAGES CXX C
|
LANGUAGES CXX C
|
||||||
)
|
)
|
||||||
@@ -48,10 +47,18 @@ include(GNUInstallDirs)
|
|||||||
################################################################################
|
################################################################################
|
||||||
option(QTK_DEBUG "Enable debugger" OFF)
|
option(QTK_DEBUG "Enable debugger" OFF)
|
||||||
option(QTK_SUBMODULES "Update external project (assimp) submodule" OFF)
|
option(QTK_SUBMODULES "Update external project (assimp) submodule" OFF)
|
||||||
|
option(QTK_GUI "Build the Qtk desktop application" ON)
|
||||||
|
option(QTK_PLUGINS "Install Qtk plugins to Qt Creator path." OFF)
|
||||||
option(QTK_EXAMPLE "Build the Qtk example desktop application" ON)
|
option(QTK_EXAMPLE "Build the Qtk example desktop application" ON)
|
||||||
option(QTK_CCACHE "Enable ccache" ON)
|
option(QTK_CCACHE "Enable ccache" ON)
|
||||||
|
|
||||||
|
if (QTK_CCACHE)
|
||||||
|
set(CMAKE_CXX_COMPILER_LAUNCHER ccache)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Install Qtk for use within Qt Creator projects only, instead of system-wide.
|
# Install Qtk for use within Qt Creator projects only, instead of system-wide.
|
||||||
option(QTK_PREFIX_QTCREATOR "Install Qtk to Qt Creator. Untested." OFF)
|
option(QTK_PREFIX_QTCREATOR "Install Qtk to Qt Creator. Untested." OFF)
|
||||||
|
|
||||||
# Option for bringing your own assimp installation; Otherwise not needed
|
# Option for bringing your own assimp installation; Otherwise not needed
|
||||||
# + If assimp is available system-wide we can just set QTK_SUBMODULES OFF
|
# + If assimp is available system-wide we can just set QTK_SUBMODULES OFF
|
||||||
option(
|
option(
|
||||||
@@ -60,18 +67,6 @@ option(
|
|||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
|
|
||||||
# Qtk Component Options
|
|
||||||
option(QTK_PLUGINS "Install Qtk plugins to Qt Designer path." OFF)
|
|
||||||
# Options for qtk_gui
|
|
||||||
option(QTK_GUI "Build the Qtk desktop application" ON)
|
|
||||||
option(QTK_GUI_SCENE
|
|
||||||
"Fetch model resources and build the GUI with an example scene." OFF
|
|
||||||
)
|
|
||||||
|
|
||||||
if (QTK_CCACHE)
|
|
||||||
set(CMAKE_CXX_COMPILER_LAUNCHER ccache)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(QTK_DEBUG OR CMAKE_BUILD_TYPE MATCHES "^[Dd][Ee][Bb][Uu][Gg]$")
|
if(QTK_DEBUG OR CMAKE_BUILD_TYPE MATCHES "^[Dd][Ee][Bb][Uu][Gg]$")
|
||||||
set(QTK_DEBUG ON)
|
set(QTK_DEBUG ON)
|
||||||
set(CMAKE_BUILD_TYPE Debug)
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
@@ -84,7 +79,7 @@ endif()
|
|||||||
set(QT_INSTALL_DIR "$ENV{HOME}/Qt/6.5.0/gcc_64/lib/cmake" CACHE PATH "Path to Qt6 install.")
|
set(QT_INSTALL_DIR "$ENV{HOME}/Qt/6.5.0/gcc_64/lib/cmake" CACHE PATH "Path to Qt6 install.")
|
||||||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||||
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install")
|
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install")
|
||||||
endif()
|
endif ()
|
||||||
|
|
||||||
set(QTK_RESOURCES "${CMAKE_SOURCE_DIR}/resources")
|
set(QTK_RESOURCES "${CMAKE_SOURCE_DIR}/resources")
|
||||||
set(QTK_OSX_ICONS ${CMAKE_SOURCE_DIR}/resources/icons/osx/kilroy.icns)
|
set(QTK_OSX_ICONS ${CMAKE_SOURCE_DIR}/resources/icons/osx/kilroy.icns)
|
||||||
@@ -157,15 +152,8 @@ list(APPEND VAR_NAMES QT6_INSTALL_PLUGINS)
|
|||||||
|
|
||||||
# Find Assimp.
|
# Find Assimp.
|
||||||
if(QTK_SUBMODULES)
|
if(QTK_SUBMODULES)
|
||||||
if(APPLE)
|
# Required to statically link.
|
||||||
# Avoid zlib redefining fdopen, causing build failures in apple clang.
|
add_compile_options(-fPIC)
|
||||||
# https://github.com/assimp/assimp/issues/6118
|
|
||||||
add_compile_definitions(-Dfdopen=fdopen)
|
|
||||||
endif()
|
|
||||||
if(NOT WIN32)
|
|
||||||
# Required to statically link.
|
|
||||||
add_compile_options(-fPIC)
|
|
||||||
endif()
|
|
||||||
set(BUILD_SHARED_LIBS OFF CACHE STRING "Build static assimp libs" FORCE)
|
set(BUILD_SHARED_LIBS OFF CACHE STRING "Build static assimp libs" FORCE)
|
||||||
set(ASSIMP_BUILD_ZLIB ON CACHE STRING "Build Zlib with assimp." FORCE)
|
set(ASSIMP_BUILD_ZLIB ON CACHE STRING "Build Zlib with assimp." FORCE)
|
||||||
set(
|
set(
|
||||||
@@ -182,14 +170,6 @@ if(QTK_SUBMODULES)
|
|||||||
"${CMAKE_CURRENT_SOURCE_DIR}/extern/assimp/assimp/"
|
"${CMAKE_CURRENT_SOURCE_DIR}/extern/assimp/assimp/"
|
||||||
EXCLUDE_FROM_ALL
|
EXCLUDE_FROM_ALL
|
||||||
)
|
)
|
||||||
install(
|
|
||||||
TARGETS assimp zlibstatic
|
|
||||||
EXPORT qtk_export
|
|
||||||
COMPONENT qtk
|
|
||||||
ARCHIVE DESTINATION lib
|
|
||||||
LIBRARY DESTINATION lib
|
|
||||||
RUNTIME DESTINATION bin
|
|
||||||
)
|
|
||||||
else()
|
else()
|
||||||
find_package(assimp REQUIRED)
|
find_package(assimp REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
@@ -204,8 +184,8 @@ endif()
|
|||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
if(QTK_EXAMPLE)
|
if(QTK_EXAMPLE)
|
||||||
# Create a namespaced alias for linking with libqtk in the example.
|
# Create a namespaced alias for linking with qtk_library in the example.
|
||||||
add_library(${PROJECT_NAME}::qtk ALIAS qtk)
|
add_library(${PROJECT_NAME}::qtk_library ALIAS qtk_library)
|
||||||
add_subdirectory(example-app EXCLUDE_FROM_ALL)
|
add_subdirectory(example-app EXCLUDE_FROM_ALL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -220,25 +200,3 @@ foreach(VAR_NAME IN LISTS VAR_NAMES VAR_PATHS)
|
|||||||
message(STATUS "[Qtk] ${VAR_NAME}=${${VAR_NAME}}")
|
message(STATUS "[Qtk] ${VAR_NAME}=${${VAR_NAME}}")
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
message(STATUS "[Qtk] Installation prefix: ${CMAKE_INSTALL_PREFIX}")
|
|
||||||
message(STATUS "[Qtk] Found Qt6: ${Qt6Core_VERSION}")
|
|
||||||
|
|
||||||
# qt_generate_deploy_app_script is supported on Linux in QtCore >= 6.5.0.
|
|
||||||
# qt_generate_deploy_app_script supports Windows and OSX in QtCore >= 6.3.
|
|
||||||
# https://doc.qt.io/qt-6.5/qt-generate-deploy-app-script.html
|
|
||||||
# https://doc.qt.io/archives/qt-6.4/qt-generate-deploy-app-script.html
|
|
||||||
# The application can still build and run, we just can't install.
|
|
||||||
if(QTK_GUI OR QTK_EXAMPLE)
|
|
||||||
if(UNIX AND NOT APPLE)
|
|
||||||
# Ubuntu 24.04 provides QtCore 6.4.2 in qt-base-dev.
|
|
||||||
# This version of qt_generate_deploy_app_script does not support Linux.
|
|
||||||
if (Qt6_VERSION VERSION_LESS "6.5.0")
|
|
||||||
message(WARNING "[Qtk] Installation is only supported on Qt >=6.5.\n")
|
|
||||||
endif()
|
|
||||||
elseif(APPLE OR WIN32)
|
|
||||||
# Predates qt_generate_deploy_app_script.
|
|
||||||
if (Qt6_VERSION VERSION_LESS "6.3.0")
|
|
||||||
message(WARNING "[Qtk] Installation is only supported on Qt >=6.5.\n")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|||||||
194
README.md
@@ -1,18 +1,13 @@
|
|||||||
# Qtk
|
# Qtk
|
||||||
|
|
||||||
[](https://github.com/shaunrd0/qtk/actions/workflows/build.yml)
|
[](https://github.com/shaunrd0/qtk/actions/workflows/all-builds.yml)
|
||||||
[](https://github.com/shaunrd0/qtk/actions/workflows/linting.yml)
|
[](https://github.com/shaunrd0/qtk/actions/workflows/linting.yml)
|
||||||
|
|
||||||
|
Qtk is a Qt OpenGL graphics library that wraps some QOpenGL functionality in convenience classes
|
||||||
|
that allow rendering geometry in 2D and 3D using custom GLSL shader programs.
|
||||||
|
|
||||||
The Qtk desktop application provides a model loader using [Assimp](https://assimp.org/) within a Qt widget application.
|
The Qtk desktop application provides a model loader using [Assimp](https://assimp.org/) within a Qt widget application.
|
||||||
You can fly around the scene using WASD while holding down the left or right mouse button.
|
You can fly around the scene using WASD while holding down the left or right mouse button.
|
||||||
[QtkWidget](./src/designer-plugins/qtkwidget.h) is the primary QOpenGLWidget used to render the scene and handle input.
|
|
||||||
|
|
||||||
The underlying shared library [libqtk](./src/qtk) wraps QOpenGL objects in convenience classes that leverage
|
|
||||||
lower-level OpenGL APIs to handle the rendering process manually. Many of these classes offer
|
|
||||||
ways to expand the low-level OpenGL logic within a Qt application without having to set up much scaffolding.
|
|
||||||
|
|
||||||
The Qtk GUI is built using custom [Qt Designer plugins](https://doc.qt.io/qt-6/designer-creating-custom-widgets.html). These can be installed to Qt Designer for
|
|
||||||
use in other Qt applications, or built exclusively for Qtk. See [Build Options](#build-options) for more details.
|
|
||||||
|
|
||||||
Object names can be double-clicked in the tree view panel for quick camera navigation.
|
Object names can be double-clicked in the tree view panel for quick camera navigation.
|
||||||
Properties of the object, like shader code and translation / scale, can be viewed and modified in the side panel.
|
Properties of the object, like shader code and translation / scale, can be viewed and modified in the side panel.
|
||||||
@@ -29,13 +24,7 @@ detached from the main window in this way.
|
|||||||
The small triangles floating near 3D models represent the light source being used for the shader.
|
The small triangles floating near 3D models represent the light source being used for the shader.
|
||||||
These appear on models using phong, specular, and diffuse lighting techniques.
|
These appear on models using phong, specular, and diffuse lighting techniques.
|
||||||
|
|
||||||
The example scene contains basic examples like texture mapping to make a crate from simple cube geometry.
|
The default scene contains basic examples like texture mapping to make a crate from basic cube geometry
|
||||||
This scene is used in the following screenshots, and can be built locally by enabling
|
|
||||||
the `QTK_GUI_SCENE` [Build Option](#build-options) described below. Because this scene
|
|
||||||
uses large 3D model resources, this option is disabled by default.
|
|
||||||
|
|
||||||
The default scene with this option disabled is empty, but comes with a default skybox.
|
|
||||||
Models can be added to the scene by clicking and dragging an `.obj` into the scene view.
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -60,99 +49,43 @@ Key features that are planned:
|
|||||||
- [x] Runtime loading of `.obj` or similar 3D models.
|
- [x] Runtime loading of `.obj` or similar 3D models.
|
||||||
- [x] Drag-and-drop interaction for adding objects to the scene.
|
- [x] Drag-and-drop interaction for adding objects to the scene.
|
||||||
- [x] Shader / object properties panel to modify related settings.
|
- [x] Shader / object properties panel to modify related settings.
|
||||||
- [x] Reduce size of application resources and git references.
|
|
||||||
- [ ] Runtime reloading of modified GLSL shaders attached to objects within scenes.
|
- [ ] Runtime reloading of modified GLSL shaders attached to objects within scenes.
|
||||||
- [ ] Multiple views of a scene at one time.
|
- [ ] Multiple views of a scene at one time.
|
||||||
- [ ] Camera control modes such as panning, orbiting, or following objects.
|
- [ ] Camera control modes such as panning, orbiting, or following objects.
|
||||||
- [ ] Save / load scene data. The current model requires writing C++ code.
|
- [ ] Save / load scene data. The current model requires writing C++ code.
|
||||||
- [ ] Basic text editor for quickly modifying shaders attached to objects.
|
- [ ] Basic text editor for quickly modifying shaders attached to objects.
|
||||||
|
- [ ] Reduce size of application resources and git references.
|
||||||
|
|
||||||
For examples of using libqtk, see the [example-app](./example-app)
|
For examples of using the Qtk API, see the `example-app` project in the root of
|
||||||
project in the root of this repository.
|
this repository.
|
||||||
|
|
||||||
To get textures loading on models look
|
To get textures loading on models look
|
||||||
into [material files](http://www.paulbourke.net/dataformats/mtl/)
|
into [material files](http://www.paulbourke.net/dataformats/mtl/)
|
||||||
and see some examples at [qtk-resources/resources/models](https://git.shaunreed.com/shaunrd0/qtk-resources/src/branch/master/models).
|
and see some examples in the `resources/models/` directory.
|
||||||
|
|
||||||
### Source Builds
|
### Source Builds
|
||||||
|
|
||||||
Qtk was developed and tested using CLion
|
Qtk was developed and tested using CLion
|
||||||
and [Qt Creator](https://github.com/qt-creator/qt-creator).
|
and [Qt Creator](https://github.com/qt-creator/qt-creator).
|
||||||
Simply open the root `CMakeLists.txt` with either of these editors and default
|
Simply open the root `CMakeLists.txt` with either of these editors and
|
||||||
configurations will be loaded. To simplify providing Qt to the build, Qt Creator
|
configurations will be loaded.
|
||||||
is the recommended option.
|
|
||||||
|
|
||||||
If you have manually installed [Qt6 Open Source Binaries](https://www.qt.io/download-qt-installer)
|
This project has been ported to **Qt 6.6.0**, which is not yet available in
|
||||||
for your system, be sure to correctly set your `CMAKE_PREFIX_PATH` in the next steps.
|
Ubuntu apt repositories.
|
||||||
On Ubuntu 24.04 the default installation directory to use for this path using Qt 6.5.0 is `$HOME/Qt/6.5.0/gcc_64/lib/cmake`.
|
To run this project, you will *need* to
|
||||||
|
install [Qt6 Open Source Binaries](https://www.qt.io/download-qt-installer) for
|
||||||
The Ubuntu apt repositories contain all the packages we need to build all targets.
|
your system, **version 6.6.0** or later.
|
||||||
To build Qtk desktop application with the scene in the screenshots below run the following commands.
|
Be sure to take note of the Qt6 installation directory, as we will need it to
|
||||||
|
correctly set our `CMAKE_PREFIX_PATH` in the next steps.
|
||||||
```bash
|
|
||||||
sudo apt update && sudo apt install cmake build-essential git ccache libxkbcommon-dev libassimp-dev qt6-base-dev qt6-tools-dev zlib1g-dev
|
|
||||||
cmake -DQTK_GUI_SCENE=ON -B build
|
|
||||||
cmake --build build
|
|
||||||
./build/bin/qtk_gui
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Build Options
|
|
||||||
|
|
||||||
Qtk is composed of three separate components.
|
|
||||||
|
|
||||||
* The shared library [libqtk](./src/qtk) provides classes that leverage QOpenGL functionality
|
|
||||||
while still using lower-level OpenGL APIs to customize the rendering process.
|
|
||||||
Many of these classes can be further expanded, such as [Qtk::Scene](./src/qtk/scene.h).
|
|
||||||
This taget, `qtk` in cmake, is always selected to build and install as
|
|
||||||
it is required by all other components in this project.
|
|
||||||
* The [Qtk desktop application](./src/app) is built using libqtk within a Qt application.
|
|
||||||
This target, `qtk_gui` in cmake, is optional and can be controlled using the `QTK_GUI` option below.
|
|
||||||
* The GUI for the Qtk desktop application is constructed using a [custom set of Qt Designer widget plugins](./src/designer-plugins) that are also built using libqtk.
|
|
||||||
If `QTK_GUI` is disabled this target (`qtk_plugins`) is optional and can be controlled using the `QTK_PLUGINS` options below.
|
|
||||||
|
|
||||||
|
|
||||||
| Name | Description | Default |
|
|
||||||
|--------------------------|--------------------------------------------------------------|:--------|
|
|
||||||
| QTK_DEBUG | Enable debug mode. | OFF |
|
|
||||||
| QTK_SUBMODULES | Use git submodules to fetch assimp dependency. | OFF |
|
|
||||||
| QTK_EXAMPLE | Build the libqtk example desktop application. | ON |
|
|
||||||
| QTK_CCACHE | Enable CCACHE. | ON |
|
|
||||||
| QTK_ASSIMP_NEW_INTERFACE | Use the assimp::assimp interface. Recommended for WIN / OSX. | OFF |
|
|
||||||
| QTK_PLUGINS* | Install Qtk plugins to Qt Designer. | OFF |
|
|
||||||
| QTK_GUI | Build and install Qtk desktop application. | ON |
|
|
||||||
| QTK_GUI_SCENE | Fetch external 3D model resources for example scene. | OFF |
|
|
||||||
|
|
||||||
*The Qtk plugins are always built if `QTK_GUI` is enabled. Disabling this option
|
|
||||||
with QTK_GUI set will not mark the plugins for installation if we do
|
|
||||||
`cmake --install build/` without selecting a component. If both `QTK_GUI` and
|
|
||||||
`QTK_PLUGINS` are unset, neither will be built.
|
|
||||||
|
|
||||||
If you are building on **Windows / Mac**, consider setting
|
If you are building on **Windows / Mac**, consider setting
|
||||||
the `-DQTK_ASSIMP_NEW_INTERFACE` cmake build option.
|
the `-DQTK_ASSIMP_NEW_INTERFACE` cmake build option.
|
||||||
|
|
||||||
By default, the build will not initialize Assimp as a git submodule and build
|
If the build is configured with all options enabled, we can subsequently install
|
||||||
from source.
|
individual components as needed with cmake.
|
||||||
We can turn this on by setting the `-DQTK_SUBMODULES=ON` flag when running
|
|
||||||
CMake.
|
|
||||||
Building using this option will fetch and build Assimp for us, but builds will
|
|
||||||
take longer as a result.
|
|
||||||
Using `-DQTK_SUBMODULES=ON` supports providing assimp on cross-platform builds (
|
|
||||||
Windows / Mac / Linux) and may be easier to configure.
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cmake -B build-all -DQTK_GUI=ON -DQTK_PLUGINS=ON -DQTK_EXAMPLE=ON -DQTK_SUBMODULES=ON -DCMAKE_PREFIX_PATH=$HOME/Qt/6.6.0/gcc_64
|
sudo apt update -y && sudo apt install libassimp-dev cmake build-essential git ccache libgl1-mesa-dev libglvnd-dev zlib1g-dev -y
|
||||||
```
|
|
||||||
|
|
||||||
#### Qtk Components
|
|
||||||
|
|
||||||
As described in [Build Options](#build-options), Qtk is composed of three separate components.
|
|
||||||
Each component can be individually selected for building or installation.
|
|
||||||
|
|
||||||
For this example we will configure the build with all options enabled.
|
|
||||||
In the separate sections below we can install individual components with cmake.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo apt update -y && sudo apt install cmake build-essential git ccache libxkbcommon-dev libassimp-dev qt6-base-dev qt6-tools-dev -y
|
|
||||||
git clone https://github.com/shaunrd0/qtk
|
git clone https://github.com/shaunrd0/qtk
|
||||||
cd qtk
|
cd qtk
|
||||||
# Configure the build with all components enabled
|
# Configure the build with all components enabled
|
||||||
@@ -161,33 +94,54 @@ cmake -B build-all -DQTK_GUI=ON -DQTK_PLUGINS=ON -DQTK_EXAMPLE=ON -DCMAKE_PREFIX
|
|||||||
cmake --build build-all/
|
cmake --build build-all/
|
||||||
````
|
````
|
||||||
|
|
||||||
Now that we have all the components fully built, the following sections will
|
By default, the build will not initialize Assimp as a git submodule and build
|
||||||
install each component individually.
|
from source.
|
||||||
If you want to uninstall previously installed components, run the following command.
|
We can turn this on by setting the `-DQTK_SUBMODULES=ON` flag when running
|
||||||
|
CMake.
|
||||||
|
Building using this option will fetch and build Assimp for us, but builds will
|
||||||
|
take longer as a result.
|
||||||
|
Using `-DQTK_SUBMODULES=ON` supports providing assimp on cross-platform builds (
|
||||||
|
Windows / Mac / Linux) and may be easier
|
||||||
|
to configure.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo xargs rm -v < install_manifest.txt
|
cmake -B build-all -DQTK_GUI=ON -DQTK_PLUGINS=ON -DQTK_EXAMPLE=ON -DQTK_SUBMODULES=ON -DCMAKE_PREFIX_PATH=$HOME/Qt/6.6.0/gcc_64
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Qtk Library
|
#### Qtk GUI
|
||||||
|
|
||||||
Shared libqtk library for working with lower-level OpenGL to customize the rendering process.
|
```bash
|
||||||
|
cmake --build build-all/ --target qtk_gui -- -j $(nproc)
|
||||||
|
# Install Qtk desktop application (output removed)
|
||||||
|
# Installation prefix path must be absolute, since Qtk uses Qt deploy tools.
|
||||||
|
cmake --install build-all/ --component qtk_gui --prefix=$(pwd)/install
|
||||||
|
./install/bin/qtk_gui
|
||||||
|
```
|
||||||
|
|
||||||
|
If any errors are encountered loading plugins, we can debug plugin loading by
|
||||||
|
setting the following environment variable -
|
||||||
|
|
||||||
|
```bash
|
||||||
|
QT_DEBUG_PLUGINS=1 ./install/bin/qtk_gui
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Qtk Library
|
||||||
|
|
||||||
|
Qtk provides a simple library for working with QOpenGL.
|
||||||
We can install this library on a system path or a custom path and then
|
We can install this library on a system path or a custom path and then
|
||||||
set `CMAKE_PREFIX_PATH` to point to this location when building an application
|
set `CMAKE_PREFIX_PATH` to point to this location when building an application
|
||||||
using libqtk.
|
using libqtk.
|
||||||
|
|
||||||
Here we will install to the `/usr/local/` path.
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Install libqtk only
|
# Install libqtk only
|
||||||
cmake --build build-all/ --target qtk -- -j $(nproc)
|
cmake --build build-all/ --target qtk_library -- -j $(nproc)
|
||||||
cmake --install build-all/ --component qtk --prefix=/usr/local
|
cmake --install build-all/ --component qtk_library --prefix=/usr/local
|
||||||
-- Install configuration: "Release"
|
-- Install configuration: "Release"
|
||||||
-- Installing: /usr/local/lib/cmake/Qtk/QtkConfig.cmake
|
-- Installing: /usr/local/lib/cmake/Qtk/QtkConfig.cmake
|
||||||
-- Installing: /usr/local/lib/cmake/Qtk/QtkConfigVersion.cmake
|
-- Installing: /usr/local/lib/cmake/Qtk/QtkConfigVersion.cmake
|
||||||
-- Installing: /usr/local/lib/cmake/Qtk/QtkTargets.cmake
|
-- Installing: /usr/local/lib/cmake/Qtk/QtkTargets.cmake
|
||||||
-- Installing: /usr/local/lib/cmake/Qtk/QtkTargets-release.cmake
|
-- Installing: /usr/local/lib/cmake/Qtk/QtkTargets-release.cmake
|
||||||
-- Installing: /usr/local/lib/static/libqtk.a
|
-- Installing: /usr/local/lib/static/libqtk_library.a
|
||||||
-- Installing: /usr/local/include/qtk/camera3d.h
|
-- Installing: /usr/local/include/qtk/camera3d.h
|
||||||
-- Installing: /usr/local/include/qtk/input.h
|
-- Installing: /usr/local/include/qtk/input.h
|
||||||
-- Installing: /usr/local/include/qtk/meshrenderer.h
|
-- Installing: /usr/local/include/qtk/meshrenderer.h
|
||||||
@@ -204,26 +158,7 @@ cmake --install build-all/ --component qtk --prefix=/usr/local
|
|||||||
-- Installing: /usr/local/include/qtk/transform3D.h
|
-- Installing: /usr/local/include/qtk/transform3D.h
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Qtk GUI
|
#### Qtk Plugin Collection
|
||||||
|
|
||||||
The Qtk desktop application can be built and installed with the following commands.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cmake --build build-all/ --target qtk_gui -- -j $(nproc)
|
|
||||||
# Install Qtk desktop application (output removed)
|
|
||||||
# Installation prefix path must be absolute, since Qtk uses Qt deploy tools.
|
|
||||||
cmake --install build-all/ --component qtk_gui --prefix=$(pwd)/install
|
|
||||||
./install/bin/qtk_gui
|
|
||||||
```
|
|
||||||
|
|
||||||
If any errors are encountered loading plugins, we can debug plugin loading by
|
|
||||||
setting the following environment variable
|
|
||||||
|
|
||||||
```bash
|
|
||||||
QT_DEBUG_PLUGINS=1 ./install/bin/qtk_gui
|
|
||||||
```
|
|
||||||
|
|
||||||
##### Qtk Plugin Collection
|
|
||||||
|
|
||||||
This project defines a collection of widget plugins for use with Qt Designer.
|
This project defines a collection of widget plugins for use with Qt Designer.
|
||||||
These plugins were used to build the interface for the Qtk desktop application.
|
These plugins were used to build the interface for the Qtk desktop application.
|
||||||
@@ -244,12 +179,19 @@ cmake --build build-all/ --target qtk_plugins -- -j $(nproc)
|
|||||||
# The path here should be initialized during build configuration, so no need for --prefix
|
# The path here should be initialized during build configuration, so no need for --prefix
|
||||||
cmake --install build-all/ --component qtk_plugins
|
cmake --install build-all/ --component qtk_plugins
|
||||||
-- Install configuration: "Release"
|
-- Install configuration: "Release"
|
||||||
-- Up-to-date: /home/shaun/Qt/6.6.0/gcc_64/../../Tools/QtCreator/lib/Qt/lib/libqtk.a
|
-- Up-to-date: /home/shaun/Qt/6.6.0/gcc_64/../../Tools/QtCreator/lib/Qt/lib/libqtk_library.a
|
||||||
-- Up-to-date: /home/shaun/Qt/6.6.0/gcc_64/../../Tools/QtCreator/lib/Qt/lib/libqtk_plugin_library.a
|
-- Up-to-date: /home/shaun/Qt/6.6.0/gcc_64/../../Tools/QtCreator/lib/Qt/lib/libqtk_plugin_library.a
|
||||||
-- Up-to-date: /home/shaun/Qt/6.6.0/gcc_64/../../Tools/QtCreator/lib/Qt/plugins/designer/libqtk_collection.so
|
-- Up-to-date: /home/shaun/Qt/6.6.0/gcc_64/../../Tools/QtCreator/lib/Qt/plugins/designer/libqtk_collection.so
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Example libqtk Application
|
To uninstall after a previous installation, we can run the following command
|
||||||
|
from the root of the repository.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
xargs rm < build/install_manifest.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Qtk Example
|
||||||
|
|
||||||
There is a simple example of using libqtk in the [example-app/](example-app)
|
There is a simple example of using libqtk in the [example-app/](example-app)
|
||||||
directory. The example can be built standalone using `find_package` or as a
|
directory. The example can be built standalone using `find_package` or as a
|
||||||
@@ -271,7 +213,7 @@ This project is using `clang-format` version `>=15.0.5`.
|
|||||||
On Ubuntu 24.04, clang-format 18 is available to install in apt repositories.
|
On Ubuntu 24.04, clang-format 18 is available to install in apt repositories.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt install clang-format clang-tidy
|
sudo apt install clang-format
|
||||||
```
|
```
|
||||||
|
|
||||||
If `clang-format --version` is any earlier than `15.0.0`, running `clang-format` will fail because this project uses configuration options made available since `15.0.0`.
|
If `clang-format --version` is any earlier than `15.0.0`, running `clang-format` will fail because this project uses configuration options made available since `15.0.0`.
|
||||||
@@ -296,18 +238,14 @@ If you'd still like to run these tools manually, see the instructions below.
|
|||||||
cd qtk
|
cd qtk
|
||||||
# Build
|
# Build
|
||||||
cmake -B build && cmake --build build -- -j $(nproc)
|
cmake -B build && cmake --build build -- -j $(nproc)
|
||||||
```
|
clang-tidy -p build/ --fix --config-file=.clang-tidy src/**/*.cpp src/**/*.h example-app/*.cpp example-app/*.h
|
||||||
|
|
||||||
```bash
|
|
||||||
export SOURCES=src/**/*.cpp src/**/*.h example-app/*.cpp example-app/*.h
|
|
||||||
run-clang-tidy -p build/ -j $(nproc --ignore=1) -fix -config-file=.clang-tidy $SOURCES
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Last we need to run `clang-format`, this can be done with the command directly.
|
Last we need to run `clang-format`, this can be done with the command directly.
|
||||||
This will reformat all the code in the repository.
|
This will reformat all the code in the repository.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
clang-format -i --style=file:.clang-format $SOURCES
|
clang-format -i --style=file:.clang-format src/**/*.cpp src/**/*.h example-app/*.cpp example-app/*.h
|
||||||
```
|
```
|
||||||
|
|
||||||
`clang-format` can be run with git integration (or CLion if you prefer).
|
`clang-format` can be run with git integration (or CLion if you prefer).
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
## Example client project using qtk ##
|
## Example client project using qtk ##
|
||||||
## ##
|
## ##
|
||||||
## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ##
|
## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ##
|
||||||
## All Content (c) 2025 Shaun Reed, all rights reserved ##
|
## All Content (c) 2023 Shaun Reed, all rights reserved ##
|
||||||
################################################################################
|
################################################################################
|
||||||
cmake_minimum_required(VERSION 3.23)
|
cmake_minimum_required(VERSION 3.23)
|
||||||
|
|
||||||
@@ -56,8 +56,8 @@ endif()
|
|||||||
|
|
||||||
# Allow add_subdirectory on this project to use target ALIAS if available.
|
# Allow add_subdirectory on this project to use target ALIAS if available.
|
||||||
# If this example project is opened standalone we will use find_package.
|
# If this example project is opened standalone we will use find_package.
|
||||||
if(NOT TARGET Qtk::qtk)
|
if(NOT TARGET Qtk::qtk_library)
|
||||||
find_package(Qtk 0.3 REQUIRED)
|
find_package(Qtk 0.2 REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(Qt6 COMPONENTS Core Widgets OpenGLWidgets REQUIRED)
|
find_package(Qt6 COMPONENTS Core Widgets OpenGLWidgets REQUIRED)
|
||||||
@@ -77,27 +77,20 @@ configure_file(
|
|||||||
|
|
||||||
qt_add_executable(qtk_example ${EXAMPLE_SOURCES})
|
qt_add_executable(qtk_example ${EXAMPLE_SOURCES})
|
||||||
target_link_libraries(qtk_example PUBLIC Qt6::Widgets Qt6::OpenGLWidgets Qt6::Core)
|
target_link_libraries(qtk_example PUBLIC Qt6::Widgets Qt6::OpenGLWidgets Qt6::Core)
|
||||||
target_link_libraries(qtk_example PUBLIC Qtk::qtk)
|
target_link_libraries(qtk_example PUBLIC Qtk::qtk_library)
|
||||||
target_include_directories(qtk_example PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
|
target_include_directories(qtk_example PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
|
|
||||||
# qt_generate_deploy_app_script supports Windows and OSX in QtCore >= 6.3.
|
install(
|
||||||
# qt_generate_deploy_app_script is supported on Linux in QtCore >= 6.5.0.
|
TARGETS qtk_example
|
||||||
if((Qt6_VERSION VERSION_GREATER_EQUAL "6.3.0" AND (WIN32 OR APPLE))
|
COMPONENT qtk_example
|
||||||
OR Qt6_VERSION VERSION_GREATER_EQUAL "6.5.0")
|
BUNDLE DESTINATION .
|
||||||
install(
|
LIBRARY DESTINATION lib
|
||||||
TARGETS qtk_example
|
ARCHIVE DESTINATION lib/static
|
||||||
COMPONENT qtk_example
|
RUNTIME DESTINATION bin
|
||||||
BUNDLE DESTINATION .
|
)
|
||||||
LIBRARY DESTINATION lib
|
qt_generate_deploy_app_script(
|
||||||
ARCHIVE DESTINATION lib/static
|
TARGET qtk_example
|
||||||
RUNTIME DESTINATION bin
|
OUTPUT_SCRIPT QTK_EXAMPLE_DEPLOY_SCRIPT
|
||||||
)
|
NO_UNSUPPORTED_PLATFORM_ERROR
|
||||||
qt_generate_deploy_app_script(
|
)
|
||||||
TARGET qtk_example
|
install(SCRIPT ${QTK_EXAMPLE_DEPLOY_SCRIPT} COMPONENT qtk_example)
|
||||||
OUTPUT_SCRIPT QTK_EXAMPLE_DEPLOY_SCRIPT
|
|
||||||
NO_UNSUPPORTED_PLATFORM_ERROR
|
|
||||||
)
|
|
||||||
install(SCRIPT ${QTK_EXAMPLE_DEPLOY_SCRIPT} COMPONENT qtk_example)
|
|
||||||
elseif(NOT Qtk_IS_TOP_LEVEL)
|
|
||||||
message(WARNING "[Qtk] Installation is only supported on Qt >=6.5.\n")
|
|
||||||
endif()
|
|
||||||
|
|||||||
@@ -22,7 +22,12 @@ ExampleScene::~ExampleScene() = default;
|
|||||||
|
|
||||||
void ExampleScene::init()
|
void ExampleScene::init()
|
||||||
{
|
{
|
||||||
setSkybox(new Qtk::Skybox);
|
setSkybox(new Qtk::Skybox("Skybox"));
|
||||||
|
|
||||||
|
std::string spartanPath = QTK_EXAMPLE_SOURCE_DIR;
|
||||||
|
spartanPath += "/../resources/models/spartan/spartan.obj";
|
||||||
|
auto spartan = addObject(new Model("spartan", spartanPath.c_str()));
|
||||||
|
spartan->getTransform().setTranslation(-4.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
auto mesh = addObject(
|
auto mesh = addObject(
|
||||||
new Qtk::MeshRenderer("rightTriangle", Triangle(QTK_DRAW_ELEMENTS)));
|
new Qtk::MeshRenderer("rightTriangle", Triangle(QTK_DRAW_ELEMENTS)));
|
||||||
|
|||||||
2
extern/assimp/assimp
vendored
BIN
resources/images/plaster.png
Normal file
|
After Width: | Height: | Size: 3.8 MiB |
@@ -1,21 +0,0 @@
|
|||||||
<RCC>
|
|
||||||
<qresource prefix="/textures">
|
|
||||||
<file alias="crate.png">images/crate.png</file>
|
|
||||||
<file alias="stone.png">images/stone.png</file>
|
|
||||||
<file alias="wood.png">images/wood.png</file>
|
|
||||||
<file>skybox/back.png</file>
|
|
||||||
<file>skybox/bottom.png</file>
|
|
||||||
<file>skybox/front.png</file>
|
|
||||||
<file>skybox/left.png</file>
|
|
||||||
<file>skybox/right.png</file>
|
|
||||||
<file>skybox/top.png</file>
|
|
||||||
</qresource>
|
|
||||||
<qresource prefix="/icons">
|
|
||||||
<file>fontawesome-free-6.2.1-desktop/svgs/solid/cube.svg</file>
|
|
||||||
<file>fontawesome-free-6.2.1-desktop/svgs/regular/trash-can.svg</file>
|
|
||||||
<file>fontawesome-free-6.2.1-desktop/svgs/regular/folder-open.svg</file>
|
|
||||||
<file>fontawesome-free-6.2.1-desktop/svgs/regular/floppy-disk.svg</file>
|
|
||||||
<file>fontawesome-free-6.2.1-desktop/svgs/brands/git-alt.svg</file>
|
|
||||||
<file alias="icon.png">icons/icon.png</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
||||||
55
resources/models/alien-hominid/alien.mtl
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
# Blender MTL File: 'None'
|
||||||
|
# Material Count: 4
|
||||||
|
|
||||||
|
newmtl AlienHominid
|
||||||
|
Ns 225.000000
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.800000 0.533344 0.000000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.450000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Bump normal.png
|
||||||
|
map_Kd diffuse.png
|
||||||
|
map_Ns roughness.png
|
||||||
|
refl specular.png
|
||||||
|
|
||||||
|
newmtl Blaster
|
||||||
|
Ns 225.000000
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.800000 0.800000 0.800000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.450000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Bump blaster_normal.png
|
||||||
|
map_Kd blaster_diffuse.png
|
||||||
|
map_Ke blaster_emissive.png
|
||||||
|
map_Ns blaster_roughness.png
|
||||||
|
refl blaster_specular.png
|
||||||
|
|
||||||
|
newmtl Screenshot_2021-04-19_194508
|
||||||
|
Ns 225.000000
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.800000 0.800000 0.800000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.450000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd smoke.png
|
||||||
|
map_d smoke.png
|
||||||
|
|
||||||
|
newmtl Untitled-1
|
||||||
|
Ns 77.904748
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.800000 0.800000 0.800000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.450000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd Untitled-1.png
|
||||||
|
map_d Untitled-1.png
|
||||||
116822
resources/models/alien-hominid/alien.obj
Normal file
BIN
resources/models/alien-hominid/blaster_diffuse.png
Normal file
|
After Width: | Height: | Size: 14 MiB |
BIN
resources/models/alien-hominid/blaster_emissive.png
Normal file
|
After Width: | Height: | Size: 455 KiB |
BIN
resources/models/alien-hominid/blaster_normal.png
Normal file
|
After Width: | Height: | Size: 9.4 MiB |
BIN
resources/models/alien-hominid/blaster_roughness.png
Normal file
|
After Width: | Height: | Size: 5.2 MiB |
BIN
resources/models/alien-hominid/blaster_specular.png
Normal file
|
After Width: | Height: | Size: 2.8 MiB |
BIN
resources/models/alien-hominid/diffuse.png
Normal file
|
After Width: | Height: | Size: 8.8 MiB |
BIN
resources/models/alien-hominid/normal.png
Normal file
|
After Width: | Height: | Size: 10 MiB |
BIN
resources/models/alien-hominid/roughness.png
Normal file
|
After Width: | Height: | Size: 4.0 MiB |
BIN
resources/models/alien-hominid/specular.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
resources/models/backpack/ao.jpg
Normal file
|
After Width: | Height: | Size: 1.8 MiB |
16
resources/models/backpack/backpack.mtl
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Blender MTL File: 'None'
|
||||||
|
# Material Count: 1
|
||||||
|
|
||||||
|
newmtl Scene_-_Root
|
||||||
|
Ns 225.000000
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.800000 0.800000 0.800000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.0 0.0 0.0
|
||||||
|
Ni 1.450000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd diffuse.jpg
|
||||||
|
map_Bump normal.png
|
||||||
|
map_Ks specular.jpg
|
||||||
|
|
||||||
199481
resources/models/backpack/backpack.obj
Normal file
BIN
resources/models/backpack/diffuse.jpg
Normal file
|
After Width: | Height: | Size: 5.8 MiB |
BIN
resources/models/backpack/normal.png
Normal file
|
After Width: | Height: | Size: 14 MiB |
BIN
resources/models/backpack/roughness.jpg
Normal file
|
After Width: | Height: | Size: 4.2 MiB |
3
resources/models/backpack/source_attribution.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Model by Berk Gedik, from: https://sketchfab.com/3d-models/survival-guitar-backpack-low-poly-799f8c4511f84fab8c3f12887f7e6b36
|
||||||
|
|
||||||
|
Modified material assignment (Joey de Vries) for easier load in OpenGL model loading chapter, and renamed albedo to diffuse and metallic to specular to match non-PBR lighting setup.
|
||||||
BIN
resources/models/backpack/specular.jpg
Normal file
|
After Width: | Height: | Size: 6.4 MiB |
7
resources/models/bird/bird.mtl
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
newmtl material_0
|
||||||
|
map_bump normal.jpg
|
||||||
|
norm normal.jpg
|
||||||
|
map_Kd diffuse.jpg
|
||||||
|
occlusion occlusion.jpg
|
||||||
|
Pm 0
|
||||||
|
Pr 0.793152
|
||||||
80009
resources/models/bird/bird.obj
Executable file
BIN
resources/models/bird/diffuse.jpg
Executable file
|
After Width: | Height: | Size: 11 MiB |
BIN
resources/models/bird/normal.jpg
Executable file
|
After Width: | Height: | Size: 3.3 MiB |
BIN
resources/models/bird/occlusion.jpg
Executable file
|
After Width: | Height: | Size: 1.7 MiB |
12
resources/models/floor.obj
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# Blender v2.82 (sub 7) OBJ File: ''
|
||||||
|
# www.blender.org
|
||||||
|
mtllib floor.mtl
|
||||||
|
o floor
|
||||||
|
v -1.000000 -0.000000 1.000000
|
||||||
|
v 1.000000 -0.000000 1.000000
|
||||||
|
v 1.000000 0.000000 -1.000000
|
||||||
|
v -1.000000 0.000000 -1.000000
|
||||||
|
vn 0.0000 1.0000 0.0000
|
||||||
|
usemtl Default_OBJ
|
||||||
|
s off
|
||||||
|
f 1//1 2//1 3//1 4//1
|
||||||
BIN
resources/models/scythe/diffuse.png
Executable file
|
After Width: | Height: | Size: 133 KiB |
8
resources/models/scythe/scythe.mtl
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
# WaveFront *.mtl file (generated by CINEMA 4D)
|
||||||
|
|
||||||
|
newmtl item/objectcomponents/weapon/staff_2h_artifactdeadwind_d_03.m2_Geoset_000
|
||||||
|
Ka 0.25 0.25 0.25
|
||||||
|
Kd 1 1 1
|
||||||
|
map_Kd diffuse.png
|
||||||
|
illum 7
|
||||||
|
|
||||||
5915
resources/models/scythe/scythe.obj
Executable file
BIN
resources/models/spartan/Spartan_Arms_Mat_AO.png
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
BIN
resources/models/spartan/Spartan_Arms_Mat_BaseColor.png
Normal file
|
After Width: | Height: | Size: 4.0 MiB |
BIN
resources/models/spartan/Spartan_Arms_Mat_Metallic.png
Normal file
|
After Width: | Height: | Size: 807 KiB |
BIN
resources/models/spartan/Spartan_Arms_Mat_Normal.png
Normal file
|
After Width: | Height: | Size: 5.9 MiB |
BIN
resources/models/spartan/Spartan_Arms_Mat_Roughness.png
Normal file
|
After Width: | Height: | Size: 1.5 MiB |
BIN
resources/models/spartan/Spartan_Arms_Mat_Specular.png
Normal file
|
After Width: | Height: | Size: 614 KiB |
BIN
resources/models/spartan/Spartan_Chest_Mat_AO.png
Normal file
|
After Width: | Height: | Size: 1.7 MiB |
BIN
resources/models/spartan/Spartan_Chest_Mat_BaseColor.png
Normal file
|
After Width: | Height: | Size: 4.8 MiB |
BIN
resources/models/spartan/Spartan_Chest_Mat_Metallic.png
Normal file
|
After Width: | Height: | Size: 1.3 MiB |
BIN
resources/models/spartan/Spartan_Chest_Mat_Normal.png
Normal file
|
After Width: | Height: | Size: 4.5 MiB |
BIN
resources/models/spartan/Spartan_Chest_Mat_Roughness.png
Normal file
|
After Width: | Height: | Size: 2.2 MiB |
BIN
resources/models/spartan/Spartan_Chest_Mat_Specular.png
Normal file
|
After Width: | Height: | Size: 885 KiB |
BIN
resources/models/spartan/Spartan_Ears_Mat_AO.png
Normal file
|
After Width: | Height: | Size: 96 KiB |
BIN
resources/models/spartan/Spartan_Ears_Mat_BaseColor.png
Normal file
|
After Width: | Height: | Size: 1.1 MiB |
BIN
resources/models/spartan/Spartan_Ears_Mat_Metallic.png
Normal file
|
After Width: | Height: | Size: 426 KiB |
BIN
resources/models/spartan/Spartan_Ears_Mat_Normal.png
Normal file
|
After Width: | Height: | Size: 983 KiB |
BIN
resources/models/spartan/Spartan_Ears_Mat_Roughness.png
Normal file
|
After Width: | Height: | Size: 484 KiB |
BIN
resources/models/spartan/Spartan_Ears_Mat_Specular.png
Normal file
|
After Width: | Height: | Size: 279 KiB |
BIN
resources/models/spartan/Spartan_Helmet_Mat_AO.png
Normal file
|
After Width: | Height: | Size: 930 KiB |
BIN
resources/models/spartan/Spartan_Helmet_Mat_BaseColor.png
Normal file
|
After Width: | Height: | Size: 3.9 MiB |
BIN
resources/models/spartan/Spartan_Helmet_Mat_Metallic.png
Normal file
|
After Width: | Height: | Size: 1.3 MiB |
BIN
resources/models/spartan/Spartan_Helmet_Mat_Normal.png
Normal file
|
After Width: | Height: | Size: 4.4 MiB |
BIN
resources/models/spartan/Spartan_Helmet_Mat_Roughness.png
Normal file
|
After Width: | Height: | Size: 1.7 MiB |
BIN
resources/models/spartan/Spartan_Helmet_Mat_Specular.png
Normal file
|
After Width: | Height: | Size: 862 KiB |
BIN
resources/models/spartan/Spartan_Legs_Mat_AO.png
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
BIN
resources/models/spartan/Spartan_Legs_Mat_BaseColor.png
Normal file
|
After Width: | Height: | Size: 4.0 MiB |
BIN
resources/models/spartan/Spartan_Legs_Mat_Metallic.png
Normal file
|
After Width: | Height: | Size: 1008 KiB |
BIN
resources/models/spartan/Spartan_Legs_Mat_Normal.png
Normal file
|
After Width: | Height: | Size: 4.8 MiB |
BIN
resources/models/spartan/Spartan_Legs_Mat_Roughness.png
Normal file
|
After Width: | Height: | Size: 1.8 MiB |
BIN
resources/models/spartan/Spartan_Legs_Mat_Specular.png
Normal file
|
After Width: | Height: | Size: 638 KiB |
BIN
resources/models/spartan/Spartan_Shoulder_Mat_AO.png
Normal file
|
After Width: | Height: | Size: 844 KiB |
BIN
resources/models/spartan/Spartan_Shoulder_Mat_BaseColor.png
Normal file
|
After Width: | Height: | Size: 3.4 MiB |
BIN
resources/models/spartan/Spartan_Shoulder_Mat_Metallic.png
Normal file
|
After Width: | Height: | Size: 1.1 MiB |
BIN
resources/models/spartan/Spartan_Shoulder_Mat_Normal.png
Normal file
|
After Width: | Height: | Size: 3.8 MiB |
BIN
resources/models/spartan/Spartan_Shoulder_Mat_Roughness.png
Normal file
|
After Width: | Height: | Size: 1.7 MiB |
BIN
resources/models/spartan/Spartan_Shoulder_Mat_Specular.png
Normal file
|
After Width: | Height: | Size: 761 KiB |
BIN
resources/models/spartan/Spartan_Sketchfab.fbx
Normal file
BIN
resources/models/spartan/Spartan_Undersuit_Mat_AO.png
Normal file
|
After Width: | Height: | Size: 3.1 MiB |
BIN
resources/models/spartan/Spartan_Undersuit_Mat_BaseColor.png
Normal file
|
After Width: | Height: | Size: 14 MiB |
BIN
resources/models/spartan/Spartan_Undersuit_Mat_Metallic.png
Normal file
|
After Width: | Height: | Size: 2.5 MiB |
BIN
resources/models/spartan/Spartan_Undersuit_Mat_Normal.png
Normal file
|
After Width: | Height: | Size: 24 MiB |
BIN
resources/models/spartan/Spartan_Undersuit_Mat_Roughness.png
Normal file
|
After Width: | Height: | Size: 4.9 MiB |
BIN
resources/models/spartan/Spartan_Undersuit_Mat_Specular.png
Normal file
|
After Width: | Height: | Size: 1.1 MiB |
BIN
resources/models/spartan/lambert1_Colour-Opacity.png
Normal file
|
After Width: | Height: | Size: 7.8 MiB |
BIN
resources/models/spartan/lambert1_Nrm.png
Normal file
|
After Width: | Height: | Size: 4.3 MiB |
BIN
resources/models/spartan/lambert1_Roughness.png
Normal file
|
After Width: | Height: | Size: 1.9 MiB |
104
resources/models/spartan/spartan.mtl
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
# Blender MTL File: 'None'
|
||||||
|
# Material Count: 8
|
||||||
|
|
||||||
|
newmtl Spartan_Arms_Mat
|
||||||
|
Ns 179.999996
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 1.000000 1.000000 1.000000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.450000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd Spartan_Arms_Mat_BaseColor.png
|
||||||
|
map_Bump Spartan_Arms_Mat_Normal.png
|
||||||
|
refl Spartan_Arms_Mat_Specular.png
|
||||||
|
|
||||||
|
|
||||||
|
newmtl Spartan_Chest_Mat
|
||||||
|
Ns 179.999996
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 1.000000 1.000000 1.000000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.450000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd Spartan_Chest_Mat_BaseColor.png
|
||||||
|
map_Bump Spartan_Chest_Mat_Normal.png
|
||||||
|
refl Spartan_Chest_Mat_Specular.png
|
||||||
|
|
||||||
|
newmtl Spartan_Ear_Mat
|
||||||
|
Ns 179.999996
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 1.000000 1.000000 1.000000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.450000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd Spartan_Ears_Mat_BaseColor.png
|
||||||
|
map_Bump Spartan_Ears_Mat_Normal.png
|
||||||
|
refl Spartan_Ears_Mat_Specular.png
|
||||||
|
|
||||||
|
newmtl Spartan_Helmet_Mat
|
||||||
|
Ns 179.999996
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 1.000000 1.000000 1.000000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.450000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd Spartan_Helmet_Mat_BaseColor.png
|
||||||
|
map_Bump Spartan_Helmet_Mat_Normal.png
|
||||||
|
refl Spartan_Helmet_Mat_Specular.png
|
||||||
|
|
||||||
|
newmtl Spartan_Legs_Mat
|
||||||
|
Ns 179.999996
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 1.000000 1.000000 1.000000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.450000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd Spartan_Legs_Mat_BaseColor.png
|
||||||
|
map_Bump Spartan_Legs_Mat_Normal.png
|
||||||
|
refl Spartan_Legs_Mat_Specular.png
|
||||||
|
|
||||||
|
newmtl Spartan_Shoulders_Mat
|
||||||
|
Ns 179.999996
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 1.000000 1.000000 1.000000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.450000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd Spartan_Shoulder_Mat_BaseColor.png
|
||||||
|
map_Bump Spartan_Shoulder_Mat_Normal.png
|
||||||
|
refl Spartan_Shoulder_Mat_Specular.png
|
||||||
|
|
||||||
|
newmtl Spartan_Undersuit_Mat
|
||||||
|
Ns 179.999996
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 1.000000 1.000000 1.000000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.450000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd Spartan_Undersuit_Mat_BaseColor.png
|
||||||
|
map_Bump Spartan_Undersuit_Mat_Normal.png
|
||||||
|
refl Spartan_Undersuit_Mat_Specular.png
|
||||||
|
|
||||||
|
newmtl lambert1
|
||||||
|
Ns 179.999996
|
||||||
|
Ka 1.000000 1.000000 1.000000
|
||||||
|
Kd 0.500000 0.500000 0.500000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
Ni 1.450000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
121956
resources/models/spartan/spartan.obj
Normal file
1834
resources/models/sphere.obj
Normal file
@@ -1,5 +1,6 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/textures">
|
<qresource prefix="/textures">
|
||||||
|
<file alias="plaster.png">images/plaster.png</file>
|
||||||
<file alias="crate.png">images/crate.png</file>
|
<file alias="crate.png">images/crate.png</file>
|
||||||
<file alias="stone.png">images/stone.png</file>
|
<file alias="stone.png">images/stone.png</file>
|
||||||
<file alias="wood.png">images/wood.png</file>
|
<file alias="wood.png">images/wood.png</file>
|
||||||
@@ -27,6 +28,8 @@
|
|||||||
<file alias="solid.vert">shaders/vertex/solid.vert</file>
|
<file alias="solid.vert">shaders/vertex/solid.vert</file>
|
||||||
<file alias="solid-perspective.frag">shaders/fragment/solid-perspective.frag</file>
|
<file alias="solid-perspective.frag">shaders/fragment/solid-perspective.frag</file>
|
||||||
<file alias="solid-perspective.vert">shaders/vertex/solid-perspective.vert</file>
|
<file alias="solid-perspective.vert">shaders/vertex/solid-perspective.vert</file>
|
||||||
|
<file alias="multi-color.frag">shaders/fragment/multi-color.frag</file>
|
||||||
|
<file alias="multi-color.vert">shaders/vertex/multi-color.vert</file>
|
||||||
<file alias="rgb-normals.frag">shaders/fragment/rgb-normals.frag</file>
|
<file alias="rgb-normals.frag">shaders/fragment/rgb-normals.frag</file>
|
||||||
<file alias="rgb-normals.vert">shaders/vertex/rgb-normals.vert</file>
|
<file alias="rgb-normals.vert">shaders/vertex/rgb-normals.vert</file>
|
||||||
<file alias="texture-cubemap.frag">shaders/fragment/texture-cubemap.frag</file>
|
<file alias="texture-cubemap.frag">shaders/fragment/texture-cubemap.frag</file>
|
||||||
@@ -41,9 +44,88 @@
|
|||||||
<file alias="solid-specular.vert">shaders/vertex/solid-specular.vert</file>
|
<file alias="solid-specular.vert">shaders/vertex/solid-specular.vert</file>
|
||||||
<file alias="solid-phong.frag">shaders/fragment/solid-phong.frag</file>
|
<file alias="solid-phong.frag">shaders/fragment/solid-phong.frag</file>
|
||||||
<file alias="solid-phong.vert">shaders/vertex/solid-phong.vert</file>
|
<file alias="solid-phong.vert">shaders/vertex/solid-phong.vert</file>
|
||||||
|
<file alias="model-basic.frag">shaders/fragment/model-basic.frag</file>
|
||||||
|
<file alias="model-basic.vert">shaders/vertex/model-basic.vert</file>
|
||||||
<file alias="model-phong.frag">shaders/fragment/model-phong.frag</file>
|
<file alias="model-phong.frag">shaders/fragment/model-phong.frag</file>
|
||||||
<file alias="model-phong.vert">shaders/vertex/model-phong.vert</file>
|
<file alias="model-phong.vert">shaders/vertex/model-phong.vert</file>
|
||||||
<file alias="model-normals.frag">shaders/fragment/model-normals.frag</file>
|
<file alias="model-normals.frag">shaders/fragment/model-normals.frag</file>
|
||||||
<file alias="model-normals.vert">shaders/vertex/model-normals.vert</file>
|
<file alias="model-normals.vert">shaders/vertex/model-normals.vert</file>
|
||||||
|
<file alias="skybox.frag">skybox/skybox.frag</file>
|
||||||
|
<file alias="skybox.vert">skybox/skybox.vert</file>
|
||||||
|
</qresource>
|
||||||
|
<qresource prefix="/models">
|
||||||
|
<file>models/spartan/spartan.obj</file>
|
||||||
|
<file>models/alien-hominid/alien.obj</file>
|
||||||
|
<file>models/spartan/spartan.mtl</file>
|
||||||
|
<file>models/spartan/Spartan_Ears_Mat_BaseColor.png</file>
|
||||||
|
<file>models/spartan/Spartan_Undersuit_Mat_Specular.png</file>
|
||||||
|
<file>models/spartan/Spartan_Undersuit_Mat_Roughness.png</file>
|
||||||
|
<file>models/spartan/Spartan_Undersuit_Mat_Normal.png</file>
|
||||||
|
<file>models/spartan/Spartan_Undersuit_Mat_Metallic.png</file>
|
||||||
|
<file>models/spartan/Spartan_Undersuit_Mat_BaseColor.png</file>
|
||||||
|
<file>models/spartan/Spartan_Undersuit_Mat_AO.png</file>
|
||||||
|
<file>models/spartan/Spartan_Shoulder_Mat_Specular.png</file>
|
||||||
|
<file>models/spartan/Spartan_Shoulder_Mat_Roughness.png</file>
|
||||||
|
<file>models/spartan/Spartan_Shoulder_Mat_Normal.png</file>
|
||||||
|
<file>models/spartan/Spartan_Shoulder_Mat_Metallic.png</file>
|
||||||
|
<file>models/spartan/Spartan_Shoulder_Mat_BaseColor.png</file>
|
||||||
|
<file>models/spartan/Spartan_Shoulder_Mat_AO.png</file>
|
||||||
|
<file>models/spartan/Spartan_Legs_Mat_Specular.png</file>
|
||||||
|
<file>models/spartan/Spartan_Legs_Mat_Roughness.png</file>
|
||||||
|
<file>models/spartan/Spartan_Legs_Mat_Normal.png</file>
|
||||||
|
<file>models/spartan/Spartan_Legs_Mat_Metallic.png</file>
|
||||||
|
<file>models/spartan/Spartan_Legs_Mat_BaseColor.png</file>
|
||||||
|
<file>models/spartan/Spartan_Legs_Mat_AO.png</file>
|
||||||
|
<file>models/spartan/Spartan_Helmet_Mat_Specular.png</file>
|
||||||
|
<file>models/spartan/Spartan_Helmet_Mat_Roughness.png</file>
|
||||||
|
<file>models/spartan/Spartan_Helmet_Mat_Normal.png</file>
|
||||||
|
<file>models/spartan/Spartan_Helmet_Mat_Metallic.png</file>
|
||||||
|
<file>models/spartan/Spartan_Helmet_Mat_BaseColor.png</file>
|
||||||
|
<file>models/spartan/Spartan_Helmet_Mat_AO.png</file>
|
||||||
|
<file>models/spartan/Spartan_Ears_Mat_Specular.png</file>
|
||||||
|
<file>models/spartan/Spartan_Ears_Mat_Roughness.png</file>
|
||||||
|
<file>models/spartan/Spartan_Ears_Mat_Normal.png</file>
|
||||||
|
<file>models/spartan/Spartan_Ears_Mat_Metallic.png</file>
|
||||||
|
<file>models/spartan/Spartan_Ears_Mat_AO.png</file>
|
||||||
|
<file>models/spartan/Spartan_Chest_Mat_Specular.png</file>
|
||||||
|
<file>models/spartan/Spartan_Chest_Mat_Roughness.png</file>
|
||||||
|
<file>models/spartan/Spartan_Chest_Mat_Normal.png</file>
|
||||||
|
<file>models/spartan/Spartan_Chest_Mat_Metallic.png</file>
|
||||||
|
<file>models/spartan/Spartan_Chest_Mat_BaseColor.png</file>
|
||||||
|
<file>models/spartan/Spartan_Chest_Mat_AO.png</file>
|
||||||
|
<file>models/spartan/Spartan_Arms_Mat_Specular.png</file>
|
||||||
|
<file>models/spartan/Spartan_Arms_Mat_Roughness.png</file>
|
||||||
|
<file>models/spartan/Spartan_Arms_Mat_Normal.png</file>
|
||||||
|
<file>models/spartan/Spartan_Arms_Mat_Metallic.png</file>
|
||||||
|
<file>models/spartan/Spartan_Arms_Mat_BaseColor.png</file>
|
||||||
|
<file>models/spartan/Spartan_Arms_Mat_AO.png</file>
|
||||||
|
<file>models/spartan/lambert1_Roughness.png</file>
|
||||||
|
<file>models/spartan/lambert1_Nrm.png</file>
|
||||||
|
<file>models/spartan/lambert1_Colour-Opacity.png</file>
|
||||||
|
<file>models/backpack/specular.jpg</file>
|
||||||
|
<file>models/backpack/roughness.jpg</file>
|
||||||
|
<file>models/backpack/diffuse.jpg</file>
|
||||||
|
<file>models/backpack/normal.png</file>
|
||||||
|
<file>models/backpack/backpack.obj</file>
|
||||||
|
<file>models/backpack/backpack.mtl</file>
|
||||||
|
<file>models/backpack/ao.jpg</file>
|
||||||
|
<file>models/alien-hominid/specular.png</file>
|
||||||
|
<file>models/alien-hominid/roughness.png</file>
|
||||||
|
<file>models/alien-hominid/normal.png</file>
|
||||||
|
<file>models/alien-hominid/diffuse.png</file>
|
||||||
|
<file>models/alien-hominid/blaster_specular.png</file>
|
||||||
|
<file>models/alien-hominid/blaster_roughness.png</file>
|
||||||
|
<file>models/alien-hominid/blaster_normal.png</file>
|
||||||
|
<file>models/alien-hominid/blaster_emissive.png</file>
|
||||||
|
<file>models/alien-hominid/blaster_diffuse.png</file>
|
||||||
|
<file>models/alien-hominid/alien.mtl</file>
|
||||||
|
<file>models/scythe/scythe.obj</file>
|
||||||
|
<file>models/scythe/scythe.mtl</file>
|
||||||
|
<file>models/scythe/diffuse.png</file>
|
||||||
|
<file>models/bird/occlusion.jpg</file>
|
||||||
|
<file>models/bird/normal.jpg</file>
|
||||||
|
<file>models/bird/diffuse.jpg</file>
|
||||||
|
<file>models/bird/bird.obj</file>
|
||||||
|
<file>models/bird/bird.mtl</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
11
resources/shaders/fragment/model-basic.frag
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#version 330 core
|
||||||
|
out vec4 fColor;
|
||||||
|
|
||||||
|
in vec2 vTextureCoord;
|
||||||
|
|
||||||
|
uniform sampler2D texture_diffuse1;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
fColor = texture(texture_diffuse1, vTextureCoord);
|
||||||
|
}
|
||||||
9
resources/shaders/fragment/multi-color.frag
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#version 330
|
||||||
|
in vec4 vColor;
|
||||||
|
|
||||||
|
out vec4 fColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
fColor = vColor;
|
||||||
|
}
|
||||||
16
resources/shaders/vertex/model-basic.vert
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#version 330 core
|
||||||
|
layout (location = 0) in vec3 aPosition;
|
||||||
|
layout (location = 1) in vec3 aNormal;
|
||||||
|
layout (location = 2) in vec2 aTextureCoord;
|
||||||
|
|
||||||
|
out vec2 vTextureCoord;
|
||||||
|
|
||||||
|
uniform mat4 uModel;
|
||||||
|
uniform mat4 uView;
|
||||||
|
uniform mat4 uProjection;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vTextureCoord = aTextureCoord;
|
||||||
|
gl_Position = uProjection * uView * uModel * vec4(aPosition, 1.0);
|
||||||
|
}
|
||||||
16
resources/shaders/vertex/multi-color.vert
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#version 330
|
||||||
|
layout(location = 0) in vec3 aPosition;
|
||||||
|
layout(location = 1) in vec3 aColor;
|
||||||
|
|
||||||
|
out vec4 vColor;
|
||||||
|
|
||||||
|
uniform mat4 uModel; // Model
|
||||||
|
uniform mat4 uView; // View
|
||||||
|
uniform mat4 uProjection; // Projection
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = uProjection * uView * uModel * vec4(aPosition, 1.0);
|
||||||
|
|
||||||
|
vColor = vec4(aColor, 1.0f);
|
||||||
|
}
|
||||||
9
resources/skybox/skybox.frag
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#version 330
|
||||||
|
uniform samplerCube uTexture;
|
||||||
|
|
||||||
|
varying vec3 vTexCoord;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragColor = texture(uTexture, vTexCoord);
|
||||||
|
}
|
||||||
15
resources/skybox/skybox.vert
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#version 330
|
||||||
|
layout(location = 0) in vec3 aPosition;
|
||||||
|
|
||||||
|
out vec3 vTexCoord;
|
||||||
|
|
||||||
|
uniform mat4 uProjectionMatrix;
|
||||||
|
uniform mat4 uViewMatrix;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// Strip translation column from camera's 4x4 matrix
|
||||||
|
mat4 view = mat4(mat3(uViewMatrix));
|
||||||
|
gl_Position = uProjectionMatrix * view * vec4(aPosition, 1.0);
|
||||||
|
vTexCoord = aPosition;
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
## Project for working with OpenGL and Qt6 widgets ##
|
## Project for working with OpenGL and Qt6 widgets ##
|
||||||
## ##
|
## ##
|
||||||
## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ##
|
## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ##
|
||||||
## All Content (c) 2025 Shaun Reed, all rights reserved ##
|
## All Content (c) 2023 Shaun Reed, all rights reserved ##
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Qtk Library
|
# Qtk Library
|
||||||
@@ -13,22 +13,22 @@ install(
|
|||||||
FILES
|
FILES
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
||||||
COMPONENT qtk
|
COMPONENT qtk_library
|
||||||
DESTINATION lib/cmake/${PROJECT_NAME}
|
DESTINATION lib/cmake/${PROJECT_NAME}
|
||||||
)
|
)
|
||||||
install(
|
install(
|
||||||
EXPORT qtk_export
|
EXPORT qtk_export
|
||||||
FILE ${PROJECT_NAME}Targets.cmake
|
FILE ${PROJECT_NAME}Targets.cmake
|
||||||
NAMESPACE ${PROJECT_NAME}::
|
NAMESPACE ${PROJECT_NAME}::
|
||||||
COMPONENT qtk
|
COMPONENT qtk_library
|
||||||
DESTINATION lib/cmake/${PROJECT_NAME}
|
DESTINATION lib/cmake/${PROJECT_NAME}
|
||||||
)
|
)
|
||||||
# System install for libqtk
|
# System install for qtk_library
|
||||||
install(
|
install(
|
||||||
TARGETS qtk
|
TARGETS qtk_library
|
||||||
# Associate libqtk target with qtk-export
|
# Associate qtk_library target with qtk-export
|
||||||
EXPORT qtk_export
|
EXPORT qtk_export
|
||||||
COMPONENT qtk
|
COMPONENT qtk_library
|
||||||
FILE_SET HEADERS DESTINATION include
|
FILE_SET HEADERS DESTINATION include
|
||||||
INCLUDES DESTINATION include
|
INCLUDES DESTINATION include
|
||||||
LIBRARY DESTINATION lib
|
LIBRARY DESTINATION lib
|
||||||
|
|||||||
@@ -2,44 +2,21 @@
|
|||||||
## Project for working with OpenGL and Qt6 widgets ##
|
## Project for working with OpenGL and Qt6 widgets ##
|
||||||
## ##
|
## ##
|
||||||
## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ##
|
## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ##
|
||||||
## All Content (c) 2025 Shaun Reed, all rights reserved ##
|
## All Content (c) 2023 Shaun Reed, all rights reserved ##
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Qtk Application
|
# Qtk Application
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Build without the example scene if QTK_GUI_SCENE is unset.
|
set(QTK_GUI_SOURCES
|
||||||
if (QTK_GUI_SCENE)
|
qtkmainwindow.cpp qtkmainwindow.h qtkmainwindow.ui
|
||||||
set(QTK_GUI_SOURCES
|
qtkscene.cpp qtkscene.h
|
||||||
qtkmainwindow.cpp qtkmainwindow.h qtkmainwindow.ui
|
main.cpp
|
||||||
# This scene will clone a git repository for required 3D models.
|
)
|
||||||
qtkscene.cpp qtkscene.h
|
|
||||||
main.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
qt6_add_big_resources(QTK_GUI_SOURCES "${QTK_RESOURCES}/resources.qrc")
|
|
||||||
else()
|
|
||||||
# The scene will use a default skybox with no models or examples.
|
|
||||||
# Models can be added by click-and-dragging an .obj into the scene.
|
|
||||||
set(QTK_GUI_SOURCES
|
|
||||||
qtkmainwindow.cpp qtkmainwindow.h qtkmainwindow.ui
|
|
||||||
main.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
qt6_add_big_resources(
|
|
||||||
QTK_GUI_SOURCES
|
|
||||||
"${QTK_RESOURCES}/minimal_resources.qrc"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
qt_add_executable(qtk_gui ${QTK_GUI_SOURCES})
|
qt_add_executable(qtk_gui ${QTK_GUI_SOURCES})
|
||||||
target_link_libraries(qtk_gui PRIVATE qtk_plugin_library)
|
target_link_libraries(qtk_gui PRIVATE qtk_plugin_library)
|
||||||
|
|
||||||
if (QTK_GUI_SCENE)
|
|
||||||
target_compile_definitions(qtk_gui PRIVATE -DQTK_GUI_SCENE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
set_target_properties(qtk_gui PROPERTIES WIN32_EXECUTABLE TRUE)
|
set_target_properties(qtk_gui PROPERTIES WIN32_EXECUTABLE TRUE)
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
@@ -56,25 +33,21 @@ elseif(APPLE)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# qt_generate_deploy_app_script supports Windows and OSX in QtCore >= 6.3.
|
install(
|
||||||
# qt_generate_deploy_app_script is supported on Linux in QtCore >= 6.5.0.
|
TARGETS qtk_gui
|
||||||
if((Qt6_VERSION VERSION_GREATER_EQUAL "6.3.0" AND (WIN32 OR APPLE))
|
COMPONENT qtk_gui
|
||||||
OR Qt6_VERSION VERSION_GREATER_EQUAL "6.5.0")
|
BUNDLE DESTINATION .
|
||||||
install(
|
LIBRARY DESTINATION lib
|
||||||
TARGETS qtk_gui
|
ARCHIVE DESTINATION lib
|
||||||
COMPONENT qtk_gui
|
RUNTIME DESTINATION bin
|
||||||
BUNDLE DESTINATION .
|
)
|
||||||
LIBRARY DESTINATION lib
|
|
||||||
ARCHIVE DESTINATION lib
|
qt_generate_deploy_app_script(
|
||||||
RUNTIME DESTINATION bin
|
TARGET qtk_gui
|
||||||
)
|
OUTPUT_SCRIPT QTK_DEPLOY_SCRIPT
|
||||||
qt_generate_deploy_app_script(
|
NO_UNSUPPORTED_PLATFORM_ERROR
|
||||||
TARGET qtk_gui
|
)
|
||||||
OUTPUT_SCRIPT QTK_DEPLOY_SCRIPT
|
install(SCRIPT ${QTK_DEPLOY_SCRIPT} COMPONENT qtk_gui)
|
||||||
NO_UNSUPPORTED_PLATFORM_ERROR
|
|
||||||
)
|
|
||||||
install(SCRIPT ${QTK_DEPLOY_SCRIPT} COMPONENT qtk_gui)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
if(MSVC AND TARGET Qt6::qmake)
|
if(MSVC AND TARGET Qt6::qmake)
|
||||||
|
|||||||
@@ -9,10 +9,12 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
#include "qtkmainwindow.h"
|
#include "qtkmainwindow.h"
|
||||||
|
#include "qtkscene.h"
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
initResources();
|
Q_INIT_RESOURCE(resources);
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
auto window = MainWindow::getMainWindow();
|
auto window = MainWindow::getMainWindow();
|
||||||
@@ -22,7 +24,7 @@ int main(int argc, char * argv[])
|
|||||||
// NOTE: We set the scene here and not in QtkMainWindow to detach the scene
|
// NOTE: We set the scene here and not in QtkMainWindow to detach the scene
|
||||||
// from the QtkWidget plugin (qtk_plugin_library build target).
|
// from the QtkWidget plugin (qtk_plugin_library build target).
|
||||||
// Once we can save / load scenes, this call, and QtkScene, can be removed.
|
// Once we can save / load scenes, this call, and QtkScene, can be removed.
|
||||||
window->setScene(new AppScene);
|
window->setScene(new QtkScene);
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
|
|
||||||
|
|||||||
@@ -48,16 +48,6 @@ MainWindow::MainWindow(QWidget * parent) : QMainWindow(parent)
|
|||||||
&Qtk::ToolBox::updateFocus);
|
&Qtk::ToolBox::updateFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(ui_->actionDelete_Object,
|
|
||||||
&QAction::triggered,
|
|
||||||
this,
|
|
||||||
&MainWindow::deleteObject);
|
|
||||||
|
|
||||||
connect(ui_->actionLoad_Model,
|
|
||||||
&QAction::triggered,
|
|
||||||
this,
|
|
||||||
&MainWindow::loadObject);
|
|
||||||
|
|
||||||
// TODO: Fix / use MainWindow in Qt Designer to add these dock widgets.
|
// TODO: Fix / use MainWindow in Qt Designer to add these dock widgets.
|
||||||
// For now we will add them manually, but we should be able to do this in the
|
// For now we will add them manually, but we should be able to do this in the
|
||||||
// designer. At the moment if you edit the UI in designer the dock widget
|
// designer. At the moment if you edit the UI in designer the dock widget
|
||||||
@@ -72,7 +62,7 @@ MainWindow::MainWindow(QWidget * parent) : QMainWindow(parent)
|
|||||||
ui_->menuView->addAction(ui_->qtk__TreeView->toggleViewAction());
|
ui_->menuView->addAction(ui_->qtk__TreeView->toggleViewAction());
|
||||||
|
|
||||||
// Set the window icon used for Qtk.
|
// Set the window icon used for Qtk.
|
||||||
setWindowIcon(getIcon());
|
setWindowIcon(Qtk::getIcon());
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@@ -114,26 +104,6 @@ void MainWindow::refreshScene(const QString & sceneName)
|
|||||||
ui_->qtk__TreeView->updateView(getQtkWidget()->getScene());
|
ui_->qtk__TreeView->updateView(getQtkWidget()->getScene());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::deleteObject()
|
|
||||||
{
|
|
||||||
if (auto object = ui_->qtk__ToolBox->getObjectFocus(); object != Q_NULLPTR) {
|
|
||||||
auto scene = getQtkWidget()->getScene();
|
|
||||||
switch (object->getType()) {
|
|
||||||
case Qtk::Object::Type::QTK_MESH:
|
|
||||||
scene->removeObject(dynamic_cast<Qtk::MeshRenderer *>(object));
|
|
||||||
ui_->qtk__ToolBox->clearFocus();
|
|
||||||
break;
|
|
||||||
case Qtk::Object::Type::QTK_MODEL:
|
|
||||||
scene->removeObject(dynamic_cast<Qtk::Model *>(object));
|
|
||||||
ui_->qtk__ToolBox->clearFocus();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
qDebug() << "Failed to delete model with invalid type";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::setScene(Qtk::Scene * scene)
|
void MainWindow::setScene(Qtk::Scene * scene)
|
||||||
{
|
{
|
||||||
connect(scene,
|
connect(scene,
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QPlainTextEdit>
|
||||||
|
|
||||||
#include "designer-plugins/debugconsole.h"
|
#include "designer-plugins/debugconsole.h"
|
||||||
|
|
||||||
@@ -49,40 +49,9 @@ namespace Ui
|
|||||||
*/
|
*/
|
||||||
class EmptyScene : public Qtk::Scene
|
class EmptyScene : public Qtk::Scene
|
||||||
{
|
{
|
||||||
void init() override
|
void init() override { setSceneName("Empty Scene"); }
|
||||||
{
|
|
||||||
setSkybox(new Qtk::Skybox(":/textures/skybox/right.png",
|
|
||||||
":/textures/skybox/top.png",
|
|
||||||
":/textures/skybox/front.png",
|
|
||||||
":/textures/skybox/left.png",
|
|
||||||
":/textures/skybox/bottom.png",
|
|
||||||
":/textures/skybox/back.png",
|
|
||||||
"Skybox"));
|
|
||||||
setSceneName("Empty Scene");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Conditionally include the QtkScene header if the example is enabled.
|
|
||||||
* Set AppScene type to use in main() for creating the scene.
|
|
||||||
* Define helper function to initialize Qt resources for the application.
|
|
||||||
* These resources are different based on if the example is enabled.
|
|
||||||
*/
|
|
||||||
#ifdef QTK_GUI_SCENE
|
|
||||||
#include "qtkscene.h"
|
|
||||||
using AppScene = QtkScene;
|
|
||||||
inline void initResources()
|
|
||||||
{
|
|
||||||
Q_INIT_RESOURCE(resources);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
using AppScene = EmptyScene;
|
|
||||||
inline void initResources()
|
|
||||||
{
|
|
||||||
Q_INIT_RESOURCE(minimal_resources);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MainWindow class to provide an example of using a QtkWidget within a Qt
|
* MainWindow class to provide an example of using a QtkWidget within a Qt
|
||||||
* window application.
|
* window application.
|
||||||
@@ -128,15 +97,10 @@ class MainWindow : public QMainWindow
|
|||||||
Qtk::QtkWidget * getQtkWidget(const QString & name);
|
Qtk::QtkWidget * getQtkWidget(const QString & name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param scene The new scene to view.
|
* @param scene The new scene to view.
|
||||||
*/
|
*/
|
||||||
void setScene(Qtk::Scene * scene);
|
void setScene(Qtk::Scene * scene);
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Default icon to use for Qtk desktop application.
|
|
||||||
*/
|
|
||||||
static QIcon getIcon() { return QIcon(":/icons/icon.png"); }
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/**
|
/**
|
||||||
* Trigger a refresh for widgets related to a scene that has been updated.
|
* Trigger a refresh for widgets related to a scene that has been updated.
|
||||||
@@ -144,23 +108,6 @@ class MainWindow : public QMainWindow
|
|||||||
*/
|
*/
|
||||||
void refreshScene(const QString & sceneName);
|
void refreshScene(const QString & sceneName);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Opens a QFileDialog for selecting an object file to load into the scene.
|
|
||||||
*/
|
|
||||||
void loadObject()
|
|
||||||
{
|
|
||||||
const QUrl file = QFileDialog::getOpenFileName(
|
|
||||||
this, tr("Load Model"), QDir::homePath(), tr("Object Files (*.obj)"));
|
|
||||||
getQtkWidget()->getScene()->loadModel(file.fileName().replace(".obj", ""),
|
|
||||||
file.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes the currently selected object from the scene.
|
|
||||||
*/
|
|
||||||
void deleteObject();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Private Members
|
* Private Members
|
||||||
|
|||||||
@@ -222,9 +222,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionLoad_Model">
|
<action name="actionLoad_Model">
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset>
|
||||||
<normaloff>:/icons/fontawesome-free-6.2.1-desktop/svgs/solid/cube.svg</normaloff>:/icons/fontawesome-free-6.2.1-desktop/svgs/solid/cube.svg</iconset>
|
<normaloff>:/icons/fontawesome-free-6.2.1-desktop/svgs/solid/cube.svg</normaloff>:/icons/fontawesome-free-6.2.1-desktop/svgs/solid/cube.svg</iconset>
|
||||||
@@ -237,9 +234,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionDelete_Object">
|
<action name="actionDelete_Object">
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset>
|
||||||
<normaloff>:/icons/fontawesome-free-6.2.1-desktop/svgs/regular/trash-can.svg</normaloff>:/icons/fontawesome-free-6.2.1-desktop/svgs/regular/trash-can.svg</iconset>
|
<normaloff>:/icons/fontawesome-free-6.2.1-desktop/svgs/regular/trash-can.svg</normaloff>:/icons/fontawesome-free-6.2.1-desktop/svgs/regular/trash-can.svg</iconset>
|
||||||
|
|||||||
@@ -6,10 +6,6 @@
|
|||||||
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
||||||
##############################################################################*/
|
##############################################################################*/
|
||||||
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QProcess>
|
|
||||||
|
|
||||||
#include "qtkscene.h"
|
#include "qtkscene.h"
|
||||||
|
|
||||||
using namespace Qtk;
|
using namespace Qtk;
|
||||||
@@ -39,38 +35,8 @@ QtkScene::~QtkScene()
|
|||||||
|
|
||||||
void QtkScene::init()
|
void QtkScene::init()
|
||||||
{
|
{
|
||||||
// Clone qtk-resources if it doesn't already exist.
|
|
||||||
QDir repoDir("resources/");
|
|
||||||
if (!repoDir.exists()) {
|
|
||||||
qDebug() << "Cloning qtk-resources repository to " << repoDir.absolutePath()
|
|
||||||
<< "...";
|
|
||||||
|
|
||||||
// Run git clone
|
|
||||||
QProcess gitProcess;
|
|
||||||
gitProcess.setWorkingDirectory(QCoreApplication::applicationDirPath());
|
|
||||||
gitProcess.start("git",
|
|
||||||
{"clone",
|
|
||||||
"https://git.shaunreed.com/shaunrd0/qtk-resources.git",
|
|
||||||
repoDir.absolutePath()});
|
|
||||||
|
|
||||||
// Wait indefinitely for the process to complete
|
|
||||||
gitProcess.waitForFinished(-1);
|
|
||||||
// Check the result
|
|
||||||
if (gitProcess.exitCode() == 0) {
|
|
||||||
qDebug() << "Repository cloned successfully.";
|
|
||||||
} else {
|
|
||||||
qDebug() << "Git clone failed:" << gitProcess.readAllStandardError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a skybox to the scene using default cube map images and settings.
|
// Add a skybox to the scene using default cube map images and settings.
|
||||||
setSkybox(new Qtk::Skybox(":/textures/skybox/right.png",
|
setSkybox(new Qtk::Skybox("Skybox"));
|
||||||
":/textures/skybox/top.png",
|
|
||||||
":/textures/skybox/front.png",
|
|
||||||
":/textures/skybox/left.png",
|
|
||||||
":/textures/skybox/bottom.png",
|
|
||||||
":/textures/skybox/back.png",
|
|
||||||
"Skybox"));
|
|
||||||
|
|
||||||
/* Create a red cube with a mini master chief on top. */
|
/* Create a red cube with a mini master chief on top. */
|
||||||
auto myCube = new MeshRenderer("My cube", Cube(Qtk::QTK_DRAW_ELEMENTS));
|
auto myCube = new MeshRenderer("My cube", Cube(Qtk::QTK_DRAW_ELEMENTS));
|
||||||
@@ -78,7 +44,8 @@ void QtkScene::init()
|
|||||||
myCube->getTransform().setTranslation(5.0f, 0.0f, 0.0f);
|
myCube->getTransform().setTranslation(5.0f, 0.0f, 0.0f);
|
||||||
addObject(myCube);
|
addObject(myCube);
|
||||||
|
|
||||||
auto mySpartan = new Model("My spartan", QTK_SPARTAN);
|
auto mySpartan =
|
||||||
|
new Model("My spartan", ":/models/models/spartan/spartan.obj");
|
||||||
mySpartan->getTransform().setTranslation(5.0f, 0.5f, 0.0f);
|
mySpartan->getTransform().setTranslation(5.0f, 0.5f, 0.0f);
|
||||||
mySpartan->getTransform().setScale(0.5f);
|
mySpartan->getTransform().setScale(0.5f);
|
||||||
addObject(mySpartan);
|
addObject(mySpartan);
|
||||||
@@ -115,27 +82,31 @@ void QtkScene::init()
|
|||||||
//
|
//
|
||||||
// 3D Model loading
|
// 3D Model loading
|
||||||
|
|
||||||
auto model = addObject(new Qtk::Model("backpack", QTK_BACKPACK));
|
auto model = addObject(
|
||||||
|
new Qtk::Model("backpack", ":/models/models/backpack/backpack.obj"));
|
||||||
// Sometimes model textures need flipped in certain directions
|
// Sometimes model textures need flipped in certain directions
|
||||||
model->flipTexture("diffuse.jpg", false, true);
|
model->flipTexture("diffuse.jpg", false, true);
|
||||||
model->getTransform().setTranslation(0.0f, 0.0f, -10.0f);
|
model->getTransform().setTranslation(0.0f, 0.0f, -10.0f);
|
||||||
|
|
||||||
model = addObject(new Qtk::Model("bird", QTK_BIRD));
|
model = addObject(new Qtk::Model("bird", ":/models/models/bird/bird.obj"));
|
||||||
model->getTransform().setTranslation(2.0f, 2.0f, -10.0f);
|
model->getTransform().setTranslation(2.0f, 2.0f, -10.0f);
|
||||||
// Sometimes the models are very large
|
// Sometimes the models are very large
|
||||||
model->getTransform().scale(0.0025f);
|
model->getTransform().scale(0.0025f);
|
||||||
model->getTransform().rotate(-110.0f, 0.0f, 1.0f, 0.0f);
|
model->getTransform().rotate(-110.0f, 0.0f, 1.0f, 0.0f);
|
||||||
|
|
||||||
model = addObject(new Qtk::Model("alien", QTK_ALIEN));
|
model = addObject(
|
||||||
|
new Qtk::Model("alien", ":/models/models/alien-hominid/alien.obj"));
|
||||||
model->getTransform().setTranslation(2.0f, -1.0f, -5.0f);
|
model->getTransform().setTranslation(2.0f, -1.0f, -5.0f);
|
||||||
model->getTransform().scale(0.15f);
|
model->getTransform().scale(0.15f);
|
||||||
|
|
||||||
model = addObject(new Qtk::Model("My scythe", QTK_SCYTHE));
|
model = addObject(
|
||||||
|
new Qtk::Model("My scythe", ":/models/models/scythe/scythe.obj"));
|
||||||
model->getTransform().setTranslation(-6.0f, 0.0f, -10.0f);
|
model->getTransform().setTranslation(-6.0f, 0.0f, -10.0f);
|
||||||
model->getTransform().rotate(-90.0f, 1.0f, 0.0f, 0.0f);
|
model->getTransform().rotate(-90.0f, 1.0f, 0.0f, 0.0f);
|
||||||
model->getTransform().rotate(90.0f, 0.0f, 1.0f, 0.0f);
|
model->getTransform().rotate(90.0f, 0.0f, 1.0f, 0.0f);
|
||||||
|
|
||||||
model = addObject(new Qtk::Model("masterChief", QTK_SPARTAN));
|
model = addObject(
|
||||||
|
new Qtk::Model("masterChief", ":/models/models/spartan/spartan.obj"));
|
||||||
model->getTransform().setTranslation(-1.5f, 0.5f, -2.0f);
|
model->getTransform().setTranslation(-1.5f, 0.5f, -2.0f);
|
||||||
|
|
||||||
|
|
||||||
@@ -261,7 +232,7 @@ void QtkScene::init()
|
|||||||
|
|
||||||
/* Test alien Model with phong lighting and specular mapping. */
|
/* Test alien Model with phong lighting and specular mapping. */
|
||||||
model = addObject(new Qtk::Model("alienTest",
|
model = addObject(new Qtk::Model("alienTest",
|
||||||
QTK_ALIEN,
|
":/models/models/alien-hominid/alien.obj",
|
||||||
":/shaders/model-phong.vert",
|
":/shaders/model-phong.vert",
|
||||||
":/shaders/model-phong.frag"));
|
":/shaders/model-phong.frag"));
|
||||||
model->getTransform().setTranslation(3.0f, -1.0f, 10.0f);
|
model->getTransform().setTranslation(3.0f, -1.0f, 10.0f);
|
||||||
@@ -288,7 +259,7 @@ void QtkScene::init()
|
|||||||
|
|
||||||
/* Test spartan Model with phong lighting, specular and normal mapping. */
|
/* Test spartan Model with phong lighting, specular and normal mapping. */
|
||||||
model = addObject(new Qtk::Model("spartanTest",
|
model = addObject(new Qtk::Model("spartanTest",
|
||||||
QTK_SPARTAN,
|
":/models/models/spartan/spartan.obj",
|
||||||
":/shaders/model-phong.vert",
|
":/shaders/model-phong.vert",
|
||||||
":/shaders/model-phong.frag"));
|
":/shaders/model-phong.frag"));
|
||||||
model->getTransform().setTranslation(0.0f, -1.0f, 10.0f);
|
model->getTransform().setTranslation(0.0f, -1.0f, 10.0f);
|
||||||
@@ -426,7 +397,6 @@ void QtkScene::draw()
|
|||||||
// WARNING: We must call the base class draw() function first.
|
// WARNING: We must call the base class draw() function first.
|
||||||
// + This will handle rendering core scene components like the Skybox.
|
// + This will handle rendering core scene components like the Skybox.
|
||||||
Scene::draw();
|
Scene::draw();
|
||||||
const QVector3D cameraPosition = getCamera().getTransform().getTranslation();
|
|
||||||
|
|
||||||
mTestPhong->bindShaders();
|
mTestPhong->bindShaders();
|
||||||
mTestPhong->setUniform("uModelInverseTransposed",
|
mTestPhong->setUniform("uModelInverseTransposed",
|
||||||
@@ -434,12 +404,14 @@ void QtkScene::draw()
|
|||||||
mTestPhong->setUniform(
|
mTestPhong->setUniform(
|
||||||
"uLightPosition",
|
"uLightPosition",
|
||||||
MeshRenderer::getInstance("phongLight")->getTransform().getTranslation());
|
MeshRenderer::getInstance("phongLight")->getTransform().getTranslation());
|
||||||
mTestPhong->setUniform("uCameraPosition", cameraPosition);
|
mTestPhong->setUniform("uCameraPosition",
|
||||||
|
QtkScene::getCamera().getTransform().getTranslation());
|
||||||
mTestPhong->releaseShaders();
|
mTestPhong->releaseShaders();
|
||||||
mTestPhong->draw();
|
mTestPhong->draw();
|
||||||
|
|
||||||
mTestAmbient->bindShaders();
|
mTestAmbient->bindShaders();
|
||||||
mTestAmbient->setUniform("uCameraPosition", cameraPosition);
|
mTestAmbient->setUniform(
|
||||||
|
"uCameraPosition", QtkScene::getCamera().getTransform().getTranslation());
|
||||||
mTestAmbient->releaseShaders();
|
mTestAmbient->releaseShaders();
|
||||||
mTestAmbient->draw();
|
mTestAmbient->draw();
|
||||||
|
|
||||||
@@ -451,7 +423,8 @@ void QtkScene::draw()
|
|||||||
MeshRenderer::getInstance("diffuseLight")
|
MeshRenderer::getInstance("diffuseLight")
|
||||||
->getTransform()
|
->getTransform()
|
||||||
.getTranslation());
|
.getTranslation());
|
||||||
mTestDiffuse->setUniform("uCameraPosition", cameraPosition);
|
mTestDiffuse->setUniform(
|
||||||
|
"uCameraPosition", QtkScene::getCamera().getTransform().getTranslation());
|
||||||
mTestDiffuse->releaseShaders();
|
mTestDiffuse->releaseShaders();
|
||||||
mTestDiffuse->draw();
|
mTestDiffuse->draw();
|
||||||
|
|
||||||
@@ -463,70 +436,67 @@ void QtkScene::draw()
|
|||||||
MeshRenderer::getInstance("specularLight")
|
MeshRenderer::getInstance("specularLight")
|
||||||
->getTransform()
|
->getTransform()
|
||||||
.getTranslation());
|
.getTranslation());
|
||||||
mTestSpecular->setUniform("uCameraPosition", cameraPosition);
|
mTestSpecular->setUniform(
|
||||||
|
"uCameraPosition", QtkScene::getCamera().getTransform().getTranslation());
|
||||||
mTestSpecular->releaseShaders();
|
mTestSpecular->releaseShaders();
|
||||||
mTestSpecular->draw();
|
mTestSpecular->draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtkScene::update()
|
void QtkScene::update()
|
||||||
{
|
{
|
||||||
auto getModel = Model::getInstance;
|
auto mySpartan = Model::getInstance("My spartan");
|
||||||
const QVector3D cameraPosition = getCamera().getTransform().getTranslation();
|
mySpartan->getTransform().rotate(0.75f, 0.0f, 1.0f, 0.0f);
|
||||||
|
|
||||||
// Models may have failed to load, so we should check before accessing.
|
auto myCube = MeshRenderer::getInstance("My cube");
|
||||||
if (auto mySpartan = getModel("My spartan"); mySpartan) {
|
myCube->getTransform().rotate(-0.75f, 0.0f, 1.0f, 0.0f);
|
||||||
mySpartan->getTransform().rotate(0.75f, 0.0f, 1.0f, 0.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (auto myCube = getModel("My cube"); myCube) {
|
auto position = MeshRenderer::getInstance("alienTestLight")
|
||||||
myCube->getTransform().rotate(-0.75f, 0.0f, 1.0f, 0.0f);
|
->getTransform()
|
||||||
}
|
.getTranslation();
|
||||||
|
auto alien = Model::getInstance("alienTest");
|
||||||
|
alien->setUniform("uLight.position", position);
|
||||||
|
alien->setUniform("uCameraPosition",
|
||||||
|
QtkScene::getCamera().getTransform().getTranslation());
|
||||||
|
auto posMatrix = alien->getTransform().toMatrix();
|
||||||
|
alien->setUniform("uMVP.normalMatrix", posMatrix.normalMatrix());
|
||||||
|
alien->setUniform("uMVP.model", posMatrix);
|
||||||
|
alien->setUniform("uMVP.view", QtkScene::getCamera().toMatrix());
|
||||||
|
alien->setUniform("uMVP.projection", QtkScene::getProjectionMatrix());
|
||||||
|
alien->getTransform().rotate(0.75f, 0.0f, 1.0f, 0.0f);
|
||||||
|
|
||||||
QMatrix4x4 posMatrix;
|
position = MeshRenderer::getInstance("spartanTestLight")
|
||||||
if (auto alien = getModel("alienTest"); alien) {
|
->getTransform()
|
||||||
alien->setLightPosition("alienTestLight");
|
.getTranslation();
|
||||||
|
auto spartan = Model::getInstance("spartanTest");
|
||||||
|
spartan->setUniform("uLight.position", position);
|
||||||
|
spartan->setUniform("uCameraPosition",
|
||||||
|
QtkScene::getCamera().getTransform().getTranslation());
|
||||||
|
posMatrix = spartan->getTransform().toMatrix();
|
||||||
|
spartan->setUniform("uMVP.normalMatrix", posMatrix.normalMatrix());
|
||||||
|
spartan->setUniform("uMVP.model", posMatrix);
|
||||||
|
spartan->setUniform("uMVP.view", QtkScene::getCamera().toMatrix());
|
||||||
|
spartan->setUniform("uMVP.projection", QtkScene::getProjectionMatrix());
|
||||||
|
spartan->getTransform().rotate(0.75f, 0.0f, 1.0f, 0.0f);
|
||||||
|
|
||||||
alien->setUniform("uCameraPosition", cameraPosition);
|
auto phong = MeshRenderer::getInstance("testPhong");
|
||||||
posMatrix = alien->getTransform().toMatrix();
|
phong->getTransform().rotate(0.75f, 1.0f, 0.5f, 0.0f);
|
||||||
alien->setUniform("uMVP.normalMatrix", posMatrix.normalMatrix());
|
phong->bindShaders();
|
||||||
alien->setUniform("uMVP.model", posMatrix);
|
position =
|
||||||
alien->setUniform("uMVP.view", QtkScene::getCamera().toMatrix());
|
MeshRenderer::getInstance("testLight")->getTransform().getTranslation();
|
||||||
alien->setUniform("uMVP.projection", QtkScene::getProjectionMatrix());
|
phong->setUniform("uLight.position", position);
|
||||||
alien->getTransform().rotate(0.75f, 0.0f, 1.0f, 0.0f);
|
phong->setUniform("uCameraPosition",
|
||||||
}
|
QtkScene::getCamera().getTransform().getTranslation());
|
||||||
|
posMatrix = phong->getTransform().toMatrix();
|
||||||
if (auto spartan = getModel("spartanTest"); spartan) {
|
phong->setUniform("uMVP.normalMatrix", posMatrix.normalMatrix());
|
||||||
spartan->setLightPosition("spartanTestLight");
|
phong->setUniform("uMVP.model", posMatrix);
|
||||||
|
phong->setUniform("uMVP.view", QtkScene::getCamera().toMatrix());
|
||||||
spartan->setUniform("uCameraPosition", cameraPosition);
|
phong->setUniform("uMVP.projection", QtkScene::getProjectionMatrix());
|
||||||
posMatrix = spartan->getTransform().toMatrix();
|
phong->releaseShaders();
|
||||||
spartan->setUniform("uMVP.normalMatrix", posMatrix.normalMatrix());
|
|
||||||
spartan->setUniform("uMVP.model", posMatrix);
|
|
||||||
spartan->setUniform("uMVP.view", QtkScene::getCamera().toMatrix());
|
|
||||||
spartan->setUniform("uMVP.projection", QtkScene::getProjectionMatrix());
|
|
||||||
spartan->getTransform().rotate(0.75f, 0.0f, 1.0f, 0.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (auto phong = getModel("testPhong"); phong) {
|
|
||||||
phong->setLightPosition("testLight");
|
|
||||||
|
|
||||||
phong->getTransform().rotate(0.75f, 1.0f, 0.5f, 0.0f);
|
|
||||||
phong->bindShaders();
|
|
||||||
phong->setUniform("uCameraPosition", cameraPosition);
|
|
||||||
posMatrix = phong->getTransform().toMatrix();
|
|
||||||
phong->setUniform("uMVP.normalMatrix", posMatrix.normalMatrix());
|
|
||||||
phong->setUniform("uMVP.model", posMatrix);
|
|
||||||
phong->setUniform("uMVP.view", QtkScene::getCamera().toMatrix());
|
|
||||||
phong->setUniform("uMVP.projection", QtkScene::getProjectionMatrix());
|
|
||||||
phong->releaseShaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
// MeshRenderers are lower level opengl objects baked into the source code.
|
|
||||||
auto getMesh = MeshRenderer::getInstance;
|
|
||||||
|
|
||||||
// Rotate lighting example cubes
|
// Rotate lighting example cubes
|
||||||
mTestPhong->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
|
mTestPhong->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
|
||||||
getMesh("noLight")->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
|
MeshRenderer::getInstance("noLight")->getTransform().rotate(
|
||||||
|
0.75f, 0.5f, 0.3f, 0.2f);
|
||||||
mTestAmbient->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
|
mTestAmbient->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
|
||||||
mTestDiffuse->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
|
mTestDiffuse->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
|
||||||
mTestSpecular->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
|
mTestSpecular->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
|
||||||
@@ -534,27 +504,46 @@ void QtkScene::update()
|
|||||||
// Examples of various translations and rotations
|
// Examples of various translations and rotations
|
||||||
|
|
||||||
// Rotate in multiple directions simultaneously
|
// Rotate in multiple directions simultaneously
|
||||||
getMesh("rgbNormalsCube")->getTransform().rotate(0.75f, 0.2f, 0.4f, 0.6f);
|
MeshRenderer::getInstance("rgbNormalsCube")
|
||||||
|
->getTransform()
|
||||||
|
.rotate(0.75f, 0.2f, 0.4f, 0.6f);
|
||||||
|
|
||||||
// Pitch forward and roll sideways
|
// Pitch forward and roll sideways
|
||||||
getMesh("leftTriangle")->getTransform().rotate(0.75f, 1.0f, 0.0f, 0.0f);
|
MeshRenderer::getInstance("leftTriangle")
|
||||||
getMesh("rightTriangle")->getTransform().rotate(0.75f, 0.0f, 0.0f, 1.0f);
|
->getTransform()
|
||||||
|
.rotate(0.75f, 1.0f, 0.0f, 0.0f);
|
||||||
|
MeshRenderer::getInstance("rightTriangle")
|
||||||
|
->getTransform()
|
||||||
|
.rotate(0.75f, 0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
// Move between two positions over time
|
// Move between two positions over time
|
||||||
static float translateX = 0.025f;
|
static float translateX = 0.025f;
|
||||||
float limit = -9.0f; // Origin position.x - 2.0f
|
float limit = -9.0f; // Origin position.x - 2.0f
|
||||||
float posX = getMesh("topTriangle")->getTransform().getTranslation().x();
|
float posX = MeshRenderer::getInstance("topTriangle")
|
||||||
|
->getTransform()
|
||||||
|
.getTranslation()
|
||||||
|
.x();
|
||||||
if (posX < limit || posX > limit + 4.0f) {
|
if (posX < limit || posX > limit + 4.0f) {
|
||||||
translateX = -translateX;
|
translateX = -translateX;
|
||||||
}
|
}
|
||||||
getMesh("topTriangle")->getTransform().translate(translateX, 0.0f, 0.0f);
|
MeshRenderer::getInstance("topTriangle")
|
||||||
getMesh("bottomTriangle")->getTransform().translate(-translateX, 0.0f, 0.0f);
|
->getTransform()
|
||||||
|
.translate(translateX, 0.0f, 0.0f);
|
||||||
|
MeshRenderer::getInstance("bottomTriangle")
|
||||||
|
->getTransform()
|
||||||
|
.translate(-translateX, 0.0f, 0.0f);
|
||||||
// And lets rotate the triangles in two directions at once
|
// And lets rotate the triangles in two directions at once
|
||||||
getMesh("topTriangle")->getTransform().rotate(0.75f, 0.2f, 0.0f, 0.4f);
|
MeshRenderer::getInstance("topTriangle")
|
||||||
getMesh("bottomTriangle")->getTransform().rotate(0.75f, 0.0f, 0.2f, 0.4f);
|
->getTransform()
|
||||||
|
.rotate(0.75f, 0.2f, 0.0f, 0.4f);
|
||||||
|
MeshRenderer::getInstance("bottomTriangle")
|
||||||
|
->getTransform()
|
||||||
|
.rotate(0.75f, 0.0f, 0.2f, 0.4f);
|
||||||
// And make the bottom triangle green, instead of RGB
|
// And make the bottom triangle green, instead of RGB
|
||||||
|
|
||||||
// Rotate center cube in several directions simultaneously
|
// Rotate center cube in several directions simultaneously
|
||||||
// + Not subject to gimbal lock since we are using quaternions :)
|
// + Not subject to gimbal lock since we are using quaternions :)
|
||||||
getMesh("centerCube")->getTransform().rotate(0.75f, 0.2f, 0.4f, 0.6f);
|
MeshRenderer::getInstance("centerCube")
|
||||||
|
->getTransform()
|
||||||
|
.rotate(0.75f, 0.2f, 0.4f, 0.6f);
|
||||||
}
|
}
|
||||||
|
|||||||