From bedffa799183d13279a421c7bc7244369eba18d3 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Wed, 4 Dec 2024 15:15:03 +0100 Subject: [PATCH 01/38] [CORE] Added a macro that indicates the OGRE version --- CMakeLists.txt | 1 + cmake/templates/vpConfig.h.in | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6635e2b875..34bf6a769d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -984,6 +984,7 @@ include(cmake/VISPExtraTargets.cmake) include(cmake/OgreTools.cmake) if(USE_OGRE) vp_set_ogre_media() + set(VISP_HAVE_OGRE_VERSION "(${OGRE_VERSION_MAJOR}<<16 | ${OGRE_VERSION_MINOR}<<8 | ${OGRE_VERSION_PATCH})") # for vpConfig.h endif() #---------------------------------------------------------------------- diff --git a/cmake/templates/vpConfig.h.in b/cmake/templates/vpConfig.h.in index 1703725de2..e18fb2339c 100644 --- a/cmake/templates/vpConfig.h.in +++ b/cmake/templates/vpConfig.h.in @@ -274,6 +274,9 @@ namespace vp = VISP_NAMESPACE_NAME; // Defined if Ogre3d is available. #cmakedefine VISP_HAVE_OGRE +#ifdef VISP_HAVE_OGRE +# define VISP_HAVE_OGRE_VERSION ${VISP_HAVE_OGRE_VERSION} +#endif // Defined if Ogre3d plugins.cfg is available. #cmakedefine VISP_HAVE_OGRE_PLUGINS_PATH "${VISP_HAVE_OGRE_PLUGINS_PATH}" From 3afccd10b10933874f9e6e15c37b546bbc7ac0f4 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Wed, 4 Dec 2024 15:45:05 +0100 Subject: [PATCH 02/38] [CORE] Removed a deprecated warning in vpAROgre --- modules/ar/src/ogre-simulator/vpAROgre.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index 199ed37052..1de080b7bc 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -283,6 +283,7 @@ void vpAROgre::init(bool cf.load(resourceFile); // Go through all sections & settings in the file +#if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); Ogre::String secName, typeName, archName; @@ -296,6 +297,20 @@ void vpAROgre::init(bool Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName); } } +#else + const Ogre::ConfigFile::SettingsBySection_ §ionsNamesAndSettigns = cf.getSettingsBySection(); + Ogre::String secName, typeName, archName; + for (std::pair name_settings : sectionsNamesAndSettigns) { + secName = name_settings.first; + Ogre::ConfigFile::SettingsMultiMap settings = name_settings.second; + Ogre::ConfigFile::SettingsMultiMap::iterator i; + for (i = settings.begin(); i != settings.end(); ++i) { + typeName = i->first; + archName = i->second; + Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName); + } +} +#endif std::cout << "##################### add resources" << std::endl; // Add Optional resources (given by the user). for (std::list::const_iterator iter = mOptionalResourceLocation.begin(); @@ -934,7 +949,7 @@ void vpAROgre::closeOIS(void) OIS::InputManager::destroyInputSystem(mInputManager); mInputManager = 0; - } +} #endif } From 7853efd28b097bcda676e1ff9781ab211710de0c Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Wed, 4 Dec 2024 16:07:00 +0100 Subject: [PATCH 03/38] [FIX] Fix "no matching function for call to showConfigDialog" when using Ogre >= 1.10 --- modules/ar/include/visp3/ar/vpAROgre.h | 4 ++++ modules/ar/src/ogre-simulator/vpAROgre.cpp | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/ar/include/visp3/ar/vpAROgre.h b/modules/ar/include/visp3/ar/vpAROgre.h index 87c2baa8ad..b50bdcf8e0 100644 --- a/modules/ar/include/visp3/ar/vpAROgre.h +++ b/modules/ar/include/visp3/ar/vpAROgre.h @@ -61,6 +61,10 @@ #include #include +#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) +#include +#endif + #ifdef VISP_HAVE_OIS #include #endif diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index 1de080b7bc..791e4d5602 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -309,7 +309,7 @@ void vpAROgre::init(bool archName = i->second; Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName); } -} + } #endif std::cout << "##################### add resources" << std::endl; // Add Optional resources (given by the user). @@ -323,7 +323,12 @@ void vpAROgre::init(bool bool canInit = true; if (mshowConfigDialog) { mRoot->restoreConfig(); - if (!mRoot->showConfigDialog()) { +#if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) + bool isOK = mRoot->showConfigDialog(); +#else + bool isOK = mRoot->showConfigDialog(OgreBites::getNativeConfigDialog()); +#endif + if (!isOK) { canInit = false; } } @@ -949,7 +954,7 @@ void vpAROgre::closeOIS(void) OIS::InputManager::destroyInputSystem(mInputManager); mInputManager = 0; -} + } #endif } From 1715f01844444b0f00acd78f1a380d6034c97371 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Wed, 4 Dec 2024 16:41:22 +0100 Subject: [PATCH 04/38] [FIX] Fixed "error: 'Ogre::WindowEventUtilities' has not been declared" and "Ogre::WindowEventListener : expected class-name before '{' token" --- modules/ar/include/visp3/ar/vpAROgre.h | 4 ++++ modules/ar/src/ogre-simulator/vpAROgre.cpp | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/modules/ar/include/visp3/ar/vpAROgre.h b/modules/ar/include/visp3/ar/vpAROgre.h index b50bdcf8e0..b387eade8d 100644 --- a/modules/ar/include/visp3/ar/vpAROgre.h +++ b/modules/ar/include/visp3/ar/vpAROgre.h @@ -65,6 +65,10 @@ #include #endif +#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 11<<8 | 0)) +#include +#endif + #ifdef VISP_HAVE_OIS #include #endif diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index 791e4d5602..aec421c9c8 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -50,6 +50,13 @@ #include +#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 11<<8 | 0)) +#include +typedef OgreBites::WindowEventUtilities OgreWindowEventUtilities; +#else +typedef Ogre::WindowEventUtilities OgreWindowEventUtilities; +#endif + BEGIN_VISP_NAMESPACE /*! Constructor. @@ -309,7 +316,7 @@ void vpAROgre::init(bool archName = i->second; Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName); } - } +} #endif std::cout << "##################### add resources" << std::endl; // Add Optional resources (given by the user). @@ -428,7 +435,7 @@ void vpAROgre::init(bool mRoot->addFrameListener(this); // Register as a Window listener - Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this); + OgreWindowEventUtilities::addWindowEventListener(mWindow, this); #ifdef VISP_HAVE_OIS // Initialise OIS @@ -483,7 +490,7 @@ vpAROgre::~vpAROgre(void) closeOIS(); if (mWindow) { - Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this); + OgreWindowEventUtilities::removeWindowEventListener(mWindow, this); windowClosed(mWindow); } @@ -526,7 +533,7 @@ bool vpAROgre::frameStarted(const Ogre::FrameEvent &evt) bool result = customframeStarted(evt); // Listen to the window - Ogre::WindowEventUtilities::messagePump(); + OgreWindowEventUtilities::messagePump(); processInputEvent(evt); // See if we have to stop rendering @@ -954,7 +961,7 @@ void vpAROgre::closeOIS(void) OIS::InputManager::destroyInputSystem(mInputManager); mInputManager = 0; - } +} #endif } From 36fe7767c78aa6ec96817f9c1057379c9c495293 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Wed, 4 Dec 2024 16:54:27 +0100 Subject: [PATCH 05/38] [FIX] Fixed "mBackground->setMaterial(BackgroundMaterial);" related error --- modules/ar/src/ogre-simulator/vpAROgre.cpp | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index aec421c9c8..b7537c5206 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -316,7 +316,7 @@ void vpAROgre::init(bool archName = i->second; Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName); } -} + } #endif std::cout << "##################### add resources" << std::endl; // Add Optional resources (given by the user). @@ -864,7 +864,17 @@ void vpAROgre::createBackground(vpImage & /* I */) Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false); // Background Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false); // Background Backgroundmaterial->getTechnique(0)->getPass(0)->createTextureUnitState("BackgroundTexture"); +#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) + Ogre::MaterialPtr mMaterial; + Ogre::String matName("BackgroundMaterial"); + //if it doesnt already exist + if (!Ogre::MaterialManager::getSingleton().resourceExists(matName)) { + mMaterial = Ogre::MaterialManager::getSingleton().create(matName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true); + } + mBackground->setMaterial(mMaterial); // Attach the material to the rectangle +#else mBackground->setMaterial("BackgroundMaterial"); // Attach the material to the rectangle +#endif mBackground->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND); // To be rendered in Background // Add the background to the Scene Graph so it will be rendered @@ -938,7 +948,17 @@ void vpAROgre::createBackground(vpImage & /* I */) Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false); // Background Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false); // Background Backgroundmaterial->getTechnique(0)->getPass(0)->createTextureUnitState("BackgroundTexture"); +#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) + Ogre::MaterialPtr mMaterial; + Ogre::String matName("BackgroundMaterial"); + //if it doesnt already exist + if (!Ogre::MaterialManager::getSingleton().resourceExists(matName)) { + mMaterial = Ogre::MaterialManager::getSingleton().create(matName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true); + } + mBackground->setMaterial(mMaterial); // Attach the material to the rectangle +#else mBackground->setMaterial("BackgroundMaterial"); // Attach the material to the rectangle +#endif mBackground->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND); // To be rendered in Background // Add the background to the Scene Graph so it will be rendered @@ -961,7 +981,7 @@ void vpAROgre::closeOIS(void) OIS::InputManager::destroyInputSystem(mInputManager); mInputManager = 0; -} + } #endif } From 5537544f66efcf9c30f73ded5fb1f03bcf358afc Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Wed, 4 Dec 2024 17:04:30 +0100 Subject: [PATCH 06/38] [FIX] Fixed "cannot convert 'Ogre::Matrix4' to 'const Ogre::Affine3&'" --- modules/ar/src/ogre-simulator/vpAROgre.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index b7537c5206..d97c1d9120 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -51,6 +51,7 @@ #include #if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 11<<8 | 0)) +#include #include typedef OgreBites::WindowEventUtilities OgreWindowEventUtilities; #else @@ -1081,7 +1082,12 @@ void vpAROgre::updateCameraParameters(const vpHomogeneousMatrix &cMw) (Ogre::Real)-cMw[1][0], (Ogre::Real)-cMw[1][1], (Ogre::Real)-cMw[1][2], (Ogre::Real)-cMw[1][3], (Ogre::Real)-cMw[2][0], (Ogre::Real)-cMw[2][1], (Ogre::Real)-cMw[2][2], (Ogre::Real)-cMw[2][3], (Ogre::Real)0, (Ogre::Real)0, (Ogre::Real)0, (Ogre::Real)1); +#if (VISP_HAVE_OGRE_VERSION >= (1 << 16 | 11 << 8 | 0)) + Ogre::Affine3 ModelViewAsAffine(ModelView); + mCamera->setCustomViewMatrix(true, ModelViewAsAffine); +#else mCamera->setCustomViewMatrix(true, ModelView); +#endif } /*! From 8bb0792c431216acd8636fb6fdd3606a4fea3c98 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Thu, 5 Dec 2024 10:29:10 +0100 Subject: [PATCH 07/38] [FIX] Fixed visp-images dataset detection Moved detection of the visp-images outside the vp_add_test method, to make the detection possible even when tests are disabled --- CMakeLists.txt | 7 +++++++ cmake/VISPModule.cmake | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34bf6a769d..dcd35cee4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,6 +142,13 @@ set(VISP_SOVERSION "${VISP_VERSION_MAJOR}.${VISP_VERSION_MINOR}") # Package revision number set(VISP_REVISION "1") +# Try to locate visp-images and, if it exists, its version +vp_find_dataset(VISP_DATASET_FOUND VISP_DATASET_LOCATION + VISP_DATASET_VERSION + VISP_DATASET_VERSION_MAJOR + VISP_DATASET_VERSION_MINOR + VISP_DATASET_VERSION_PATCH) + #----------------------------------------------------------------------------- # TO BE CHECKED BEFORE NEXT RELEASE # diff --git a/cmake/VISPModule.cmake b/cmake/VISPModule.cmake index 3bab489d17..a9f958256e 100644 --- a/cmake/VISPModule.cmake +++ b/cmake/VISPModule.cmake @@ -990,12 +990,6 @@ macro(vp_add_tests) if(BUILD_TESTS AND EXISTS "${test_path}") __vp_parse_test_sources(TEST ${ARGN}) - vp_find_dataset(VISP_DATASET_FOUND VISP_DATASET_LOCATION - VISP_DATASET_VERSION - VISP_DATASET_VERSION_MAJOR - VISP_DATASET_VERSION_MINOR - VISP_DATASET_VERSION_PATCH) - set(__exclude_ctest "") foreach(__folder ${VISP_TEST_${the_module}_CTEST_EXCLUDE_FOLDER} ) file(GLOB_RECURSE __files "${CMAKE_CURRENT_LIST_DIR}/test/${__folder}/*.cpp") From 6c7cc06760f6cfdbfa37ac413b2bfe6c2a380a17 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 10 Dec 2024 10:55:24 +0100 Subject: [PATCH 08/38] [FIX] Fixed deprecated warnings due to the setting of the lights in AROgre --- example/ogre-simulator/AROgre.cpp | 9 +++++++-- example/ogre-simulator/AROgreBasic.cpp | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/example/ogre-simulator/AROgre.cpp b/example/ogre-simulator/AROgre.cpp index 3bb85a4c08..7417e0ad27 100644 --- a/example/ogre-simulator/AROgre.cpp +++ b/example/ogre-simulator/AROgre.cpp @@ -224,7 +224,13 @@ class vpAROgreExample : public vpAROgre light->setDiffuseColour(1.0, 1.0, 1.0); // scaled RGB values light->setSpecularColour(1.0, 1.0, 1.0); // scaled RGB values // Lumiere ponctuelle +#if (VISP_HAVE_OGRE_VERSION < (1 << 16 | 10 << 8 | 0)) light->setPosition(-5, -5, 10); +#else + Ogre::SceneNode *spotLightNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); + spotLightNode->attachObject(light); + spotLightNode->setPosition(Ogre::Vector3(-5, -5, 10)); +#endif light->setType(Ogre::Light::LT_POINT); light->setAttenuation((Ogre::Real)100, (Ogre::Real)1.0, (Ogre::Real)0.045, (Ogre::Real)0.0075); // Ombres @@ -655,7 +661,6 @@ int main(int argc, const char **argv) vpAROgreExample ogre(mcam, (unsigned int)grabber.getWidth(), (unsigned int)grabber.getHeight()); // Initialize it ogre.init(IC); - double t0 = vpTime::measureTimeMs(); // Rendering loop @@ -734,5 +739,5 @@ int main() std::cout << "- Install Ogre3D, configure again ViSP using cmake and build again this example" << std::endl; #endif return EXIT_SUCCESS; - } +} #endif diff --git a/example/ogre-simulator/AROgreBasic.cpp b/example/ogre-simulator/AROgreBasic.cpp index 774156e558..637660775e 100644 --- a/example/ogre-simulator/AROgreBasic.cpp +++ b/example/ogre-simulator/AROgreBasic.cpp @@ -527,7 +527,13 @@ int main(int argc, const char **argv) Ogre::Light *light = ogre.getSceneManager()->createLight(); light->setDiffuseColour(1, 1, 1); // scaled RGB values light->setSpecularColour(1, 1, 1); // scaled RGB values +#if (VISP_HAVE_OGRE_VERSION < (1 << 16 | 10 << 8 | 0)) light->setPosition(-5, -5, 10); +#else + Ogre::SceneNode *spotLightNode = ogre.getSceneManager()->getRootSceneNode()->createChildSceneNode(); + spotLightNode->attachObject(light); + spotLightNode->setPosition(Ogre::Vector3(-5, -5, 10)); +#endif light->setType(Ogre::Light::LT_POINT); // Rendering loop From 9d1813729e2db1ae17aa41014ca640e3eca34562 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 10 Dec 2024 10:56:10 +0100 Subject: [PATCH 09/38] [FIX] Fixed resource loading and setMaterial issue --- modules/ar/src/ogre-simulator/vpAROgre.cpp | 96 ++++++++++------------ 1 file changed, 45 insertions(+), 51 deletions(-) diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index d97c1d9120..e73f5f73b3 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -273,52 +273,53 @@ void vpAROgre::init(bool std::vector resourcesPaths = vpIoTools::splitChain(std::string(mResourcePath), std::string(";")); for (size_t i = 0; i < resourcesPaths.size(); i++) { resourceFile = resourcesPaths[i] + "/resources.cfg"; - if (vpIoTools::checkFilename(resourceFile)) { - resourcesFileExists = true; - break; + if (!vpIoTools::checkFilename(resourceFile)) { + continue; + } + resourcesFileExists = true; + std::cout << "######################### Load resource file: " << resourceFile << std::endl; + Ogre::ConfigFile cf; + cf.load(resourceFile); + // Go through all sections & settings in the file +#if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) + Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); + + Ogre::String secName, typeName, archName; + while (seci.hasMoreElements()) { + secName = seci.peekNextKey(); + Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); + Ogre::ConfigFile::SettingsMultiMap::iterator i; + for (i = settings->begin(); i != settings->end(); ++i) { + typeName = i->first; + archName = i->second; + Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName); + } + } +#else + const Ogre::ConfigFile::SettingsBySection_ §ionsNamesAndSettigns = cf.getSettingsBySection(); + Ogre::String secName, typeName, archName; + for (std::pair name_settings : sectionsNamesAndSettigns) { + secName = name_settings.first; + Ogre::ConfigFile::SettingsMultiMap settings = name_settings.second; + Ogre::ConfigFile::SettingsMultiMap::iterator i; + for (i = settings.begin(); i != settings.end(); ++i) { + typeName = i->first; + archName = i->second; + Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName); + } } +#endif } if (!resourcesFileExists) { std::string errorMsg = std::string("Error: the requested resource file \"resources.cfg\"") + std::string("doesn't exist in ") + std::string(mResourcePath); - std::cout << errorMsg << std::endl; + std::cout << errorMsg << std::endl << std::flush; throw(vpException(vpException::ioError, errorMsg)); } - std::cout << "######################### Load resource file: " << resourceFile << std::endl; - Ogre::ConfigFile cf; - cf.load(resourceFile); - // Go through all sections & settings in the file -#if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) - Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); - - Ogre::String secName, typeName, archName; - while (seci.hasMoreElements()) { - secName = seci.peekNextKey(); - Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); - Ogre::ConfigFile::SettingsMultiMap::iterator i; - for (i = settings->begin(); i != settings->end(); ++i) { - typeName = i->first; - archName = i->second; - Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName); - } - } -#else - const Ogre::ConfigFile::SettingsBySection_ §ionsNamesAndSettigns = cf.getSettingsBySection(); - Ogre::String secName, typeName, archName; - for (std::pair name_settings : sectionsNamesAndSettigns) { - secName = name_settings.first; - Ogre::ConfigFile::SettingsMultiMap settings = name_settings.second; - Ogre::ConfigFile::SettingsMultiMap::iterator i; - for (i = settings.begin(); i != settings.end(); ++i) { - typeName = i->first; - archName = i->second; - Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName); - } - } -#endif + std::cout << "##################### add resources" << std::endl; // Add Optional resources (given by the user). for (std::list::const_iterator iter = mOptionalResourceLocation.begin(); @@ -417,9 +418,13 @@ void vpAROgre::init(bool // ST_INTERIOR = Quake3 BSP //----------------------------------------------------- +#if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); +#else + mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); +#endif - // Create the camera +// Create the camera createCamera(); // Create a viewport @@ -866,13 +871,7 @@ void vpAROgre::createBackground(vpImage & /* I */) Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false); // Background Backgroundmaterial->getTechnique(0)->getPass(0)->createTextureUnitState("BackgroundTexture"); #if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) - Ogre::MaterialPtr mMaterial; - Ogre::String matName("BackgroundMaterial"); - //if it doesnt already exist - if (!Ogre::MaterialManager::getSingleton().resourceExists(matName)) { - mMaterial = Ogre::MaterialManager::getSingleton().create(matName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true); - } - mBackground->setMaterial(mMaterial); // Attach the material to the rectangle + mBackground->setMaterial(Backgroundmaterial); // Attach the material to the rectangle #else mBackground->setMaterial("BackgroundMaterial"); // Attach the material to the rectangle #endif @@ -949,14 +948,9 @@ void vpAROgre::createBackground(vpImage & /* I */) Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false); // Background Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false); // Background Backgroundmaterial->getTechnique(0)->getPass(0)->createTextureUnitState("BackgroundTexture"); + #if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) - Ogre::MaterialPtr mMaterial; - Ogre::String matName("BackgroundMaterial"); - //if it doesnt already exist - if (!Ogre::MaterialManager::getSingleton().resourceExists(matName)) { - mMaterial = Ogre::MaterialManager::getSingleton().create(matName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true); - } - mBackground->setMaterial(mMaterial); // Attach the material to the rectangle + mBackground->setMaterial(Backgroundmaterial); // Attach the material to the rectangle #else mBackground->setMaterial("BackgroundMaterial"); // Attach the material to the rectangle #endif From 8472d16787b8e3f3dba5981b79feee6ae2587d16 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 10 Dec 2024 11:07:14 +0100 Subject: [PATCH 10/38] [FIX] Fix deprecated warning due to createSceneManager --- modules/ar/src/ogre-simulator/vpAROgre.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index e73f5f73b3..76103b3e27 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -421,7 +421,7 @@ void vpAROgre::init(bool #if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); #else - mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); + mSceneMgr = mRoot->createSceneManager(Ogre::DefaultSceneManagerFactory::FACTORY_TYPE_NAME, Ogre::BLANKSTRING); #endif // Create the camera From 0ea8a3559a1f6a29d3a55950c230b7dff6ca3135 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 10 Dec 2024 11:17:34 +0100 Subject: [PATCH 11/38] [FIX] Fixed deprecated warning due to getSceneManagerIterator --- modules/ar/src/ogre-simulator/vpAROgre.cpp | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index 76103b3e27..1e390f6171 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -501,8 +501,18 @@ vpAROgre::~vpAROgre(void) } // Delete root - if (Ogre::Root::getSingletonPtr() && !Ogre::Root::getSingletonPtr()->getSceneManagerIterator().hasMoreElements() && - mRoot) { + bool hasNoMoreElements = false; +#if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) + if (Ogre::Root::getSingletonPtr()) { + hasNoMoreElements = !Ogre::Root::getSingletonPtr()->getSceneManagerIterator().hasMoreElements(); + } +#else + if (Ogre::Root::getSingletonPtr()) { + hasNoMoreElements = Ogre::Root::getSingletonPtr()->getSceneManagers().empty(); + } +#endif + + if (hasNoMoreElements && mRoot) { delete mRoot; } mRoot = 0; @@ -978,13 +988,13 @@ void vpAROgre::closeOIS(void) mInputManager = 0; } #endif -} + } -/*! - Update the projection parameters of the camera. -*/ -// Note: equation taken from: -// http://strawlab.org/2011/11/05/augmented-reality-with-OpenGL/ + /*! + Update the projection parameters of the camera. + */ + // Note: equation taken from: + // http://strawlab.org/2011/11/05/augmented-reality-with-OpenGL/ void vpAROgre::updateCameraProjection(void) { if (mCamera != 0) { From 31a128b8feef49fde3435f915afa7a0e9f195b05 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 10 Dec 2024 12:22:47 +0100 Subject: [PATCH 12/38] [WIP] Working on the CMake file for Ogre --- cmake/OgreTools.cmake | 51 +++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/cmake/OgreTools.cmake b/cmake/OgreTools.cmake index 4813e5fca9..02c1f8c6f5 100644 --- a/cmake/OgreTools.cmake +++ b/cmake/OgreTools.cmake @@ -182,6 +182,7 @@ function(vp_set_ogre_media) /usr/share/OGRE-1.8.0/media /usr/share/OGRE-1.8.1/media /usr/share/OGRE-1.9.0/media + /usr/share/OGRE/Media ) endif() @@ -274,13 +275,14 @@ function(vp_set_ogre_media) # Here we copy all the minimal media files # - media/materials/... # - media/models/... - if(OGRE_MEDIA_NOT_AVAILABLE) + # if(OGRE_MEDIA_NOT_AVAILABLE) file(COPY modules/ar/data/ogre-simulator/media DESTINATION ${VISP_BINARY_DIR}/data/ogre-simulator) - endif() + # endif() if(ogre_resources_cfg_exists) - set(VISP_HAVE_OGRE_RESOURCES_PATH "${ogre_resources_cfg_exists}" CACHE INTERNAL "Ogre resources location") - else() + set(VISP_HAVE_OGRE_RESOURCES_PATH "${ogre_resources_cfg_exists};" CACHE INTERNAL "Ogre resources location") + endif() + # else() # Here we create a resources.cfg if it was not found # we create a resources.cfg file for vpAROgre.cpp @@ -288,22 +290,23 @@ function(vp_set_ogre_media) # If OGRE_MEDIA_DIR is not found, we set it to VISP_HAVE_OGRE_RESOURCES_PATH in order to use # the minimal requested media to run the examples #-------------- - set(VISP_HAVE_OGRE_RESOURCES_PATH "${VISP_BINARY_DIR}/data/ogre-simulator" CACHE INTERNAL "Ogre resources location") + set(OGRE_DATA_ROOT_DIR "${VISP_BINARY_DIR}/data/ogre-simulator") + set(VISP_HAVE_OGRE_RESOURCES_PATH "${VISP_HAVE_OGRE_RESOURCES_PATH}${OGRE_DATA_ROOT_DIR}" CACHE INTERNAL "Ogre resources location") - if(OGRE_MEDIA_NOT_AVAILABLE) - set(OGRE_MEDIA_DIR ${VISP_HAVE_OGRE_RESOURCES_PATH}/media) - endif() + # if(OGRE_MEDIA_NOT_AVAILABLE) + set(OGRE_VISP_MEDIA_DIR "${VISP_BINARY_DIR}/data/ogre-simulator/media") + # endif() - # Here we add all the subdirs in @OGRE_MEDIA_DIR@/* as resource location. - vp_get_relative_subdirs(media_subdirs ${OGRE_MEDIA_DIR}) - set(OGRE_RESOURCES_FileSystem "FileSystem=${OGRE_MEDIA_DIR}\n") + # Here we add all the subdirs in @OGRE_VISP_MEDIA_DIR@/* as resource location. + vp_get_relative_subdirs(media_subdirs ${OGRE_VISP_MEDIA_DIR}) + set(OGRE_RESOURCES_FileSystem "FileSystem=${OGRE_VISP_MEDIA_DIR}\n") foreach(m ${media_subdirs}) - set(OGRE_RESOURCES_FileSystem "${OGRE_RESOURCES_FileSystem}FileSystem=${OGRE_MEDIA_DIR}/${m}\n") + set(OGRE_RESOURCES_FileSystem "${OGRE_RESOURCES_FileSystem}FileSystem=${OGRE_VISP_MEDIA_DIR}/${m}\n") endforeach() configure_file( ${VISP_SOURCE_DIR}/cmake/templates/resources.cfg.in - ${VISP_HAVE_OGRE_RESOURCES_PATH}/resources.cfg + ${OGRE_DATA_ROOT_DIR}/resources.cfg IMMEDIATE @ONLY ) @@ -316,14 +319,14 @@ function(vp_set_ogre_media) # make the var global set(VISP_INSTALL_DIR_OGRE_RESOURCES ${VISP_INSTALL_DIR_OGRE_RESOURCES} CACHE INTERNAL "Ogre media install dir") - if(OGRE_MEDIA_NOT_AVAILABLE) - set(OGRE_MEDIA_DIR ${VISP_INSTALL_DIR_OGRE_RESOURCES}/media) - endif() + # if(OGRE_MEDIA_NOT_AVAILABLE) + set(OGRE_VISP_INSTALL_MEDIA_DIR ${VISP_INSTALL_DIR_OGRE_RESOURCES}/media) + # endif() - # Here we add all the subdirs in @OGRE_MEDIA_DIR@/* as resource location. - set(OGRE_RESOURCES_FileSystem "FileSystem=${OGRE_MEDIA_DIR}\n") + # Here we add all the subdirs in @OGRE_VISP_INSTALL_MEDIA_DIR@/* as resource location. + set(OGRE_RESOURCES_FileSystem "FileSystem=${OGRE_VISP_INSTALL_MEDIA_DIR}\n") foreach(m ${media_subdirs}) - set(OGRE_RESOURCES_FileSystem "${OGRE_RESOURCES_FileSystem}FileSystem=${OGRE_MEDIA_DIR}/${m}\n") + set(OGRE_RESOURCES_FileSystem "${OGRE_RESOURCES_FileSystem}FileSystem=${OGRE_VISP_INSTALL_MEDIA_DIR}/${m}\n") endforeach() # install rule for resources.cfg and Ogre media if they are not available: @@ -339,14 +342,14 @@ function(vp_set_ogre_media) PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE COMPONENT dev ) - if(OGRE_MEDIA_NOT_AVAILABLE) + # if(OGRE_MEDIA_NOT_AVAILABLE) install(DIRECTORY ${VISP_BINARY_DIR}/data/ogre-simulator/media DESTINATION ${VISP_INSTALL_DATAROOTDIR}/data/ogre-simulator FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE COMPONENT dev ) - endif() + # endif() else() configure_file( ${VISP_SOURCE_DIR}/cmake/templates/resources.cfg.in @@ -359,16 +362,16 @@ function(vp_set_ogre_media) PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE COMPONENT dev ) - if(OGRE_MEDIA_NOT_AVAILABLE) + # if(OGRE_MEDIA_NOT_AVAILABLE) install(DIRECTORY ${VISP_BINARY_DIR}/data/ogre-simulator/media DESTINATION ${VISP_INSTALL_DATAROOTDIR}/data/ogre-simulator FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE COMPONENT dev ) - endif() + # endif() endif() - endif() + # endif() endfunction() macro(vp_set_ogre_advanced_var) From f6b69c28702139b682c7fbebb084fed5eee48114 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Wed, 11 Dec 2024 11:06:49 +0100 Subject: [PATCH 13/38] [CORE] Fixed deprecated warnings due to light->setPosition in tutorials --- modules/ar/src/ogre-simulator/vpAROgre.cpp | 6 ++++-- .../ibvs/tutorial-ibvs-4pts-ogre-tracking.cpp | 10 ++++++++-- .../visual-servo/ibvs/tutorial-ibvs-4pts-ogre.cpp | 13 +++++++++---- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index 1e390f6171..af5177c746 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -670,8 +670,9 @@ void vpAROgre::display(const vpImage &I, const vpHomogeneousMatri mWindow->update(); keepOn = true; } - else + else { keepOn = false; + } } /*! @@ -686,8 +687,9 @@ void vpAROgre::display(const vpImage &I, const vpHomogeneousMatrix &cMw) mWindow->update(); keepOn = true; } - else + else { keepOn = false; + } } /*! diff --git a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre-tracking.cpp b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre-tracking.cpp index 29aaf59e55..c14ef5f598 100644 --- a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre-tracking.cpp +++ b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre-tracking.cpp @@ -103,8 +103,14 @@ int main() Ogre::Light *light = ogre.getSceneManager()->createLight(); light->setDiffuseColour(1, 1, 1); // scaled RGB values light->setSpecularColour(1, 1, 1); // scaled RGB values - light->setPosition((Ogre::Real)cdMo[0][3], (Ogre::Real)cdMo[1][3], (Ogre::Real)(-cdMo[2][3])); light->setType(Ogre::Light::LT_POINT); +#if (VISP_HAVE_OGRE_VERSION < (1 << 16 | 10 << 8 | 0)) + light->setPosition((Ogre::Real)cdMo[0][3], (Ogre::Real)cdMo[1][3], (Ogre::Real)(-cdMo[2][3])); +#else + Ogre::SceneNode *spotLightNode = ogre.getSceneManager()->getRootSceneNode()->createChildSceneNode(); + spotLightNode->attachObject(light); + spotLightNode->setPosition((Ogre::Real)cdMo[0][3], (Ogre::Real)cdMo[1][3], (Ogre::Real)(-cdMo[2][3])); +#endif vpServo task; task.setServo(vpServo::EYEINHAND_CAMERA); @@ -229,4 +235,4 @@ int main() } return EXIT_SUCCESS; #endif - } +} diff --git a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre.cpp b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre.cpp index b4ec58637b..c021f30a58 100644 --- a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre.cpp +++ b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre.cpp @@ -58,9 +58,14 @@ int main() // Add an optional point light source Ogre::Light *light = ogre.getSceneManager()->createLight(); light->setDiffuseColour(1, 1, 1); // scaled RGB values - light->setSpecularColour(1, 1, 1); // scaled RGB values - light->setPosition((Ogre::Real)cdMo[0][3], (Ogre::Real)cdMo[1][3], (Ogre::Real)(-cdMo[2][3])); light->setType(Ogre::Light::LT_POINT); +#if (VISP_HAVE_OGRE_VERSION < (1 << 16 | 10 << 8 | 0)) + light->setPosition((Ogre::Real)cdMo[0][3], (Ogre::Real)cdMo[1][3], (Ogre::Real)(-cdMo[2][3])); +#else + Ogre::SceneNode *spotLightNode = ogre.getSceneManager()->getRootSceneNode()->createChildSceneNode(); + spotLightNode->attachObject(light); + spotLightNode->setPosition((Ogre::Real)cdMo[0][3], (Ogre::Real)cdMo[1][3], (Ogre::Real)(-cdMo[2][3])); +#endif #endif vpServo task; @@ -89,7 +94,7 @@ int main() for (int i = 0; i < 4; i++) { point[i].track(cMo); vpFeatureBuilder::create(p[i], point[i]); - } + } #if defined(VISP_HAVE_OGRE) // Update the scene from the new camera position ogre.display(background, cMo); @@ -97,8 +102,8 @@ int main() vpColVector v = task.computeControlLaw(); robot.setVelocity(vpRobot::CAMERA_FRAME, v); vpTime::wait(robot.getSamplingTime() * 1000); + } } -} catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; } From 2f49d90b596252bc1fe57f62618b0dd30d049b83 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Wed, 11 Dec 2024 15:37:10 +0100 Subject: [PATCH 14/38] [CORE] Add Ogre dir log during CMake configuration if USE_OGRE --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index dcd35cee4f..cd0e6df1b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1928,6 +1928,13 @@ endif() if(USE_YARP) status(" Yarp dir:" "${YARP_DIR}") endif() +if(USE_OGRE) + if(NOT ${OGRE_DIR} STREQUAL "") + status(" Ogre dir:" "${OGRE_DIR}") + else() + status(" Ogre dir:" "includes in ${OGRE_INCLUDE_DIR} , core lib in ${OGRE_LIBRARY_REL} , other libs in ${OGRE_PLUGIN_DIR_REL}") + endif() +endif() # ========================== auxiliary ========================== status("") From e6758041ec09ed4da26df8fab7dafae01cb9b388 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Wed, 11 Dec 2024 15:38:45 +0100 Subject: [PATCH 15/38] [FIX] Initialize the VISP_HAVE_OGRE_RESOURCES_PATH to empty string because it seemed to cause a problem when running successive configure steps --- cmake/OgreTools.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/OgreTools.cmake b/cmake/OgreTools.cmake index 02c1f8c6f5..c7e2e4ca78 100644 --- a/cmake/OgreTools.cmake +++ b/cmake/OgreTools.cmake @@ -279,6 +279,8 @@ function(vp_set_ogre_media) file(COPY modules/ar/data/ogre-simulator/media DESTINATION ${VISP_BINARY_DIR}/data/ogre-simulator) # endif() + # Initialize the variable + set(VISP_HAVE_OGRE_RESOURCES_PATH "" CACHE INTERNAL "Ogre resources location") if(ogre_resources_cfg_exists) set(VISP_HAVE_OGRE_RESOURCES_PATH "${ogre_resources_cfg_exists};" CACHE INTERNAL "Ogre resources location") endif() From 852dd7a8c3218f480423edeb8155185dfc196ced Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Thu, 12 Dec 2024 11:06:23 +0100 Subject: [PATCH 16/38] [KO] Pbs : of include in 1.12.10, of linkage in 1.9.0 --- modules/ar/include/visp3/ar/vpAROgre.h | 19 ++++ modules/ar/src/ogre-simulator/vpAROgre.cpp | 112 ++++++++++++++++----- 2 files changed, 108 insertions(+), 23 deletions(-) diff --git a/modules/ar/include/visp3/ar/vpAROgre.h b/modules/ar/include/visp3/ar/vpAROgre.h index b387eade8d..b09df0b69c 100644 --- a/modules/ar/include/visp3/ar/vpAROgre.h +++ b/modules/ar/include/visp3/ar/vpAROgre.h @@ -62,6 +62,7 @@ #include #if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) +#include #include #endif @@ -69,6 +70,13 @@ #include #endif +#ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM +#include +#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) +#include +#endif +#endif // INCLUDE_RTSHADER_SYSTEM + #ifdef VISP_HAVE_OIS #include #endif @@ -353,6 +361,10 @@ class VISP_EXPORT vpAROgre : public Ogre::FrameListener, bool stopTest(const Ogre::FrameEvent &evt); + bool initialiseRTShaderSystem(); + + void destroyRTShaderSystem(); + protected: // Attributes Ogre::String name; /**Name of th Window*/ @@ -371,6 +383,13 @@ class VISP_EXPORT vpAROgre : public Ogre::FrameListener, OIS::Keyboard *mKeyboard; #endif +#ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM + Ogre::RTShader::ShaderGenerator *mShaderGenerator; // The Shader generator instance. +#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) + OgreBites::SGTechniqueResolverListener *mMaterialMgrListener; // Shader generator material manager listener. +#endif +#endif // INCLUDE_RTSHADER_SYSTEM + // ViSP AR System bool keepOn; /** Has the application received a signal to stop(false) or not (true) */ diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index af5177c746..0e4eb2a981 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -85,7 +85,64 @@ vpAROgre::vpAROgre(const vpCameraParameters &cam, unsigned int width, unsigned i mImageRGBA(), mImage(), mPixelBuffer(), mBackground(nullptr), mBackgroundHeight(0), mBackgroundWidth(0), mWindowHeight(height), mWindowWidth(width), windowHidden(false), mNearClipping(0.001), mFarClipping(200), mcam(cam), mshowConfigDialog(true), mOptionalResourceLocation() -{ } +{ +#ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM +#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) + mMaterialMgrListener = NULL; +#endif + mShaderGenerator = NULL; +#endif +} + +/** +Initialize the RT Shader system. +*/ +bool vpAROgre::initialiseRTShaderSystem() +{ +#ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM + if (Ogre::RTShader::ShaderGenerator::initialize()) { + mShaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr(); + +#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) +// Create and register the material manager listener if it doesn't exist yet. + if (!mMaterialMgrListener) { + mMaterialMgrListener = new OgreBites::SGTechniqueResolverListener(mShaderGenerator); + Ogre::MaterialManager::getSingleton().addListener(mMaterialMgrListener); + } +#else +//TODO +#endif + return true; + } +#endif + return false; +} + +/** +Destroy the RT Shader system. +*/ +void vpAROgre::destroyRTShaderSystem() +{ +#ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM + // Restore default scheme. + Ogre::MaterialManager::getSingleton().setActiveScheme(Ogre::MaterialManager::DEFAULT_SCHEME_NAME); + +#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) + // Unregister the material manager listener. + if (mMaterialMgrListener != NULL) { + Ogre::MaterialManager::getSingleton().removeListener(mMaterialMgrListener); + delete mMaterialMgrListener; + mMaterialMgrListener = NULL; + } +#endif + +// Destroy RTShader system. + if (mShaderGenerator != NULL) { + Ogre::RTShader::ShaderGenerator::destroy(); + mShaderGenerator = NULL; + } +#endif +} /*! Initialisation of Ogre with a grey level background. @@ -256,6 +313,18 @@ void vpAROgre::init(bool mRoot = Ogre::Root::getSingletonPtr(); } +#if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) + mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); +#else + mSceneMgr = mRoot->createSceneManager(Ogre::DefaultSceneManagerFactory::FACTORY_TYPE_NAME, Ogre::BLANKSTRING); +#endif + + // Initialize the RTShaderSystem, if available + bool hasInitializedTheRTSS = initialiseRTShaderSystem(); + if (!hasInitializedTheRTSS) { + std::cout << "[vpAROgre::init] RTSS is not available." << std::endl; + } + // Load resource paths from config file // File format is: @@ -293,8 +362,8 @@ void vpAROgre::init(bool typeName = i->first; archName = i->second; Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName); - } - } + } +} #else const Ogre::ConfigFile::SettingsBySection_ §ionsNamesAndSettigns = cf.getSettingsBySection(); Ogre::String secName, typeName, archName; @@ -309,7 +378,7 @@ void vpAROgre::init(bool } } #endif - } +} if (!resourcesFileExists) { std::string errorMsg = std::string("Error: the requested resource file \"resources.cfg\"") + std::string("doesn't exist in ") + std::string(mResourcePath); @@ -418,12 +487,6 @@ void vpAROgre::init(bool // ST_INTERIOR = Quake3 BSP //----------------------------------------------------- -#if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) - mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); -#else - mSceneMgr = mRoot->createSceneManager(Ogre::DefaultSceneManagerFactory::FACTORY_TYPE_NAME, Ogre::BLANKSTRING); -#endif - // Create the camera createCamera(); @@ -495,6 +558,9 @@ vpAROgre::~vpAROgre(void) // Close OIS closeOIS(); + // Destroy the RTSS, if available + destroyRTShaderSystem(); + if (mWindow) { OgreWindowEventUtilities::removeWindowEventListener(mWindow, this); windowClosed(mWindow); @@ -505,7 +571,7 @@ vpAROgre::~vpAROgre(void) #if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) if (Ogre::Root::getSingletonPtr()) { hasNoMoreElements = !Ogre::Root::getSingletonPtr()->getSceneManagerIterator().hasMoreElements(); - } +} #else if (Ogre::Root::getSingletonPtr()) { hasNoMoreElements = Ogre::Root::getSingletonPtr()->getSceneManagers().empty(); @@ -516,13 +582,13 @@ vpAROgre::~vpAROgre(void) delete mRoot; } mRoot = 0; -} + } -/*! - Function testing if the program must stop rendering or not. - \param evt : Frame event to process. - \return False if the program must be stopped. -*/ + /*! + Function testing if the program must stop rendering or not. + \param evt : Frame event to process. + \return False if the program must be stopped. + */ bool vpAROgre::stopTest(const Ogre::FrameEvent &evt) { // Always keep this part @@ -988,7 +1054,7 @@ void vpAROgre::closeOIS(void) OIS::InputManager::destroyInputSystem(mInputManager); mInputManager = 0; - } +} #endif } @@ -1072,11 +1138,11 @@ void vpAROgre::updateBackgroundTexture(const vpImage &I) // Unlock the pixel buffer mPixelBuffer->unlock(); -} + } -/*! - Update Camera parameters from a pose calculation. -*/ + /*! + Update Camera parameters from a pose calculation. + */ void vpAROgre::updateCameraParameters(const vpHomogeneousMatrix &cMw) { // The matrix is given to Ogre with some changes to fit with the world @@ -1138,7 +1204,7 @@ void vpAROgre::getRenderingOutput(vpImage &I, const vpHomogeneousMatrix // Unlock the pixel buffer mPixelBuffer->unlock(); -} + } END_VISP_NAMESPACE #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_ar.a(vpAROgre.cpp.o) has no symbols From c5dbc8a07829bfbb38d4003fbcb6ca2e4dc168ff Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Mon, 16 Dec 2024 09:18:35 +0100 Subject: [PATCH 17/38] [FIX] Fixed warnings when loading the resources using Ogre 1.12.10 --- cmake/OgreTools.cmake | 3 +- modules/ar/src/ogre-simulator/vpAROgre.cpp | 208 ++++++++++----------- 2 files changed, 106 insertions(+), 105 deletions(-) diff --git a/cmake/OgreTools.cmake b/cmake/OgreTools.cmake index c7e2e4ca78..5a2e7f086f 100644 --- a/cmake/OgreTools.cmake +++ b/cmake/OgreTools.cmake @@ -108,6 +108,7 @@ macro(vp_create_ogre_plugin_config_file) endif() if(OGRE_PLUGIN_DIR_REL) + list(APPEND PLUGIN_REL ${OGRE_RTShaderSystem_LIBRARY_REL}) list(APPEND PLUGIN_REL ${OGRE_RenderSystem_Direct3D9_LIBRARY_REL}) list(APPEND PLUGIN_REL ${OGRE_RenderSystem_Direct3D10_LIBRARY_REL}) list(APPEND PLUGIN_REL ${OGRE_RenderSystem_Direct3D11_LIBRARY_REL}) @@ -377,7 +378,7 @@ function(vp_set_ogre_media) endfunction() macro(vp_set_ogre_advanced_var) - set(ogre_components_ Paging Terrain Plugin_BSPSceneManager Plugin_CgProgramManager Plugin_OctreeSceneManager Plugin_OctreeZone Plugin_PCZSceneManager Plugin_ParticleFX RenderSystem_Direct3D11 RenderSystem_Direct3D9 RenderSystem_GLES2 RenderSystem_GLES RenderSystem_GL) + set(ogre_components_ Paging Terrain Plugin_BSPSceneManager Plugin_CgProgramManager Plugin_OctreeSceneManager Plugin_OctreeZone Plugin_PCZSceneManager Plugin_ParticleFX RenderSystem_Direct3D11 RenderSystem_Direct3D9 RenderSystem_GLES2 RenderSystem_GLES RenderSystem_GL RTShaderSystem) foreach(component_ ${ogre_components_}) mark_as_advanced(OGRE_${component_}_INCLUDE_DIR) mark_as_advanced(OGRE_${component_}_LIBRARY_DBG) diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index 0e4eb2a981..78c97dd940 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -313,12 +313,90 @@ void vpAROgre::init(bool mRoot = Ogre::Root::getSingletonPtr(); } + // Create the window + bool canInit = true; + if (mshowConfigDialog) { + mRoot->restoreConfig(); +#if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) + bool isOK = mRoot->showConfigDialog(); +#else + bool isOK = mRoot->showConfigDialog(OgreBites::getNativeConfigDialog()); +#endif + if (!isOK) { + canInit = false; + } + } + else { + if (!mRoot->restoreConfig()) { + canInit = false; + } + } + + if (!mRoot->isInitialised()) { + if (!canInit) { // We set the default renderer system + const Ogre::RenderSystemList &lRenderSystemList = mRoot->getAvailableRenderers(); + if (lRenderSystemList.size() == 0) { + throw "ConfigDialog aborted"; // Exit the application on cancel + } + + Ogre::RenderSystem *lRenderSystem = lRenderSystemList.at(0); + std::cout << "Using " << lRenderSystem->getName() << " as renderer." << std::endl; + mRoot->setRenderSystem(lRenderSystem); + } + + mRoot->initialise(false); + } + #if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); #else mSceneMgr = mRoot->createSceneManager(Ogre::DefaultSceneManagerFactory::FACTORY_TYPE_NAME, Ogre::BLANKSTRING); #endif + bool fullscreen = false; + Ogre::NameValuePairList misc; + Ogre::ConfigOptionMap config = mRoot->getRenderSystem()->getConfigOptions(); + Ogre::ConfigOptionMap::const_iterator it = config.begin(); + + while (it != config.end()) { + Ogre::String leftconf = (*it).first; + Ogre::String rightconf = (*it).second.currentValue; + + if (leftconf == "Video Mode") { + if (canInit) { + std::stringstream ss(rightconf.c_str()); + std::string dummy; + ss >> mWindowWidth >> dummy >> mWindowHeight; + if (ss.fail()) { + std::cout << "Cannot read Ogre video mode" << std::endl; + } + } + else if (mWindowWidth == 0 && mWindowHeight == 0) { + mWindowWidth = mBackgroundWidth; + mWindowHeight = mBackgroundHeight; + } + } + else if (leftconf == "Full Screen") { + if (canInit && (rightconf == "Yes")) { + fullscreen = true; + } + } + else { + misc[leftconf] = rightconf; + } + + ++it; + } + + // With Ogre version >= 1.8.1 we hide the window + if (hidden) { +#if (OGRE_VERSION >= (1 << 16 | 8 << 8 | 1)) + misc["hidden"] = "true"; + windowHidden = true; +#endif + } + mWindow = mRoot->createRenderWindow(name, mWindowWidth, mWindowHeight, fullscreen, &misc); + // Initialize the RTShaderSystem, if available bool hasInitializedTheRTSS = initialiseRTShaderSystem(); if (!hasInitializedTheRTSS) { @@ -362,8 +440,8 @@ void vpAROgre::init(bool typeName = i->first; archName = i->second; Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName); - } -} + } + } #else const Ogre::ConfigFile::SettingsBySection_ §ionsNamesAndSettigns = cf.getSettingsBySection(); Ogre::String secName, typeName, archName; @@ -378,7 +456,7 @@ void vpAROgre::init(bool } } #endif -} + } if (!resourcesFileExists) { std::string errorMsg = std::string("Error: the requested resource file \"resources.cfg\"") + std::string("doesn't exist in ") + std::string(mResourcePath); @@ -397,84 +475,6 @@ void vpAROgre::init(bool *iter, "FileSystem", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); } - // Create the window - bool canInit = true; - if (mshowConfigDialog) { - mRoot->restoreConfig(); -#if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) - bool isOK = mRoot->showConfigDialog(); -#else - bool isOK = mRoot->showConfigDialog(OgreBites::getNativeConfigDialog()); -#endif - if (!isOK) { - canInit = false; - } - } - else { - if (!mRoot->restoreConfig()) { - canInit = false; - } - } - - if (!mRoot->isInitialised()) { - if (!canInit) { // We set the default renderer system - const Ogre::RenderSystemList &lRenderSystemList = mRoot->getAvailableRenderers(); - if (lRenderSystemList.size() == 0) { - throw "ConfigDialog aborted"; // Exit the application on cancel - } - - Ogre::RenderSystem *lRenderSystem = lRenderSystemList.at(0); - std::cout << "Using " << lRenderSystem->getName() << " as renderer." << std::endl; - mRoot->setRenderSystem(lRenderSystem); - } - - mRoot->initialise(false); - } - - bool fullscreen = false; - Ogre::NameValuePairList misc; - Ogre::ConfigOptionMap config = mRoot->getRenderSystem()->getConfigOptions(); - Ogre::ConfigOptionMap::const_iterator it = config.begin(); - - while (it != config.end()) { - Ogre::String leftconf = (*it).first; - Ogre::String rightconf = (*it).second.currentValue; - - if (leftconf == "Video Mode") { - if (canInit) { - std::stringstream ss(rightconf.c_str()); - std::string dummy; - ss >> mWindowWidth >> dummy >> mWindowHeight; - if (ss.fail()) { - std::cout << "Cannot read Ogre video mode" << std::endl; - } - } - else if (mWindowWidth == 0 && mWindowHeight == 0) { - mWindowWidth = mBackgroundWidth; - mWindowHeight = mBackgroundHeight; - } - } - else if (leftconf == "Full Screen") { - if (canInit && (rightconf == "Yes")) { - fullscreen = true; - } - } - else { - misc[leftconf] = rightconf; - } - - ++it; - } - - // With Ogre version >= 1.8.1 we hide the window - if (hidden) { -#if (OGRE_VERSION >= (1 << 16 | 8 << 8 | 1)) - misc["hidden"] = "true"; - windowHidden = true; -#endif - } - mWindow = mRoot->createRenderWindow(name, mWindowWidth, mWindowHeight, fullscreen, &misc); - // Initialise resources Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); //----------------------------------------------------- @@ -546,11 +546,11 @@ void vpAROgre::init(bool /*Ogre::Viewport* Viewport =*/RTarget->addViewport(mCamera); RTarget->getViewport(0)->setClearEveryFrame(true); RTarget->getViewport(0)->setOverlaysEnabled(false); -} + } -/*! - Destructor. -*/ + /*! + Destructor. + */ vpAROgre::~vpAROgre(void) { // Destroy 3D scene @@ -571,7 +571,7 @@ vpAROgre::~vpAROgre(void) #if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) if (Ogre::Root::getSingletonPtr()) { hasNoMoreElements = !Ogre::Root::getSingletonPtr()->getSceneManagerIterator().hasMoreElements(); -} + } #else if (Ogre::Root::getSingletonPtr()) { hasNoMoreElements = Ogre::Root::getSingletonPtr()->getSceneManagers().empty(); @@ -582,13 +582,13 @@ vpAROgre::~vpAROgre(void) delete mRoot; } mRoot = 0; - } +} - /*! - Function testing if the program must stop rendering or not. - \param evt : Frame event to process. - \return False if the program must be stopped. - */ +/*! + Function testing if the program must stop rendering or not. + \param evt : Frame event to process. + \return False if the program must be stopped. +*/ bool vpAROgre::stopTest(const Ogre::FrameEvent &evt) { // Always keep this part @@ -1054,15 +1054,15 @@ void vpAROgre::closeOIS(void) OIS::InputManager::destroyInputSystem(mInputManager); mInputManager = 0; -} -#endif } +#endif +} - /*! - Update the projection parameters of the camera. - */ - // Note: equation taken from: - // http://strawlab.org/2011/11/05/augmented-reality-with-OpenGL/ +/*! + Update the projection parameters of the camera. +*/ +// Note: equation taken from: +// http://strawlab.org/2011/11/05/augmented-reality-with-OpenGL/ void vpAROgre::updateCameraProjection(void) { if (mCamera != 0) { @@ -1138,11 +1138,11 @@ void vpAROgre::updateBackgroundTexture(const vpImage &I) // Unlock the pixel buffer mPixelBuffer->unlock(); - } +} - /*! - Update Camera parameters from a pose calculation. - */ +/*! + Update Camera parameters from a pose calculation. +*/ void vpAROgre::updateCameraParameters(const vpHomogeneousMatrix &cMw) { // The matrix is given to Ogre with some changes to fit with the world @@ -1204,7 +1204,7 @@ void vpAROgre::getRenderingOutput(vpImage &I, const vpHomogeneousMatrix // Unlock the pixel buffer mPixelBuffer->unlock(); - } +} END_VISP_NAMESPACE #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_ar.a(vpAROgre.cpp.o) has no symbols From 492c99f44411084502e97f0bf1ff11bbb4b02dae Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Mon, 16 Dec 2024 11:03:05 +0100 Subject: [PATCH 18/38] [FIX] Fixed segfault that occured in tuto-ibvs-ogre-tracking --- modules/ar/src/ogre-simulator/vpAROgre.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index 78c97dd940..7dd3036bcf 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -546,13 +546,14 @@ void vpAROgre::init(bool /*Ogre::Viewport* Viewport =*/RTarget->addViewport(mCamera); RTarget->getViewport(0)->setClearEveryFrame(true); RTarget->getViewport(0)->setOverlaysEnabled(false); - } +} - /*! - Destructor. - */ +/*! + Destructor. +*/ vpAROgre::~vpAROgre(void) { + mPixelBuffer.reset(); // Destroy 3D scene destroyScene(); // Close OIS @@ -566,7 +567,7 @@ vpAROgre::~vpAROgre(void) windowClosed(mWindow); } - // Delete root +// Delete root bool hasNoMoreElements = false; #if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) if (Ogre::Root::getSingletonPtr()) { From 343aea96b37a03ed8e26720b3e924d05ccc03b21 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Mon, 16 Dec 2024 17:05:43 +0100 Subject: [PATCH 19/38] [FIX] FIx include + linkage problems for ogre 1.12+ --- modules/ar/CMakeLists.txt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/ar/CMakeLists.txt b/modules/ar/CMakeLists.txt index 15c70e9c76..252b0a2eb3 100644 --- a/modules/ar/CMakeLists.txt +++ b/modules/ar/CMakeLists.txt @@ -51,7 +51,6 @@ if(USE_OGRE) endif() # hack to fix possible presence of NOTFOUND in OGRE_INCLUDE_DIRS - #message("OGRE_INCLUDE_DIRS: ${OGRE_INCLUDE_DIRS}") foreach(inc_ ${OGRE_INCLUDE_DIRS}) if(NOT ${inc_} MATCHES "NOTFOUND") list(APPEND opt_system_incs ${inc_}) @@ -68,6 +67,18 @@ if(USE_OGRE) else() list(APPEND opt_libs ${OGRE_LIBRARIES}) endif() + + if(${OGRE_VERSION} GREATER_EQUAL "1.12.0") + foreach(component ${OGRE_COMPONENTS}) + set(ogre_target "OGRE_${component}_LIBRARIES") + if(TARGET ${${ogre_target}}) + get_target_property(inc_dirs ${${ogre_target}} INTERFACE_INCLUDE_DIRECTORIES) + if(inc_dirs) + list(APPEND opt_system_incs ${inc_dirs}) + endif() + endif() + endforeach() + endif() endif(USE_OGRE) if(USE_OIS AND USE_OGRE) @@ -188,6 +199,5 @@ endif() vp_add_module(ar visp_core) vp_glob_module_sources() - vp_module_include_directories(${opt_incs} SYSTEM ${opt_system_incs}) vp_create_module(${opt_libs}) From 963737e8725766c1f180125b97ca05b528929bb6 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 17 Dec 2024 10:37:59 +0100 Subject: [PATCH 20/38] [FIX] Fixed CMake errors related to v1.9 --- cmake/OgreTools.cmake | 1 - modules/ar/CMakeLists.txt | 18 +++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cmake/OgreTools.cmake b/cmake/OgreTools.cmake index 5a2e7f086f..fefc0374c8 100644 --- a/cmake/OgreTools.cmake +++ b/cmake/OgreTools.cmake @@ -108,7 +108,6 @@ macro(vp_create_ogre_plugin_config_file) endif() if(OGRE_PLUGIN_DIR_REL) - list(APPEND PLUGIN_REL ${OGRE_RTShaderSystem_LIBRARY_REL}) list(APPEND PLUGIN_REL ${OGRE_RenderSystem_Direct3D9_LIBRARY_REL}) list(APPEND PLUGIN_REL ${OGRE_RenderSystem_Direct3D10_LIBRARY_REL}) list(APPEND PLUGIN_REL ${OGRE_RenderSystem_Direct3D11_LIBRARY_REL}) diff --git a/modules/ar/CMakeLists.txt b/modules/ar/CMakeLists.txt index 252b0a2eb3..452e7cc02f 100644 --- a/modules/ar/CMakeLists.txt +++ b/modules/ar/CMakeLists.txt @@ -68,15 +68,19 @@ if(USE_OGRE) list(APPEND opt_libs ${OGRE_LIBRARIES}) endif() - if(${OGRE_VERSION} GREATER_EQUAL "1.12.0") + if(NOT OGRE_VERSION) + set(OGRE_VERSION "${OGRE_VERSION_MAJOR}.${OGRE_VERSION_MINOR}.${OGRE_VERSION_PATCH}") + endif() + + if(NOT(${OGRE_VERSION_MAJOR} EQUAL 1 AND ${OGRE_VERSION_MINOR} LESS_EQUAL 9)) foreach(component ${OGRE_COMPONENTS}) - set(ogre_target "OGRE_${component}_LIBRARIES") - if(TARGET ${${ogre_target}}) - get_target_property(inc_dirs ${${ogre_target}} INTERFACE_INCLUDE_DIRECTORIES) - if(inc_dirs) - list(APPEND opt_system_incs ${inc_dirs}) - endif() + set(ogre_target "OGRE_${component}_LIBRARIES") + if(TARGET ${${ogre_target}}) + get_target_property(inc_dirs ${${ogre_target}} INTERFACE_INCLUDE_DIRECTORIES) + if(inc_dirs) + list(APPEND opt_system_incs ${inc_dirs}) endif() + endif() endforeach() endif() endif(USE_OGRE) From 2706336f237a5cdf6af9524aa6169b7d6e36ff79 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 17 Dec 2024 10:44:13 +0100 Subject: [PATCH 21/38] [FIX] Fixed release of the shared ptr for ogre v1.9 --- modules/ar/include/visp3/ar/vpAROgre.h | 17 +++++++-------- modules/ar/src/ogre-simulator/vpAROgre.cpp | 24 +++++++++------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/modules/ar/include/visp3/ar/vpAROgre.h b/modules/ar/include/visp3/ar/vpAROgre.h index b09df0b69c..f328932bc9 100644 --- a/modules/ar/include/visp3/ar/vpAROgre.h +++ b/modules/ar/include/visp3/ar/vpAROgre.h @@ -61,8 +61,7 @@ #include #include -#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) -#include +#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10 <<8 | 0)) #include #endif @@ -70,11 +69,15 @@ #include #endif -#ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM +#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 12 <<8 | 0)) +#include +#elif (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10 <<8 | 0)) +#include +#endif + +#if defined(OGRE_BUILD_COMPONENT_RTSHADERSYSTEM) & (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10 <<8 | 0)) #include -#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) #include -#endif #endif // INCLUDE_RTSHADER_SYSTEM #ifdef VISP_HAVE_OIS @@ -383,11 +386,9 @@ class VISP_EXPORT vpAROgre : public Ogre::FrameListener, OIS::Keyboard *mKeyboard; #endif -#ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM +#if defined(OGRE_BUILD_COMPONENT_RTSHADERSYSTEM) & (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10 <<8 | 0)) Ogre::RTShader::ShaderGenerator *mShaderGenerator; // The Shader generator instance. -#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) OgreBites::SGTechniqueResolverListener *mMaterialMgrListener; // Shader generator material manager listener. -#endif #endif // INCLUDE_RTSHADER_SYSTEM // ViSP AR System diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index 7dd3036bcf..42e65a03fb 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -86,10 +86,8 @@ vpAROgre::vpAROgre(const vpCameraParameters &cam, unsigned int width, unsigned i mWindowHeight(height), mWindowWidth(width), windowHidden(false), mNearClipping(0.001), mFarClipping(200), mcam(cam), mshowConfigDialog(true), mOptionalResourceLocation() { -#ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM -#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) +#if defined(OGRE_BUILD_COMPONENT_RTSHADERSYSTEM) & (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10 <<8 | 0)) mMaterialMgrListener = NULL; -#endif mShaderGenerator = NULL; #endif } @@ -99,19 +97,15 @@ Initialize the RT Shader system. */ bool vpAROgre::initialiseRTShaderSystem() { -#ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM +#if defined(OGRE_BUILD_COMPONENT_RTSHADERSYSTEM) & (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10 <<8 | 0)) if (Ogre::RTShader::ShaderGenerator::initialize()) { mShaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr(); -#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) -// Create and register the material manager listener if it doesn't exist yet. + // Create and register the material manager listener if it doesn't exist yet. if (!mMaterialMgrListener) { mMaterialMgrListener = new OgreBites::SGTechniqueResolverListener(mShaderGenerator); Ogre::MaterialManager::getSingleton().addListener(mMaterialMgrListener); } -#else -//TODO -#endif return true; } #endif @@ -123,20 +117,18 @@ Destroy the RT Shader system. */ void vpAROgre::destroyRTShaderSystem() { -#ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM +#if defined(OGRE_BUILD_COMPONENT_RTSHADERSYSTEM) & (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10 <<8 | 0)) // Restore default scheme. Ogre::MaterialManager::getSingleton().setActiveScheme(Ogre::MaterialManager::DEFAULT_SCHEME_NAME); -#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) // Unregister the material manager listener. if (mMaterialMgrListener != NULL) { Ogre::MaterialManager::getSingleton().removeListener(mMaterialMgrListener); delete mMaterialMgrListener; mMaterialMgrListener = NULL; } -#endif -// Destroy RTShader system. + // Destroy RTShader system. if (mShaderGenerator != NULL) { Ogre::RTShader::ShaderGenerator::destroy(); mShaderGenerator = NULL; @@ -553,8 +545,12 @@ void vpAROgre::init(bool */ vpAROgre::~vpAROgre(void) { +#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) mPixelBuffer.reset(); - // Destroy 3D scene +#else + mPixelBuffer.setNull(); +#endif +// Destroy 3D scene destroyScene(); // Close OIS closeOIS(); From 6e013092a2452624b2ea45bb2c8181c585ea39d1 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 17 Dec 2024 15:58:09 +0100 Subject: [PATCH 22/38] [WIP] Working on a fix for Ogre v1.10 and v1.11 --- modules/ar/CMakeLists.txt | 64 ++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 15 deletions(-) diff --git a/modules/ar/CMakeLists.txt b/modules/ar/CMakeLists.txt index 452e7cc02f..0cf5f20785 100644 --- a/modules/ar/CMakeLists.txt +++ b/modules/ar/CMakeLists.txt @@ -43,7 +43,36 @@ if(USE_OGRE) # With Ubuntu 20.04, OGRE_LIBRARIES contains Boost::thread that cannot # be exported as is on pain of producing a build issue when ViSP is used # as a 3rd party. That's why here we get its imported location. + + if(NOT OGRE_VERSION) + set(OGRE_VERSION "${OGRE_VERSION_MAJOR}.${OGRE_VERSION_MINOR}.${OGRE_VERSION_PATCH}") + endif() + + if(${OGRE_VERSION_MAJOR} EQUAL 1 AND (${OGRE_VERSION_MINOR} EQUAL 10 OR ${OGRE_VERSION_MINOR} EQUAL 11)) + find_package(Boost REQUIRED COMPONENTS thread) + find_library(OgreMainSEARCH NAMES OgreMain PATHS ${OGRE_LIBRARY_DIRS}) + endif() + + if(NOT(${OGRE_VERSION_MAJOR} EQUAL 1 AND ${OGRE_VERSION_MINOR} LESS_EQUAL 9)) + foreach(component ${OGRE_COMPONENTS}) + set(ogre_target "OGRE_${component}_LIBRARIES") + foreach(ogre_libray ${${ogre_target}}) + if(TARGET ${ogre_libray}) + get_target_property(inc_dirs ${ogre_libray} INTERFACE_INCLUDE_DIRECTORIES) + if(inc_dirs) + list(APPEND opt_system_incs ${inc_dirs}) + endif() + endif() + if(${OGRE_VERSION_MAJOR} EQUAL 1 AND (${OGRE_VERSION_MINOR} EQUAL 10 OR ${OGRE_VERSION_MINOR} EQUAL 11)) + message("Looking for library ${ogre_libray} in folder ${OGRE_LIBRARY_DIRS}") + find_library(${ogre_libray}SEARCH NAMES ${ogre_libray} PATHS ${OGRE_LIBRARY_DIRS}) + endif() + endforeach() + endforeach() + endif() + vp_filter_libraries_with_imported_location(OGRE_LIBRARIES) + mark_as_advanced(OGRE_SAMPLES_INCLUDEPATH) #message("OGRE_SAMPLES_INCLUDEPATH: ${OGRE_SAMPLES_INCLUDEPATH}") if(OGRE_SAMPLES_INCLUDEPATH) @@ -65,26 +94,18 @@ if(USE_OGRE) endif() endforeach() else() - list(APPEND opt_libs ${OGRE_LIBRARIES}) - endif() - - if(NOT OGRE_VERSION) - set(OGRE_VERSION "${OGRE_VERSION_MAJOR}.${OGRE_VERSION_MINOR}.${OGRE_VERSION_PATCH}") - endif() - - if(NOT(${OGRE_VERSION_MAJOR} EQUAL 1 AND ${OGRE_VERSION_MINOR} LESS_EQUAL 9)) - foreach(component ${OGRE_COMPONENTS}) - set(ogre_target "OGRE_${component}_LIBRARIES") - if(TARGET ${${ogre_target}}) - get_target_property(inc_dirs ${${ogre_target}} INTERFACE_INCLUDE_DIRECTORIES) - if(inc_dirs) - list(APPEND opt_system_incs ${inc_dirs}) + foreach(lib_ ${OGRE_LIBRARIES}) + if(${lib_} MATCHES "^Ogre") + list(APPEND opt_libs ${${lib_}SEARCH}) + else() + list(APPEND opt_libs ${lib_}) endif() - endif() endforeach() endif() endif(USE_OGRE) +message("opt_libs = ${opt_libs}") + if(USE_OIS AND USE_OGRE) list(APPEND opt_system_incs ${OIS_INCLUDE_DIR}) list(APPEND opt_libs ${OIS_LIBRARIES}) @@ -205,3 +226,16 @@ vp_glob_module_sources() vp_module_include_directories(${opt_incs} SYSTEM ${opt_system_incs}) vp_create_module(${opt_libs}) + +get_cmake_property(_variableNames VARIABLES) +list (SORT _variableNames) +foreach (_variableName ${_variableNames}) + unset(MATCHED) + string(REGEX MATCH ".*O[gG][rR][eE].*" MATCHED ${_variableName}) + if (NOT MATCHED) + continue() + endif() + message(STATUS "${_variableName}=${${_variableName}}") +endforeach() + +# message(FATAL_ERROR "Stopping after AR module") From abb8395a4caeed2fa9bf373e5975366bdde031b6 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Thu, 19 Dec 2024 08:28:54 +0100 Subject: [PATCH 23/38] [FIX] Fixed compilation error for ogre 1.10 --- modules/ar/src/ogre-simulator/vpAROgre.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index 42e65a03fb..ff6cd10536 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -420,7 +420,7 @@ void vpAROgre::init(bool Ogre::ConfigFile cf; cf.load(resourceFile); // Go through all sections & settings in the file -#if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) +#if (VISP_HAVE_OGRE_VERSION < (1<<16 | 11<<8 | 0)) Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); Ogre::String secName, typeName, archName; @@ -545,7 +545,7 @@ void vpAROgre::init(bool */ vpAROgre::~vpAROgre(void) { -#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) +#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 11<<8 | 0)) mPixelBuffer.reset(); #else mPixelBuffer.setNull(); @@ -565,7 +565,7 @@ vpAROgre::~vpAROgre(void) // Delete root bool hasNoMoreElements = false; -#if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) +#if (VISP_HAVE_OGRE_VERSION < (1<<16 | 11<<8 | 0)) if (Ogre::Root::getSingletonPtr()) { hasNoMoreElements = !Ogre::Root::getSingletonPtr()->getSceneManagerIterator().hasMoreElements(); } @@ -945,7 +945,7 @@ void vpAROgre::createBackground(vpImage & /* I */) Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false); // Background Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false); // Background Backgroundmaterial->getTechnique(0)->getPass(0)->createTextureUnitState("BackgroundTexture"); -#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) +#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 11<<8 | 0)) mBackground->setMaterial(Backgroundmaterial); // Attach the material to the rectangle #else mBackground->setMaterial("BackgroundMaterial"); // Attach the material to the rectangle @@ -1024,7 +1024,7 @@ void vpAROgre::createBackground(vpImage & /* I */) Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false); // Background Backgroundmaterial->getTechnique(0)->getPass(0)->createTextureUnitState("BackgroundTexture"); -#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10<<8 | 0)) +#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 11<<8 | 0)) mBackground->setMaterial(Backgroundmaterial); // Attach the material to the rectangle #else mBackground->setMaterial("BackgroundMaterial"); // Attach the material to the rectangle From 52745ec26ae39e26135cc281c3f9cbaefedcc44b Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Thu, 19 Dec 2024 08:29:32 +0100 Subject: [PATCH 24/38] [FIX] Avoid creating Ogre targets if they already exist --- modules/ar/CMakeLists.txt | 42 ++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/modules/ar/CMakeLists.txt b/modules/ar/CMakeLists.txt index 0cf5f20785..a13d61c238 100644 --- a/modules/ar/CMakeLists.txt +++ b/modules/ar/CMakeLists.txt @@ -50,7 +50,12 @@ if(USE_OGRE) if(${OGRE_VERSION_MAJOR} EQUAL 1 AND (${OGRE_VERSION_MINOR} EQUAL 10 OR ${OGRE_VERSION_MINOR} EQUAL 11)) find_package(Boost REQUIRED COMPONENTS thread) - find_library(OgreMainSEARCH NAMES OgreMain PATHS ${OGRE_LIBRARY_DIRS}) + link_directories(${OGRE_LIBRARY_DIRS}) + if(NOT(TARGET OgreMain)) + find_library(OgreMainSEARCH NAMES OgreMain PATHS ${OGRE_LIBRARY_DIRS}) + add_library(OgreMain SHARED IMPORTED) + set_property(TARGET OgreMain PROPERTY IMPORTED_LOCATION ${OgreMainSEARCH}) + endif() endif() if(NOT(${OGRE_VERSION_MAJOR} EQUAL 1 AND ${OGRE_VERSION_MINOR} LESS_EQUAL 9)) @@ -64,8 +69,16 @@ if(USE_OGRE) endif() endif() if(${OGRE_VERSION_MAJOR} EQUAL 1 AND (${OGRE_VERSION_MINOR} EQUAL 10 OR ${OGRE_VERSION_MINOR} EQUAL 11)) - message("Looking for library ${ogre_libray} in folder ${OGRE_LIBRARY_DIRS}") - find_library(${ogre_libray}SEARCH NAMES ${ogre_libray} PATHS ${OGRE_LIBRARY_DIRS}) + unset(MATCHED) + string(REGEX MATCH ".*O[gG][rR][eE].*" MATCHED ${ogre_libray}) + if (NOT MATCHED) + continue() + endif() + if(NOT(TARGET ${ogre_libray})) + find_library(${ogre_libray}SEARCH NAMES ${ogre_libray} PATHS ${OGRE_LIBRARY_DIRS}) + add_library(${ogre_libray} SHARED IMPORTED) + set_property(TARGET ${ogre_libray} PROPERTY IMPORTED_LOCATION ${${ogre_libray}SEARCH}) + endif() endif() endforeach() endforeach() @@ -94,18 +107,10 @@ if(USE_OGRE) endif() endforeach() else() - foreach(lib_ ${OGRE_LIBRARIES}) - if(${lib_} MATCHES "^Ogre") - list(APPEND opt_libs ${${lib_}SEARCH}) - else() - list(APPEND opt_libs ${lib_}) - endif() - endforeach() + list(APPEND opt_libs ${OGRE_LIBRARIES}) endif() endif(USE_OGRE) -message("opt_libs = ${opt_libs}") - if(USE_OIS AND USE_OGRE) list(APPEND opt_system_incs ${OIS_INCLUDE_DIR}) list(APPEND opt_libs ${OIS_LIBRARIES}) @@ -226,16 +231,3 @@ vp_glob_module_sources() vp_module_include_directories(${opt_incs} SYSTEM ${opt_system_incs}) vp_create_module(${opt_libs}) - -get_cmake_property(_variableNames VARIABLES) -list (SORT _variableNames) -foreach (_variableName ${_variableNames}) - unset(MATCHED) - string(REGEX MATCH ".*O[gG][rR][eE].*" MATCHED ${_variableName}) - if (NOT MATCHED) - continue() - endif() - message(STATUS "${_variableName}=${${_variableName}}") -endforeach() - -# message(FATAL_ERROR "Stopping after AR module") From bf95f77493129f583b3f9719ce3f565a752281ba Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Thu, 19 Dec 2024 08:57:43 +0100 Subject: [PATCH 25/38] [CLEAN] Solved a warning when using ogre 1.9.1 from apt --- modules/ar/src/ogre-simulator/vpAROgre.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index ff6cd10536..6b1c9a68db 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -389,11 +389,13 @@ void vpAROgre::init(bool } mWindow = mRoot->createRenderWindow(name, mWindowWidth, mWindowHeight, fullscreen, &misc); +#if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10 <<8 | 0)) // Initialize the RTShaderSystem, if available bool hasInitializedTheRTSS = initialiseRTShaderSystem(); if (!hasInitializedTheRTSS) { std::cout << "[vpAROgre::init] RTSS is not available." << std::endl; } +#endif // Load resource paths from config file From 213589e492556210b6380f4a0e8f0be18a560a26 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Thu, 19 Dec 2024 10:55:15 +0100 Subject: [PATCH 26/38] [CORE] Added CMakes lines that might be useful for compiled versions of Ogre --- modules/ar/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/ar/CMakeLists.txt b/modules/ar/CMakeLists.txt index a13d61c238..f9223451ea 100644 --- a/modules/ar/CMakeLists.txt +++ b/modules/ar/CMakeLists.txt @@ -67,6 +67,11 @@ if(USE_OGRE) if(inc_dirs) list(APPEND opt_system_incs ${inc_dirs}) endif() + ## The following lines are not needed for Ogre 1.9 and 1.12, but might be useful for compiled versions of Ogre + # get_target_property(interface_libs ${ogre_libray} INTERFACE_LINK_LIBRARIES) + # if(interface_libs) + # list(APPEND opt_libs ${interface_libs}) + # endif() endif() if(${OGRE_VERSION_MAJOR} EQUAL 1 AND (${OGRE_VERSION_MINOR} EQUAL 10 OR ${OGRE_VERSION_MINOR} EQUAL 11)) unset(MATCHED) From 1fdc37b7ad51571d2a1d8b349b9a9033b2489e96 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Thu, 19 Dec 2024 11:08:17 +0100 Subject: [PATCH 27/38] [CLEAN] Removed commented CMake lines --- cmake/OgreTools.cmake | 150 +++++++++++++++++++----------------------- 1 file changed, 69 insertions(+), 81 deletions(-) diff --git a/cmake/OgreTools.cmake b/cmake/OgreTools.cmake index fefc0374c8..9a240e9d9d 100644 --- a/cmake/OgreTools.cmake +++ b/cmake/OgreTools.cmake @@ -275,105 +275,93 @@ function(vp_set_ogre_media) # Here we copy all the minimal media files # - media/materials/... # - media/models/... - # if(OGRE_MEDIA_NOT_AVAILABLE) - file(COPY modules/ar/data/ogre-simulator/media DESTINATION ${VISP_BINARY_DIR}/data/ogre-simulator) - # endif() + file(COPY modules/ar/data/ogre-simulator/media DESTINATION ${VISP_BINARY_DIR}/data/ogre-simulator) # Initialize the variable set(VISP_HAVE_OGRE_RESOURCES_PATH "" CACHE INTERNAL "Ogre resources location") if(ogre_resources_cfg_exists) set(VISP_HAVE_OGRE_RESOURCES_PATH "${ogre_resources_cfg_exists};" CACHE INTERNAL "Ogre resources location") endif() - # else() - # Here we create a resources.cfg if it was not found - - # we create a resources.cfg file for vpAROgre.cpp - # case 1: normal case - # If OGRE_MEDIA_DIR is not found, we set it to VISP_HAVE_OGRE_RESOURCES_PATH in order to use - # the minimal requested media to run the examples - #-------------- - set(OGRE_DATA_ROOT_DIR "${VISP_BINARY_DIR}/data/ogre-simulator") - set(VISP_HAVE_OGRE_RESOURCES_PATH "${VISP_HAVE_OGRE_RESOURCES_PATH}${OGRE_DATA_ROOT_DIR}" CACHE INTERNAL "Ogre resources location") - - # if(OGRE_MEDIA_NOT_AVAILABLE) - set(OGRE_VISP_MEDIA_DIR "${VISP_BINARY_DIR}/data/ogre-simulator/media") - # endif() - - # Here we add all the subdirs in @OGRE_VISP_MEDIA_DIR@/* as resource location. - vp_get_relative_subdirs(media_subdirs ${OGRE_VISP_MEDIA_DIR}) - set(OGRE_RESOURCES_FileSystem "FileSystem=${OGRE_VISP_MEDIA_DIR}\n") - foreach(m ${media_subdirs}) - set(OGRE_RESOURCES_FileSystem "${OGRE_RESOURCES_FileSystem}FileSystem=${OGRE_VISP_MEDIA_DIR}/${m}\n") - endforeach() + # Here we create a resources.cfg if it was not found + + # we create a resources.cfg file for vpAROgre.cpp + # case 1: normal case + # If OGRE_MEDIA_DIR is not found, we set it to VISP_HAVE_OGRE_RESOURCES_PATH in order to use + # the minimal requested media to run the examples + #-------------- + set(OGRE_DATA_ROOT_DIR "${VISP_BINARY_DIR}/data/ogre-simulator") + set(VISP_HAVE_OGRE_RESOURCES_PATH "${VISP_HAVE_OGRE_RESOURCES_PATH}${OGRE_DATA_ROOT_DIR}" CACHE INTERNAL "Ogre resources location") + + set(OGRE_VISP_MEDIA_DIR "${VISP_BINARY_DIR}/data/ogre-simulator/media") + + # Here we add all the subdirs in @OGRE_VISP_MEDIA_DIR@/* as resource location. + vp_get_relative_subdirs(media_subdirs ${OGRE_VISP_MEDIA_DIR}) + set(OGRE_RESOURCES_FileSystem "FileSystem=${OGRE_VISP_MEDIA_DIR}\n") + foreach(m ${media_subdirs}) + set(OGRE_RESOURCES_FileSystem "${OGRE_RESOURCES_FileSystem}FileSystem=${OGRE_VISP_MEDIA_DIR}/${m}\n") + endforeach() - configure_file( - ${VISP_SOURCE_DIR}/cmake/templates/resources.cfg.in - ${OGRE_DATA_ROOT_DIR}/resources.cfg - IMMEDIATE @ONLY - ) + configure_file( + ${VISP_SOURCE_DIR}/cmake/templates/resources.cfg.in + ${OGRE_DATA_ROOT_DIR}/resources.cfg + IMMEDIATE @ONLY + ) - # case 2: install or packaging case - # If OGRE_MEDIA_DIR is not found, we set it to VISP_INSTALL_DIR_OGRE_RESOURCES in order to use - # the minimal requested media to run the examples - #-------------- - set(VISP_INSTALL_DIR_OGRE_RESOURCES "${CMAKE_INSTALL_PREFIX}/${VISP_INSTALL_DATAROOTDIR}/data/ogre-simulator") + # case 2: install or packaging case + # If OGRE_MEDIA_DIR is not found, we set it to VISP_INSTALL_DIR_OGRE_RESOURCES in order to use + # the minimal requested media to run the examples + #-------------- + set(VISP_INSTALL_DIR_OGRE_RESOURCES "${CMAKE_INSTALL_PREFIX}/${VISP_INSTALL_DATAROOTDIR}/data/ogre-simulator") - # make the var global - set(VISP_INSTALL_DIR_OGRE_RESOURCES ${VISP_INSTALL_DIR_OGRE_RESOURCES} CACHE INTERNAL "Ogre media install dir") + # make the var global + set(VISP_INSTALL_DIR_OGRE_RESOURCES ${VISP_INSTALL_DIR_OGRE_RESOURCES} CACHE INTERNAL "Ogre media install dir") - # if(OGRE_MEDIA_NOT_AVAILABLE) - set(OGRE_VISP_INSTALL_MEDIA_DIR ${VISP_INSTALL_DIR_OGRE_RESOURCES}/media) - # endif() + set(OGRE_VISP_INSTALL_MEDIA_DIR ${VISP_INSTALL_DIR_OGRE_RESOURCES}/media) - # Here we add all the subdirs in @OGRE_VISP_INSTALL_MEDIA_DIR@/* as resource location. - set(OGRE_RESOURCES_FileSystem "FileSystem=${OGRE_VISP_INSTALL_MEDIA_DIR}\n") - foreach(m ${media_subdirs}) - set(OGRE_RESOURCES_FileSystem "${OGRE_RESOURCES_FileSystem}FileSystem=${OGRE_VISP_INSTALL_MEDIA_DIR}/${m}\n") - endforeach() + # Here we add all the subdirs in @OGRE_VISP_INSTALL_MEDIA_DIR@/* as resource location. + set(OGRE_RESOURCES_FileSystem "FileSystem=${OGRE_VISP_INSTALL_MEDIA_DIR}\n") + foreach(m ${media_subdirs}) + set(OGRE_RESOURCES_FileSystem "${OGRE_RESOURCES_FileSystem}FileSystem=${OGRE_VISP_INSTALL_MEDIA_DIR}/${m}\n") + endforeach() - # install rule for resources.cfg and Ogre media if they are not available: - if(UNIX) - configure_file( - ${VISP_SOURCE_DIR}/cmake/templates/resources.cfg.in - ${VISP_BINARY_DIR}/unix-install/resources.cfg - IMMEDIATE @ONLY - ) - install(FILES - ${VISP_BINARY_DIR}/unix-install/resources.cfg + # install rule for resources.cfg and Ogre media if they are not available: + if(UNIX) + configure_file( + ${VISP_SOURCE_DIR}/cmake/templates/resources.cfg.in + ${VISP_BINARY_DIR}/unix-install/resources.cfg + IMMEDIATE @ONLY + ) + install(FILES + ${VISP_BINARY_DIR}/unix-install/resources.cfg + DESTINATION ${VISP_INSTALL_DATAROOTDIR}/data/ogre-simulator + PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE + COMPONENT dev + ) + install(DIRECTORY + ${VISP_BINARY_DIR}/data/ogre-simulator/media DESTINATION ${VISP_INSTALL_DATAROOTDIR}/data/ogre-simulator - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE + FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE COMPONENT dev ) - # if(OGRE_MEDIA_NOT_AVAILABLE) - install(DIRECTORY - ${VISP_BINARY_DIR}/data/ogre-simulator/media - DESTINATION ${VISP_INSTALL_DATAROOTDIR}/data/ogre-simulator - FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE - COMPONENT dev - ) - # endif() - else() - configure_file( - ${VISP_SOURCE_DIR}/cmake/templates/resources.cfg.in - ${VISP_BINARY_DIR}/win-install/resources.cfg - IMMEDIATE @ONLY - ) - install(FILES - ${VISP_BINARY_DIR}/win-install/resources.cfg + else() + configure_file( + ${VISP_SOURCE_DIR}/cmake/templates/resources.cfg.in + ${VISP_BINARY_DIR}/win-install/resources.cfg + IMMEDIATE @ONLY + ) + install(FILES + ${VISP_BINARY_DIR}/win-install/resources.cfg + DESTINATION ${VISP_INSTALL_DATAROOTDIR}/data/ogre-simulator + PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE + COMPONENT dev + ) + install(DIRECTORY + ${VISP_BINARY_DIR}/data/ogre-simulator/media DESTINATION ${VISP_INSTALL_DATAROOTDIR}/data/ogre-simulator - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE + FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE COMPONENT dev ) - # if(OGRE_MEDIA_NOT_AVAILABLE) - install(DIRECTORY - ${VISP_BINARY_DIR}/data/ogre-simulator/media - DESTINATION ${VISP_INSTALL_DATAROOTDIR}/data/ogre-simulator - FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE - COMPONENT dev - ) - # endif() - endif() - # endif() + endif() endfunction() macro(vp_set_ogre_advanced_var) From 4f3e5925738b2911c559b1497933d579c9ceba35 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Thu, 19 Dec 2024 11:32:46 +0100 Subject: [PATCH 28/38] [CORE] Made vpAROgre compatible with Ogre 13.1.0 --- modules/ar/src/ogre-simulator/vpAROgre.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index 6b1c9a68db..dd6bab9379 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -101,7 +101,7 @@ bool vpAROgre::initialiseRTShaderSystem() if (Ogre::RTShader::ShaderGenerator::initialize()) { mShaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr(); - // Create and register the material manager listener if it doesn't exist yet. +// Create and register the material manager listener if it doesn't exist yet. if (!mMaterialMgrListener) { mMaterialMgrListener = new OgreBites::SGTechniqueResolverListener(mShaderGenerator); Ogre::MaterialManager::getSingleton().addListener(mMaterialMgrListener); @@ -182,6 +182,12 @@ void vpAROgre::init(vpImage &I, false, #endif hidden); + +#if (VISP_HAVE_OGRE_VERSION >= (13 <<16 | 0 <<8 | 0)) +// Register the scene manager. + Ogre::RTShader::ShaderGenerator::getSingleton().addSceneManager(Ogre::Root::getSingletonPtr()->getSceneManager("SceneManagerInstance0")); +#endif + // Create the background image which will come from the grabber createBackground(I); } @@ -232,6 +238,12 @@ void vpAROgre::init(vpImage &I, false, #endif hidden); + +#if (VISP_HAVE_OGRE_VERSION >= (13 <<16 | 0 <<8 | 0)) +// Register the scene manager. + Ogre::RTShader::ShaderGenerator::getSingleton().addSceneManager(Ogre::Root::getSingletonPtr()->getSceneManager("SceneManagerInstance0")); +#endif + // Create the background image which will come from the grabber createBackground(I); } @@ -342,7 +354,7 @@ void vpAROgre::init(bool #if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); #else - mSceneMgr = mRoot->createSceneManager(Ogre::DefaultSceneManagerFactory::FACTORY_TYPE_NAME, Ogre::BLANKSTRING); + mSceneMgr = mRoot->createSceneManager(Ogre::DefaultSceneManagerFactory::FACTORY_TYPE_NAME, "SceneManagerInstance0"); #endif bool fullscreen = false; From d1a074985a71e5026cbdcd7fc2a8b52acdf4f286 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Mon, 6 Jan 2025 07:55:23 +0100 Subject: [PATCH 29/38] Cleanup Ogre location feedback in ViSP-third-party.txt --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd0e6df1b0..5570b1b7c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1932,7 +1932,9 @@ if(USE_OGRE) if(NOT ${OGRE_DIR} STREQUAL "") status(" Ogre dir:" "${OGRE_DIR}") else() - status(" Ogre dir:" "includes in ${OGRE_INCLUDE_DIR} , core lib in ${OGRE_LIBRARY_REL} , other libs in ${OGRE_PLUGIN_DIR_REL}") + status(" Ogre inc dir:" "${OGRE_INCLUDE_DIR}") + status(" Ogre Main lib:" "${OGRE_LIBRARY_REL}") + status(" Ogre plugin dir:" "${OGRE_PLUGIN_DIR_REL}") endif() endif() From b35385512ae80797832d17b4b02816f1b008040e Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Mon, 6 Jan 2025 10:41:42 +0100 Subject: [PATCH 30/38] [FIX] Fix tutorial-ibvs-ogre-tracking when using Ogre 14.0 --- modules/ar/include/visp3/ar/vpAROgre.h | 2 + modules/ar/src/ogre-simulator/vpAROgre.cpp | 16 +++++++- .../visual-servo/ibvs/sphere/Sphere.material | 41 +++++-------------- .../ibvs/tutorial-ibvs-4pts-ogre-tracking.cpp | 5 ++- 4 files changed, 31 insertions(+), 33 deletions(-) diff --git a/modules/ar/include/visp3/ar/vpAROgre.h b/modules/ar/include/visp3/ar/vpAROgre.h index f328932bc9..24b19e3edd 100644 --- a/modules/ar/include/visp3/ar/vpAROgre.h +++ b/modules/ar/include/visp3/ar/vpAROgre.h @@ -217,6 +217,8 @@ class VISP_EXPORT vpAROgre : public Ogre::FrameListener, updateCameraProjection(); } + void setMaterial(const std::string &entityName, const std::string &materialName); + /*! Set the near distance for clipping. diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index dd6bab9379..3a93997812 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -353,8 +353,10 @@ void vpAROgre::init(bool #if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); -#else +#elif (VISP_HAVE_OGRE_VERSION < (14<<16 | 0<<8 | 0)) mSceneMgr = mRoot->createSceneManager(Ogre::DefaultSceneManagerFactory::FACTORY_TYPE_NAME, "SceneManagerInstance0"); +#else + mSceneMgr = mRoot->createSceneManager(Ogre::SMT_DEFAULT, "SceneManagerInstance0"); #endif bool fullscreen = false; @@ -792,6 +794,18 @@ void vpAROgre::load(const std::string &entityName, const std::string &model) newNode->attachObject(newEntity); } +/*! + Change the material of an entity. + \param entityName : Name of the Entity and SceneNode to create. + \param materialName : Name of the material to use, as known by the MaterialManager. +*/ +void vpAROgre::setMaterial(const std::string &entityName, const std::string &materialName) +{ + // Reset the position + Ogre::Entity *entity = mSceneMgr->getEntity(entityName); + entity->setMaterialName(materialName); +} + /*! Change position of a ScneneNode. \param sceneName : Name of the SceneNode to move. diff --git a/tutorial/visual-servo/ibvs/sphere/Sphere.material b/tutorial/visual-servo/ibvs/sphere/Sphere.material index 7d7b3e79d4..6fbae096ef 100644 --- a/tutorial/visual-servo/ibvs/sphere/Sphere.material +++ b/tutorial/visual-servo/ibvs/sphere/Sphere.material @@ -1,35 +1,16 @@ // Sphere genrated by blender2ogre 0.5.9 -material Sphere +material UniformBlue { - receive_shadows on + technique + { + pass + { + lighting on - technique - { - pass Sphere - { - ambient 0.800000011920929 0.05124254152178764 0.020676089450716972 1.0 - diffuse 0.6400000190734865 0.04099403382828881 0.01654087180705177 1.0 - specular 0.24183237552642822 0.5 0.13772326707839966 1.0 12.5 - emissive 0.0 0.0 0.0 1.0 - - alpha_to_coverage off - colour_write on - cull_hardware clockwise - depth_check on - depth_func less_equal - depth_write on - illumination_stage - light_clip_planes off - light_scissor off - lighting on - normalise_normals off - polygon_mode solid - scene_blend one zero - scene_blend_op add - shading gouraud - transparent_sorting on - - } - } + ambient 0.3 0.3 0.3 1 + diffuse 0 0 1 1 + emissive 0 0 0 1 + } + } } diff --git a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre-tracking.cpp b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre-tracking.cpp index c14ef5f598..bbdc2bc587 100644 --- a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre-tracking.cpp +++ b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-ogre-tracking.cpp @@ -92,6 +92,7 @@ int main() s << "Sphere" << i; name[i] = s.str(); ogre.load(name[i], "Sphere.mesh"); + ogre.setMaterial(name[i], "UniformBlue"); ogre.setScale(name[i], 0.02f, 0.02f, 0.02f); // Rescale the sphere to 2 cm radius // Set the position of each sphere in the object frame @@ -101,8 +102,8 @@ int main() // Add an optional point light source Ogre::Light *light = ogre.getSceneManager()->createLight(); - light->setDiffuseColour(1, 1, 1); // scaled RGB values - light->setSpecularColour(1, 1, 1); // scaled RGB values + light->setDiffuseColour(1., 1., 1.); // scaled RGB values + light->setSpecularColour(1., 1., 1.); // scaled RGB values light->setType(Ogre::Light::LT_POINT); #if (VISP_HAVE_OGRE_VERSION < (1 << 16 | 10 << 8 | 0)) light->setPosition((Ogre::Real)cdMo[0][3], (Ogre::Real)cdMo[1][3], (Ogre::Real)(-cdMo[2][3])); From 5b8c7d7e34f7f2e0bed3654e11d9de4faf2cb1aa Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 7 Jan 2025 08:15:41 +0100 Subject: [PATCH 31/38] [CORE] Replaced hard-coded scene manager name by a 'computed' one --- modules/ar/include/visp3/ar/vpAROgre.h | 2 ++ modules/ar/src/ogre-simulator/vpAROgre.cpp | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/modules/ar/include/visp3/ar/vpAROgre.h b/modules/ar/include/visp3/ar/vpAROgre.h index 24b19e3edd..b26832054a 100644 --- a/modules/ar/include/visp3/ar/vpAROgre.h +++ b/modules/ar/include/visp3/ar/vpAROgre.h @@ -371,12 +371,14 @@ class VISP_EXPORT vpAROgre : public Ogre::FrameListener, void destroyRTShaderSystem(); protected: + static unsigned int sID; // Attributes Ogre::String name; /**Name of th Window*/ // OGRE 3D System Ogre::Root *mRoot; /** Application's root */ Ogre::Camera *mCamera; /** Camera */ + Ogre::String mSceneManagerName; /**Name of th scene manager*/ Ogre::SceneManager *mSceneMgr; /** Scene manager */ Ogre::RenderWindow *mWindow; /** Display window */ Ogre::String mResourcePath; /** Path to resources.cfg */ diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index 3a93997812..10820f3363 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -59,6 +59,8 @@ typedef Ogre::WindowEventUtilities OgreWindowEventUtilities; #endif BEGIN_VISP_NAMESPACE +unsigned int vpAROgre::sID = 0; + /*! Constructor. @@ -86,6 +88,10 @@ vpAROgre::vpAROgre(const vpCameraParameters &cam, unsigned int width, unsigned i mWindowHeight(height), mWindowWidth(width), windowHidden(false), mNearClipping(0.001), mFarClipping(200), mcam(cam), mshowConfigDialog(true), mOptionalResourceLocation() { + std::stringstream nameSceneManager; + nameSceneManager << "SceneManagerInstance" << sID; + mSceneManagerName = nameSceneManager.str(); + ++sID; #if defined(OGRE_BUILD_COMPONENT_RTSHADERSYSTEM) & (VISP_HAVE_OGRE_VERSION >= (1<<16 | 10 <<8 | 0)) mMaterialMgrListener = NULL; mShaderGenerator = NULL; @@ -185,7 +191,7 @@ void vpAROgre::init(vpImage &I, #if (VISP_HAVE_OGRE_VERSION >= (13 <<16 | 0 <<8 | 0)) // Register the scene manager. - Ogre::RTShader::ShaderGenerator::getSingleton().addSceneManager(Ogre::Root::getSingletonPtr()->getSceneManager("SceneManagerInstance0")); + Ogre::RTShader::ShaderGenerator::getSingleton().addSceneManager(Ogre::Root::getSingletonPtr()->getSceneManager(mSceneManagerName)); #endif // Create the background image which will come from the grabber @@ -241,7 +247,7 @@ void vpAROgre::init(vpImage &I, #if (VISP_HAVE_OGRE_VERSION >= (13 <<16 | 0 <<8 | 0)) // Register the scene manager. - Ogre::RTShader::ShaderGenerator::getSingleton().addSceneManager(Ogre::Root::getSingletonPtr()->getSceneManager("SceneManagerInstance0")); + Ogre::RTShader::ShaderGenerator::getSingleton().addSceneManager(Ogre::Root::getSingletonPtr()->getSceneManager(mSceneManagerName)); #endif // Create the background image which will come from the grabber @@ -354,9 +360,9 @@ void vpAROgre::init(bool #if (VISP_HAVE_OGRE_VERSION < (1<<16 | 10<<8 | 0)) mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); #elif (VISP_HAVE_OGRE_VERSION < (14<<16 | 0<<8 | 0)) - mSceneMgr = mRoot->createSceneManager(Ogre::DefaultSceneManagerFactory::FACTORY_TYPE_NAME, "SceneManagerInstance0"); + mSceneMgr = mRoot->createSceneManager(Ogre::DefaultSceneManagerFactory::FACTORY_TYPE_NAME, mSceneManagerName); #else - mSceneMgr = mRoot->createSceneManager(Ogre::SMT_DEFAULT, "SceneManagerInstance0"); + mSceneMgr = mRoot->createSceneManager(Ogre::SMT_DEFAULT, mSceneManagerName); #endif bool fullscreen = false; @@ -545,13 +551,8 @@ void vpAROgre::init(bool "rtf", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, mWindow->getWidth(), mWindow->getHeight(), 0, Ogre::PF_R8G8B8A8, Ogre::TU_RENDERTARGET); - // Ogre::TexturePtr Texture = - // Ogre::TextureManager::getSingleton().createManual("rtf", - // Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,Ogre::TEX_TYPE_2D, - // 640,480, 0, Ogre::PF_R8G8B8A8, - // Ogre::TU_RENDERTARGET); Ogre::RenderTexture *RTarget = Texture->getBuffer()->getRenderTarget(); - /*Ogre::Viewport* Viewport =*/RTarget->addViewport(mCamera); + RTarget->addViewport(mCamera); RTarget->getViewport(0)->setClearEveryFrame(true); RTarget->getViewport(0)->setOverlaysEnabled(false); } From b34b11309aef30ff361c41ff2c0408a73a33c819 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 7 Jan 2025 08:38:32 +0100 Subject: [PATCH 32/38] [CORE] Added AROgreBasic to the unit tests list --- example/ogre-simulator/AROgreBasic.cpp | 72 ++++++++++++++++++-------- example/ogre-simulator/CMakeLists.txt | 2 + 2 files changed, 51 insertions(+), 23 deletions(-) diff --git a/example/ogre-simulator/AROgreBasic.cpp b/example/ogre-simulator/AROgreBasic.cpp index 637660775e..426cef60b2 100644 --- a/example/ogre-simulator/AROgreBasic.cpp +++ b/example/ogre-simulator/AROgreBasic.cpp @@ -73,7 +73,7 @@ #include // List of allowed command line options -#define GETOPTARGS "ci:p:h" +#define GETOPTARGS "cdi:p:h" #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; @@ -125,6 +125,9 @@ OPTIONS: Default\n\ -c\n\ Disable the mouse click. Useful to automate the \n\ execution of this program without human intervention.\n\ +\n\ + -d\n\ + Disable the display.\n\ \n\ -h\n\ Print the help.\n", @@ -142,11 +145,12 @@ OPTIONS: Default\n\ \param ipath : Input image path. \param ppath : Personal image path. \param click_allowed : Mouse click activation. + \param use_display : Activate the display. \return false if the program has to be stopped, true otherwise. */ -bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, bool &click_allowed) +bool getOptions(int argc, const char **argv, std::string &ipath, std::string &ppath, bool &click_allowed, bool &use_display) { const char *optarg_; int c; @@ -156,6 +160,9 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &pp case 'c': click_allowed = false; break; + case 'd': + use_display = false; + break; case 'i': ipath = optarg_; break; @@ -192,29 +199,32 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &pp world */ void computeInitialPose(vpCameraParameters *mcam, vpImage &I, vpPose *mPose, vpDot2 *md, - vpImagePoint *mcog, vpHomogeneousMatrix *cMo, vpPoint *mP, const bool &opt_click_allowed) + vpImagePoint *mcog, vpHomogeneousMatrix *cMo, vpPoint *mP, const bool &opt_click_allowed, bool opt_display) { // --------------------------------------------------- // Code inspired from ViSP example of camera pose // ---------------------------------------------------- - bool opt_display = true; - - //#if defined(VISP_HAVE_X11) && ! defined(APPLE) + vpDisplay *display = nullptr; + if (opt_display) { #if defined(VISP_HAVE_X11) && !(defined(__APPLE__) && defined(__MACH__)) - // produce an error on OSX: ‘typedef int Cursor’ - // /usr/X11R6/include/X11/X.h:108: error: ‘Cursor’ has a previous - // declaration as ‘typedef XID Cursor’. That's why it should not be - // used on APPLE platforms - vpDisplayX display; + // produce an error on OSX: ‘typedef int Cursor’ + // /usr/X11R6/include/X11/X.h:108: error: ‘Cursor’ has a previous + // declaration as ‘typedef XID Cursor’. That's why it should not be + // used on APPLE platforms + display = new vpDisplayX(); #elif defined(VISP_HAVE_GTK) - vpDisplayGTK display; + display = new vpDisplayGTK(); #elif defined(VISP_HAVE_GDI) - vpDisplayGDI display; + display = new vpDisplayGDI(); #elif defined(HAVE_OPENCV_HIGHGUI) - vpDisplayOpenCV display; + display = new vpDisplayOpenCV(); #elif defined(VISP_HAVE_D3D9) - vpDisplayD3D display; + display = new vpDisplayD3D(); +#else + opt_display = false; // No display is available #endif + } + //#if defined(VISP_HAVE_X11) && ! defined(APPLE) for (unsigned int i = 0; i < 4; i++) { if (opt_display) { @@ -228,7 +238,7 @@ void computeInitialPose(vpCameraParameters *mcam, vpImage &I, vpP if (opt_display) { try { // Display size is automatically defined by the image (I) size - display.init(I, 100, 100, "Preliminary Pose Calculation"); + display->init(I, 100, 100, "Preliminary Pose Calculation"); // display the image // The image class has a member that specify a pointer toward // the display that has been initialized in the display declaration @@ -288,9 +298,11 @@ void computeInitialPose(vpCameraParameters *mcam, vpImage &I, vpP md[j].display(I); // flush the display buffer - vpDisplay::flush(I); + if (opt_display) { + vpDisplay::flush(I); + } try { - if (opt_click_allowed) { + if (opt_click_allowed && opt_display) { md[i].initTracking(I); // std::cout << "click " << i << " " << md[i] << std::endl; } @@ -392,6 +404,10 @@ void computeInitialPose(vpCameraParameters *mcam, vpImage &I, vpP vpDisplay::flush(I); vpTime::wait(1000); } + + if (opt_display && display != nullptr) { + delete display; + } } int main(int argc, const char **argv) @@ -409,6 +425,7 @@ int main(int argc, const char **argv) std::string dirname; std::string filename; bool opt_click_allowed = true; + bool opt_display = true; // Get the visp-images-data package path or VISP_INPUT_IMAGE_PATH // environment variable value @@ -419,7 +436,7 @@ int main(int argc, const char **argv) ipath = env_ipath; // Read the command line options - if (getOptions(argc, argv, opt_ipath, opt_ppath, opt_click_allowed) == false) { + if (getOptions(argc, argv, opt_ipath, opt_ppath, opt_click_allowed, opt_display) == false) { return EXIT_FAILURE; } @@ -452,6 +469,12 @@ int main(int argc, const char **argv) return EXIT_FAILURE; } + if (!opt_display && opt_click_allowed) { + std::cerr << std::endl << "ERROR:" << std::endl; + std::cerr << " Display is disabled but clicks are required !" << std::endl; + return EXIT_FAILURE; + } + std::ostringstream s; if (opt_ppath.empty()) { @@ -499,7 +522,7 @@ int main(int argc, const char **argv) grabber.acquire(Idisplay); vpCameraParameters mcamTmp(592, 570, grabber.getWidth() / 2, grabber.getHeight() / 2); // Compute the initial pose of the camera - computeInitialPose(&mcamTmp, Idisplay, &mPose, md, mcog, &cMo, mP, opt_click_allowed); + computeInitialPose(&mcamTmp, Idisplay, &mPose, md, mcog, &cMo, mP, opt_click_allowed, opt_display); // Close the framegrabber grabber.close(); @@ -518,7 +541,8 @@ int main(int argc, const char **argv) // Create a vpRAOgre object with color background vpAROgre ogre(mcam, grabber.getWidth(), grabber.getHeight()); // Initialize it - ogre.init(IC); + ogre.setShowConfigDialog(opt_display); + ogre.init(IC, false, !opt_display); ogre.load("Robot", "robot.mesh"); ogre.setScale("Robot", 0.001f, 0.001f, 0.001f); ogre.setRotation("Robot", vpRotationMatrix(vpRxyzVector(M_PI / 2, -M_PI / 2, 0))); @@ -571,9 +595,11 @@ int main(int argc, const char **argv) mPose.computePose(vpPose::VIRTUAL_VS, cMo); // Display with ogre - ogre.display(IC, cMo); + if (opt_display) { + ogre.display(IC, cMo); + } - // Wait so that the video does not go too fast +// Wait so that the video does not go too fast vpTime::wait(15); } // Close the grabber diff --git a/example/ogre-simulator/CMakeLists.txt b/example/ogre-simulator/CMakeLists.txt index 7209cc76d4..1a5f65c160 100644 --- a/example/ogre-simulator/CMakeLists.txt +++ b/example/ogre-simulator/CMakeLists.txt @@ -56,3 +56,5 @@ foreach(cpp ${example_cpp}) visp_add_dependency(${cpp} "examples") endif() endforeach() + +visp_add_test(AROgreBasic AROgreBasic ${OPTION_TO_DESACTIVE_DISPLAY} -c) From 84a6550745abe955b19659e16173cff7b9f014bb Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 7 Jan 2025 11:28:32 +0100 Subject: [PATCH 33/38] [TEST] Test AROgreBasic only if dataset is available --- example/ogre-simulator/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/example/ogre-simulator/CMakeLists.txt b/example/ogre-simulator/CMakeLists.txt index 1a5f65c160..8f327adbde 100644 --- a/example/ogre-simulator/CMakeLists.txt +++ b/example/ogre-simulator/CMakeLists.txt @@ -57,4 +57,8 @@ foreach(cpp ${example_cpp}) endif() endforeach() +# Add test only if dataset found for isolated build +visp_find_dataset(DATASET_FOUND) +if(DATASET_FOUND) visp_add_test(AROgreBasic AROgreBasic ${OPTION_TO_DESACTIVE_DISPLAY} -c) +endif() From 8a89f8686eea85797bb1f00d93a23c1cecaa4aa1 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 7 Jan 2025 11:31:40 +0100 Subject: [PATCH 34/38] [FIX] Fix multiple insertion of same resource and segfault when destroying uninitialized vpAROgre --- modules/ar/include/visp3/ar/vpAROgre.h | 3 +- modules/ar/src/ogre-simulator/vpAROgre.cpp | 125 +++++++++++++-------- 2 files changed, 78 insertions(+), 50 deletions(-) diff --git a/modules/ar/include/visp3/ar/vpAROgre.h b/modules/ar/include/visp3/ar/vpAROgre.h index b26832054a..4ff34b97b5 100644 --- a/modules/ar/include/visp3/ar/vpAROgre.h +++ b/modules/ar/include/visp3/ar/vpAROgre.h @@ -374,11 +374,12 @@ class VISP_EXPORT vpAROgre : public Ogre::FrameListener, static unsigned int sID; // Attributes Ogre::String name; /**Name of th Window*/ + bool mInitialized; /** True once init(bool, bool) has been called.*/ // OGRE 3D System Ogre::Root *mRoot; /** Application's root */ Ogre::Camera *mCamera; /** Camera */ - Ogre::String mSceneManagerName; /**Name of th scene manager*/ + Ogre::String mSceneManagerName; /**Name of the scene manager*/ Ogre::SceneManager *mSceneMgr; /** Scene manager */ Ogre::RenderWindow *mWindow; /** Display window */ Ogre::String mResourcePath; /** Path to resources.cfg */ diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index 10820f3363..17a84fb4fa 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -78,7 +78,7 @@ unsigned int vpAROgre::sID = 0; */ vpAROgre::vpAROgre(const vpCameraParameters &cam, unsigned int width, unsigned int height, const char *resourcePath, const char *pluginsPath) - : name("ViSP - Augmented Reality"), mRoot(0), mCamera(0), mSceneMgr(0), mWindow(0), mResourcePath(resourcePath), + : name("ViSP - Augmented Reality"), mInitialized(false), mRoot(0), mCamera(0), mSceneMgr(0), mWindow(0), mResourcePath(resourcePath), mPluginsPath(pluginsPath), #ifdef VISP_HAVE_OIS mInputManager(0), mKeyboard(0), @@ -547,14 +547,21 @@ void vpAROgre::init(bool #endif // Initialise a render to texture to be able to retrieve a screenshot - Ogre::TexturePtr Texture = Ogre::TextureManager::getSingleton().createManual( - "rtf", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, mWindow->getWidth(), - mWindow->getHeight(), 0, Ogre::PF_R8G8B8A8, Ogre::TU_RENDERTARGET); - - Ogre::RenderTexture *RTarget = Texture->getBuffer()->getRenderTarget(); - RTarget->addViewport(mCamera); - RTarget->getViewport(0)->setClearEveryFrame(true); - RTarget->getViewport(0)->setOverlaysEnabled(false); + try { + Ogre::TexturePtr Texture = Ogre::TextureManager::getSingleton().createManual( + "rtf", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, mWindow->getWidth(), + mWindow->getHeight(), 0, Ogre::PF_R8G8B8A8, Ogre::TU_RENDERTARGET); + + Ogre::RenderTexture *RTarget = Texture->getBuffer()->getRenderTarget(); + RTarget->addViewport(mCamera); + RTarget->getViewport(0)->setClearEveryFrame(true); + RTarget->getViewport(0)->setOverlaysEnabled(false); + } + catch (const Ogre::Exception &e) { + std::cout << "Info: Texture rtf is already known by the resource manager." << std::endl; + } + + mInitialized = true; } /*! @@ -562,6 +569,9 @@ void vpAROgre::init(bool */ vpAROgre::~vpAROgre(void) { + if (!mInitialized) { + return; + } #if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 11<<8 | 0)) mPixelBuffer.reset(); #else @@ -935,20 +945,30 @@ void vpAROgre::createBackground(vpImage & /* I */) // If we are using opengl we can boost a little bit performances with a // dynamic texture if (mRoot->getRenderSystem()->getName() == "OpenGL Rendering Subsystem") { - Ogre::TextureManager::getSingleton().createManual( + try { + Ogre::TextureManager::getSingleton().createManual( "BackgroundTexture", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, mBackgroundWidth, // width mBackgroundHeight, // height 0, // num of mip maps Ogre::PF_BYTE_L, Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE); + } + catch (const Ogre::Exception &e) { + std::cout << "Info: Texture BackgroundTexture is already known by the resource manager." << std::endl; + } } else { - Ogre::TextureManager::getSingleton().createManual( + try { + Ogre::TextureManager::getSingleton().createManual( "BackgroundTexture", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, mBackgroundWidth, // width mBackgroundHeight, // height 0, // num of mip maps Ogre::PF_BYTE_L, Ogre::TU_DEFAULT); + } + catch (const Ogre::Exception &e) { + std::cout << "Info: Texture BackgroundTexture is already known by the resource manager." << std::endl; + } } // Pointer to the dynamic texture @@ -961,25 +981,24 @@ void vpAROgre::createBackground(vpImage & /* I */) mPixelBuffer = dynTexPtr->getBuffer(); // Material to apply the texture to the background - Ogre::MaterialPtr Backgroundmaterial = Ogre::MaterialManager::getSingleton().create( + try { + Ogre::MaterialPtr Backgroundmaterial = Ogre::MaterialManager::getSingleton().create( "BackgroundMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); - //#if ( OGRE_VERSION >= (1 << 16 | 9 << 8 | 0) ) - // .dynamicCast(); - //#else - // ; - //#endif - Ogre::Technique *Backgroundtechnique = Backgroundmaterial->createTechnique(); - Backgroundtechnique->createPass(); - Backgroundmaterial->getTechnique(0)->getPass(0)->setLightingEnabled(false); - Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false); // Background - Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false); // Background - Backgroundmaterial->getTechnique(0)->getPass(0)->createTextureUnitState("BackgroundTexture"); + Ogre::Technique *Backgroundtechnique = Backgroundmaterial->createTechnique(); + Backgroundtechnique->createPass(); + Backgroundmaterial->getTechnique(0)->getPass(0)->setLightingEnabled(false); + Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false); // Background + Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false); // Background + Backgroundmaterial->getTechnique(0)->getPass(0)->createTextureUnitState("BackgroundTexture"); #if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 11<<8 | 0)) - mBackground->setMaterial(Backgroundmaterial); // Attach the material to the rectangle + mBackground->setMaterial(Backgroundmaterial); // Attach the material to the rectangle #else - mBackground->setMaterial("BackgroundMaterial"); // Attach the material to the rectangle + mBackground->setMaterial("BackgroundMaterial"); // Attach the material to the rectangle #endif - mBackground->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND); // To be rendered in Background + } + catch (const Ogre::Exception &e) { + std::cout << "Info: Material BackgroundMaterial is already known by the resource manager." << std::endl; + } // Add the background to the Scene Graph so it will be rendered Ogre::SceneNode *BackgroundNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("BackgoundNode"); @@ -1008,23 +1027,31 @@ void vpAROgre::createBackground(vpImage & /* I */) // If we are using opengl we can boost a little bit performances with a // dynamic texture if (mRoot->getRenderSystem()->getName() == "OpenGL Rendering Subsystem") { - Ogre::TextureManager::getSingleton().createManual( + try { + Ogre::TextureManager::getSingleton().createManual( "BackgroundTexture", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, mBackgroundWidth, // width mBackgroundHeight, // height 0, // num of mip maps - // Ogre::PF_BYTE_RGBA, Ogre::PF_BYTE_BGRA, Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE); + } + catch (const Ogre::Exception &e) { + std::cout << "Info: Texture BackgroundTexture is already known by the resource manager." << std::endl; + } } else { // As that texture does not seem to work properly with direct3D we // use a default texture - Ogre::TextureManager::getSingleton().createManual( - "BackgroundTexture", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, - mBackgroundWidth, // width - mBackgroundHeight, // height - 0, // num of mip maps - // Ogre::PF_BYTE_RGBA, - Ogre::PF_BYTE_BGRA, Ogre::TU_DEFAULT); + try { + Ogre::TextureManager::getSingleton().createManual( + "BackgroundTexture", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, + mBackgroundWidth, // width + mBackgroundHeight, // height + 0, // num of mip maps + Ogre::PF_BYTE_BGRA, Ogre::TU_DEFAULT); + } + catch (const Ogre::Exception &e) { + std::cout << "Info: Texture BackgroundTexture is already known by the resource manager." << std::endl; + } } // Pointer to the dynamic texture @@ -1039,25 +1066,25 @@ void vpAROgre::createBackground(vpImage & /* I */) mPixelBuffer = dynTexPtr->getBuffer(); // Material to apply the texture to the background - Ogre::MaterialPtr Backgroundmaterial = Ogre::MaterialManager::getSingleton().create( + try { + Ogre::MaterialPtr Backgroundmaterial = Ogre::MaterialManager::getSingleton().create( "BackgroundMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); - //#if ( OGRE_VERSION >= (1 << 16 | 9 << 8 | 0) ) - // .dynamicCast(); - //#else - // ; - //#endif - Ogre::Technique *Backgroundtechnique = Backgroundmaterial->createTechnique(); - Backgroundtechnique->createPass(); - Backgroundmaterial->getTechnique(0)->getPass(0)->setLightingEnabled(false); - Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false); // Background - Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false); // Background - Backgroundmaterial->getTechnique(0)->getPass(0)->createTextureUnitState("BackgroundTexture"); + Ogre::Technique *Backgroundtechnique = Backgroundmaterial->createTechnique(); + Backgroundtechnique->createPass(); + Backgroundmaterial->getTechnique(0)->getPass(0)->setLightingEnabled(false); + Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false); // Background + Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false); // Background + Backgroundmaterial->getTechnique(0)->getPass(0)->createTextureUnitState("BackgroundTexture"); #if (VISP_HAVE_OGRE_VERSION >= (1<<16 | 11<<8 | 0)) - mBackground->setMaterial(Backgroundmaterial); // Attach the material to the rectangle + mBackground->setMaterial(Backgroundmaterial); // Attach the material to the rectangle #else - mBackground->setMaterial("BackgroundMaterial"); // Attach the material to the rectangle + mBackground->setMaterial("BackgroundMaterial"); // Attach the material to the rectangle #endif + } + catch (const Ogre::Exception &e) { + std::cout << "Info: Material BackgroundMaterial is already known by the resource manager." << std::endl; + } mBackground->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND); // To be rendered in Background // Add the background to the Scene Graph so it will be rendered From be230d3e1ee9e9d37c49f973f0aecdc238e0e65e Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 7 Jan 2025 11:56:49 +0100 Subject: [PATCH 35/38] [TEST] Added github action to test ogre --- .github/workflows/ubuntu-ogre-apt.yml | 114 ++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 .github/workflows/ubuntu-ogre-apt.yml diff --git a/.github/workflows/ubuntu-ogre-apt.yml b/.github/workflows/ubuntu-ogre-apt.yml new file mode 100644 index 0000000000..26078f4cf7 --- /dev/null +++ b/.github/workflows/ubuntu-ogre-apt.yml @@ -0,0 +1,114 @@ +name: Ubuntu-dep-apt + +# https://www.jeffgeerling.com/blog/2020/running-github-actions-workflow-on-schedule-and-other-events +on: + pull_request: + types: [opened, reopened, synchronize] + schedule: + - cron: '0 2 * * SUN' + +# https://stackoverflow.com/questions/66335225/how-to-cancel-previous-runs-in-the-pr-when-you-push-new-commitsupdate-the-curre#comment133398800_72408109 +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency +concurrency: + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: true + +jobs: + build-ubuntu-dep-apt: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-22.04, ubuntu-latest] + compiler: [ {CC: /usr/bin/gcc-9, CXX: /usr/bin/g++-9}, {CC: /usr/bin/gcc-10, CXX: /usr/bin/g++-10}, {CC: /usr/bin/clang, CXX: /usr/bin/clang++} ] + standard: [ 11, 17 ] + ogre: [ogre-1.9, ogre-1.12] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Print system information + run: lscpu + + - name: Print OS information + run: lsb_release -a + + - name: Print compiler information + run: dpkg --list | grep compiler + + - name: Install dependencies for Ogre 1.9 + if: matrix.ogre == 'ogre-1.9' + run: sudo apt-get update && sudo apt-get install -y libx11-dev libdc1394-dev libv4l-dev liblapack-dev libopenblas-dev libeigen3-dev libopencv-dev nlohmann-json3-dev libogre-1.9-dev + + - name: Install dependencies for Ogre 1.12 + if: matrix.ogre == 'ogre-1.12' + run: sudo apt-get update && sudo apt-get install -y libx11-dev libdc1394-dev libv4l-dev liblapack-dev libopenblas-dev libeigen3-dev libopencv-dev nlohmann-json3-dev libogre-1.12-dev + + - name: Clone visp-images + env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + # https://remarkablemark.org/blog/2022/09/25/check-git-branch-exists-in-remote-repository/ + run: | + git clone --depth 1 https://github.com/lagadic/visp-images ${HOME}/visp-images + echo "VISP_INPUT_IMAGE_PATH=$HOME/visp-images" >> $GITHUB_ENV + echo ${VISP_INPUT_IMAGE_PATH} + + - name: Clone visp_sample + run: | + git clone --depth 1 https://github.com/lagadic/visp_sample ${HOME}/visp_sample + + - name: Configure CMake + run: | + mkdir build + cd build + CC=${{ matrix.compiler.CC }} + CXX=${{ matrix.compiler.CXX }} + CXX_STANDARD=${{ matrix.standard }} + echo "CC: $CC" + echo "CXX: $CXX" + echo "Standard: $CXX_STANDARD" + cmake .. -DCMAKE_C_COMPILER="${CC}" -DCMAKE_CXX_COMPILER="${CXX}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/usr/local -DCMAKE_VERBOSE_MAKEFILE=ON -DUSE_CXX_STANDARD=$CXX_STANDARD + cat ViSP-third-party.txt + + - name: Compile + working-directory: build + run: | + make -j$(nproc) install + + - name: Run unit tests + working-directory: build + run: ctest -j$(nproc) --output-on-failure + + - name: ViSP as 3rdparty with cmake + run: | + cd ${HOME}/visp_sample + mkdir visp_sample-build + cd visp_sample-build + CC=${{ matrix.compiler.CC }} + CXX=${{ matrix.compiler.CXX }} + cmake .. -DCMAKE_C_COMPILER="${CC}" -DCMAKE_CXX_COMPILER="${CXX}" -DVISP_DIR=/tmp/usr/local/lib/cmake/visp -DCMAKE_VERBOSE_MAKEFILE=ON + make -j$(nproc) + + - name: ViSP as 3rdparty with visp.pc and pkg-config + run: | + cd ${HOME}/visp_sample + export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/tmp/usr/local/lib/pkgconfig + CC=${{ matrix.compiler.CC }} + CXX=${{ matrix.compiler.CXX }} + pkg-config --cflags visp + pkg-config --libs visp + make CXX=${{ matrix.compiler.CXX }} -j$(nproc) -f Makefile.visp.pc + make CXX=${{ matrix.compiler.CXX }} -j$(nproc) -f Makefile.visp.pc clean + + - name: ViSP as 3rdparty with visp-config + run: | + cd ${HOME}/visp_sample + export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/tmp/usr/local/lib/pkgconfig + export VISP_INSTALL_PREFIX=/tmp/usr/local + CC=${{ matrix.compiler.CC }} + CXX=${{ matrix.compiler.CXX }} + $VISP_INSTALL_PREFIX/bin/visp-config --cflags + $VISP_INSTALL_PREFIX/bin/visp-config --libs + make CXX=${{ matrix.compiler.CXX }} -j$(nproc) -f Makefile.visp-config + make CXX=${{ matrix.compiler.CXX }} -j$(nproc) -f Makefile.visp-config clean From 6330e1da54f79e558977285c6f1e740bb29d0535 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 7 Jan 2025 14:50:06 +0100 Subject: [PATCH 36/38] [TEST] Renamed ogre github action --- .github/workflows/ubuntu-ogre-apt.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ubuntu-ogre-apt.yml b/.github/workflows/ubuntu-ogre-apt.yml index 26078f4cf7..dbe5addd58 100644 --- a/.github/workflows/ubuntu-ogre-apt.yml +++ b/.github/workflows/ubuntu-ogre-apt.yml @@ -1,4 +1,4 @@ -name: Ubuntu-dep-apt +name: Ubuntu-ogre-apt # https://www.jeffgeerling.com/blog/2020/running-github-actions-workflow-on-schedule-and-other-events on: @@ -14,7 +14,7 @@ concurrency: cancel-in-progress: true jobs: - build-ubuntu-dep-apt: + build-ubuntu-ogre-apt: runs-on: ${{ matrix.os }} strategy: fail-fast: false From 6349a3920eaea2fd742105e4202421d37f4f1676 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 7 Jan 2025 15:09:11 +0100 Subject: [PATCH 37/38] [TEST] Installing ogre dependencies in the github action --- .github/workflows/ubuntu-ogre-apt.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ubuntu-ogre-apt.yml b/.github/workflows/ubuntu-ogre-apt.yml index dbe5addd58..e649e68cc3 100644 --- a/.github/workflows/ubuntu-ogre-apt.yml +++ b/.github/workflows/ubuntu-ogre-apt.yml @@ -37,13 +37,16 @@ jobs: - name: Print compiler information run: dpkg --list | grep compiler + - name: Install ViSP dependencies + run: sudo apt-get update && sudo apt-get install -y libx11-dev libdc1394-dev libv4l-dev liblapack-dev libopenblas-dev libeigen3-dev libopencv-dev nlohmann-json3-dev + - name: Install dependencies for Ogre 1.9 if: matrix.ogre == 'ogre-1.9' - run: sudo apt-get update && sudo apt-get install -y libx11-dev libdc1394-dev libv4l-dev liblapack-dev libopenblas-dev libeigen3-dev libopencv-dev nlohmann-json3-dev libogre-1.9-dev + run: sudo apt-get update && sudo apt-get install -y libgles2-mesa-dev libvulkan-dev glslang-dev libxrandr-dev libxaw7-dev libx11-dev libzzip-dev libsdl2-dev libogre-1.9-dev - name: Install dependencies for Ogre 1.12 if: matrix.ogre == 'ogre-1.12' - run: sudo apt-get update && sudo apt-get install -y libx11-dev libdc1394-dev libv4l-dev liblapack-dev libopenblas-dev libeigen3-dev libopencv-dev nlohmann-json3-dev libogre-1.12-dev + run: sudo apt-get update && sudo apt-get install -y libgles2-mesa-dev libvulkan-dev glslang-dev libxrandr-dev libxaw7-dev libx11-dev libzzip-dev libsdl2-dev libogre-1.12-dev - name: Clone visp-images env: From 988d23d97a2aa3c4f79d059ecadf4aa3cfa451b3 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 7 Jan 2025 16:42:26 +0100 Subject: [PATCH 38/38] [TEST] Fix Ogre CI : Ogre cannot be run without a valid X11 context --- example/ogre-simulator/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/example/ogre-simulator/CMakeLists.txt b/example/ogre-simulator/CMakeLists.txt index 8f327adbde..5c5d7434a3 100644 --- a/example/ogre-simulator/CMakeLists.txt +++ b/example/ogre-simulator/CMakeLists.txt @@ -57,8 +57,4 @@ foreach(cpp ${example_cpp}) endif() endforeach() -# Add test only if dataset found for isolated build -visp_find_dataset(DATASET_FOUND) -if(DATASET_FOUND) -visp_add_test(AROgreBasic AROgreBasic ${OPTION_TO_DESACTIVE_DISPLAY} -c) -endif() +# AROgreBasic cannot be used as unit test because requires a valid X11 context