示例#1
0
void TerrainGeometryManager::configureTerrainDefaults()
{
	OGRE_NEW TerrainGlobalOptions();

	Light *light = gEnv->terrainManager->getMainLight();
	TerrainGlobalOptions *terrainOptions = TerrainGlobalOptions::getSingletonPtr();
	// Configure global
	terrainOptions->setMaxPixelError(IOPT("MaxPixelError", 5));

	// Important to set these so that the terrain knows what to use for derived (non-realtime) data
	if (light)
	{
		terrainOptions->setLightMapDirection(light->getDerivedDirection());
		terrainOptions->setCompositeMapDiffuse(light->getDiffuseColour());
	}
	terrainOptions->setCompositeMapAmbient(gEnv->sceneManager->getAmbientLight());

	// Configure default import settings for if we use imported image
	Ogre::Terrain::ImportData& defaultimp = mTerrainGroup->getDefaultImportSettings();
	defaultimp.terrainSize  = terrainSize; // the heightmap size
	defaultimp.worldSize    = worldSize; // this is the scaled up size, like 12km
	defaultimp.inputScale   = mapsizey;
	defaultimp.minBatchSize = IOPT("minBatchSize", 33);
	defaultimp.maxBatchSize = IOPT("maxBatchSize", 65);

	// optimizations
	TerrainMaterialGeneratorA::SM2Profile* matProfile = static_cast<TerrainMaterialGeneratorA::SM2Profile*>(terrainOptions->getDefaultMaterialGenerator()->getActiveProfile());
	if (matProfile)
	{
		matProfile->setLightmapEnabled(BOPT("LightmapEnabled", false));
		matProfile->setLayerNormalMappingEnabled(BOPT("NormalMappingEnabled", false));
		matProfile->setLayerSpecularMappingEnabled(BOPT("SpecularMappingEnabled", false));
		matProfile->setLayerParallaxMappingEnabled(BOPT("ParallaxMappingEnabled", false));
		matProfile->setGlobalColourMapEnabled(BOPT("GlobalColourMapEnabled", false));
		matProfile->setReceiveDynamicShadowsDepth(BOPT("ReceiveDynamicShadowsDepth", true));
	}

	terrainOptions->setLayerBlendMapSize(IOPT("LayerBlendMapSize", 1024));
	terrainOptions->setCompositeMapSize(IOPT("CompositeMapSize", 1024));
	terrainOptions->setCompositeMapDistance(IOPT("CompositeMapDistance", 4000));
	terrainOptions->setSkirtSize(IOPT("SkirtSize", 30));
	terrainOptions->setLightMapSize(IOPT("LightMapSize", 1024));
	terrainOptions->setCastsDynamicShadows(BOPT("CastsDynamicShadows", true));

	terrainOptions->setUseRayBoxDistanceCalculation(false);

	// load layer basics now
	loadLayers(0, 0, 0);
}
  void configureTerrainDefaults( Light* l )
  {
    // Configure global
    mTerrainGlobals->setMaxPixelError( 8 );
    // testing composite map
    mTerrainGlobals->setCompositeMapDistance( 3000 );
    //mTerrainGlobals->setUseRayBoxDistanceCalculation(true);
    //mTerrainGlobals->getDefaultMaterialGenerator()->setDebugLevel(1);
    //mTerrainGlobals->setLightMapSize(256);
#if OGRE_NO_GLES3_SUPPORT == 1
        // Disable the lightmap for OpenGL ES 2.0. The minimum number of samplers allowed is 8(as opposed to 16 on desktop).
        // Otherwise we will run over the limit by just one. The minimum was raised to 16 in GL ES 3.0.
    if( Ogre::Root::getSingletonPtr()->getRenderSystem()->getName().find( "OpenGL ES 2" ) != String::npos )
    {
      TerrainMaterialGeneratorA::SM2Profile* matProfile =
        static_cast<TerrainMaterialGeneratorA::SM2Profile*>(mTerrainGlobals->getDefaultMaterialGenerator()->getActiveProfile());
      matProfile->setLightmapEnabled( false );
    }
#endif
    // Important to set these so that the terrain knows what to use for derived (non-realtime) data
    mTerrainGlobals->setLightMapDirection( l->getDerivedDirection() );
    mTerrainGlobals->setCompositeMapAmbient( mSceneMgr->getAmbientLight() );
    //mTerrainGlobals->setCompositeMapAmbient(ColourValue::Red);
    mTerrainGlobals->setCompositeMapDiffuse( l->getDiffuseColour() );

    // Configure default import settings for if we use imported image
    Terrain::ImportData& defaultimp = mTerrainGroup->getDefaultImportSettings();
    defaultimp.terrainSize = TERRAIN_SIZE;
    defaultimp.worldSize = TERRAIN_WORLD_SIZE;
    defaultimp.inputScale = 600;
    defaultimp.minBatchSize = 33;
    defaultimp.maxBatchSize = 65;
    // textures
    defaultimp.layerList.resize( 3 );
    defaultimp.layerList[0].worldSize = 100;
    defaultimp.layerList[0].textureNames.push_back( "dirt_grayrocky_diffusespecular.dds" );
    defaultimp.layerList[0].textureNames.push_back( "dirt_grayrocky_normalheight.dds" );
    defaultimp.layerList[1].worldSize = 30;
    defaultimp.layerList[1].textureNames.push_back( "grass_green-01_diffusespecular.dds" );
    defaultimp.layerList[1].textureNames.push_back( "grass_green-01_normalheight.dds" );
    defaultimp.layerList[2].worldSize = 200;
    defaultimp.layerList[2].textureNames.push_back( "growth_weirdfungus-03_diffusespecular.dds" );
    defaultimp.layerList[2].textureNames.push_back( "growth_weirdfungus-03_normalheight.dds" );
  }