2013-11-30 10:54:27 +00:00
|
|
|
#include "TerrainShapePreviewRenderer.h"
|
2012-12-28 11:28:01 +00:00
|
|
|
|
2013-11-16 18:12:42 +00:00
|
|
|
#include "TexturesDefinition.h"
|
2013-11-30 10:54:27 +00:00
|
|
|
#include "TextureLayerDefinition.h"
|
2013-11-16 18:12:42 +00:00
|
|
|
#include "Zone.h"
|
2013-11-30 10:54:27 +00:00
|
|
|
#include "SurfaceMaterial.h"
|
|
|
|
#include "NoiseGenerator.h"
|
|
|
|
#include "BasePreview.h"
|
2013-12-09 10:59:57 +00:00
|
|
|
#include "Scenery.h"
|
2013-12-08 19:54:34 +00:00
|
|
|
#include "LightComponent.h"
|
|
|
|
#include "LightStatus.h"
|
2013-12-09 10:59:57 +00:00
|
|
|
#include "TerrainRenderer.h"
|
2012-12-28 11:28:01 +00:00
|
|
|
|
2013-12-15 13:28:46 +00:00
|
|
|
TerrainShapePreviewRenderer::TerrainShapePreviewRenderer(TerrainDefinition* terrain)
|
2013-01-20 21:17:03 +00:00
|
|
|
{
|
2013-12-15 13:28:46 +00:00
|
|
|
_terrain = terrain;
|
2013-01-20 21:17:03 +00:00
|
|
|
|
2013-12-15 13:28:46 +00:00
|
|
|
render_quality = 3;
|
2013-01-20 21:17:03 +00:00
|
|
|
|
2013-12-15 13:28:46 +00:00
|
|
|
disableClouds();
|
2013-01-20 21:17:03 +00:00
|
|
|
|
2013-12-15 13:28:46 +00:00
|
|
|
getScenery()->getTextures()->clear();
|
|
|
|
getScenery()->getTextures()->addLayer();
|
|
|
|
TextureLayerDefinition* layer = getScenery()->getTextures()->getTextureLayer(0);
|
|
|
|
layer->terrain_zone->clear();
|
|
|
|
layer->displacement_height = 0.0;
|
|
|
|
layer->material->base = colorToHSL(COLOR_WHITE);
|
|
|
|
layer->material->reflection = 0.05;
|
|
|
|
layer->material->shininess = 2.0;
|
|
|
|
layer->validate();
|
|
|
|
layer->_detail_noise->clearLevels();
|
|
|
|
}
|
2012-12-28 11:28:01 +00:00
|
|
|
|
2013-12-15 13:28:46 +00:00
|
|
|
Vector3 TerrainShapePreviewRenderer::getCameraLocation(const Vector3 &target)
|
2013-11-30 10:54:27 +00:00
|
|
|
{
|
2013-12-15 13:28:46 +00:00
|
|
|
return target.add(Vector3(-10.0, 15.0, 10.0));
|
2013-11-30 10:54:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TerrainShapePreviewRenderer::bindEvent(BasePreview* preview)
|
2012-12-28 11:28:01 +00:00
|
|
|
{
|
2013-11-30 10:54:27 +00:00
|
|
|
preview->addOsd(QString("geolocation"));
|
2012-12-28 11:28:01 +00:00
|
|
|
|
2013-11-30 10:54:27 +00:00
|
|
|
preview->configScaling(20.0, 1000.0, 20.0, 200.0);
|
|
|
|
preview->configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerrainShapePreviewRenderer::updateEvent()
|
|
|
|
{
|
2013-12-09 10:59:57 +00:00
|
|
|
getScenery()->setTerrain(_terrain);
|
|
|
|
|
|
|
|
prepare();
|
|
|
|
|
2013-12-20 16:30:27 +00:00
|
|
|
disableAtmosphere();
|
2013-11-30 10:54:27 +00:00
|
|
|
}
|
|
|
|
|
2013-11-30 17:06:41 +00:00
|
|
|
Color TerrainShapePreviewRenderer::getColor2D(double x, double y, double scaling)
|
2013-11-30 10:54:27 +00:00
|
|
|
{
|
|
|
|
double height;
|
2012-12-28 11:28:01 +00:00
|
|
|
|
2013-12-09 10:59:57 +00:00
|
|
|
height = getTerrainRenderer()->getHeight(x, y, 1);
|
|
|
|
if (height > getTerrainRenderer()->getWaterHeight())
|
2013-11-30 10:54:27 +00:00
|
|
|
{
|
2013-12-09 10:59:57 +00:00
|
|
|
return getTerrainRenderer()->getFinalColor(Vector3(x, height, y), 0.000001);
|
2013-11-30 10:54:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-30 17:06:41 +00:00
|
|
|
return getWaterColor(x, y, scaling);
|
2013-11-30 10:54:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-30 17:06:41 +00:00
|
|
|
Color TerrainShapePreviewRenderer::getWaterColor(double, double, double)
|
2013-11-30 10:54:27 +00:00
|
|
|
{
|
2013-11-30 17:06:41 +00:00
|
|
|
return COLOR_BLUE;
|
2012-12-28 11:28:01 +00:00
|
|
|
}
|