求问c++中用osg库加载一个osgb文件的多个瓦片osgb到一个场景中时,应该如何做,目前我的做法是将osgb基本的瓦片文件读取,然后加载到一个osg::Group中进行保存最后渲染

但是在运行过程中,可以加载文件,但是渲染出的场景是空的,如下图


求问这是哪里出了问题,为啥想加载多个osgb场景就是空的,是因为没有规定他们的相对位置吗?按理来说osgb文件中本身不是已经包含了它本身的相对位置吗?
请问各位!感谢!
下面是我的代码
#include <osg/Node>
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
// 判断文件是否是基本的瓦片,文件名与文件夹名一致
bool isBasicTile(const fs::path& filePath) {
std::string folderName = filePath.parent_path().filename().string();
std::string filename = filePath.stem().string();
return folderName == filename; // 判断文件名与文件夹名是否一致
}
int main(int argc, char** argv) {
if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " <base_path>" << std::endl;
return 1;
}
// 获取根目录路径
std::string basePath = argv[1];
// 创建根节点
osg::ref_ptr<osg::Group> root = new osg::Group();
// 遍历给定目录
for (const auto& entry : fs::recursive_directory_iterator(basePath)) {
// 只加载符合规则的基本瓦片文件
if (entry.is_regular_file() && entry.path().extension() == ".osgb" && isBasicTile(entry.path())) {
std::string filePath = entry.path().string();
std::cout << "Loading basic tile: " << filePath << std::endl;
// 使用 OSG 加载瓦片文件
osg::ref_ptr<osg::Node> tileNode = osgDB::readNodeFile(filePath);
// 将每个符合条件的瓦片节点添加到根节点
root->addChild(tileNode.get());
}
}
// 创建 Viewer 并设置根节点为场景数据
osgViewer::Viewer viewer;
viewer.setSceneData(root.get());
// 运行渲染循环
return viewer.run();
}