📄 ogrepaginglandscapeoptions.cpp
字号:
/***************************************************************************
OgrePagingLandScapeOptions.cpp - description
-------------------
begin : Sun Mar 02 2003
copyright : (C) 2003 by Jose A Milan
email : spoke2@supercable.es
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <OgreConfigFile.h>
#include <OgreSDDataChunk.h>
#include "OgrePagingLandScapeOptions.h"
namespace Ogre
{
//-----------------------------------------------------------------------
template<> PagingLandScapeOptions* Singleton<PagingLandScapeOptions>::ms_Singleton = 0;
//-----------------------------------------------------------------------
PagingLandScapeOptions::PagingLandScapeOptions()
{
data2DFormat = "HeightField";
landscape_filename = "";
landscape_extension = "";
change_factor = 1;
max_adjacent_pages = 1;
max_preload_pages = 2;
PageSize = 257;
InitLOD = 7;
world_width = -1;
world_height = -1;
scale = Vector3( 1, 1, 1 );
lit = false;
colored = false;
num_renderables = 2500;
num_tiles = 5000;
split_factor = 1.5;
threshold = 100;
// TODO: Terminar esto.
//Perspective = ViewportWidth ( 2 * tan(HorizontalFOV / 2) );
Perspective = 800 * ( 2 * tan(22.5) );
cameraThreshold = 5;
num_tiles_merge_process = 30;
num_tiles_split_process = 15;
num_renderables_morph_process = 0;
num_renderables_demorph_process = 0;
num_renderables_morph_step = 0;
};
//-----------------------------------------------------------------------
PagingLandScapeOptions::~PagingLandScapeOptions()
{
}
void PagingLandScapeOptions::load( const String& filename )
{
/* Set up the options */
ConfigFile config;
config.load( filename );
data2DFormat = config.getSetting( "Data2DFormat" );
landscape_filename = config.getSetting( "LandScapeFileName" );
landscape_extension = config.getSetting( "LandScapeExtension" );
num_renderables = StringUtil::toReal( config.getSetting( "MaxNumRenderables" ) );
num_tiles = StringUtil::toReal( config.getSetting( "MaxNumTiles" ) );
split_factor = StringUtil::toReal( config.getSetting( "SplitFactor" ) );
threshold = StringUtil::toReal( config.getSetting( "Threshold" ) );
cameraThreshold = StringUtil::toReal( config.getSetting( "CameraThreshold" ) );
// To avoid the use of a square root.
cameraThreshold *= cameraThreshold;
num_tiles_merge_process = StringUtil::toReal( config.getSetting( "MaxNumTilesMergesProcess" ) );
num_tiles_split_process = StringUtil::toReal( config.getSetting( "MaxNumTilesSplitsProcess" ) );
num_renderables_morph_process = StringUtil::toReal( config.getSetting( "MaxNumRenderablesMorphProcess" ));
num_renderables_demorph_process = StringUtil::toReal( config.getSetting( "MaxNumRenderablesDeMorphProcess" ));
num_renderables_morph_step = StringUtil::toReal( config.getSetting( "NumRenderablesMorphStep" ) );
scale.x = StringUtil::toReal( config.getSetting( "ScaleX" ) );
scale.y = StringUtil::toReal( config.getSetting( "ScaleY" ) );
scale.z = StringUtil::toReal( config.getSetting( "ScaleZ" ) );
max_adjacent_pages = StringUtil::toReal( config.getSetting( "MaxAdjacentPages" ) );
max_preload_pages = StringUtil::toReal( config.getSetting( "MaxPreloadedPages" ) );
world_height = StringUtil::toReal( config.getSetting( "Height" ) );
world_width = StringUtil::toReal( config.getSetting( "Width" ) );
PageSize = StringUtil::toReal( config.getSetting( "PageSize" ) );
//InitLOD = StringUtil::toReal( config.getSetting( "InitLOD" ) );
change_factor = StringUtil::toReal( config.getSetting( "ChangeFactor" ) ) * ( PageSize / 9 );
colored = ( config.getSetting( "VertexColors" ) == "yes" );
lit = ( config.getSetting( "VertexNormals" ) == "yes" );
}
//-----------------------------------------------------------------------
bool PagingLandScapeOptions::setOption( const String& strKey, const void* pValue )
{
if ( strKey == "SplitFactor" )
{
split_factor = *(reinterpret_cast<const float *>(pValue));
return true;
}
if ( strKey == "Threshold" )
{
threshold = *(reinterpret_cast<const float *>(pValue));
return true;
}
if ( strKey == "MaxNumTilesMergesProcess" )
{
num_tiles_merge_process = *(reinterpret_cast<const int *>(pValue));
return true;
}
if ( strKey == "MaxNumTilesSplitsProcess" )
{
num_tiles_split_process = *(reinterpret_cast<const int *>(pValue));
return true;
}
if ( strKey == "MaxNumRenderablesMorphProcess" )
{
num_renderables_morph_process = *(reinterpret_cast<const int *>(pValue));
return true;
}
if ( strKey == "MaxNumRenderablesDeMorphProcess" )
{
num_renderables_demorph_process = *(reinterpret_cast<const int *>(pValue));
return true;
}
/*
if ( strKey == "NumRenderablesMorphStep" )
{
num_renderables_morph_step = *(reinterpret_cast<const int *>(pValue));
return true;
}
*/
return false;
}
//-----------------------------------------------------------------------
bool PagingLandScapeOptions::getOption( const String& strKey, void* pDestValue )
{
if ( strKey == "MaxNumRenderables" )
{
* static_cast < int * > ( pDestValue ) = num_renderables;
return true;
}
if ( strKey == "MaxNumTiles" )
{
* static_cast < int * > ( pDestValue ) = num_tiles;
return true;
}
if ( strKey == "SplitFactor" )
{
* static_cast < float * > ( pDestValue ) = split_factor;
return true;
}
if ( strKey == "Threshold" )
{
* static_cast < float * > ( pDestValue ) = threshold;
return true;
}
if ( strKey == "MaxNumTilesMergesProcess" )
{
* static_cast < int * > ( pDestValue ) = num_tiles_merge_process;
return true;
}
if ( strKey == "MaxNumTilesSplitsProcess" )
{
* static_cast < int * > ( pDestValue ) = num_tiles_split_process;
return true;
}
if ( strKey == "MaxNumRenderablesMorphProcess" )
{
* static_cast < int * > ( pDestValue ) = num_renderables_morph_process;
return true;
}
if ( strKey == "MaxNumRenderablesDeMorphProcess" )
{
* static_cast < int * > ( pDestValue ) = num_renderables_demorph_process;
return true;
}
// 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;
}
/*
if ( strKey == "NumRenderablesMorphStep" )
{
* static_cast < int * > ( pDestValue ) = num_renderables_morph_step;
return true;
}
*/
return false;
}
//-----------------------------------------------------------------------
bool PagingLandScapeOptions::hasOption( const String& strKey )
{
if ( strKey == "MaxNumRenderables" )
{
return true;
}
if ( strKey == "MaxNumTiles" )
{
return true;
}
if ( strKey == "SplitFactor" )
{
return true;
}
if ( strKey == "Threshold" )
{
return true;
}
if ( strKey == "MaxNumTilesMergesProcess" )
{
return true;
}
if ( strKey == "MaxNumTilesSplitsProcess" )
{
return true;
}
if ( strKey == "MaxNumRenderablesMorphProcess" )
{
return true;
}
if ( strKey == "MaxNumRenderablesDeMorphProcess" )
{
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;
}
/*
if ( strKey == "NumRenderablesMorphStep" )
{
return true;
}
*/
return false;
}
//-----------------------------------------------------------------------
bool PagingLandScapeOptions::getOptionValues( const String& strKey, std::list<SDDataChunk>& refValueList )
{
if ( strKey == "MaxNumRenderables" )
{
refValueList.push_back(SDDataChunk());
return true;
}
if ( strKey == "MaxNumTiles" )
{
refValueList.push_back(SDDataChunk());
return true;
}
if ( strKey == "SplitFactor" )
{
refValueList.push_back(SDDataChunk());
return true;
}
if ( strKey == "Threshold" )
{
refValueList.push_back(SDDataChunk());
return true;
}
if ( strKey == "MaxNumTilesMergesProcess" )
{
refValueList.push_back(SDDataChunk());
return true;
}
if ( strKey == "MaxNumTilesSplitsProcess" )
{
refValueList.push_back(SDDataChunk());
return true;
}
if ( strKey == "MaxNumRenderablesMorphProcess" )
{
refValueList.push_back(SDDataChunk());
return true;
}
if ( strKey == "MaxNumRenderablesDeMorphProcess" )
{
refValueList.push_back(SDDataChunk());
return true;
}
/*
if ( strKey == "NumRenderablesMorphStep" )
{
refValueList.push_back(SDDataChunk());
return true;
}
*/
return false;
}
//-----------------------------------------------------------------------
bool PagingLandScapeOptions::getOptionKeys( std::list<String>& refKeys )
{
refKeys.push_back( "MaxNumRenderables" );
refKeys.push_back( "MaxNumTiles" );
refKeys.push_back( "SplitFactor" );
refKeys.push_back( "Threshold" );
refKeys.push_back( "MaxNumTilesMergesProcess" );
refKeys.push_back( "MaxNumTilesSplitsProcess" );
refKeys.push_back( "MaxNumRenderablesMorphProcess" );
refKeys.push_back( "MaxNumRenderablesDeMorphProcess" );
// 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" );
// refKeys.push_back( "NumRenderablesMorphStep" );
return true;
}
//-----------------------------------------------------------------------
PagingLandScapeOptions& PagingLandScapeOptions::getSingleton(void)
{
return Singleton<PagingLandScapeOptions>::getSingleton();
}
} //namespace
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -