diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0dede7f..6d6f207 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,4 +16,3 @@ jobs: repository: STORM-IRIT/Radium-Releases event-type: code-update-event client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}' - diff --git a/.github/workflows/pull-request-ci.yml b/.github/workflows/pull-request-ci.yml index 23d3fdd..7340927 100644 --- a/.github/workflows/pull-request-ci.yml +++ b/.github/workflows/pull-request-ci.yml @@ -8,8 +8,15 @@ on: pull_request: branches: - master + - release-candidate + push: + branches: + - release-candidate + env: - ext-dir: ${GITHUB_WORKSPACE//\\//}/external/install/ + install_prefix: install + build_prefix: build + src_prefix: src jobs: build: @@ -18,12 +25,23 @@ jobs: fail-fast: false matrix: config: - - { name: "Windows MSVC", suffix: "Windows", os: windows-latest, cc: "cl.exe", cxx: "cl.exe", assimp: "OFF" } + - { name: "Windows MSVC", suffix: "Windows", os: windows-latest, cc: "cl.exe", cxx: "cl.exe", assimp: "OFF"} - { name: "Ubuntu gcc", suffix: "Ubuntu-gcc", os: ubuntu-24.04, cc: "gcc", cxx: "g++", assimp: "ON" } - { name: "MacOS clang", suffix: "macOS", os: macos-latest, cc: "clang", cxx: "clang++", assimp: "ON" } - + build-type: + - "Release" steps: - - uses: seanmiddleditch/gha-setup-ninja@master + - name: Compute paths + id: paths + run: | + radium_build_dir="${{ env.build_prefix }}/${{ matrix.build-type }}/Radium-Engine" + radium_install_dir="${{ env.install_prefix }}/${{ matrix.build-type }}/Radium-Engine" + external_build_dir="${{ env.build_prefix }}/${{ matrix.build-type }}/external" + external_install_dir="${{ env.install_prefix }}/${{ matrix.build-type }}/external" + echo "radium_build_dir=$radium_build_dir" >> $GITHUB_OUTPUT + echo "radium_install_dir=$radium_install_dir" >> $GITHUB_OUTPUT + echo "external_build_dir=$external_build_dir" >> $GITHUB_OUTPUT + echo "external_install_dir=$external_install_dir" >> $GITHUB_OUTPUT - name: Add msbuild to PATH uses: seanmiddleditch/gha-setup-vsdevenv@master @@ -33,46 +51,49 @@ jobs: uses: jurplel/install-qt-action@v4 with: cache: true - cache-key-prefix: install-qt-action-${{ matrix.config.name }}-6.2.9 + cache-key-prefix: install-qt-action-${{ matrix.config.name }}-6.2.0 version: 6.2.0 - name: Prepare directories run: | - mkdir -p install/ - mkdir -p src/ - mkdir -p src/Radium-Apps - mkdir -p build/Radium-Engine - mkdir -p build/Radium-Apps - mkdir -p external/install/ - mkdir -p external/build/ + mkdir -p "${{ env.src_prefix }}" + mkdir -p "${{ steps.paths.outputs.radium_build_dir }}" + mkdir -p "${{ steps.paths.outputs.external_build_dir }}" + mkdir -p "${{ steps.paths.outputs.radium_install_dir }}" + mkdir -p "${{ steps.paths.outputs.external_install_dir }}" - name: Clone Radium + id: sha run: | - cd src && git clone --recurse-submodules https://github.com/STORM-IRIT/Radium-Engine.git --single-branch && cd .. + git clone --recurse-submodules https://github.com/STORM-IRIT/Radium-Engine.git --single-branch ${{ env.src_prefix }}/Radium-Engine + radium_sha=`git -C ${{ env.src_prefix }}/Radium-Engine rev-parse --short HEAD` + echo "radium_sha=$radium_sha" >> $GITHUB_OUTPUT - - name: Cache externals - id: cache-external + - name: Cache radium install + id: cache-radium-install uses: actions/cache@v4 with: - path: external - key: ${{ runner.os }}-${{ matrix.config.cc }}-external-${{ hashFiles('src/Radium-Engine/external/**/CMakeLists.txt') }} - - - name: Configure and build external - if: steps.cache-external.outputs.cache-hit != 'true' - run: | - cd external/build/ - cmake ../../src/Radium-Engine/external -GNinja -DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} -DCMAKE_C_COMPILER=${{ matrix.config.cc }} -DCMAKE_BUILD_TYPE=Release -DRADIUM_IO_ASSIMP=${{ matrix.config.assimp }} -DCMAKE_EXECUTE_PROCESS_COMMAND_ECHO=STDOUT -DRADIUM_UPDATE_VERSION=OFF -DRADIUM_EXTERNAL_CMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_INSTALL_PREFIX=../install/ - cmake --build . --parallel --config Release - - - name: Configure Radium - run: | - cd build/Radium-Engine - cmake ../../src/Radium-Engine -GNinja -DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} -DCMAKE_C_COMPILER=${{ matrix.config.cc }} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../../install/ -DRADIUM_IO_ASSIMP=${{ matrix.config.assimp }} -DCMAKE_EXECUTE_PROCESS_COMMAND_ECHO=STDOUT -DRADIUM_UPDATE_VERSION=OFF -DRADIUM_EXTERNAL_CMAKE_INSTALL_MESSAGE=LAZY -DRADIUM_INSTALL_DOC=OFF -DRADIUM_ENABLE_TESTING=OFF -C ${{env.ext-dir}}/radium-options.cmake - - - name: Build Radium + path: | + ${{ steps.paths.outputs.external_install_dir }} + ${{ steps.paths.outputs.radium_install_dir }} + key: ${{ matrix.config.name }}-radium-v1-${{ steps.sha.outputs.radium_sha }} + - name: Cache radium build + id: cache-radium-build + uses: actions/cache@v4 + with: + path: | + ${{ steps.paths.outputs.external_build_dir }} + ${{ steps.paths.outputs.radium_build_dir }} + key: ${{ matrix.config.name }}-radium-build-v1 + - name: Configure and build radium + if: steps.cache-radium-install.outputs.cache-hit != 'true' run: | - cd build/Radium-Engine - cmake --build . --parallel --config Release --target install + "${{ env.src_prefix }}/Radium-Engine/scripts/build.sh" \ + -B ${{ env.build_prefix }} \ + -G Ninja --cxx ${{ matrix.config.cxx }} --cc ${{ matrix.config.cc }} \ + -c ${{ matrix.build-type }} --enable-testing OFF \ + --install-external "${{ steps.paths.outputs.external_install_dir }}" \ + --install-radium "${{ steps.paths.outputs.radium_install_dir }}" - name: Clone Radium Apps uses: actions/checkout@master @@ -81,10 +102,12 @@ jobs: - name: Configure Radium Apps run: | - cd build/Radium-Apps - cmake ../../src/Radium-Apps -GNinja -DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} -DCMAKE_C_COMPILER=${{ matrix.config.cc }} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../../install/ -DRadium_DIR=../../install/lib/cmake/Radium + cmake -S "${{ env.src_prefix }}/Radium-Apps" -B "${{ env.build_prefix }}/Radium-Apps" -GNinja \ + -DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} -DCMAKE_C_COMPILER=${{ matrix.config.cc }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ + -DCMAKE_INSTALL_PREFIX=${{ env.install_prefix }}/Radium-Apps \ + -DRadium_DIR="${{ github.workspace }}/${{ steps.paths.outputs.radium_install_dir }}/lib/cmake/Radium" - name: Build Radium Apps run: | - cd build/Radium-Apps - cmake --build . --parallel --config Release --target install + cmake --build "${{ env.build_prefix }}/Radium-Apps" --parallel --config ${{ matrix.build-type }} --target install diff --git a/.github/workflows/release-candidate-push-ci.yml b/.github/workflows/release-candidate-push-ci.yml deleted file mode 100644 index 8ed5310..0000000 --- a/.github/workflows/release-candidate-push-ci.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: Compile Radium Apps (Release Candidate) - -defaults: - run: - shell: bash - -on: - push: - branches: - - release-candidate -env: - ext-dir: ${GITHUB_WORKSPACE//\\//}/external/install/ - -jobs: - build-rc: - runs-on: ${{ matrix.config.os }} - strategy: - fail-fast: false - matrix: - config: - - { name: "Windows MSVC", suffix: "Windows", os: windows-latest, cc: "cl.exe", cxx: "cl.exe", assimp: "OFF" } - - { name: "Ubuntu gcc", suffix: "Ubuntu-gcc", os: ubuntu-24.04, cc: "gcc", cxx: "g++", assimp: "ON" } - - { name: "MacOS clang", suffix: "macOS", os: macos-latest, cc: "clang", cxx: "clang++", assimp: "ON" } - - steps: - - uses: seanmiddleditch/gha-setup-ninja@master - - - name: Add msbuild to PATH - uses: seanmiddleditch/gha-setup-vsdevenv@master - if: runner.os == 'Windows' - - - name: Install Qt - uses: jurplel/install-qt-action@v4 - with: - cache: true - cache-key-prefix: install-qt-action-${{ matrix.config.name }}-6.2.9 - version: 6.2.0 - - - name: Prepare directories - run: | - mkdir -p install/ - mkdir -p src/ - mkdir -p src/Radium-Apps - mkdir -p build/Radium-Engine - mkdir -p build/Radium-Apps - mkdir -p external/install/ - mkdir -p external/build/ - - - name: Clone Radium - run: | - cd src && git clone --recurse-submodules https://github.com/STORM-IRIT/Radium-Engine.git --single-branch --branch release-candidate && cd .. - - - name: Cache externals - id: cache-external - uses: actions/cache@v4 - with: - path: external - key: ${{ runner.os }}-${{ matrix.config.cc }}-external-${{ hashFiles('src/Radium-Engine/external/**/CMakeLists.txt') }} - - - name: Configure and build external - if: steps.cache-external.outputs.cache-hit != 'true' - run: | - cd external/build/ - cmake ../../src/Radium-Engine/external -GNinja -DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} -DCMAKE_C_COMPILER=${{ matrix.config.cc }} -DCMAKE_BUILD_TYPE=Release -DRADIUM_IO_ASSIMP=${{ matrix.config.assimp }} -DCMAKE_EXECUTE_PROCESS_COMMAND_ECHO=STDOUT -DRADIUM_UPDATE_VERSION=OFF -DRADIUM_EXTERNAL_CMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_INSTALL_PREFIX=../install/ - cmake --build . --parallel --config Release - - - name: Configure Radium - run: | - cd build/Radium-Engine - cmake ../../src/Radium-Engine -GNinja -DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} -DCMAKE_C_COMPILER=${{ matrix.config.cc }} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../../install/ -DRADIUM_IO_ASSIMP=${{ matrix.config.assimp }} -DCMAKE_EXECUTE_PROCESS_COMMAND_ECHO=STDOUT -DRADIUM_UPDATE_VERSION=OFF -DRADIUM_EXTERNAL_CMAKE_INSTALL_MESSAGE=LAZY -DRADIUM_INSTALL_DOC=OFF -DRADIUM_ENABLE_TESTING=OFF -C ${{env.ext-dir}}/radium-options.cmake - - - name: Build Radium - run: | - cd build/Radium-Engine - cmake --build . --parallel --config Release --target install - - - name: Clone Radium Apps - uses: actions/checkout@master - with: - path: src/Radium-Apps - - - name: Configure Radium Apps - run: | - cd build/Radium-Apps - cmake ../../src/Radium-Apps -GNinja -DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} -DCMAKE_C_COMPILER=${{ matrix.config.cc }} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../../install/ -DRadium_DIR=../../install/lib/cmake/Radium - - - name: Build Radium Apps - run: | - cd build/Radium-Apps - cmake --build . --parallel --config Release --target install diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..28cc11d --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,12 @@ +# https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml +default: true +MD002: false +MD033: false + +MD013: + line_length: 520 + code_block_line_length: 200 +MD034: true +MD041: false +# link fragments from php markdown are not recognized +MD051: false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..0b97671 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,30 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks + +ci: + autoupdate_branch: release-candidate + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + exclude: ^tests/.*/data/.*$ + - id: end-of-file-fixer + exclude: ^tests/.*/data/.*$ + - id: check-yaml + - id: check-added-large-files +- repo: https://github.com/cheshirekow/cmake-format-precommit + rev: v0.6.13 + hooks: + - id: cmake-format +- repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.45.0 + hooks: + - id: markdownlint + args: [-f] +- repo: https://github.com/pre-commit/mirrors-clang-format + rev: v20.1.8 + hooks: + - id: clang-format + types_or: [c++, c, cuda] diff --git a/CLISubdivider/CMakeLists.txt b/CLISubdivider/CMakeLists.txt index 9690c01..5b6e6ab 100644 --- a/CLISubdivider/CMakeLists.txt +++ b/CLISubdivider/CMakeLists.txt @@ -1,19 +1,16 @@ cmake_minimum_required(VERSION 3.18) -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------- # exampleApp executables setup project(Radium-CLI-Subdivider) -find_package( Radium REQUIRED Core IO) +find_package(Radium REQUIRED Core IO) -#------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ # Application specific - add_executable(${PROJECT_NAME} main.cpp) -target_link_libraries (${PROJECT_NAME} PUBLIC Radium::Core Radium::IO) +target_link_libraries(${PROJECT_NAME} PUBLIC Radium::Core Radium::IO) # call the installation configuration (defined in RadiumConfig.cmake) -configure_radium_app( - NAME ${PROJECT_NAME} -) +configure_radium_app(NAME ${PROJECT_NAME}) diff --git a/CLISubdivider/README.md b/CLISubdivider/README.md index d52ab1f..6039bd1 100644 --- a/CLISubdivider/README.md +++ b/CLISubdivider/README.md @@ -1,8 +1,9 @@ # Radium Subdivider Command-Line Interface -Load a triangle mesh and subdivide it using OpenMesh. +Load a triangle mesh and subdivide it using OpenMesh. ## CLI parameters + ```cpp std::cout << "Usage :\n" << argv[0] << " -i input.obj -o output -s type -n iteration \n\n" @@ -14,43 +15,47 @@ std::cout << "Usage :\n" "iteration of subdivision\n\n"; ``` - ## Code breakdown + Excluding command parsing, only very few steps are required to load, simplify and save the object: - 1. Load triangular mesh or generate -```cpp -Ra::Core::Geometry::TriangleMesh mesh; -Ra::IO::OBJFileManager obj; +1. Load triangular mesh or generate -// Load geometry as triangle -if ( inputFilename.empty() ) { mesh = Ra::Core::Geometry::makeBox(); } -else { obj.load( inputFilename, mesh ); } -``` + ```cpp + Ra::Core::Geometry::TriangleMesh mesh; + Ra::IO::OBJFileManager obj; - 2. Create topological structure from the loaded geometry, and OpenMesh datastructures. -```cpp -// Create topological structure -Ra::Core::Geometry::TopologicalMesh topologicalMesh( mesh ); + // Load geometry as triangle + if ( inputFilename.empty() ) { mesh = Ra::Core::Geometry::makeBox(); } + else { obj.load( inputFilename, mesh ); } + ``` -// Create CatmullClarkSubdivider -using Subdivider = -OpenMesh::Subdivider::Uniform::SubdividerT; -Subdiviser subdiviser(Ra::Core::Geometry::CatmullClarkSubdivider); -``` +2. Create topological structure from the loaded geometry, and OpenMesh datastructures. - 3. Create OpenMesh subdivider and process geometry -```cpp -subdivider.attach( topologicalMesh ); -subdivider( nIter ); -subdivider.detach(); -``` + ```cpp + // Create topological structure + Ra::Core::Geometry::TopologicalMesh topologicalMesh( mesh ); - 4. Convert and save simplified geometry -```cpp -// Convert processed topological structure to triangle mesh -mesh = topologicalMesh.toTriangleMesh(); + // Create CatmullClarkSubdivider + using Subdivider = + OpenMesh::Subdivider::Uniform::SubdividerT; + Subdiviser subdiviser(Ra::Core::Geometry::CatmullClarkSubdivider); + ``` + +3. Create OpenMesh subdivider and process geometry + + ```cpp + subdivider.attach( topologicalMesh ); + subdivider( nIter ); + subdivider.detach(); + ``` + +4. Convert and save simplified geometry + + ```cpp + // Convert processed topological structure to triangle mesh + mesh = topologicalMesh.toTriangleMesh(); -// Save triangle mesh to obj file -obj.save( outputFilename, mesh ); -``` \ No newline at end of file + // Save triangle mesh to obj file + obj.save( outputFilename, mesh ); + ``` diff --git a/CLISubdivider/main.cpp b/CLISubdivider/main.cpp index a20a970..fe75ddc 100644 --- a/CLISubdivider/main.cpp +++ b/CLISubdivider/main.cpp @@ -9,15 +9,15 @@ /// Macro used for testing only, to add attibutes to the TopologicalMesh /// before subdivisition /// \FIXME Must be removed once using Radium::IO with attribute loading. -//#define TEST_ATTRIBUTES_SUBDIV +// #define TEST_ATTRIBUTES_SUBDIV struct args { bool valid; int iteration; std::string outputFilename; std::string inputFilename; - std::unique_ptr< - OpenMesh::Subdivider::Uniform::SubdividerT> + std::unique_ptr> subdivider; }; @@ -41,42 +41,34 @@ void printHelp( char* argv[] ) { args processArgs( int argc, char* argv[] ) { args ret; - bool outputFilenameSet{false}; - bool subdividerSet{false}; + bool outputFilenameSet { false }; + bool subdividerSet { false }; ret.iteration = 1; - for ( int i = 1; i < argc; i += 2 ) - { - if ( std::string( argv[i] ) == std::string( "-i" ) ) - { + for ( int i = 1; i < argc; i += 2 ) { + if ( std::string( argv[i] ) == std::string( "-i" ) ) { if ( i + 1 < argc ) { ret.inputFilename = argv[i + 1]; } } - else if ( std::string( argv[i] ) == std::string( "-o" ) ) - { - if ( i + 1 < argc ) - { + else if ( std::string( argv[i] ) == std::string( "-o" ) ) { + if ( i + 1 < argc ) { ret.outputFilename = argv[i + 1]; outputFilenameSet = true; } } - else if ( std::string( argv[i] ) == std::string( "-s" ) ) - { - if ( i + 1 < argc ) - { - std::string a{argv[i + 1]}; + else if ( std::string( argv[i] ) == std::string( "-s" ) ) { + if ( i + 1 < argc ) { + std::string a { argv[i + 1] }; subdividerSet = true; - if ( a == std::string( "catmull" ) ) - { + if ( a == std::string( "catmull" ) ) { ret.subdivider = std::make_unique(); } - else if ( a == std::string( "loop" ) ) - { ret.subdivider = std::make_unique(); } - else - { subdividerSet = false; } + else if ( a == std::string( "loop" ) ) { + ret.subdivider = std::make_unique(); + } + else { subdividerSet = false; } } } - else if ( std::string( argv[i] ) == std::string( "-n" ) ) - { + else if ( std::string( argv[i] ) == std::string( "-n" ) ) { if ( i + 1 < argc ) { ret.iteration = std::stoi( std::string( argv[i + 1] ) ); } } } @@ -88,14 +80,13 @@ int main( int argc, char* argv[] ) { using namespace Ra::Core::Utils; // log args a = processArgs( argc, argv ); if ( !a.valid ) { printHelp( argv ); } - else - { + else { Ra::Core::Geometry::TriangleMesh mesh; Ra::IO::OBJFileManager obj; // Load geometry as triangle if ( a.inputFilename.empty() ) { mesh = Ra::Core::Geometry::makeBox(); } - else { obj.load( a.inputFilename, mesh ); } + else { obj.load( a.inputFilename, mesh ); } // Create topological structure Ra::Core::Geometry::deprecated::TopologicalMesh topologicalMesh( mesh ); diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a85692..0f14cf4 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.18) +cmake_minimum_required(VERSION 3.18) project(Radium-apps) # Set default build type to Release @@ -7,24 +7,28 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") endif() -# set the installation directory for all the apps at once. This will make the same definition ignore on all the -# included applications -if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - - # Compute default paths following Radium's logic - if (CMAKE_BUILD_TYPE STREQUAL "Release") - set(RADIUM_APPS_BUNDLE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/installed-${CMAKE_CXX_COMPILER_ID}) - else () - set(RADIUM_APPS_BUNDLE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/installed-${CMAKE_CXX_COMPILER_ID}-${CMAKE_BUILD_TYPE}) - endif () - - set (CMAKE_INSTALL_PREFIX "${RADIUM_APPS_BUNDLE_DIRECTORY}/" CACHE PATH - "Install path prefix, prepended onto install directories." FORCE ) - message( "Set install prefix to ${CMAKE_INSTALL_PREFIX}" ) - set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT False) +# set the installation directory for all the apps at once. This will make the +# same definition ignore on all the included applications +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + + # Compute default paths following Radium's logic + if(CMAKE_BUILD_TYPE STREQUAL "Release") + set(RADIUM_APPS_BUNDLE_DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/installed-${CMAKE_CXX_COMPILER_ID}) + else() + set(RADIUM_APPS_BUNDLE_DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/installed-${CMAKE_CXX_COMPILER_ID}-${CMAKE_BUILD_TYPE} + ) + endif() + + set(CMAKE_INSTALL_PREFIX + "${RADIUM_APPS_BUNDLE_DIRECTORY}/" + CACHE PATH "Install path prefix, prepended onto install directories." + FORCE) + message("Set install prefix to ${CMAKE_INSTALL_PREFIX}") + set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT False) endif() - # Be nice to visual studio set_property(GLOBAL PROPERTY USE_FOLDERS ON) diff --git a/README.md b/README.md index a353059..618674d 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,52 @@ # Radium Applications + Radium is a research 3D Engine for rendering, animation and processing. It is developed and maintained by the [STORM research group](https://www.irit.fr/STORM/site/). This repository holds front-end applications (GUI, command line) based on Radium Libraries - - Sandbox: Graphical frontend of the Radium Engine. This application aims at demonstrating the capabilities of the Radium Libraries. It can be extended using Radium plugins. - - CLISubdivider: Example of command line application. Loads obj files and run subdivision algorithms implemented with OpenMesh. - + +- Sandbox: Graphical frontend of the Radium Engine. This application aims at demonstrating the capabilities of the Radium Libraries. It can be extended using Radium plugins. +- CLISubdivider: Example of command line application. Loads obj files and run subdivision algorithms implemented with OpenMesh. + To get more details about each application, checkout the Readme files in each application directory. -# How to get these applications -## Pre-compiled binaries -Pre-compiled binaries can be downloaded from https://github.com/STORM-IRIT/Radium-Releases/releases/. +## How to get these applications + +### Pre-compiled binaries + +Pre-compiled binaries can be downloaded from . The downloaded archive contains: - - Radium libraries - - Radium example applications (this repository) -## Compilation instructions +- Radium libraries +- Radium example applications (this repository) + +### Compilation instructions + To compile this repository, you first need to compile and install the [Radium libraries](https://github.com/STORM-IRIT/Radium-Engine). -Then, configure this project using cmake. -You need to tell cmake where to find the installed Radium package by setting the `Radium_DIR` variable to the right location (see more details in Radium Engine documentation: https://storm-irit.github.io/Radium-Engine/). +Then, configure this project using cmake. +You need to tell cmake where to find the installed Radium package by setting the `Radium_DIR` variable to the right location (see more details in Radium Engine documentation: ). +## How to write your own application -# How to write your own application This repository also demonstrate how to write applications and extend Radium ecosystem. Radium provides a set of tools simplifying the deployment of such applications, which among other things take care of the portability and relocatability of the binaries. -Other minimal application examples are available at https://github.com/STORM-IRIT/Radium-Engine/tree/master/tests/ExampleApps. +Other minimal application examples are available at . In order to write your own application, you need to follow theses instructions. +### Setting a CMakeLists.txt to compile and install an application -## Setting a CMakeLists.txt to compile and install an application To compile and execute an application, either in the build tree or after installation, the Radium environment must be configured, compiled and installed beforehand. The main CMakeLists.txt file for compiling a Radium Based application could be as simple as + ```cmake # set the minimal cmake version supported by Radium cmake system cmake_minimum_required(VERSION 3.6) @@ -82,18 +89,22 @@ configure_radium_app( ) ``` -### Configure the application +#### Configure the application + Radium does not support in-source builds (it is bad practice anyway). You then must first create a buid directory that will be the root of the buildtree. - mkdir build - cd build +```bash +mkdir build +cd build +``` If the Radium environment was installed in the directory `pathToRadiumInstallation`, configure the project with : - cmake ../ -DRadium_DIR=pathToRadiumInstallation/lib/cmake/Radium - +```bash +cmake ../ -DRadium_DIR=pathToRadiumInstallation/lib/cmake/Radium +``` By default, the application will be installed in a directory called `installed-` in the application buildtree. This installed diff --git a/Sandbox/CMakeLists.txt b/Sandbox/CMakeLists.txt index 0a34b35..d6767c0 100644 --- a/Sandbox/CMakeLists.txt +++ b/Sandbox/CMakeLists.txt @@ -2,88 +2,72 @@ cmake_minimum_required(VERSION 3.18) if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_GREATER "3.9") - cmake_policy(SET CMP0071 NEW) + cmake_policy(SET CMP0071 NEW) endif() -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------- # exampleApp executables setup project(Radium-Sandbox) -# Set default install location to installed- folder in build dir -# we do not want to install to /usr by default -if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set (CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/installed-${CMAKE_CXX_COMPILER_ID}" CACHE PATH - "Install path prefix, prepended onto install directories." FORCE ) - message( "Set install prefix to ${CMAKE_INSTALL_PREFIX}" ) +# Set default install location to installed- folder in build dir we +# do not want to install to /usr by default +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX + "${CMAKE_CURRENT_BINARY_DIR}/installed-${CMAKE_CXX_COMPILER_ID}" + CACHE PATH "Install path prefix, prepended onto install directories." + FORCE) + message("Set install prefix to ${CMAKE_INSTALL_PREFIX}") endif() -find_package( Radium REQUIRED Core Engine Gui PluginBase IO) +find_package( + Radium + REQUIRED + Core + Engine + Gui + PluginBase + IO) -#------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ # Application specific - find_qt_package(COMPONENTS Core Widgets OpenGL REQUIRED) -set( Qt_LIBRARIES Qt::Core Qt::Widgets Qt::OpenGL ) +set(Qt_LIBRARIES Qt::Core Qt::Widgets Qt::OpenGL) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(app_sources - main.cpp - MainApplication.cpp - Gui/ColorWidget.cpp - Gui/MainWindow.cpp - Gui/MaterialEditor.cpp - Gui/TransformEditorWidget.cpp - ) + main.cpp MainApplication.cpp Gui/ColorWidget.cpp Gui/MainWindow.cpp + Gui/MaterialEditor.cpp Gui/TransformEditorWidget.cpp) set(app_headers - MainApplication.hpp - Gui/ColorWidget.hpp - Gui/MainWindow.hpp - Gui/MaterialEditor.hpp - Gui/RotationEditor.hpp - Gui/TransformEditorWidget.hpp - Gui/VectorEditor.hpp - ) - -set(app_uis - Gui/ui/MainWindow.ui - Gui/ui/RotationEditor.ui - Gui/ui/VectorEditor.ui - ) + MainApplication.hpp + Gui/ColorWidget.hpp + Gui/MainWindow.hpp + Gui/MaterialEditor.hpp + Gui/RotationEditor.hpp + Gui/TransformEditorWidget.hpp + Gui/VectorEditor.hpp) -qt_wrap_ui(app_uis_moc ${app_uis}) +set(app_uis Gui/ui/MainWindow.ui Gui/ui/RotationEditor.ui + Gui/ui/VectorEditor.ui) -set(app_resources - Resources/ApplicationIcons.qrc - ) +qt_wrap_ui(app_uis_moc ${app_uis}) +set(app_resources Resources/ApplicationIcons.qrc) set(CMAKE_INCLUDE_CURRENT_DIR ON) -include_directories( - ${CMAKE_CURRENT_BINARY_DIR} # Moc - ) +include_directories(${CMAKE_CURRENT_BINARY_DIR} # Moc +) add_executable( - ${PROJECT_NAME} MACOSX_BUNDLE - ${app_sources} - ${app_headers} - ${app_inlines} - ${app_uis_moc} - ${app_resources} - ) - -target_link_libraries (${PROJECT_NAME} PUBLIC - Radium::Core - Radium::Engine - Radium::Gui - Radium::IO - ${Qt_LIBRARIES}) - -configure_radium_app( - NAME ${PROJECT_NAME} - USE_PLUGINS -) + ${PROJECT_NAME} MACOSX_BUNDLE ${app_sources} ${app_headers} ${app_inlines} + ${app_uis_moc} ${app_resources}) + +target_link_libraries( + ${PROJECT_NAME} PUBLIC Radium::Core Radium::Engine Radium::Gui Radium::IO + ${Qt_LIBRARIES}) + +configure_radium_app(NAME ${PROJECT_NAME} USE_PLUGINS) # radium_cotire( ${app_target} ) diff --git a/Sandbox/Gui/ColorWidget.cpp b/Sandbox/Gui/ColorWidget.cpp index aba1c23..64da0f2 100644 --- a/Sandbox/Gui/ColorWidget.cpp +++ b/Sandbox/Gui/ColorWidget.cpp @@ -28,8 +28,7 @@ void ColorWidget::colorChanged() { void ColorWidget::mousePressEvent( QMouseEvent* /*event*/ ) { QColor color = QColorDialog::getColor( m_currentColor ); - if ( color != m_currentColor ) - { + if ( color != m_currentColor ) { m_currentColor = color; colorChanged(); diff --git a/Sandbox/Gui/MainWindow.cpp b/Sandbox/Gui/MainWindow.cpp index 7a8a24f..ebdfc49 100644 --- a/Sandbox/Gui/MainWindow.cpp +++ b/Sandbox/Gui/MainWindow.cpp @@ -76,8 +76,7 @@ MainWindow::MainWindow( QWidget* parent ) : MainWindowInterface( parent ) { mainApp->getEngine()->getSystem( "SkeletonBasedAnimationSystem" ) ); m_skelAnim = new Ra::Gui::SkeletonBasedAnimationUI( animSystem, m_timeline ); toolBox->addTab( m_skelAnim, "SkeletonBased Animation" ); - for ( int i = 0; i < m_skelAnim->getActionNb(); ++i ) - { + for ( int i = 0; i < m_skelAnim->getActionNb(); ++i ) { toolBar->addAction( m_skelAnim->getAction( i ) ); } @@ -108,8 +107,7 @@ MainWindow::~MainWindow() { } void MainWindow::cleanup() { - if ( auto signalManager = Ra::Engine::RadiumEngine::getInstance()->getSignalManager() ) - { + if ( auto signalManager = Ra::Engine::RadiumEngine::getInstance()->getSignalManager() ) { { auto& obs = signalManager->getEntityCreatedNotifier(); obs.detach( m_entityAddObserverId ); @@ -281,20 +279,21 @@ void MainWindow::createConnections() { // Connect engine signals to the appropriate callbacks auto signalManager = Ra::Engine::RadiumEngine::getInstance()->getSignalManager(); - auto& entityAddedObs = signalManager->getEntityCreatedNotifier(); - m_entityAddObserverId = entityAddedObs.attachMember( this, &MainWindow::onItemAdded); - auto& entityRemovedObs = signalManager->getEntityDestroyedNotifier(); - m_entityRemoveObserverId = entityRemovedObs.attachMember( this, &MainWindow::onItemRemoved); + auto& entityAddedObs = signalManager->getEntityCreatedNotifier(); + m_entityAddObserverId = entityAddedObs.attachMember( this, &MainWindow::onItemAdded ); + auto& entityRemovedObs = signalManager->getEntityDestroyedNotifier(); + m_entityRemoveObserverId = entityRemovedObs.attachMember( this, &MainWindow::onItemRemoved ); - auto& componentAddedObs = signalManager->getComponentCreatedNotifier(); - m_componentAddObserverId = componentAddedObs.attachMember( this, &MainWindow::onItemAdded); + auto& componentAddedObs = signalManager->getComponentCreatedNotifier(); + m_componentAddObserverId = componentAddedObs.attachMember( this, &MainWindow::onItemAdded ); auto& componentRemovedObs = signalManager->getComponentDestroyedNotifier(); - m_componentRemoveObserverId = componentRemovedObs.attachMember( this, &MainWindow::onItemRemoved); + m_componentRemoveObserverId = + componentRemovedObs.attachMember( this, &MainWindow::onItemRemoved ); - auto& roAddedObs = signalManager->getRenderObjectCreatedNotifier(); - m_roAddObserverId = roAddedObs.attachMember( this, &MainWindow::onItemAdded); - auto& roRemovedObs = signalManager->getRenderObjectDestroyedNotifier(); - m_roRemoveObserverId = roRemovedObs.attachMember( this, &MainWindow::onItemRemoved); + auto& roAddedObs = signalManager->getRenderObjectCreatedNotifier(); + m_roAddObserverId = roAddedObs.attachMember( this, &MainWindow::onItemAdded ); + auto& roRemovedObs = signalManager->getRenderObjectDestroyedNotifier(); + m_roRemoveObserverId = roRemovedObs.attachMember( this, &MainWindow::onItemRemoved ); } void MainWindow::loadFile() { @@ -302,11 +301,9 @@ void MainWindow::loadFile() { QString filter; QString allexts; - for ( const auto& loader : mainApp->m_engine->getFileLoaders() ) - { + for ( const auto& loader : mainApp->m_engine->getFileLoaders() ) { QString exts; - for ( const auto& e : loader->getFileExtensions() ) - { + for ( const auto& e : loader->getFileExtensions() ) { exts.append( QString::fromStdString( e ) + tr( " " ) ); } allexts.append( exts + tr( " " ) ); @@ -322,12 +319,10 @@ void MainWindow::loadFile() { QString path = settings.value( "files/load", QDir::homePath() ).toString(); QStringList pathList = QFileDialog::getOpenFileNames( this, "Open Files", path, filter ); - if ( !pathList.empty() ) - { + if ( !pathList.empty() ) { settings.setValue( "files/load", pathList.front() ); - for ( const auto& file : pathList ) - { + for ( const auto& file : pathList ) { emit fileLoading( file ); } auto sceneName = pathList.first().toStdString(); @@ -360,21 +355,19 @@ void MainWindow::onUpdateFramestats( const std::vector& stats ) long sumFrame = 0; long sumInterFrame = 0; - for ( uint i = 0; i < stats.size(); ++i ) - { + for ( uint i = 0; i < stats.size(); ++i ) { sumRender += Core::Utils::getIntervalMicro( stats[i].renderData.renderStart, stats[i].renderData.renderEnd ); sumTasks += Core::Utils::getIntervalMicro( stats[i].tasksStart, stats[i].tasksEnd ); sumFrame += Core::Utils::getIntervalMicro( stats[i].frameStart, stats[i].frameEnd ); - if ( i > 0 ) - { + if ( i > 0 ) { sumInterFrame += Core::Utils::getIntervalMicro( stats[i - 1].frameEnd, stats[i].frameEnd ); } } - const uint N {uint( stats.size() )}; + const uint N { uint( stats.size() ) }; const Scalar T( N * 1000000.f ); m_renderTime->setNum( int( sumRender / N ) ); m_renderUpdates->setNum( int( T / Scalar( sumRender ) ) ); @@ -404,11 +397,9 @@ void Gui::MainWindow::toggleCirclePicking( bool on ) { void MainWindow::handlePicking( const Engine::Rendering::Renderer::PickingResult& pickingResult ) { Ra::Core::Utils::Index roIndex( pickingResult.getRoIdx() ); Ra::Engine::RadiumEngine* engine = Ra::Engine::RadiumEngine::getInstance(); - if ( roIndex.isValid() ) - { + if ( roIndex.isValid() ) { auto ro = engine->getRenderObjectManager()->getRenderObject( roIndex ); - if ( ro->getType() != Ra::Engine::Rendering::RenderObjectType::UI ) - { + if ( ro->getType() != Ra::Engine::Rendering::RenderObjectType::UI ) { Ra::Engine::Scene::Component* comp = ro->getComponent(); Ra::Engine::Scene::Entity* ent = comp->getEntity(); @@ -418,23 +409,20 @@ void MainWindow::handlePicking( const Engine::Rendering::Renderer::PickingResult QItemSelectionModel::Current ); } } - else - { m_selectionManager->clear(); } + else { m_selectionManager->clear(); } } void MainWindow::onSelectionChanged( const QItemSelection& /*selected*/, const QItemSelection& /*deselected*/ ) { - if ( m_selectionManager->hasSelection() ) - { + if ( m_selectionManager->hasSelection() ) { const ItemEntry& ent = m_selectionManager->currentItem(); emit selectedItem( ent ); m_selectedItemName->setText( QString::fromStdString( getEntryName( mainApp->getEngine(), ent ) ) ); m_editRenderObjectButton->setEnabled( false ); - if ( ent.isRoNode() ) - { + if ( ent.isRoNode() ) { m_editRenderObjectButton->setEnabled( true ); m_materialEditor->changeRenderObject( ent.m_roIndex ); @@ -446,13 +434,11 @@ void MainWindow::onSelectionChanged( const QItemSelection& /*selected*/, "RO shaders must be already added to the list" ); m_currentShaderBox->setCurrentText( shaderName.c_str() ); } - else - { m_currentShaderBox->setCurrentText( "" ); } + else { m_currentShaderBox->setCurrentText( "" ); } m_skelAnim->selectionChanged( ent ); m_timeline->selectionChanged( ent ); } - else - { + else { m_currentShaderBox->setEnabled( false ); m_currentShaderBox->setCurrentText( "" ); emit selectedItem( ItemEntry() ); @@ -499,8 +485,7 @@ void MainWindow::loadConfiguration() { path = QFileDialog::getOpenFileName( this, "Open Configuration File", path, "Configuration file (*.xml)" ); - if ( path.size() > 0 ) - { + if ( path.size() > 0 ) { settings.setValue( "configs/load", path ); KeyMappingManager::getInstance()->loadConfiguration( path.toStdString().c_str() ); } @@ -509,8 +494,7 @@ void MainWindow::loadConfiguration() { void MainWindow::onCurrentRenderChangedInUI() { // always restore displaytexture to 0 before switch to keep coherent renderer state m_displayedTextureCombo->setCurrentIndex( 0 ); - if ( m_viewer->changeRenderer( m_currentRendererCombo->currentIndex() ) ) - { + if ( m_viewer->changeRenderer( m_currentRendererCombo->currentIndex() ) ) { updateDisplayedTexture(); // in case the newly used renderer has not been set before and set another texture as its // default, set displayTexture to 0 again ;) @@ -524,8 +508,7 @@ void MainWindow::updateDisplayedTexture() { m_displayedTextureCombo->clear(); auto texs = m_viewer->getRenderer()->getAvailableTextures(); - for ( const auto& tex : texs ) - { + for ( const auto& tex : texs ) { m_displayedTextureCombo->addItem( tex.c_str() ); } } @@ -534,16 +517,14 @@ void MainWindow::updateBackgroundColor( QColor c ) { // FIXME : sometime, settings does not define colors but Qt found one .... QSettings settings; // Get or set color from/to settings - if ( !c.isValid() ) - { + if ( !c.isValid() ) { // get the default color or an already existing one auto defColor = Core::Utils::Color::linearRGBTosRGB( m_viewer->getBackgroundColor() ); auto bgk = QColor::fromRgb( defColor.rgb()[0] * 255, defColor.rgb()[1] * 255, defColor.rgb()[2] * 255 ); c = settings.value( "colors/background", bgk ).value(); } - else - { settings.setValue( "colors/background", c ); } + else { settings.setValue( "colors/background", c ); } // update the color of the button QString qss = QString( "background-color: %1" ).arg( c.name() ); @@ -590,8 +571,7 @@ void Gui::MainWindow::setROVisible( Core::Utils::Index roIndex, bool visible ) { void Gui::MainWindow::editRO() { ItemEntry item = m_selectionManager->currentItem(); - if ( item.isRoNode() ) - { + if ( item.isRoNode() ) { m_materialEditor->changeRenderObject( item.m_roIndex ); m_materialEditor->show(); } @@ -601,15 +581,12 @@ void Gui::MainWindow::showHideAllRO() { bool allEntityInvisible = true; const int j = 0; - for ( int i = 0; i < m_itemModel->rowCount(); ++i ) - { + for ( int i = 0; i < m_itemModel->rowCount(); ++i ) { auto idx = m_itemModel->index( i, j ); auto item = m_itemModel->getEntry( idx ); - if ( item.isValid() && item.isSelectable() ) - { + if ( item.isValid() && item.isSelectable() ) { bool isVisible = m_itemModel->data( idx, Qt::CheckStateRole ).toBool(); - if ( isVisible ) - { + if ( isVisible ) { allEntityInvisible = false; break; } @@ -618,12 +595,12 @@ void Gui::MainWindow::showHideAllRO() { // if all entities are invisible : show all // if at least one entity is visible : hide all - for ( int i = 0; i < m_itemModel->rowCount(); ++i ) - { + for ( int i = 0; i < m_itemModel->rowCount(); ++i ) { auto idx = m_itemModel->index( i, j ); auto item = m_itemModel->getEntry( idx ); - if ( item.isValid() && item.isSelectable() ) - { m_itemModel->setData( idx, allEntityInvisible, Qt::CheckStateRole ); } + if ( item.isValid() && item.isSelectable() ) { + m_itemModel->setData( idx, allEntityInvisible, Qt::CheckStateRole ); + } } mainApp->askForUpdate(); } @@ -643,10 +620,8 @@ void Gui::MainWindow::updateUi( Plugins::RadiumPluginInterface* plugin ) { // Add actions int nbActions; - if ( plugin->doAddAction( nbActions ) ) - { - for ( int i = 0; i < nbActions; ++i ) - { + if ( plugin->doAddAction( nbActions ) ) { + for ( int i = 0; i < nbActions; ++i ) { toolBar->insertAction( nullptr, plugin->getAction( i ) ); } toolBar->addSeparator(); @@ -661,8 +636,7 @@ void MainWindow::onFrameComplete() { tab_edition->updateValues(); // update timeline only if time changed, to allow manipulation of keyframed objects auto engine = Ra::Engine::RadiumEngine::getInstance(); - if ( !Ra::Core::Math::areApproxEqual( m_timeline->getTime(), engine->getTime() ) ) - { + if ( !Ra::Core::Math::areApproxEqual( m_timeline->getTime(), engine->getTime() ) ) { m_lockTimeSystem = true; m_timeline->onChangeCursor( engine->getTime() ); m_lockTimeSystem = false; @@ -695,40 +669,35 @@ void MainWindow::on_actionStep_triggered() { void MainWindow::timelinePlay( bool play ) { actionPlay->setChecked( play ); - if ( !m_lockTimeSystem ) - { + if ( !m_lockTimeSystem ) { Ra::Engine::RadiumEngine::getInstance()->play( play ); mainApp->setContinuousUpdate( play ); } } void MainWindow::timelineGoTo( double t ) { - if ( !m_lockTimeSystem ) - { + if ( !m_lockTimeSystem ) { Ra::Engine::RadiumEngine::getInstance()->setTime( Scalar( t ) ); mainApp->askForUpdate(); } } void MainWindow::timelineStartChanged( double t ) { - if ( !m_lockTimeSystem ) - { + if ( !m_lockTimeSystem ) { Ra::Engine::RadiumEngine::getInstance()->setStartTime( Scalar( t ) ); mainApp->askForUpdate(); } } void MainWindow::timelineEndChanged( double t ) { - if ( !m_lockTimeSystem ) - { + if ( !m_lockTimeSystem ) { Ra::Engine::RadiumEngine::getInstance()->setEndTime( Scalar( t ) ); mainApp->askForUpdate(); } } void MainWindow::timelineSetPingPong( bool status ) { - if ( !m_lockTimeSystem ) - { + if ( !m_lockTimeSystem ) { Ra::Engine::RadiumEngine::getInstance()->setForwardBackward( status ); mainApp->askForUpdate(); } @@ -738,22 +707,18 @@ void MainWindow::onItemAdded( const Engine::Scene::ItemEntry& ent ) { m_itemModel->addItem( ent ); // update the m_currentShaderBox for added RO - if ( ent.isRoNode() ) - { + if ( ent.isRoNode() ) { auto ro = Engine::RadiumEngine::getInstance()->getRenderObjectManager()->getRenderObject( ent.m_roIndex ); - if ( ro->getType() == Engine::Rendering::RenderObjectType::Geometry ) - { + if ( ro->getType() == Engine::Rendering::RenderObjectType::Geometry ) { auto material = ro->getMaterial(); const std::string& shaderName = material->getMaterialName(); auto i = m_currentShaderBox->findText( shaderName.c_str() ); - if ( i == -1 ) - { + if ( i == -1 ) { QVariant refCount( 1 ); m_currentShaderBox->addItem( QString( shaderName.c_str() ), refCount ); } - else - { + else { auto refCount = m_currentShaderBox->itemData( i ); refCount = refCount.toInt() + 1; m_currentShaderBox->setItemData( i, refCount ); @@ -765,28 +730,23 @@ void MainWindow::onItemAdded( const Engine::Scene::ItemEntry& ent ) { void MainWindow::onItemRemoved( const Engine::Scene::ItemEntry& ent ) { m_itemModel->removeItem( ent ); // update the m_currentShaderBox for removed RO - if ( ent.isRoNode() ) - { + if ( ent.isRoNode() ) { auto ro = Engine::RadiumEngine::getInstance()->getRenderObjectManager()->getRenderObject( ent.m_roIndex ); - if ( ro->getType() == Engine::Rendering::RenderObjectType::Geometry ) - { + if ( ro->getType() == Engine::Rendering::RenderObjectType::Geometry ) { auto material = ro->getMaterial(); const std::string& shaderName = material->getMaterialName(); auto i = m_currentShaderBox->findText( shaderName.c_str() ); - if ( i == -1 ) - { + if ( i == -1 ) { // Should never be there ... LOG( logERROR ) << "MainWindow::onItemRemoved : trying to remove a non existing " "ShaderBox entry"; } - else - { + else { auto refCount = m_currentShaderBox->itemData( i ); refCount = refCount.toInt() - 1; if ( refCount.toInt() == 0 ) { m_currentShaderBox->removeItem( i ); } - else - { m_currentShaderBox->setItemData( i, refCount ); } + else { m_currentShaderBox->setItemData( i, refCount ); } } } } @@ -802,24 +762,20 @@ void MainWindow::exportCurrentMesh() { // For now we only export a mesh if the selected entry is a render object. // There could be a virtual method to get a mesh representation for any object. - if ( e.isRoNode() ) - { + if ( e.isRoNode() ) { Ra::IO::OBJFileManager obj; auto ro = Engine::RadiumEngine::getInstance()->getRenderObjectManager()->getRenderObject( e.m_roIndex ); const std::shared_ptr& displ = ro->getMesh(); const Engine::Data::Mesh* mesh = dynamic_cast( displ.get() ); - if ( mesh != nullptr && obj.save( filename, mesh->getCoreGeometry() ) ) - { + if ( mesh != nullptr && obj.save( filename, mesh->getCoreGeometry() ) ) { LOG( logINFO ) << "Mesh from " << ro->getName() << " successfully exported to " << filename; } - else - { LOG( logERROR ) << "Mesh from " << ro->getName() << "failed to export"; } + else { LOG( logERROR ) << "Mesh from " << ro->getName() << "failed to export"; } } - else - { LOG( logWARNING ) << "Current entry was not a render object. No mesh was exported."; } + else { LOG( logWARNING ) << "Current entry was not a render object. No mesh was exported."; } } void MainWindow::deleteCurrentItem() { @@ -834,10 +790,8 @@ void MainWindow::deleteCurrentItem() { // Clearing the selection before deleting the object will avoid this problem. m_selectionManager->clear(); if ( e.isRoNode() ) { e.m_component->removeRenderObject( e.m_roIndex ); } - else if ( e.isComponentNode() ) - { e.m_entity->removeComponent( e.m_component->getName() ); } - else if ( e.isEntityNode() ) - { + else if ( e.isComponentNode() ) { e.m_entity->removeComponent( e.m_component->getName() ); } + else if ( e.isEntityNode() ) { Engine::RadiumEngine::getInstance()->getEntityManager()->removeEntity( e.m_entity->getIndex() ); } @@ -855,13 +809,11 @@ void MainWindow::resetScene() { void MainWindow::fitCamera() { auto aabb = Engine::RadiumEngine::getInstance()->computeSceneAabb(); - if ( aabb.isEmpty() ) - { + if ( aabb.isEmpty() ) { m_viewer->getCameraManipulator()->resetCamera(); mainApp->askForUpdate(); } - else - { m_viewer->fitCameraToScene( aabb ); } + else { m_viewer->fitCameraToScene( aabb ); } } void MainWindow::activateCamera( const std::string& sceneName ) { @@ -870,14 +822,12 @@ void MainWindow::activateCamera( const std::string& sceneName ) { std::string loadedEntityName = Core::Utils::getBaseName( sceneName, false ); auto rootEntity = Engine::RadiumEngine::getInstance()->getEntityManager()->getEntity( loadedEntityName ); - if ( rootEntity != nullptr ) - { + if ( rootEntity != nullptr ) { auto fc = std::find_if( rootEntity->getComponents().begin(), rootEntity->getComponents().end(), []( const auto& c ) { return ( c->getName().compare( 0, 7, "CAMERA_" ) == 0 ); } ); - if ( fc != rootEntity->getComponents().end() ) - { + if ( fc != rootEntity->getComponents().end() ) { LOG( logINFO ) << "Activating camera " << ( *fc )->getName(); auto cameraManager = static_cast( diff --git a/Sandbox/Gui/MainWindow.hpp b/Sandbox/Gui/MainWindow.hpp index 131ebda..b7dc6ee 100644 --- a/Sandbox/Gui/MainWindow.hpp +++ b/Sandbox/Gui/MainWindow.hpp @@ -211,34 +211,34 @@ class MainWindow : public Ra::Gui::MainWindowInterface, private Ui::MainWindow private: /// Stores the internal model of engine objects for selection and visibility. - Gui::ItemModel* m_itemModel {nullptr}; + Gui::ItemModel* m_itemModel { nullptr }; /// Stores and manages the current selection. - Gui::SelectionManager* m_selectionManager {nullptr}; + Gui::SelectionManager* m_selectionManager { nullptr }; /// Widget to allow material edition. - std::unique_ptr m_materialEditor {nullptr}; + std::unique_ptr m_materialEditor { nullptr }; /// Viewer widget - Ra::Gui::Viewer* m_viewer {nullptr}; + Ra::Gui::Viewer* m_viewer { nullptr }; /// Skeleton-based animation gui - Ra::Gui::SkeletonBasedAnimationUI* m_skelAnim {nullptr}; + Ra::Gui::SkeletonBasedAnimationUI* m_skelAnim { nullptr }; /// Timeline gui - Ra::Gui::Timeline* m_timeline {nullptr}; + Ra::Gui::Timeline* m_timeline { nullptr }; /// Guard TimeSystem against issue with Timeline signals. - bool m_lockTimeSystem {false}; + bool m_lockTimeSystem { false }; /// Observers id for engine event ///@{ - int m_entityAddObserverId {-1}; - int m_entityRemoveObserverId {-1}; - int m_componentAddObserverId {-1}; - int m_componentRemoveObserverId {-1}; - int m_roAddObserverId {-1}; - int m_roRemoveObserverId {-1}; + int m_entityAddObserverId { -1 }; + int m_entityRemoveObserverId { -1 }; + int m_componentAddObserverId { -1 }; + int m_componentRemoveObserverId { -1 }; + int m_roAddObserverId { -1 }; + int m_roRemoveObserverId { -1 }; ///@} }; diff --git a/Sandbox/Gui/MaterialEditor.cpp b/Sandbox/Gui/MaterialEditor.cpp index e5b3c59..c18d8fc 100644 --- a/Sandbox/Gui/MaterialEditor.cpp +++ b/Sandbox/Gui/MaterialEditor.cpp @@ -17,7 +17,7 @@ MaterialEditor::MaterialEditor( QWidget* parent ) : m_matParamsEditor = new Ra::Gui::MaterialParameterEditor( this ); connect( m_matParamsEditor, &Ra::Gui::MaterialParameterEditor::materialParametersModified, - [this](const std::string&) { emit materialChanged(); } ); + [this]( const std::string& ) { emit materialChanged(); } ); layout->addWidget( m_matParamsEditor ); } diff --git a/Sandbox/Gui/RotationEditor.hpp b/Sandbox/Gui/RotationEditor.hpp index ff0769c..55cbc47 100644 --- a/Sandbox/Gui/RotationEditor.hpp +++ b/Sandbox/Gui/RotationEditor.hpp @@ -13,9 +13,7 @@ class RotationEditor : public QWidget, private Ui::RotationEditor Q_OBJECT public: explicit RotationEditor( uint id, QString title, bool editable, QWidget* parent = nullptr ) : - QWidget( parent ), - m_id( id ), - m_relativeAxis( -1 ) { + QWidget( parent ), m_id( id ), m_relativeAxis( -1 ) { setupUi( this ); m_groupBox->setTitle( title ); @@ -165,8 +163,7 @@ class RotationEditor : public QWidget, private Ui::RotationEditor private: void valueChangedSpinRel( uint axis ) { - if ( m_relativeAxis != axis ) - { + if ( m_relativeAxis != axis ) { const Scalar x = Scalar( m_x->value() ); const Scalar y = Scalar( m_y->value() ); const Scalar z = Scalar( m_z->value() ); @@ -197,8 +194,7 @@ class RotationEditor : public QWidget, private Ui::RotationEditor } void valueChangedSlideRel( uint axis ) { - if ( m_relativeAxis != axis ) - { + if ( m_relativeAxis != axis ) { const Scalar x = Scalar( m_x->value() ); const Scalar y = Scalar( m_y->value() ); const Scalar z = Scalar( m_z->value() ); @@ -277,10 +273,8 @@ class RotationEditor : public QWidget, private Ui::RotationEditor box->blockSignals( false ); } void resetRel() { - for ( uint i = 0; i < 3; ++i ) - { - if ( i != m_relativeAxis ) - { + for ( uint i = 0; i < 3; ++i ) { + if ( i != m_relativeAxis ) { m_relSpinBoxes[i]->blockSignals( true ); m_relSpinBoxes[i]->setValue( 0 ); m_relSpinBoxes[i]->blockSignals( false ); diff --git a/Sandbox/Gui/TransformEditorWidget.cpp b/Sandbox/Gui/TransformEditorWidget.cpp index 85df8dd..1b955b2 100644 --- a/Sandbox/Gui/TransformEditorWidget.cpp +++ b/Sandbox/Gui/TransformEditorWidget.cpp @@ -6,13 +6,10 @@ namespace Ra { namespace Gui { TransformEditorWidget::TransformEditorWidget( QWidget* parent ) : - QWidget( parent ), - m_layout( new QVBoxLayout( this ) ), - m_translationEditor( nullptr ) {} + QWidget( parent ), m_layout( new QVBoxLayout( this ) ), m_translationEditor( nullptr ) {} void TransformEditorWidget::updateValues() { - if ( canEdit() ) - { + if ( canEdit() ) { getTransform(); CORE_ASSERT( m_translationEditor, "No edtitor widget !" ); m_translationEditor->blockSignals( true ); @@ -30,8 +27,7 @@ void TransformEditorWidget::onChangedPosition( const Core::Vector3& v, uint id ) void TransformEditorWidget::setEditable( const Engine::Scene::ItemEntry& ent ) { delete m_translationEditor; TransformEditor::setEditable( ent ); - if ( canEdit() ) - { + if ( canEdit() ) { m_translationEditor = new VectorEditor( 0, QString::fromStdString( getEntryName( diff --git a/Sandbox/Gui/TransformEditorWidget.hpp b/Sandbox/Gui/TransformEditorWidget.hpp index c33b9b9..2b8717f 100644 --- a/Sandbox/Gui/TransformEditorWidget.hpp +++ b/Sandbox/Gui/TransformEditorWidget.hpp @@ -3,8 +3,8 @@ #include #include -#include #include +#include class QLayout; @@ -17,7 +17,7 @@ class TransformEditorWidget : public QWidget, public Gui::TransformEditor Q_OBJECT public: explicit TransformEditorWidget( QWidget* parent = nullptr ); - ~TransformEditorWidget(){}; + ~TransformEditorWidget() {}; public slots: diff --git a/Sandbox/Gui/VectorEditor.hpp b/Sandbox/Gui/VectorEditor.hpp index 7e9b472..f4ef84e 100644 --- a/Sandbox/Gui/VectorEditor.hpp +++ b/Sandbox/Gui/VectorEditor.hpp @@ -19,8 +19,7 @@ class VectorEditor : public QWidget, private Ui::VectorEditor QString title, bool editable = true, QWidget* parent = nullptr ) : - QWidget( parent ), - m_id( id ) { + QWidget( parent ), m_id( id ) { setupUi( this ); m_groupBox->setTitle( title ); diff --git a/Sandbox/README.md b/Sandbox/README.md index d414fab..28c6e2f 100644 --- a/Sandbox/README.md +++ b/Sandbox/README.md @@ -1,9 +1,10 @@ # Radium Sandbox This application has several purpose: - - It allow to load and vizualize 3d models using Radium IO and Engine packages. - - It demonstrates standard graphical tools offered by the Radium-Engine: gizmos, picking, skeletal animation, keyframing, renderering, ... - - It offers a graphical front-end to load and use plugins easily. Just add your plugin to the Plugin path (see graphical user interface), its interface will appear in the command panel and you will be able to use it. + +- It allow to load and vizualize 3d models using Radium IO and Engine packages. +- It demonstrates standard graphical tools offered by the Radium-Engine: gizmos, picking, skeletal animation, keyframing, renderering, ... +- It offers a graphical front-end to load and use plugins easily. Just add your plugin to the Plugin path (see graphical user interface), its interface will appear in the command panel and you will be able to use it. Internally, we use this application as an integration and testing application for the Radium-Engine libraries. diff --git a/Sandbox/Resources/Icons/select.svg b/Sandbox/Resources/Icons/select.svg index 2f5e0f7..c251c1c 100644 --- a/Sandbox/Resources/Icons/select.svg +++ b/Sandbox/Resources/Icons/select.svg @@ -10,6 +10,6 @@ - diff --git a/ShaderEditor/CMakeLists.txt b/ShaderEditor/CMakeLists.txt index 7458fd2..6ee40d6 100644 --- a/ShaderEditor/CMakeLists.txt +++ b/ShaderEditor/CMakeLists.txt @@ -1,77 +1,63 @@ # Build Radium Painter cmake_minimum_required(VERSION 3.18) if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_GREATER "3.9") - cmake_policy(SET CMP0071 NEW) + cmake_policy(SET CMP0071 NEW) endif() -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------- # exampleApp executables setup project(Radium-ShaderEditor) -# Set default install location to installed- folder in build dir -# we do not want to install to /usr by default -if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set (CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/installed-${CMAKE_CXX_COMPILER_ID}" CACHE PATH - "Install path prefix, prepended onto install directories." FORCE ) - message( "Set install prefix to ${CMAKE_INSTALL_PREFIX}" ) +# Set default install location to installed- folder in build dir we +# do not want to install to /usr by default +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX + "${CMAKE_CURRENT_BINARY_DIR}/installed-${CMAKE_CXX_COMPILER_ID}" + CACHE PATH "Install path prefix, prepended onto install directories." + FORCE) + message("Set install prefix to ${CMAKE_INSTALL_PREFIX}") endif() -find_package( Radium REQUIRED Core Engine Gui IO PluginBase) +find_package( + Radium + REQUIRED + Core + Engine + Gui + IO + PluginBase) -#------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ # Application specific - find_qt_package(COMPONENTS Core Widgets OpenGL REQUIRED) -set( Qt_LIBRARIES Qt::Core Qt::Widgets Qt::OpenGL ) +set(Qt_LIBRARIES Qt::Core Qt::Widgets Qt::OpenGL) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -set(app_sources - main.cpp - ShaderEditorWidget.cpp - ) +set(app_sources main.cpp ShaderEditorWidget.cpp) -set(app_headers - CameraManipulator.hpp - ShaderEditorWidget.hpp - MyParameterProvider.hpp - ) +set(app_headers CameraManipulator.hpp ShaderEditorWidget.hpp + MyParameterProvider.hpp) -set(app_uis - ShaderEditorWidget.ui - ) +set(app_uis ShaderEditorWidget.ui) qt_wrap_ui(app_uis_moc ${app_uis}) -set(app_resources - ) - +set(app_resources) set(CMAKE_INCLUDE_CURRENT_DIR ON) -include_directories( - ${CMAKE_CURRENT_BINARY_DIR} # Moc - ) +include_directories(${CMAKE_CURRENT_BINARY_DIR} # Moc +) add_executable( - ${PROJECT_NAME} MACOSX_BUNDLE - ${app_sources} - ${app_headers} - ${app_inlines} - ${app_uis_moc} - ${app_resources} - ) + ${PROJECT_NAME} MACOSX_BUNDLE ${app_sources} ${app_headers} ${app_inlines} + ${app_uis_moc} ${app_resources}) -target_link_libraries (${PROJECT_NAME} PUBLIC - Radium::Core - Radium::Engine - Radium::Gui - Radium::IO - ${Qt_LIBRARIES}) +target_link_libraries( + ${PROJECT_NAME} PUBLIC Radium::Core Radium::Engine Radium::Gui Radium::IO + ${Qt_LIBRARIES}) -configure_radium_app( - NAME ${PROJECT_NAME} - USE_PLUGINS -) +configure_radium_app(NAME ${PROJECT_NAME} USE_PLUGINS) # radium_cotire( ${app_target} ) diff --git a/ShaderEditor/MyParameterProvider.hpp b/ShaderEditor/MyParameterProvider.hpp index 440ccff..3ee35b4 100644 --- a/ShaderEditor/MyParameterProvider.hpp +++ b/ShaderEditor/MyParameterProvider.hpp @@ -2,8 +2,7 @@ #include - -using ShaderConfigType = std::vector> ; +using ShaderConfigType = std::vector>; class MyParameterProvider : public Ra::Engine::Data::ShaderParameterProvider { @@ -24,6 +23,6 @@ class MyParameterProvider : public Ra::Engine::Data::ShaderParameterProvider } private: - Ra::Core::Utils::Color m_colorParameter {Ra::Core::Utils::Color::Green()}; - Scalar m_scalarParameter {1}; + Ra::Core::Utils::Color m_colorParameter { Ra::Core::Utils::Color::Green() }; + Scalar m_scalarParameter { 1 }; }; diff --git a/ShaderEditor/ShaderEditorWidget.cpp b/ShaderEditor/ShaderEditorWidget.cpp index 6eb5947..352d194 100644 --- a/ShaderEditor/ShaderEditorWidget.cpp +++ b/ShaderEditor/ShaderEditorWidget.cpp @@ -3,9 +3,9 @@ #include "MyParameterProvider.hpp" -#include -#include #include +#include +#include // include the custom material definition #include @@ -15,41 +15,41 @@ #include ShaderEditorWidget::ShaderEditorWidget( - const std::string& v, - const std::string& f, - std::shared_ptr< Ra::Engine::Rendering::RenderObject > ro, - Ra::Engine::Rendering::Renderer * renderer, - std::shared_ptr< Ra::Engine::Data::ShaderParameterProvider > paramProvider, - QWidget *parent) : + const std::string& v, + const std::string& f, + std::shared_ptr ro, + Ra::Engine::Rendering::Renderer* renderer, + std::shared_ptr paramProvider, + QWidget* parent ) : QWidget( parent ), ui( new Ui::ShaderEditorWidget ), _ro( ro ), _renderer( renderer ), - _paramProvider( paramProvider ) -{ - ui->setupUi(this); + _paramProvider( paramProvider ) { + ui->setupUi( this ); ui->_vertShaderEdit->setPlainText( QString::fromStdString( v ) ); ui->_fragShaderEdit->setPlainText( QString::fromStdString( f ) ); - connect( ui->_compileShaders, &QPushButton::clicked, this, &ShaderEditorWidget::updateShadersFromUI ); + connect( ui->_compileShaders, + &QPushButton::clicked, + this, + &ShaderEditorWidget::updateShadersFromUI ); } -ShaderEditorWidget::~ShaderEditorWidget() -{ +ShaderEditorWidget::~ShaderEditorWidget() { delete ui; } -void -ShaderEditorWidget::updateShadersFromUI() -{ - using ShaderConfigType = std::vector> ; +void ShaderEditorWidget::updateShadersFromUI() { + using ShaderConfigType = std::vector>; - const ShaderConfigType config { - {Ra::Engine::Data::ShaderType::ShaderType_VERTEX, ui->_vertShaderEdit->toPlainText().toStdString()}, - {Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT, ui->_fragShaderEdit->toPlainText().toStdString()}}; + const ShaderConfigType config { { Ra::Engine::Data::ShaderType::ShaderType_VERTEX, + ui->_vertShaderEdit->toPlainText().toStdString() }, + { Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT, + ui->_fragShaderEdit->toPlainText().toStdString() } }; - auto mat = static_cast( _ro->getMaterial().get() ); + auto mat = static_cast( _ro->getMaterial().get() ); mat->updateShaders( config, _paramProvider ); _renderer->buildRenderTechnique( _ro.get() ); } diff --git a/ShaderEditor/ShaderEditorWidget.hpp b/ShaderEditor/ShaderEditorWidget.hpp index 265e025..385eb11 100644 --- a/ShaderEditor/ShaderEditorWidget.hpp +++ b/ShaderEditor/ShaderEditorWidget.hpp @@ -8,17 +8,17 @@ namespace Ui { class ShaderEditorWidget; } -namespace Ra{ -namespace Engine{ -namespace Rendering{ - class RenderObject; - class Renderer; -} +namespace Ra { +namespace Engine { +namespace Rendering { +class RenderObject; +class Renderer; +} // namespace Rendering namespace Data { class ShaderParameterProvider; } -} -} +} // namespace Engine +} // namespace Ra /// /// \todo Add automatic UI generation from parameter provider @@ -26,21 +26,22 @@ class ShaderEditorWidget : public QWidget { Q_OBJECT -public: - explicit ShaderEditorWidget(const std::string& v, - const std::string& f, - std::shared_ptr< Ra::Engine::Rendering::RenderObject > ro, - Ra::Engine::Rendering::Renderer * renderer, - std::shared_ptr< Ra::Engine::Data::ShaderParameterProvider > paramProvider, - QWidget *parent = nullptr); + public: + explicit ShaderEditorWidget( + const std::string& v, + const std::string& f, + std::shared_ptr ro, + Ra::Engine::Rendering::Renderer* renderer, + std::shared_ptr paramProvider, + QWidget* parent = nullptr ); ~ShaderEditorWidget(); -private slots: + private slots: void updateShadersFromUI(); -private: - Ui::ShaderEditorWidget *ui; - std::shared_ptr< Ra::Engine::Rendering::RenderObject > _ro; - Ra::Engine::Rendering::Renderer * _renderer; - std::shared_ptr< Ra::Engine::Data::ShaderParameterProvider > _paramProvider; + private: + Ui::ShaderEditorWidget* ui; + std::shared_ptr _ro; + Ra::Engine::Rendering::Renderer* _renderer; + std::shared_ptr _paramProvider; }; diff --git a/ShaderEditor/main.cpp b/ShaderEditor/main.cpp index e7ee1b2..46c209a 100644 --- a/ShaderEditor/main.cpp +++ b/ShaderEditor/main.cpp @@ -4,9 +4,9 @@ // include the Engine/entity/component interface #include -#include -#include #include +#include +#include #include // include the custom material definition @@ -16,29 +16,29 @@ #include #include "CameraManipulator.hpp" -#include "ShaderEditorWidget.hpp" #include "MyParameterProvider.hpp" +#include "ShaderEditorWidget.hpp" #include // Qt -#include #include +#include /** * Demonstrate the usage of RawShaderMaterial functionalities */ // Vertex shader source code -const std::string _vertexShaderSource {"#include \"TransformStructs.glsl\"\n" - "layout (location = 0) in vec3 in_position;\n" - "layout (location = 0) out vec3 out_pos;\n" - "uniform Transform transform;\n" - "void main(void)\n" - "{\n" - " mat4 mvp = transform.proj * transform.view;\n" - " out_pos = in_position;\n" - " gl_Position = mvp*vec4(in_position.xyz, 1.0);\n" - "}\n"}; +const std::string _vertexShaderSource { "#include \"TransformStructs.glsl\"\n" + "layout (location = 0) in vec3 in_position;\n" + "layout (location = 0) out vec3 out_pos;\n" + "uniform Transform transform;\n" + "void main(void)\n" + "{\n" + " mat4 mvp = transform.proj * transform.view;\n" + " out_pos = in_position;\n" + " gl_Position = mvp*vec4(in_position.xyz, 1.0);\n" + "}\n" }; // Fragment shader source code const std::string _fragmentShaderSource { "layout (location = 0) in vec3 in_pos;\n" @@ -48,17 +48,14 @@ const std::string _fragmentShaderSource { "void main(void)\n" "{\n" " out_color = ( 1 + cos( 20 * ( in_pos.x + aScalarUniform ) ) ) * 0.5 * aColorUniform;\n" - "}\n"}; - - + "}\n" }; const ShaderConfigType defaultConfig { - {Ra::Engine::Data::ShaderType::ShaderType_VERTEX, _vertexShaderSource}, - {Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT, _fragmentShaderSource}}; + { Ra::Engine::Data::ShaderType::ShaderType_VERTEX, _vertexShaderSource }, + { Ra::Engine::Data::ShaderType::ShaderType_FRAGMENT, _fragmentShaderSource } }; auto paramProvider = std::make_shared(); - /** * Generate a quad with a ShaderMaterial attached * @param app @@ -66,7 +63,7 @@ auto paramProvider = std::make_shared(); */ std::shared_ptr initQuad( Ra::Gui::BaseApplication& app ) { //! [Creating the quad] - auto quad = Ra::Core::Geometry::makeZNormalQuad( {1_ra, 1_ra} ); + auto quad = Ra::Core::Geometry::makeZNormalQuad( { 1_ra, 1_ra } ); //! [Create the engine entity for the quad] auto e = app.m_engine->getEntityManager()->createEntity( "Quad Entity" ); @@ -75,10 +72,11 @@ std::shared_ptr initQuad( Ra::Gui::BaseAppl paramProvider->setOrComputeTheParameterValues(); //! [Create the shader material] - Ra::Core::Asset::RawShaderMaterialData mat {"Quad Material", defaultConfig, paramProvider}; + Ra::Core::Asset::RawShaderMaterialData mat { "Quad Material", defaultConfig, paramProvider }; //! [Create a geometry component using the custom material] - auto c = new Ra::Engine::Scene::TriangleMeshComponent( "Quad Mesh", e, std::move( quad ), &mat ); + auto c = + new Ra::Engine::Scene::TriangleMeshComponent( "Quad Mesh", e, std::move( quad ), &mat ); //! [Register the entity/component association to the geometry system ] auto system = app.m_engine->getSystem( "GeometrySystem" ); @@ -103,12 +101,16 @@ int main( int argc, char* argv[] ) { auto ro = initQuad( app ); auto viewer = app.m_mainWindow->getViewer(); - viewer->setCameraManipulator( - new CameraManipulator2D( *( viewer->getCameraManipulator() ) ) ); - - QDockWidget* dock = new QDockWidget("Shaders editor"); - dock->setWidget( new ShaderEditorWidget(defaultConfig[0].second, defaultConfig[1].second, ro, viewer->getRenderer(), paramProvider, dock) ); - app.m_mainWindow->addDockWidget(Qt::LeftDockWidgetArea, dock); + viewer->setCameraManipulator( new CameraManipulator2D( *( viewer->getCameraManipulator() ) ) ); + + QDockWidget* dock = new QDockWidget( "Shaders editor" ); + dock->setWidget( new ShaderEditorWidget( defaultConfig[0].second, + defaultConfig[1].second, + ro, + viewer->getRenderer(), + paramProvider, + dock ) ); + app.m_mainWindow->addDockWidget( Qt::LeftDockWidgetArea, dock ); return app.exec(); }