返回顶部

Ogre14.3代码片段

Ogre默认资源代码中加载

	//Ogre Resources
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/Main", "FileSystem", "OgreInternal");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/RTShaderLib", "FileSystem", "OgreInternal");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/Terrain", "FileSystem", "OgreInternal");

	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/PBR", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/PBR/filament", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/materials/programs/GLSL", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/materials/programs/GLSL120", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/materials/programs/GLSL150", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/materials/programs/GLSL400", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/materials/programs/GLSLES", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/materials/programs/SPIRV", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/materials/programs/Cg", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/materials/programs/HLSL", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/materials/programs/HLSL_Cg", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/materials/scripts", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/materials/textures", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/materials/textures/terrain", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/models", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/particle", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/DeferredShadingMedia", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/DeferredShadingMedia/DeferredShading/post", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/PCZAppMedia", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/materials/scripts/SSAO", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/materials/textures/SSAO", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/volumeTerrain", "FileSystem", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/CSMShadows", "FileSystem", "General");

	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/packs/cubemap.zip", "Zip", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/packs/cubemapsJS.zip", "Zip", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/packs/dragon.zip", "Zip", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/packs/fresneldemo.zip", "Zip", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/packs/ogredance.zip", "Zip", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/packs/Sinbad.zip", "Zip", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/packs/skybox.zip", "Zip", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/volumeTerrain/volumeTerrainBig.zip", "Zip", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/packs/DamagedHelmet.zip", "Zip", "General");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString() + "/../Media/packs/filament_shaders.zip", "Zip", "General");

	//Your Resources
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_MEDIA_DIR).toStdString() + "/models", "FileSystem");
	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_MEDIA_DIR).toStdString() + "/materials/scripts", "FileSystem");
   	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

鼠标选中显示bounding rect

	//检测鼠标是否点击了球
	float viewportX = event->pos().x()*1.0 / width(); 
	float viewportY = event->pos().y()*1.0 / height(); 
	Ogre::Ray ray = m_pCamera->getCameraToViewportRay(viewportX, viewportY);
	// 使用射线查询来检测点击的物体
	Ogre::RaySceneQuery* query = m_pSceneManager->createRayQuery(ray);
	Ogre::RaySceneQueryResult& result = query->execute();
	// 遍历查询结果,找到鼠标点击的顶点
	for (auto& entry : result)
	{
		if (entry.movable) 
		{
			Ogre::MovableObject* selectedObject = entry.movable;
			auto node = selectedObject->getParentSceneNode();
			node->showBoundingBox(!node->getShowBoundingBox());
		}
	}
posted @ 2024-11-09 09:22  Zcb0812  阅读(2)  评论(0编辑  收藏  举报