void EmberPagingLandScapeTexture::_loadMaterial()
{
  EmberPagingSceneManager* emberPagingSceneManager = static_cast<EmberPagingSceneManager*>(mParent->getSceneManager());
  IPageDataProvider* provider = emberPagingSceneManager->getProvider();
  if (provider) {
    std::auto_ptr<IPageData> pageData(provider->getPageData(IPageDataProvider::OgreIndex(mDataX, mDataZ)));
    mMaterial = pageData->getMaterial();
  }
}
Beispiel #2
0
vector<ProgramPage> Program::getPages(size_t pageSize)
{
	vector<ProgramPage> pages;

	for(size_t i = 0; i < data.size(); i+= pageSize)
	{
		size_t pageEndAddress = min(i + pageSize, data.size());

		vector<uint8_t> pageData(data.begin() +i, data.begin() + pageEndAddress);
		ProgramPage p(i, pageSize, pageData);
		pages.push_back(p);
	}

	return pages;
}
void EmberTerrainProfile::requestOptions(Ogre::Terrain* terrain)
{
    terrain->_setMorphRequired(false);
    terrain->_setNormalMapRequired(true);
    terrain->_setLightMapRequired(false, false);

    EmberTerrain* emberTerrain = static_cast<EmberTerrain*>(terrain);

    // Allocate in main thread so no race conditions
    std::unique_ptr<IPageData> pageData(mDataProvider.getPageData(emberTerrain->getIndex()));
    if (!pageData || pageData->getCompositeMapMaterial().isNull() || pageData->getCompositeMapMaterial()->getNumTechniques() == 0) {
        terrain->_setCompositeMapRequired(false);
    } else {
        terrain->_setCompositeMapRequired(true);
    }
}
Ogre::MaterialPtr EmberTerrainProfile::generateForCompositeMap(const Ogre::Terrain* terrain)
{
    const EmberTerrain* emberTerrain = static_cast<const EmberTerrain*>(terrain);

    const auto& index = emberTerrain->getIndex();

    S_LOG_VERBOSE("Loading composite map material for terrain page: " << "[" << index.first << "|" << index.second << "]");

    std::unique_ptr<IPageData> pageData(mDataProvider.getPageData(index));
    if (!pageData) {
        S_LOG_WARNING("Could not find corresponding page data for OgreTerrain at " << "[" << index.first << "|" << index.second << "]");
        return getOrCreateMaterialClone(mErrorMaterialTemplate, terrain->getMaterialName() + "_comp");
    }

    Ogre::MaterialPtr mat = pageData->getCompositeMapMaterial();

    if (!mat.isNull()) {
        return mat;
    } else {
        S_LOG_WARNING("Composite map material was not found. This might happen if the page is currently being unloaded.");
        return getOrCreateMaterialClone(mErrorMaterialTemplate, terrain->getMaterialName() + "_comp");
    }
}