Skip to content

Commit

Permalink
Merge pull request #592 from ignitionrobotics/merge_6_7_20220321
Browse files Browse the repository at this point in the history
6 -> main
  • Loading branch information
iche033 authored Mar 22, 2022
2 parents 6f5faaf + bbb2fc4 commit f3c4003
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 27 deletions.
1 change: 1 addition & 0 deletions .github/ci/packages-bionic.apt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
libogre-2.2-dev
1 change: 1 addition & 0 deletions .github/ci/packages-focal.apt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
libogre-2.2-dev
1 change: 1 addition & 0 deletions .github/ci/packages-jammy.apt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
libogre-next-dev
1 change: 0 additions & 1 deletion .github/ci/packages.apt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 14 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 15 additions & 9 deletions examples/render_pass/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,24 @@ CameraPtr createCamera(const std::string &_engineName,
{
// add gaussian noise pass
RenderPassPtr pass = rpSystem->Create<GaussianNoisePass>();
GaussianNoisePassPtr noisePass =
std::dynamic_pointer_cast<GaussianNoisePass>(pass);
noisePass->SetMean(0.1);
noisePass->SetStdDev(0.08);
camera->AddRenderPass(noisePass);
if (pass)
{
GaussianNoisePassPtr noisePass =
std::dynamic_pointer_cast<GaussianNoisePass>(pass);
noisePass->SetMean(0.1);
noisePass->SetStdDev(0.08);
camera->AddRenderPass(noisePass);
}

// add distortion pass
pass = rpSystem->Create<DistortionPass>();
DistortionPassPtr distortionPass =
std::dynamic_pointer_cast<DistortionPass>(pass);
distortionPass->SetK1(0.5);
camera->AddRenderPass(distortionPass);
if (pass)
{
DistortionPassPtr distortionPass =
std::dynamic_pointer_cast<DistortionPass>(pass);
distortionPass->SetK1(0.5);
camera->AddRenderPass(distortionPass);
}
}
//! [get render pass system]

Expand Down
23 changes: 21 additions & 2 deletions ogre2/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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})
Expand Down
1 change: 0 additions & 1 deletion ogre2/src/Ogre2GpuRays.cc
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,6 @@ void Ogre2LaserRetroMaterialSwitcher::passPosExecute(
engine->SetIgnOgreRenderingMode(IORM_NORMAL);
}


//////////////////////////////////////////////////
Ogre2GpuRays::Ogre2GpuRays()
: dataPtr(new Ogre2GpuRaysPrivate)
Expand Down
1 change: 0 additions & 1 deletion ogre2/src/Ogre2ThermalCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ class Ogre2ThermalCameraMaterialSwitcher : public Ogre::Camera::Listener
}
}


/// \internal
/// \brief Private data for the Ogre2ThermalCamera class
class ignition::rendering::Ogre2ThermalCameraPrivate
Expand Down
30 changes: 24 additions & 6 deletions ogre2/src/terrain/Terra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,31 @@ add_definitions(-DOGRE_IGNORE_UNKNOWN_DEBUG)
# $<$<CONFIG:Debug>:DEBUG=1 _DEBUG=1>)

target_include_directories(${PROJECT_NAME}
PRIVATE
# Hlms files inside Hlms/Pbs do not have #include <Hlms/Pbs/...> 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 <Hlms/Pbs/...> 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 <Hlms/Pbs/...> 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()
59 changes: 59 additions & 0 deletions test/integration/camera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f3c4003

Please sign in to comment.