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-08 19:54:34 +00:00
|
|
|
#include "LightComponent.h"
|
|
|
|
#include "LightStatus.h"
|
2012-12-28 11:28:01 +00:00
|
|
|
|
2013-11-17 22:02:36 +00:00
|
|
|
static void _getLightingStatus(Renderer*, LightStatus* status, Vector3, int)
|
2013-01-20 21:17:03 +00:00
|
|
|
{
|
2013-12-08 19:54:34 +00:00
|
|
|
LightComponent light;
|
2013-01-20 21:17:03 +00:00
|
|
|
|
|
|
|
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;
|
2013-01-27 19:57:43 +00:00
|
|
|
light.direction.z = 1.0;
|
2013-01-20 21:17:03 +00:00
|
|
|
light.direction = v3Normalize(light.direction);
|
|
|
|
light.altered = 1;
|
2013-03-07 14:07:12 +00:00
|
|
|
light.reflection = 0.0;
|
2013-12-08 19:54:34 +00:00
|
|
|
status->pushComponent(light);
|
2013-01-20 21:17:03 +00:00
|
|
|
|
|
|
|
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;
|
2013-01-27 19:57:43 +00:00
|
|
|
light.direction.z = -1.0;
|
2013-01-20 21:17:03 +00:00
|
|
|
light.direction = v3Normalize(light.direction);
|
|
|
|
light.altered = 0;
|
|
|
|
light.reflection = 0.0;
|
2013-12-08 19:54:34 +00:00
|
|
|
status->pushComponent(light);
|
2013-01-20 21:17:03 +00:00
|
|
|
}
|
|
|
|
|
2013-11-17 22:02:36 +00:00
|
|
|
static Vector3 _getCameraLocation(Renderer*, Vector3 location)
|
2013-01-31 15:10:11 +00:00
|
|
|
{
|
|
|
|
location.x -= 10.0;
|
|
|
|
location.y += 15.0;
|
|
|
|
location.z += 10.0;
|
|
|
|
return location;
|
|
|
|
}
|
|
|
|
|
2013-11-30 10:54:27 +00:00
|
|
|
static void _alterPreviewRenderer(Renderer* renderer)
|
2012-12-28 11:28:01 +00:00
|
|
|
{
|
2013-11-12 20:34:35 +00:00
|
|
|
renderer->render_quality = 3;
|
|
|
|
renderer->getCameraLocation = _getCameraLocation;
|
|
|
|
renderer->atmosphere->getLightingStatus = _getLightingStatus;
|
2012-12-28 11:28:01 +00:00
|
|
|
|
2013-11-16 18:12:42 +00:00
|
|
|
TexturesDefinition textures(NULL);
|
|
|
|
TextureLayerDefinition* layer = textures.getTextureLayer(textures.addLayer());
|
|
|
|
layer->terrain_zone->clear();
|
2013-04-11 14:38:40 +00:00
|
|
|
layer->displacement_height = 0.0;
|
2013-11-16 18:12:42 +00:00
|
|
|
layer->material->base = colorToHSL(COLOR_WHITE);
|
|
|
|
layer->material->reflection = 0.05;
|
|
|
|
layer->material->shininess = 2.0;
|
|
|
|
layer->validate();
|
2013-11-03 14:46:39 +00:00
|
|
|
layer->_detail_noise->clearLevels();
|
2013-04-11 14:38:40 +00:00
|
|
|
|
2013-11-16 18:12:42 +00:00
|
|
|
TexturesRendererClass.bind(renderer, &textures);
|
2012-12-28 11:28:01 +00:00
|
|
|
}
|
|
|
|
|
2013-11-30 10:54:27 +00:00
|
|
|
TerrainShapePreviewRenderer::TerrainShapePreviewRenderer(TerrainDefinition* terrain)
|
|
|
|
{
|
|
|
|
_terrain = terrain;
|
|
|
|
|
|
|
|
_alterPreviewRenderer(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
TerrainRendererClass.bind(this, _terrain);
|
|
|
|
}
|
|
|
|
|
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-11-30 10:54:27 +00:00
|
|
|
height = terrain->getHeight(this, x, y, 1);
|
|
|
|
if (height > terrain->getWaterHeight(this))
|
|
|
|
{
|
|
|
|
return terrain->getFinalColor(this, Vector3(x, height, y), 0.000001);
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|