diff --git a/.github/ci/packages-bionic.apt b/.github/ci/packages-bionic.apt new file mode 100644 index 000000000..ff9786e03 --- /dev/null +++ b/.github/ci/packages-bionic.apt @@ -0,0 +1 @@ +libogre-2.2-dev diff --git a/.github/ci/packages-focal.apt b/.github/ci/packages-focal.apt new file mode 100644 index 000000000..ff9786e03 --- /dev/null +++ b/.github/ci/packages-focal.apt @@ -0,0 +1 @@ +libogre-2.2-dev diff --git a/.github/ci/packages-jammy.apt b/.github/ci/packages-jammy.apt new file mode 100644 index 000000000..e93151b77 --- /dev/null +++ b/.github/ci/packages-jammy.apt @@ -0,0 +1 @@ +libogre-next-dev diff --git a/.github/ci/packages.apt b/.github/ci/packages.apt index 3c69f1925..7aacb796f 100644 --- a/.github/ci/packages.apt +++ b/.github/ci/packages.apt @@ -8,7 +8,6 @@ libignition-math7-eigen3-dev libignition-plugin-dev libignition-utils1-dev libogre-1.9-dev -libogre-2.2-dev libxi-dev libxmu-dev uuid-dev diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eab3e7460..b4b8a356b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,3 +17,12 @@ jobs: cppcheck-enabled: true cpplint-enabled: true doxygen-enabled: true + jammy-ci: + runs-on: ubuntu-latest + name: Ubuntu Jammy CI + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Compile and test + id: ci + uses: ignition-tooling/action-ignition-ci@jammy diff --git a/CMakeLists.txt b/CMakeLists.txt index e8ac0f1d9..3466019f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,14 +101,21 @@ if (OGRE_FOUND) endif() #-------------------------------------- -# Find OGRE2 -ign_find_package(IgnOGRE2 VERSION 2.2.0 - COMPONENTS HlmsPbs HlmsUnlit Overlay - REQUIRED_BY ogre2 - PRIVATE_FOR ogre2) - -if (OGRE2_FOUND) +# Find OGRE-Next +find_package(OGRE-Next QUIET) +if (OGRE-Next_FOUND) set(HAVE_OGRE2 TRUE) + set(HAVE_OGRE-Next TRUE) +else() + # Find OGRE2 + ign_find_package(IgnOGRE2 VERSION 2.2.0 + COMPONENTS HlmsPbs HlmsUnlit Overlay + REQUIRED_BY ogre2 + PRIVATE_FOR ogre2) + + if (OGRE2_FOUND) + set(HAVE_OGRE2 TRUE) + endif() endif() # Plugin install dirs diff --git a/examples/render_pass/Main.cc b/examples/render_pass/Main.cc index 73be55036..76498e7ad 100644 --- a/examples/render_pass/Main.cc +++ b/examples/render_pass/Main.cc @@ -160,18 +160,24 @@ CameraPtr createCamera(const std::string &_engineName, { // add gaussian noise pass RenderPassPtr pass = rpSystem->Create(); - GaussianNoisePassPtr noisePass = - std::dynamic_pointer_cast(pass); - noisePass->SetMean(0.1); - noisePass->SetStdDev(0.08); - camera->AddRenderPass(noisePass); + if (pass) + { + GaussianNoisePassPtr noisePass = + std::dynamic_pointer_cast(pass); + noisePass->SetMean(0.1); + noisePass->SetStdDev(0.08); + camera->AddRenderPass(noisePass); + } // add distortion pass pass = rpSystem->Create(); - DistortionPassPtr distortionPass = - std::dynamic_pointer_cast(pass); - distortionPass->SetK1(0.5); - camera->AddRenderPass(distortionPass); + if (pass) + { + DistortionPassPtr distortionPass = + std::dynamic_pointer_cast(pass); + distortionPass->SetK1(0.5); + camera->AddRenderPass(distortionPass); + } } //! [get render pass system] diff --git a/ogre2/src/CMakeLists.txt b/ogre2/src/CMakeLists.txt index bd3975cce..d38b0c472 100644 --- a/ogre2/src/CMakeLists.txt +++ b/ogre2/src/CMakeLists.txt @@ -27,9 +27,18 @@ set_property( OGRE2_VERSION="${OGRE2_VERSION}" ) +if (HAVE_OGRE-Next) + target_include_directories(${ogre2_target} + PUBLIC + ${OGRE-Next_INCLUDE_DIRS} + ${OGRE-Next_HlmsUnlit_INCLUDE_DIRS} + ${OGRE-Next_HlmsPbs_INCLUDE_DIRS}/../Common + ) +endif() + target_include_directories(${ogre2_target} PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} ) target_link_libraries(${ogre2_target} @@ -39,7 +48,17 @@ target_link_libraries(${ogre2_target} ignition-plugin${IGN_PLUGIN_VER}::register ${OPENGL_LIBRARIES} terra - IgnOGRE2::IgnOGRE2) +) + +if (HAVE_OGRE-Next) + target_link_libraries(${ogre2_target} + PRIVATE + ${OGRE-Next_LIBRARIES}) +else() + target_link_libraries(${ogre2_target} + PRIVATE + IgnOGRE2::IgnOGRE2) +endif() set (versioned ${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME_LOWER}-${engine_name}${CMAKE_SHARED_LIBRARY_SUFFIX}) set (unversioned ${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME_NO_VERSION_LOWER}-${engine_name}${CMAKE_SHARED_LIBRARY_SUFFIX}) diff --git a/ogre2/src/Ogre2GpuRays.cc b/ogre2/src/Ogre2GpuRays.cc index fce255a88..3b62fcb28 100644 --- a/ogre2/src/Ogre2GpuRays.cc +++ b/ogre2/src/Ogre2GpuRays.cc @@ -480,7 +480,6 @@ void Ogre2LaserRetroMaterialSwitcher::passPosExecute( engine->SetIgnOgreRenderingMode(IORM_NORMAL); } - ////////////////////////////////////////////////// Ogre2GpuRays::Ogre2GpuRays() : dataPtr(new Ogre2GpuRaysPrivate) diff --git a/ogre2/src/Ogre2ThermalCamera.cc b/ogre2/src/Ogre2ThermalCamera.cc index 22d154596..48ebf6e3d 100644 --- a/ogre2/src/Ogre2ThermalCamera.cc +++ b/ogre2/src/Ogre2ThermalCamera.cc @@ -156,7 +156,6 @@ class Ogre2ThermalCameraMaterialSwitcher : public Ogre::Camera::Listener } } - /// \internal /// \brief Private data for the Ogre2ThermalCamera class class ignition::rendering::Ogre2ThermalCameraPrivate diff --git a/ogre2/src/terrain/Terra/CMakeLists.txt b/ogre2/src/terrain/Terra/CMakeLists.txt index 83c9ac907..31cfd6695 100644 --- a/ogre2/src/terrain/Terra/CMakeLists.txt +++ b/ogre2/src/terrain/Terra/CMakeLists.txt @@ -29,13 +29,31 @@ add_definitions(-DOGRE_IGNORE_UNKNOWN_DEBUG) # $<$:DEBUG=1 _DEBUG=1>) target_include_directories(${PROJECT_NAME} - PRIVATE - # Hlms files inside Hlms/Pbs do not have #include thus - # we must add this one manually for this to build correctly - ${OGRE2_INCLUDE}/Hlms/Pbs - ${OGRE2_INCLUDE}/Hlms/Common PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include ) -target_link_libraries(${PROJECT_NAME} PRIVATE IgnOGRE2::IgnOGRE2) +if (HAVE_OGRE-Next) + target_include_directories(${PROJECT_NAME} + PRIVATE + # Hlms files inside Hlms/Pbs do not have #include thus + # we must add this one manually for this to build correctly + ${OGRE-Next_INCLUDE_DIRS} + ${OGRE-Next_INCLUDE_DIRS}/OGRE-Next/PlanarReflections + ${OGRE-Next_HlmsPbs_INCLUDE_DIRS} + ${OGRE-Next_HlmsPbs_INCLUDE_DIRS}/.. + ${OGRE-Next_HlmsPbs_INCLUDE_DIRS}/../Common + ) + + target_link_libraries(${PROJECT_NAME} PRIVATE ${OGRE-Next_LIBRARIES}) +else() + target_include_directories(${PROJECT_NAME} + PRIVATE + # Hlms files inside Hlms/Pbs do not have #include thus + # we must add this one manually for this to build correctly + ${OGRE2_INCLUDE}/Hlms/Pbs + ${OGRE2_INCLUDE}/Hlms/Common + ) + + target_link_libraries(${PROJECT_NAME} PRIVATE IgnOGRE2::IgnOGRE2) +endif() diff --git a/test/integration/camera.cc b/test/integration/camera.cc index c28512fb5..3ba987f2d 100644 --- a/test/integration/camera.cc +++ b/test/integration/camera.cc @@ -22,10 +22,14 @@ #include "test_config.h" // NOLINT(build/include) #include "ignition/rendering/Camera.hh" +#include "ignition/rendering/GpuRays.hh" #include "ignition/rendering/RenderEngine.hh" #include "ignition/rendering/RenderingIface.hh" #include "ignition/rendering/Scene.hh" +#include "ignition/rendering/SegmentationCamera.hh" #include "ignition/rendering/ShaderParams.hh" +#include "ignition/rendering/ThermalCamera.hh" + using namespace ignition; using namespace rendering; @@ -629,6 +633,10 @@ void CameraTest::ShaderSelection(const std::string &_renderEngine) visual->SetWorldRotation(0.0, 0.0, 0.0); visual->SetMaterial(shader); root->AddChild(visual); + // for thermal camera + visual->SetUserData("temperature", 310.0f); + // for segmentation camera + visual->SetUserData("label", 1); // visual will clone and create a unique material // so destroy this one @@ -646,8 +654,55 @@ void CameraTest::ShaderSelection(const std::string &_renderEngine) camera->SetHFOV(IGN_PI / 2); root->AddChild(camera); + // Create a gpu ray + // laser retro material switching may also affect shader materials + const double hMinAngle = -IGN_PI/2.0; + const double hMaxAngle = IGN_PI/2.0; + const double minRange = 0.1; + const double maxRange = 10.0; + const int hRayCount = 320; + const int vRayCount = 1; + GpuRaysPtr gpuRays = scene->CreateGpuRays("gpu_rays"); + gpuRays->SetWorldPosition(0, 0, 0); + gpuRays->SetNearClipPlane(minRange); + gpuRays->SetFarClipPlane(maxRange); + gpuRays->SetAngleMin(hMinAngle); + gpuRays->SetAngleMax(hMaxAngle); + gpuRays->SetRayCount(hRayCount); + gpuRays->SetVerticalRayCount(vRayCount); + root->AddChild(gpuRays); + + // Create thermal camera + // heat map material switching may also affect shader materials + auto thermalCamera = scene->CreateThermalCamera("ThermalCamera"); + ASSERT_NE(thermalCamera, nullptr); + thermalCamera->SetAmbientTemperature(296.0f); + thermalCamera->SetAspectRatio(1.333); + thermalCamera->SetImageWidth(320); + thermalCamera->SetImageHeight(240); + thermalCamera->SetHFOV(IGN_PI_2); + root->AddChild(thermalCamera); + + // Currently, only ogre2 supports segmentation cameras + SegmentationCameraPtr segmentationCamera; if (_renderEngine == "ogre2") { + // Create segmentation camera + // segmentation material switching may also affect shader materials + segmentationCamera = + scene->CreateSegmentationCamera("SegmentationCamera"); + ASSERT_NE(camera, nullptr); + segmentationCamera->SetLocalPosition(0.0, 0.0, 0.0); + segmentationCamera->SetLocalRotation(0.0, 0.0, 0.0); + segmentationCamera->SetBackgroundLabel(23); + segmentationCamera->SetSegmentationType(SegmentationType::ST_SEMANTIC); + segmentationCamera->EnableColoredMap(false); + segmentationCamera->SetAspectRatio(1.333); + segmentationCamera->SetImageWidth(320); + segmentationCamera->SetImageHeight(240); + segmentationCamera->SetHFOV(IGN_PI_2); + root->AddChild(segmentationCamera); + // worldviewproj_matrix is a constant defined by ogre. // Here we add a line to add this constant to the params. // The specified value is ignored as it will be auto bound to the @@ -664,6 +719,10 @@ void CameraTest::ShaderSelection(const std::string &_renderEngine) for (auto i = 0; i < 30; ++i) { camera->Update(); + gpuRays->Update(); + thermalCamera->Update(); + if (segmentationCamera) + segmentationCamera->Update(); } // capture a frame