void getTerrainImage(bool flipX, bool flipY, Ogre::Image& img)
{
   if(flipX)
      img.flipAroundY();
   if(flipY)
      img.flipAroundX();
}
void getTerrainImage(bool flipX, bool flipY, Ogre::Image& img)
{
	img.load("terrain1.bmp", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    if (flipX)
        img.flipAroundY();
    if (flipY)
        img.flipAroundX();
}
示例#3
0
void TerrainManager::GetTerrainImage(bool flipX, bool flipY, Ogre::Image& img)
{
    img.load(mHeightMapFileName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    if (flipX)
        img.flipAroundY();
    if (flipY)
        img.flipAroundX();
}
示例#4
0
/// FIXME
void getTerrainImage(bool flipX, bool flipY, Ogre::Image& img)
{
  img.load("height_map.png", Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
  if (flipX)
      img.flipAroundY();
  if (flipY)
      img.flipAroundX();
}
示例#5
0
void OgreWidget::getTerrainImage(bool flipX, bool flipY, Ogre::Image& img)
{
    img.load("terrain.png", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    qDebug() << "OgreWidget::getTerrainImage(): loaded terrain heightmap, width is" << img.getWidth();
    if(flipX)
        img.flipAroundY();
    if(flipY)
        img.flipAroundX();

}
示例#6
0
void TerrainManager::terrainInit(Ogre::String file, OgreManager* o)
{
	_OgreManager = o;

	initialiseResources();

	createLight();

	setGlobalOptions();

	_TerrainGroup = OGRE_NEW Ogre::TerrainGroup(_OgreManager->getSceneManager(), Ogre::Terrain::ALIGN_X_Z, 513, 12000.0f);
	_TerrainGroup->setFilenameConvention(Ogre::String("GameTerrain"), Ogre::String("dat"));
	_TerrainGroup->setOrigin(Ogre::Vector3::ZERO);

	setDefaultImportSettings();

	bool lTerrainsImported = false;
	 for (long x = 0; x <= 0; ++x)
	 {
        for (long y = 0; y <= 0; ++y)
		{
			//Define terrain function
			 Ogre::String filename = _TerrainGroup->generateFilename(x, y);
			if (Ogre::ResourceGroupManager::getSingleton().resourceExists(_TerrainGroup->getResourceGroup(), filename))
			{
				_TerrainGroup->defineTerrain(x, y);
			}
			else
			{
				Ogre::Image img;
				//Get terrain image
				Ogre::String tempFile = Ogre::StringConverter::toString(x * 10 + y);
				tempFile.append(".bmp");
				img.load("terrain.bmp", Ogre::String("TerrainResources"));
					if (x % 2 != 0)
						img.flipAroundY();
					if (y % 2 != 0)
						img.flipAroundX();
				//Get terrain image end
				_TerrainGroup->defineTerrain(x, y, &img);
				lTerrainsImported = true;
			}
			//Define terrain function end
		}
	}
	
	_TerrainGroup->loadAllTerrains(true);

	if (lTerrainsImported)
    {
        Ogre::TerrainGroup::TerrainIterator ti = _TerrainGroup->getTerrainIterator();
        while(ti.hasMoreElements())
        {
            Ogre::Terrain* t = ti.getNext()->instance;
            //Init blend maps function start
			Ogre::TerrainLayerBlendMap* blendMap0 = t->getLayerBlendMap(1);
			Ogre::TerrainLayerBlendMap* blendMap1 = t->getLayerBlendMap(2);
			Ogre::Real minHeight0 = -10;
			Ogre::Real fadeDist0 = 0;//40;
			Ogre::Real minHeight1 = -10;
			Ogre::Real fadeDist1 = 0;//15;
			float* pBlend0 = blendMap0->getBlendPointer();
			float* pBlend1 = blendMap1->getBlendPointer();
			for (Ogre::uint16 y = 0; y < t->getLayerBlendMapSize(); ++y)
			{
				for (Ogre::uint16 x = 0; x < t->getLayerBlendMapSize(); ++x)
				{
					Ogre::Real tx, ty;
 
					blendMap0->convertImageToTerrainSpace(x, y, &tx, &ty);
					Ogre::Real height = t->getHeightAtTerrainPosition(tx, ty);
					Ogre::Real val = (height - minHeight0) / fadeDist0;
					val = Ogre::Math::Clamp(val, (Ogre::Real)0, (Ogre::Real)1);
					*pBlend0++ = val;
 
					val = (height - minHeight1) / fadeDist1;
					val = Ogre::Math::Clamp(val, (Ogre::Real)0, (Ogre::Real)1);
					*pBlend1++ = val;
				}
			}
			blendMap0->dirty();
			blendMap1->dirty();
			blendMap0->update();
			blendMap1->update();
			//Init blend maps end
        }
    }

	_TerrainGroup->freeTemporaryResources();

	_OgreManager->getSceneManager()->setSkyBox(true, "Examples/EarlyMorningSkyBox", 5000, true, Ogre::Quaternion::IDENTITY, "GameResources");
}