paysages3d/src/render/preview/TerrainShapePreviewRenderer.cpp

102 lines
2.6 KiB
C++
Raw Normal View History

2013-11-30 10:54:27 +00:00
#include "TerrainShapePreviewRenderer.h"
#include "TexturesDefinition.h"
2013-11-30 10:54:27 +00:00
#include "TextureLayerDefinition.h"
#include "Zone.h"
2013-11-30 10:54:27 +00:00
#include "SurfaceMaterial.h"
#include "NoiseGenerator.h"
#include "BasePreview.h"
#include "Scenery.h"
#include "LightComponent.h"
#include "LightStatus.h"
#include "TerrainRenderer.h"
/*static void _getLightingStatus(Renderer*, LightStatus* status, Vector3, int)
{
LightComponent light;
light.color.r = 0.6;
light.color.g = 0.6;
light.color.b = 0.6;
light.direction.x = -1.0;
light.direction.y = -0.5;
light.direction.z = 1.0;
light.direction = v3Normalize(light.direction);
light.altered = 1;
light.reflection = 0.0;
status->pushComponent(light);
light.color.r = 0.2;
light.color.g = 0.2;
light.color.b = 0.2;
light.direction.x = 1.0;
light.direction.y = -0.5;
light.direction.z = -1.0;
light.direction = v3Normalize(light.direction);
light.altered = 0;
light.reflection = 0.0;
status->pushComponent(light);
}
static Vector3 _getCameraLocation(Renderer*, Vector3 location)
{
location.x -= 10.0;
location.y += 15.0;
location.z += 10.0;
return location;
}*/
2013-11-30 10:54:27 +00:00
TerrainShapePreviewRenderer::TerrainShapePreviewRenderer(TerrainDefinition* terrain)
{
_terrain = terrain;
render_quality = 3;
2013-11-30 10:54:27 +00:00
}
void TerrainShapePreviewRenderer::bindEvent(BasePreview* preview)
{
2013-11-30 10:54:27 +00:00
preview->addOsd(QString("geolocation"));
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()
{
getScenery()->setTerrain(_terrain);
prepare();
/*getCameraLocation = _getCameraLocation;
atmosphere->getLightingStatus = _getLightingStatus;*/
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();
2013-11-30 10:54:27 +00:00
}
Color TerrainShapePreviewRenderer::getColor2D(double x, double y, double scaling)
2013-11-30 10:54:27 +00:00
{
double height;
height = getTerrainRenderer()->getHeight(x, y, 1);
if (height > getTerrainRenderer()->getWaterHeight())
2013-11-30 10:54:27 +00:00
{
return getTerrainRenderer()->getFinalColor(Vector3(x, height, y), 0.000001);
2013-11-30 10:54:27 +00:00
}
else
{
return getWaterColor(x, y, scaling);
2013-11-30 10:54:27 +00:00
}
}
Color TerrainShapePreviewRenderer::getWaterColor(double, double, double)
2013-11-30 10:54:27 +00:00
{
return COLOR_BLUE;
}