⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ogrepaginglandscapeoptions.cpp

📁 使用stl技术,(还没看,是听说的)
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    InfiniteMap = (config.getSetting( "InfiniteMap" ) == "yes" );
    CoverageMap = (config.getSetting( "CoverageMap" ) == "yes" );
    LitColorMapGenerate = (config.getSetting( "LitColorMapGenerate" ) == "yes" );
    LitColorMapSplit = (config.getSetting( "LitColorMapSplit" ) == "yes" );
    ElevationMap= (config.getSetting( "ElevationMap" ) == "yes" ); 
    HeightNormalMap = (config.getSetting( "HeightNormalMap" ) == "yes" );
    AlphaSplatRGBAMaps =  (config.getSetting( "AlphaSplatRGBAMaps" ) == "yes" );
    AlphaSplatLightMaps = (config.getSetting( "AlphaSplatLightMaps" ) == "yes" );

    ColorMapName  = config.getSetting( "ColorMapName" );

    HeightMapBlurFactor = StringUtil::toReal( config.getSetting( "HeightMapBlurFactor" ) );
    Sun = Vector3( StringUtil::toReal( config.getSetting( "Sunx" ) ),
        StringUtil::toReal( config.getSetting( "Suny" ) ),
        StringUtil::toReal( config.getSetting( "Sunz" ) ));
    Amb = StringUtil::toReal( config.getSetting( "Ambient" ) );
    Diff = StringUtil::toReal( config.getSetting( "Diffuse" ) );
    Blur = (int) StringUtil::toReal( config.getSetting( "Blur" ) );

}

//-----------------------------------------------------------------------
bool PagingLandScapeOptions::setOption( const String& strKey, const void* pValue )
{
	if ( strKey == "VisibleRenderables" )
	{
		visible_renderables = * static_cast < const int * > ( pValue );
		// compute the actual distance as a square
		renderable_factor = visible_renderables * ( TileSize * scale.x + TileSize * scale.z );
        renderable_factor *= renderable_factor;
        return true;
	}
	if ( strKey == "DistanceLOD" )
	{
		distanceLOD = * static_cast < const Real * > ( pValue );
		// Compute the actual distance as a square
		LOD_factor = distanceLOD * ( TileSize * scale.x + TileSize * scale.z );
        LOD_factor *= LOD_factor;
        return true;
	}

	return false;
}

//-----------------------------------------------------------------------
bool PagingLandScapeOptions::getOption( const String& strKey, void* pDestValue )
{
	if ( strKey == "VisibleRenderables" )
	{
		* static_cast < int * > ( pDestValue ) = int (visible_renderables);
		return true;
	}
	if ( strKey == "DistanceLOD" )
	{
		* static_cast < Real * > ( pDestValue ) = Real (distanceLOD);
		return true;
	}
	if ( strKey == "VisibleDistance" )
	{
		// we need to return the square root of the distance
    * static_cast < float * > ( pDestValue ) =  Math::Sqrt (renderable_factor);
	}
	if ( strKey == "VisibleLOD" )
	{
		// we need to return the square root of the distance
		* static_cast < float * > ( pDestValue ) =  Math::Sqrt (LOD_factor);
	}
	// Some options proposed by Praetor
	if ( strKey == "Width" )
	{
		* static_cast < int * > ( pDestValue ) = world_width;
		return true;
	}
	if ( strKey == "Height" )
	{
		* static_cast < int * > ( pDestValue ) = world_height;
		return true;
	}
	if ( strKey == "PageSize" )
	{
		* static_cast < int * > ( pDestValue ) = PageSize;
		return true;
	}
	if ( strKey == "ScaleX" )
	{
		* static_cast < Real * > ( pDestValue ) = scale.x;
		return true;
	}
	if ( strKey == "ScaleY" )
	{
		* static_cast < Real * > ( pDestValue ) = scale.y;
		return true;
	}
	if ( strKey == "ScaleZ" )
	{
		* static_cast < Real * > ( pDestValue ) = scale.z;
		return true;
	}
	return false;
}

//-----------------------------------------------------------------------
bool PagingLandScapeOptions::hasOption( const String& strKey )
{
	if ( strKey == "VisibleRenderables" )
	{
		return true;
	}
	if ( strKey == "DistanceLOD" )
	{
		return true;
	}
	if ( strKey == "VisibleDistance" )
	{
		return true;
	}
	if ( strKey == "VisibleLOD" )
	{
		return true;
	}
	// Some options proposed by Praetor
	if ( strKey == "Width" )
	{
		return true;
	}
	if ( strKey == "Height" )
	{
		return true;
	}
	if ( strKey == "PageSize" )
	{
		return true;
	}
	if ( strKey == "ScaleX" )
	{
		return true;
	}
	if ( strKey == "ScaleY" )
	{
		return true;
	}
	if ( strKey == "ScaleZ" )
	{
		return true;
	}
	return false;
}

//-----------------------------------------------------------------------
bool PagingLandScapeOptions::getOptionValues( const String& strKey, std::list<SDDataChunk>& refValueList )
{
	if ( strKey == "VisibleRenderables" )
	{
		refValueList.push_back(SDDataChunk());
		return true;
	}
	if ( strKey == "DistanceLOD" )
	{
		refValueList.push_back(SDDataChunk());
		return true;
	}
	if ( strKey == "VisibleDistance" )
	{
		refValueList.push_back(SDDataChunk());
		return true;
	}
	if ( strKey == "VisibleLOD" )
	{
		refValueList.push_back(SDDataChunk());
		return true;
	}
	if ( strKey == "Width" )
	{
		refValueList.push_back(SDDataChunk());
		return true;
	}
	if ( strKey == "Height" )
	{
		refValueList.push_back(SDDataChunk());
		return true;
	}
	if ( strKey == "PageSize" )
	{
		refValueList.push_back(SDDataChunk());
		return true;
	}
	if ( strKey == "ScaleX" )
	{
		refValueList.push_back(SDDataChunk());
		return true;
	}
	if ( strKey == "ScaleY" )
	{
		refValueList.push_back(SDDataChunk());
		return true;
	}
	if ( strKey == "ScaleZ" )
	{
		refValueList.push_back(SDDataChunk());
		return true;
	}
	return false;
}

//-----------------------------------------------------------------------
bool PagingLandScapeOptions::getOptionKeys( std::list<String>& refKeys )
{
	refKeys.push_back( "VisibleRenderables" );
	refKeys.push_back( "DistanceLOD" );
	refKeys.push_back( "VisibleDistance" );
	refKeys.push_back( "VisibleLOD" );
	// Some options from Praetor
	refKeys.push_back( "Width" );
	refKeys.push_back( "Height" );
	refKeys.push_back( "PageSize" );
	refKeys.push_back( "ScaleX" );
	refKeys.push_back( "ScaleY" );
	refKeys.push_back( "ScaleZ" );
	return true;
}

//-----------------------------------------------------------------------
ColourValue PagingLandScapeOptions::_getAvgColor(const String tex)
{
    if (tex == "")
        return ColourValue ( 1.0f, 1.0f, 1.0f, 1.0f );

	Image img;

	img.load(tex);

    uint bpp = img.getNumElemBytes (img.getFormat ());
	const uchar* data = img.getData();
	int cr = 0, cg = 0, cb = 0, s = 0;
	for (size_t i = 0; i < img.getSize(); i += bpp)
	{
		cr += data[i];
		cg += data[i+1];
		cb += data[i+2];
		s++;
	}
    Real divider = 1.0f /  (s * 255.0f);
	ColourValue c (cr * divider, cg * divider, cb * divider, 1.0f);
	return c;
}

} //namespace

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -