📄 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 "OgreVector3.h"
#include "OgreColourValue.h"
#include "OgreConfigFile.h"
#include "OgreImage.h"
#include "OgreSDDataChunk.h"
#include "OgreMaterialManager.h"
#include "OgreMaterial.h"
#include "OgreTechnique.h"
#include "OgrePagingLandScapeOptions.h"
namespace Ogre
{
//-----------------------------------------------------------------------
template<> PagingLandScapeOptions* Singleton<PagingLandScapeOptions>::ms_Singleton = 0;
PagingLandScapeOptions* PagingLandScapeOptions::getSingletonPtr(void)
{
return ms_Singleton;
}
PagingLandScapeOptions& PagingLandScapeOptions::getSingleton(void)
{
assert( ms_Singleton ); return ( *ms_Singleton );
}
//-----------------------------------------------------------------------
PagingLandScapeOptions::PagingLandScapeOptions()
{
data2DFormat = "HeightField";
textureFormat = "Image";
landscape_filename = "";
landscape_extension = "";
for (int i = 0; i < 4; i++)
{
matColor[i] = ColourValue();
}
matHeight[0] = 0;
matHeight[1] = 0;
maxValue = 5000;
minValue = 0;
PageSize = 257;
TileSize = 64;
world_width = 0;
world_height = 0;
change_factor = 1;
max_adjacent_pages = 1;
max_preload_pages = 2;
renderable_factor = 10;
scale = Vector3( 1, 1, 1 );
distanceLOD = 4;
LOD_factor = 10;
num_renderables = 1000;
num_renderables_increment = 16;
num_tiles = 1000;
num_tiles_increment = 16;
cameraThreshold = 5;
#if defined(_VisibilityCheck)
visibilityAngle = 50;
#endif
num_renderables_loading = 10;
lit = false;
colored = false;
coverage_vertex_color= false;
base_vertex_color = false;
vertex_shadowed = false;
vertex_instant_colored = false;
};
//-----------------------------------------------------------------------
PagingLandScapeOptions::~PagingLandScapeOptions()
{
}
//-----------------------------------------------------------------------
void PagingLandScapeOptions::load( const String& filename )
{
/* Set up the options */
ConfigFile config;
String val;
config.load( filename );
data2DFormat = config.getSetting( "Data2DFormat" );
textureFormat = config.getSetting( "TextureFormat" );
scale.x = StringUtil::toReal( config.getSetting( "ScaleX" ) );
scale.y = StringUtil::toReal( config.getSetting( "ScaleY" ) );
scale.z = StringUtil::toReal( config.getSetting( "ScaleZ" ) );
if ( StringUtil::startsWith( data2DFormat.c_str(), "HeightFieldTC", false) )
{
maxValue = uint ( StringUtil::toReal( config.getSetting( "MaxValue" ) ) * scale.y );
minValue = uint ( StringUtil::toReal( config.getSetting( "MinValue" ) ) * scale.y );
}
else
{
maxValue = uint ( 255 * scale.y );
minValue = uint ( 0 * scale.y );
}
landscape_filename = config.getSetting( "LandScapeFileName" );
landscape_extension = config.getSetting( "LandScapeExtension" );
image_filename = config.getSetting( "ImageFilename" );
if (image_filename == "")
ImageNameLoad = false;
else
ImageNameLoad = true;
colored = ( config.getSetting( "VertexColors" ) == "yes" );
coverage_vertex_color = (config.getSetting( "CoverageVertexColor" ) == "yes" );
base_vertex_color = (config.getSetting( "BaseVertexColor" ) == "yes" );
vertex_shadowed = (config.getSetting( "BaseVertexShadow" ) == "yes" );
vertex_instant_colored = (config.getSetting( "BaseVertexInstantColor" ) == "yes" );
// ensure combination are correct
if (vertex_shadowed)
vertex_instant_colored = true;
if (coverage_vertex_color || base_vertex_color ||
vertex_shadowed || vertex_instant_colored)
colored = true;
lit = ( config.getSetting( "VertexNormals" ) == "yes" );
// Material* mSplattingMaterial = reinterpret_cast<Material *>(MaterialManager::getSingleton().getByName("SplattingMaterial"));
// matColor[0] = _getAvgColor(mSplattingMaterial->getTechnique(0)->getPass(1)->getTextureUnitState(1)->getTextureName());
// matColor[1] = _getAvgColor(mSplattingMaterial->getTechnique(0)->getPass(2)->getTextureUnitState(1)->getTextureName());
// matColor[2] = _getAvgColor(mSplattingMaterial->getTechnique(0)->getPass(3)->getTextureUnitState(1)->getTextureName());
// matColor[3] = _getAvgColor(mSplattingMaterial->getTechnique(0)->getPass(4)->getTextureUnitState(1)->getTextureName());
////
Splat_Filename_0 = config.getSetting( "SplatFilename0" );
Splat_Filename_1 = config.getSetting( "SplatFilename1" );
Splat_Filename_2 = config.getSetting( "SplatFilename2" );
Splat_Filename_3 = config.getSetting( "SplatFilename3" );
matColor[0] = _getAvgColor(Splat_Filename_0);
matColor[1] = _getAvgColor(Splat_Filename_1);
matColor[2] = _getAvgColor(Splat_Filename_2);
matColor[3] = _getAvgColor(Splat_Filename_3);
Real divider = ( maxValue - minValue ) / 255.0f;
matHeight[0] = StringUtil::toReal( config.getSetting( "MaterialHeight1" ) );
matHeight[0] = matHeight[0] * divider ;
matHeight[1] = StringUtil::toReal( config.getSetting( "MaterialHeight2" ) );
matHeight[1] = matHeight[1] * divider ;
num_renderables = (uint) StringUtil::toReal( config.getSetting( "MaxNumRenderables" ) );
num_renderables_increment = (uint) StringUtil::toReal( config.getSetting( "IncrementRenderables" ));
num_tiles = (uint) StringUtil::toReal( config.getSetting( "MaxNumTiles" ) );
num_tiles_increment = (uint) StringUtil::toReal( config.getSetting( "IncrementTiles" ));
cameraThreshold = StringUtil::toReal( config.getSetting( "CameraThreshold" ) );
// To avoid the use of a square root.
cameraThreshold *= cameraThreshold;
#if defined(_VisibilityCheck)
visibilityAngle = StringUtil::toReal( config.getSetting( "VisibilityAngle" ) );
#endif
num_renderables_loading = (uint) StringUtil::toReal( config.getSetting( "NumRenderablesLoading" ) );
max_adjacent_pages = (uint) StringUtil::toReal( config.getSetting( "MaxAdjacentPages" ) );
max_preload_pages = (uint) StringUtil::toReal( config.getSetting( "MaxPreloadedPages" ) );
world_height = (uint) StringUtil::toReal( config.getSetting( "Height" ) );
world_width = (uint) StringUtil::toReal( config.getSetting( "Width" ) );
PageSize = (uint) StringUtil::toReal( config.getSetting( "PageSize" ) );
TileSize = (uint) StringUtil::toReal( config.getSetting( "TileSize" ) );
maxRenderLevel = (uint) StringUtil::toReal( config.getSetting( "MaxRenderLevel" ) );
if (maxRenderLevel == 0)
{
while ((uint)(1 << maxRenderLevel) < TileSize)
maxRenderLevel++;
}
change_factor = StringUtil::toReal( config.getSetting( "ChangeFactor" ) ) * ( PageSize / 9 );
visible_renderables = StringUtil::toReal( config.getSetting( "VisibleRenderables" ) );
// compute the actual distance as a square
renderable_factor = visible_renderables * ( TileSize * scale.x + TileSize * scale.z );
renderable_factor *= renderable_factor;
distanceLOD = StringUtil::toReal( config.getSetting( "DistanceLOD" ) );
// Compute the actual distance as a square
LOD_factor = distanceLOD * ( TileSize * scale.x + TileSize * scale.z );
LOD_factor *= LOD_factor;
// MAP TOOL OPTIONS
Paged = (config.getSetting( "Paged" ) == "yes" );
OutDirectory = config.getSetting( "OutDirectory" );
if ( StringUtil::startsWith( OutDirectory, "LandScapeFileName", false) )
OutDirectory = landscape_filename;
PVSMap = (config.getSetting( "PVSMap" ) == "yes" );
BaseMap = (config.getSetting( "BaseMap" ) == "yes" );
RGBMaps = (config.getSetting( "RGBMaps" ) == "yes" );
ColorMapGenerate = (config.getSetting( "ColorMapGenerate" ) == "yes" );
ColorMapSplit = (config.getSetting( "ColorMapSplit" ) == "yes" );
LightMap = (config.getSetting( "LightMap" ) == "yes" );
NormalMap = (config.getSetting( "NormalMap" ) == "yes" );
HeightMap = (config.getSetting( "HeightMap" ) == "yes" );
AlphaMaps = (config.getSetting( "AlphaMaps" ) == "yes" );
ShadowMap = (config.getSetting( "ShadowMap" ) == "yes" );
HorizonMap = (config.getSetting( "HorizonMap" ) == "yes" );
LitBaseMap = (config.getSetting( "LitBaseMap" ) == "yes" );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -