From bedffa799183d13279a421c7bc7244369eba18d3 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Wed, 4 Dec 2024 15:15:03 +0100 Subject: [PATCH 01/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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/28] [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 d1a074985a71e5026cbdcd7fc2a8b52acdf4f286 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Mon, 6 Jan 2025 07:55:23 +0100 Subject: [PATCH 28/28] 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()