C++读取osgb

string data_dir = osgb_dir;
	//std::string ext = osgDB::getLowerCaseFileExtension(data_dir);
	
	osgDB::ReaderWriter::Options* options=NULL;
	std::string fileName = osgDB::findDataFile(osgb_dir, options);
	if (fileName.empty()) {
		OSG_INFO << "Reading file " << fileName <<"not found"<< std::endl;
		return;
	}
	osg::Group* g = new osg::Group;
	std::string dir = osgDB::getFilePath(fileName);
	std::string dataPath = dir + "\\Data\\";
	osgDB::DirectoryContents dirNames = osgDB::getDirectoryContents(dataPath);
	for each (std::string dir in dirNames)
	{
		if (dir.find(".") != std::string::npos)
			continue;
		std::string osgbFile = dataPath + dir + "\\" + dir + ".osgb";
		g->addChild(osgDB::readNodeFile(osgbFile));
	}

	

 

你可能感兴趣的:(C++)