paysages : Added custom camera location on renderer for top-down previews.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@514 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
cc46102f9f
commit
324a01dca1
20 changed files with 90 additions and 50 deletions
|
@ -16,7 +16,7 @@ ExplorerChunkSky::ExplorerChunkSky(Renderer* renderer, double size, SkyboxOrient
|
||||||
void ExplorerChunkSky::onRenderEvent(QGLWidget*)
|
void ExplorerChunkSky::onRenderEvent(QGLWidget*)
|
||||||
{
|
{
|
||||||
double size = _box_size;
|
double size = _box_size;
|
||||||
Vector3 camera = renderer()->camera_location;
|
Vector3 camera = renderer()->getCameraLocation(renderer(), VECTOR_ZERO);
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
switch(_orientation)
|
switch(_orientation)
|
||||||
|
|
|
@ -16,9 +16,7 @@ public:
|
||||||
{
|
{
|
||||||
_renderer = rendererCreate();
|
_renderer = rendererCreate();
|
||||||
_renderer->applyTextures = _applyTextures;
|
_renderer->applyTextures = _applyTextures;
|
||||||
_renderer->camera_location.x = 0.0;
|
_renderer->getCameraLocation = _getCameraLocation;
|
||||||
_renderer->camera_location.y = 50.0;
|
|
||||||
_renderer->camera_location.z = 0.0;
|
|
||||||
|
|
||||||
_textures = texturesCreateDefinition();
|
_textures = texturesCreateDefinition();
|
||||||
_water = waterCreateDefinition();
|
_water = waterCreateDefinition();
|
||||||
|
@ -82,6 +80,11 @@ private:
|
||||||
return texturesGetColor((TexturesDefinition*)(renderer->customData[1]), renderer, location.x, location.z, precision);
|
return texturesGetColor((TexturesDefinition*)(renderer->customData[1]), renderer, location.x, location.z, precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Vector3 _getCameraLocation(Renderer* renderer, Vector3 location)
|
||||||
|
{
|
||||||
|
return v3Add(location, v3Scale(VECTOR_UP, 50.0));
|
||||||
|
}
|
||||||
|
|
||||||
static Color _applyAerialPerspective(Renderer*, Vector3, Color base)
|
static Color _applyAerialPerspective(Renderer*, Vector3, Color base)
|
||||||
{
|
{
|
||||||
return base;
|
return base;
|
||||||
|
|
|
@ -18,7 +18,7 @@ public:
|
||||||
|
|
||||||
addOsd(QString("geolocation"));
|
addOsd(QString("geolocation"));
|
||||||
|
|
||||||
configScaling(0.5, 200.0, 3.0, 50.0);
|
configScaling(20.0, 1000.0, 20.0, 50.0);
|
||||||
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
|
|
||||||
addOsd(QString("geolocation"));
|
addOsd(QString("geolocation"));
|
||||||
|
|
||||||
configScaling(0.5, 200.0, 1.0, 50.0);
|
configScaling(20.0, 500.0, 20.0, 50.0);
|
||||||
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
||||||
}
|
}
|
||||||
~PreviewTexturesCoverage()
|
~PreviewTexturesCoverage()
|
||||||
|
@ -70,9 +70,9 @@ public:
|
||||||
|
|
||||||
_renderer = rendererCreate();
|
_renderer = rendererCreate();
|
||||||
_renderer->render_quality = 3;
|
_renderer->render_quality = 3;
|
||||||
_renderer->camera_location.x = 0.0;
|
_renderer->render_camera.location.x = 0.0;
|
||||||
_renderer->camera_location.y = 20.0;
|
_renderer->render_camera.location.y = 20.0;
|
||||||
_renderer->camera_location.z = 0.0;
|
_renderer->render_camera.location.z = 0.0;
|
||||||
|
|
||||||
_zone = zoneCreate();
|
_zone = zoneCreate();
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
addOsd(QString("geolocation"));
|
addOsd(QString("geolocation"));
|
||||||
addToggle("highlight", tr("Coverage highlight"), true);
|
addToggle("highlight", tr("Coverage highlight"), true);
|
||||||
|
|
||||||
configScaling(0.5, 200.0, 3.0, 50.0);
|
configScaling(20.0, 1000.0, 20.0, 50.0);
|
||||||
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
|
@ -117,6 +117,7 @@ protected:
|
||||||
{
|
{
|
||||||
Vector3 eye, look, location;
|
Vector3 eye, look, location;
|
||||||
|
|
||||||
|
// TODO Camera location
|
||||||
eye.x = 0.0;
|
eye.x = 0.0;
|
||||||
eye.y = scaling;
|
eye.y = scaling;
|
||||||
eye.z = -10.0 * scaling;
|
eye.z = -10.0 * scaling;
|
||||||
|
|
|
@ -22,9 +22,9 @@ SmallMaterialPreview::SmallMaterialPreview(QWidget* parent, SurfaceMaterial* mat
|
||||||
_material = material;
|
_material = material;
|
||||||
|
|
||||||
_renderer = rendererCreate();
|
_renderer = rendererCreate();
|
||||||
_renderer->camera_location.x = 0.0;
|
_renderer->render_camera.location.x = 0.0;
|
||||||
_renderer->camera_location.x = 0.0;
|
_renderer->render_camera.location.x = 0.0;
|
||||||
_renderer->camera_location.z = 10.0;
|
_renderer->render_camera.location.z = 10.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SmallMaterialPreview::~SmallMaterialPreview()
|
SmallMaterialPreview::~SmallMaterialPreview()
|
||||||
|
@ -56,7 +56,7 @@ Color SmallMaterialPreview::getColor(double x, double y)
|
||||||
}
|
}
|
||||||
|
|
||||||
point = v3Normalize(point);
|
point = v3Normalize(point);
|
||||||
color = lightingApplyOneLight(&_light, _renderer->camera_location, point, point, _material);
|
color = lightingApplyOneLight(&_light, _renderer->getCameraLocation(_renderer, point), point, point, _material);
|
||||||
if (dist > 0.95)
|
if (dist > 0.95)
|
||||||
{
|
{
|
||||||
color.a = (1.0 - dist) / 0.05;
|
color.a = (1.0 - dist) / 0.05;
|
||||||
|
|
|
@ -397,7 +397,6 @@ void WidgetExplorer::paintGL()
|
||||||
double frame_time;
|
double frame_time;
|
||||||
|
|
||||||
cameraValidateDefinition(&_current_camera, 1);
|
cameraValidateDefinition(&_current_camera, 1);
|
||||||
_renderer->camera_location = _current_camera.location;
|
|
||||||
|
|
||||||
start_time = QTime::currentTime();
|
start_time = QTime::currentTime();
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
Color basicApplyAerialPerspective(Renderer* renderer, Vector3 location, Color base)
|
Color basicApplyAerialPerspective(Renderer* renderer, Vector3 location, Color base)
|
||||||
{
|
{
|
||||||
Vector3 direction = v3Sub(location, renderer->camera_location);
|
Vector3 direction = v3Sub(location, renderer->getCameraLocation(renderer, location));
|
||||||
double distance = v3Norm(direction);
|
double distance = v3Norm(direction);
|
||||||
AtmosphereDefinition* definition = renderer->atmosphere->definition;
|
AtmosphereDefinition* definition = renderer->atmosphere->definition;
|
||||||
double near = 10.0 - definition->humidity * 10.0;
|
double near = 10.0 - definition->humidity * 10.0;
|
||||||
|
|
|
@ -1166,7 +1166,7 @@ Color brunetonGetSkyColor(AtmosphereDefinition* definition, Vector3 eye, Vector3
|
||||||
|
|
||||||
Color brunetonApplyAerialPerspective(Renderer* renderer, Vector3 location, Color base)
|
Color brunetonApplyAerialPerspective(Renderer* renderer, Vector3 location, Color base)
|
||||||
{
|
{
|
||||||
Vector3 eye = renderer->camera_location;
|
Vector3 eye = renderer->getCameraLocation(renderer, location);
|
||||||
Vector3 sun_position = v3Scale(renderer->atmosphere->getSunDirection(renderer), SUN_DISTANCE);
|
Vector3 sun_position = v3Scale(renderer->atmosphere->getSunDirection(renderer), SUN_DISTANCE);
|
||||||
|
|
||||||
double yoffset = GROUND_OFFSET - renderer->getWaterHeightInfo(renderer).base_height;
|
double yoffset = GROUND_OFFSET - renderer->getWaterHeightInfo(renderer).base_height;
|
||||||
|
|
|
@ -120,10 +120,11 @@ static Color _fakeGetSkyColor(Renderer* renderer, Vector3 direction)
|
||||||
static Color _getSkyColor(Renderer* renderer, Vector3 direction)
|
static Color _getSkyColor(Renderer* renderer, Vector3 direction)
|
||||||
{
|
{
|
||||||
AtmosphereDefinition* definition;
|
AtmosphereDefinition* definition;
|
||||||
Vector3 sun_direction, sun_position;
|
Vector3 sun_direction, sun_position, camera_location;
|
||||||
Color sky_color, sun_color;
|
Color sky_color, sun_color;
|
||||||
|
|
||||||
definition = renderer->atmosphere->definition;
|
definition = renderer->atmosphere->definition;
|
||||||
|
camera_location = renderer->getCameraLocation(renderer, VECTOR_ZERO);
|
||||||
|
|
||||||
sun_direction = renderer->atmosphere->getSunDirection(renderer);
|
sun_direction = renderer->atmosphere->getSunDirection(renderer);
|
||||||
direction = v3Normalize(direction);
|
direction = v3Normalize(direction);
|
||||||
|
@ -133,10 +134,10 @@ static Color _getSkyColor(Renderer* renderer, Vector3 direction)
|
||||||
switch (definition->model)
|
switch (definition->model)
|
||||||
{
|
{
|
||||||
case ATMOSPHERE_MODEL_BRUNETON:
|
case ATMOSPHERE_MODEL_BRUNETON:
|
||||||
sky_color = brunetonGetSkyColor(definition, renderer->camera_location, direction, sun_position);
|
sky_color = brunetonGetSkyColor(definition, camera_location, direction, sun_position);
|
||||||
break;
|
break;
|
||||||
case ATMOSPHERE_MODEL_PREETHAM:
|
case ATMOSPHERE_MODEL_PREETHAM:
|
||||||
sky_color = preethamGetSkyColor(definition, renderer->camera_location, direction, sun_position);
|
sky_color = preethamGetSkyColor(definition, camera_location, direction, sun_position);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sky_color = COLOR_BLUE;
|
sky_color = COLOR_BLUE;
|
||||||
|
@ -145,7 +146,7 @@ static Color _getSkyColor(Renderer* renderer, Vector3 direction)
|
||||||
/* Get sun shape */
|
/* Get sun shape */
|
||||||
double sun_radius = definition->sun_radius * SUN_RADIUS_SCALED;
|
double sun_radius = definition->sun_radius * SUN_RADIUS_SCALED;
|
||||||
Vector3 hit1, hit2;
|
Vector3 hit1, hit2;
|
||||||
int hits = euclidRayIntersectSphere(renderer->camera_location, direction, sun_position, sun_radius, &hit1, &hit2);
|
int hits = euclidRayIntersectSphere(camera_location, direction, sun_position, sun_radius, &hit1, &hit2);
|
||||||
if (hits > 1)
|
if (hits > 1)
|
||||||
{
|
{
|
||||||
double dist = v3Norm(v3Sub(hit2, hit1)) / sun_radius; /* distance between intersection points (relative to radius) */
|
double dist = v3Norm(v3Sub(hit2, hit1)) / sun_radius; /* distance between intersection points (relative to radius) */
|
||||||
|
|
|
@ -148,9 +148,9 @@ Renderer* atmosphereCreatePreviewRenderer()
|
||||||
{
|
{
|
||||||
Renderer* result = rendererCreate();
|
Renderer* result = rendererCreate();
|
||||||
|
|
||||||
result->camera_location.x = 0.0;
|
result->render_camera.location.x = 0.0;
|
||||||
result->camera_location.y = 7.0;
|
result->render_camera.location.y = 7.0;
|
||||||
result->camera_location.z = 0.0;
|
result->render_camera.location.z = 0.0;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,16 +8,17 @@
|
||||||
|
|
||||||
static Color _postProcessFragment(Renderer* renderer, Vector3 location, void* data)
|
static Color _postProcessFragment(Renderer* renderer, Vector3 location, void* data)
|
||||||
{
|
{
|
||||||
Vector3 direction;
|
Vector3 camera_location, direction;
|
||||||
Color result;
|
Color result;
|
||||||
|
|
||||||
UNUSED(data);
|
UNUSED(data);
|
||||||
|
|
||||||
direction = v3Sub(location, renderer->camera_location);
|
camera_location = renderer->getCameraLocation(renderer, location);
|
||||||
|
direction = v3Sub(location, camera_location);
|
||||||
|
|
||||||
/* TODO Don't compute result->color if it's fully covered by clouds */
|
/* TODO Don't compute result->color if it's fully covered by clouds */
|
||||||
result = renderer->atmosphere->getSkyColor(renderer, v3Normalize(direction));
|
result = renderer->atmosphere->getSkyColor(renderer, v3Normalize(direction));
|
||||||
result = renderer->clouds->getColor(renderer, result, renderer->camera_location, v3Add(renderer->camera_location, v3Scale(direction, 10.0)));
|
result = renderer->clouds->getColor(renderer, result, camera_location, v3Add(camera_location, v3Scale(direction, 10.0)));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -29,13 +30,15 @@ void atmosphereRenderSkydome(Renderer* renderer)
|
||||||
double step_i, step_j;
|
double step_i, step_j;
|
||||||
double current_i, current_j;
|
double current_i, current_j;
|
||||||
Vector3 vertex1, vertex2, vertex3, vertex4;
|
Vector3 vertex1, vertex2, vertex3, vertex4;
|
||||||
Vector3 direction;
|
Vector3 camera_location, direction;
|
||||||
|
|
||||||
res_i = renderer->render_quality * 40;
|
res_i = renderer->render_quality * 40;
|
||||||
res_j = renderer->render_quality * 20;
|
res_j = renderer->render_quality * 20;
|
||||||
step_i = M_PI * 2.0 / (double)res_i;
|
step_i = M_PI * 2.0 / (double)res_i;
|
||||||
step_j = M_PI / (double)res_j;
|
step_j = M_PI / (double)res_j;
|
||||||
|
|
||||||
|
camera_location = renderer->getCameraLocation(renderer, VECTOR_ZERO);
|
||||||
|
|
||||||
for (j = 0; j < res_j; j++)
|
for (j = 0; j < res_j; j++)
|
||||||
{
|
{
|
||||||
if (!renderer->addRenderProgress(renderer, 0.0))
|
if (!renderer->addRenderProgress(renderer, 0.0))
|
||||||
|
@ -52,22 +55,22 @@ void atmosphereRenderSkydome(Renderer* renderer)
|
||||||
direction.x = SPHERE_SIZE * cos(current_i) * cos(current_j);
|
direction.x = SPHERE_SIZE * cos(current_i) * cos(current_j);
|
||||||
direction.y = SPHERE_SIZE * sin(current_j);
|
direction.y = SPHERE_SIZE * sin(current_j);
|
||||||
direction.z = SPHERE_SIZE * sin(current_i) * cos(current_j);
|
direction.z = SPHERE_SIZE * sin(current_i) * cos(current_j);
|
||||||
vertex1 = v3Add(renderer->camera_location, direction);
|
vertex1 = v3Add(camera_location, direction);
|
||||||
|
|
||||||
direction.x = SPHERE_SIZE * cos(current_i + step_i) * cos(current_j);
|
direction.x = SPHERE_SIZE * cos(current_i + step_i) * cos(current_j);
|
||||||
direction.y = SPHERE_SIZE * sin(current_j);
|
direction.y = SPHERE_SIZE * sin(current_j);
|
||||||
direction.z = SPHERE_SIZE * sin(current_i + step_i) * cos(current_j);
|
direction.z = SPHERE_SIZE * sin(current_i + step_i) * cos(current_j);
|
||||||
vertex2 = v3Add(renderer->camera_location, direction);
|
vertex2 = v3Add(camera_location, direction);
|
||||||
|
|
||||||
direction.x = SPHERE_SIZE * cos(current_i + step_i) * cos(current_j + step_j);
|
direction.x = SPHERE_SIZE * cos(current_i + step_i) * cos(current_j + step_j);
|
||||||
direction.y = SPHERE_SIZE * sin(current_j + step_j);
|
direction.y = SPHERE_SIZE * sin(current_j + step_j);
|
||||||
direction.z = SPHERE_SIZE * sin(current_i + step_i) * cos(current_j + step_j);
|
direction.z = SPHERE_SIZE * sin(current_i + step_i) * cos(current_j + step_j);
|
||||||
vertex3 = v3Add(renderer->camera_location, direction);
|
vertex3 = v3Add(camera_location, direction);
|
||||||
|
|
||||||
direction.x = SPHERE_SIZE * cos(current_i) * cos(current_j + step_j);
|
direction.x = SPHERE_SIZE * cos(current_i) * cos(current_j + step_j);
|
||||||
direction.y = SPHERE_SIZE * sin(current_j + step_j);
|
direction.y = SPHERE_SIZE * sin(current_j + step_j);
|
||||||
direction.z = SPHERE_SIZE * sin(current_i) * cos(current_j + step_j);
|
direction.z = SPHERE_SIZE * sin(current_i) * cos(current_j + step_j);
|
||||||
vertex4 = v3Add(renderer->camera_location, direction);
|
vertex4 = v3Add(camera_location, direction);
|
||||||
|
|
||||||
/* TODO Triangles at poles */
|
/* TODO Triangles at poles */
|
||||||
renderer->pushQuad(renderer, vertex1, vertex4, vertex3, vertex2, _postProcessFragment, NULL);
|
renderer->pushQuad(renderer, vertex1, vertex4, vertex3, vertex2, _postProcessFragment, NULL);
|
||||||
|
|
|
@ -245,7 +245,7 @@ static Color _applyLayerLighting(CloudsLayerDefinition* definition, Renderer* re
|
||||||
|
|
||||||
return renderer->applyLightingToSurface(renderer, location, normal, &definition->material);
|
return renderer->applyLightingToSurface(renderer, location, normal, &definition->material);
|
||||||
|
|
||||||
lighting = lightingCreateStatus(renderer->lighting, location, renderer->camera_location);
|
lighting = lightingCreateStatus(renderer->lighting, location, renderer->getCameraLocation(renderer, location));
|
||||||
renderer->atmosphere->getLightingStatus(renderer, lighting, normal, 0);
|
renderer->atmosphere->getLightingStatus(renderer, lighting, normal, 0);
|
||||||
col1 = lightingApplyStatus(lighting, normal, &definition->material);
|
col1 = lightingApplyStatus(lighting, normal, &definition->material);
|
||||||
col2 = lightingApplyStatus(lighting, v3Scale(normal, -1.0), &definition->material);
|
col2 = lightingApplyStatus(lighting, v3Scale(normal, -1.0), &definition->material);
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "scenery.h"
|
#include "scenery.h"
|
||||||
|
#include "tools.h"
|
||||||
|
|
||||||
RayCastingResult _RAYCASTING_NULL = {0};
|
static RayCastingResult _RAYCASTING_NULL = {0};
|
||||||
HeightInfo _WATER_HEIGHT_INFO = {0.0, 0.0, 0.0};
|
static HeightInfo _WATER_HEIGHT_INFO = {0.0, 0.0, 0.0};
|
||||||
|
|
||||||
static void* _renderFirstPass(void* data)
|
static void* _renderFirstPass(void* data)
|
||||||
{
|
{
|
||||||
|
@ -19,21 +20,40 @@ static void* _renderFirstPass(void* data)
|
||||||
|
|
||||||
static int _addRenderProgress(Renderer* renderer, double progress)
|
static int _addRenderProgress(Renderer* renderer, double progress)
|
||||||
{
|
{
|
||||||
|
UNUSED(progress);
|
||||||
return !renderer->render_interrupt;
|
return !renderer->render_interrupt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Vector3 _getCameraLocation(Renderer* renderer, Vector3 target)
|
||||||
|
{
|
||||||
|
UNUSED(renderer);
|
||||||
|
UNUSED(target);
|
||||||
|
return renderer->render_camera.location;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Vector3 _getCameraDirection(Renderer* renderer, Vector3 target)
|
||||||
|
{
|
||||||
|
UNUSED(renderer);
|
||||||
|
UNUSED(target);
|
||||||
|
return renderer->render_camera.forward;
|
||||||
|
}
|
||||||
|
|
||||||
static double _getPrecision(Renderer* renderer, Vector3 location)
|
static double _getPrecision(Renderer* renderer, Vector3 location)
|
||||||
{
|
{
|
||||||
|
UNUSED(renderer);
|
||||||
|
UNUSED(location);
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vector3 _projectPoint(Renderer* renderer, Vector3 point)
|
static Vector3 _projectPoint(Renderer* renderer, Vector3 point)
|
||||||
{
|
{
|
||||||
|
UNUSED(renderer);
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vector3 _unprojectPoint(Renderer* renderer, Vector3 point)
|
static Vector3 _unprojectPoint(Renderer* renderer, Vector3 point)
|
||||||
{
|
{
|
||||||
|
UNUSED(renderer);
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +91,7 @@ static Color _applyTextures(Renderer* renderer, Vector3 location, double precisi
|
||||||
|
|
||||||
Color _applyLightingToSurface(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial* material)
|
Color _applyLightingToSurface(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial* material)
|
||||||
{
|
{
|
||||||
LightStatus* light = lightingCreateStatus(renderer->lighting, location, renderer->camera_location);
|
LightStatus* light = lightingCreateStatus(renderer->lighting, location, renderer->getCameraLocation(renderer, location));
|
||||||
renderer->atmosphere->getLightingStatus(renderer, light, normal, 0);
|
renderer->atmosphere->getLightingStatus(renderer, light, normal, 0);
|
||||||
Color result = lightingApplyStatus(light, normal, material);
|
Color result = lightingApplyStatus(light, normal, material);
|
||||||
lightingDeleteStatus(light);
|
lightingDeleteStatus(light);
|
||||||
|
@ -90,12 +110,13 @@ Renderer* rendererCreate()
|
||||||
result->render_progress = 0.0;
|
result->render_progress = 0.0;
|
||||||
result->is_rendering = 0;
|
result->is_rendering = 0;
|
||||||
result->render_camera = cameraCreateDefinition();
|
result->render_camera = cameraCreateDefinition();
|
||||||
result->camera_location = result->render_camera.location;
|
|
||||||
result->render_area = renderCreateArea();
|
result->render_area = renderCreateArea();
|
||||||
|
|
||||||
renderSetParams(result->render_area, params);
|
renderSetParams(result->render_area, params);
|
||||||
|
|
||||||
result->addRenderProgress = _addRenderProgress;
|
result->addRenderProgress = _addRenderProgress;
|
||||||
|
result->getCameraLocation = _getCameraLocation;
|
||||||
|
result->getCameraDirection = _getCameraDirection;
|
||||||
result->getPrecision = _getPrecision;
|
result->getPrecision = _getPrecision;
|
||||||
result->projectPoint = _projectPoint;
|
result->projectPoint = _projectPoint;
|
||||||
result->unprojectPoint = _unprojectPoint;
|
result->unprojectPoint = _unprojectPoint;
|
||||||
|
@ -151,7 +172,6 @@ void rendererStart(Renderer* renderer, RenderParams params)
|
||||||
renderer->render_progress = 0.0;
|
renderer->render_progress = 0.0;
|
||||||
|
|
||||||
cameraSetRenderSize(&renderer->render_camera, renderer->render_width, renderer->render_height);
|
cameraSetRenderSize(&renderer->render_camera, renderer->render_width, renderer->render_height);
|
||||||
renderer->camera_location = renderer->render_camera.location;
|
|
||||||
|
|
||||||
renderSetBackgroundColor(renderer->render_area, &COLOR_BLACK);
|
renderSetBackgroundColor(renderer->render_area, &COLOR_BLACK);
|
||||||
renderSetParams(renderer->render_area, params);
|
renderSetParams(renderer->render_area, params);
|
||||||
|
|
|
@ -18,13 +18,14 @@ struct Renderer
|
||||||
int render_width;
|
int render_width;
|
||||||
int render_height;
|
int render_height;
|
||||||
CameraDefinition render_camera;
|
CameraDefinition render_camera;
|
||||||
Vector3 camera_location;
|
|
||||||
|
|
||||||
/* Render related */
|
/* Render related */
|
||||||
RenderArea* render_area;
|
RenderArea* render_area;
|
||||||
double render_progress;
|
double render_progress;
|
||||||
int render_interrupt;
|
int render_interrupt;
|
||||||
int is_rendering;
|
int is_rendering;
|
||||||
|
Vector3 (*getCameraLocation)(Renderer* renderer, Vector3 target);
|
||||||
|
Vector3 (*getCameraDirection)(Renderer* renderer, Vector3 target);
|
||||||
double (*getPrecision)(Renderer* renderer, Vector3 location);
|
double (*getPrecision)(Renderer* renderer, Vector3 location);
|
||||||
Vector3 (*projectPoint)(Renderer* renderer, Vector3 point);
|
Vector3 (*projectPoint)(Renderer* renderer, Vector3 point);
|
||||||
Vector3 (*unprojectPoint)(Renderer* renderer, Vector3 point);
|
Vector3 (*unprojectPoint)(Renderer* renderer, Vector3 point);
|
||||||
|
|
|
@ -231,7 +231,6 @@ Renderer* sceneryCreateStandardRenderer()
|
||||||
result = rendererCreate();
|
result = rendererCreate();
|
||||||
|
|
||||||
cameraCopyDefinition(&_camera, &result->render_camera);
|
cameraCopyDefinition(&_camera, &result->render_camera);
|
||||||
result->camera_location = _camera.location;
|
|
||||||
|
|
||||||
result->rayWalking = _rayWalking;
|
result->rayWalking = _rayWalking;
|
||||||
result->getWaterHeightInfo = _getWaterHeightInfo;
|
result->getWaterHeightInfo = _getWaterHeightInfo;
|
||||||
|
|
|
@ -110,6 +110,9 @@ static double _getHeight(Renderer* renderer, double x, double z, int with_painti
|
||||||
|
|
||||||
static Color _fakeGetFinalColor(Renderer* renderer, Vector3 location, double precision)
|
static Color _fakeGetFinalColor(Renderer* renderer, Vector3 location, double precision)
|
||||||
{
|
{
|
||||||
|
UNUSED(renderer);
|
||||||
|
UNUSED(location);
|
||||||
|
UNUSED(precision);
|
||||||
return COLOR_GREEN;
|
return COLOR_GREEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +124,7 @@ static Color _getFinalColor(Renderer* renderer, Vector3 location, double precisi
|
||||||
|
|
||||||
/* TODO Factorize this in scenery renderer */
|
/* TODO Factorize this in scenery renderer */
|
||||||
color = renderer->atmosphere->applyAerialPerspective(renderer, location, color);
|
color = renderer->atmosphere->applyAerialPerspective(renderer, location, color);
|
||||||
color = renderer->clouds->getColor(renderer, color, renderer->camera_location, location);
|
color = renderer->clouds->getColor(renderer, color, renderer->getCameraLocation(renderer, location), location);
|
||||||
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,16 +49,23 @@ static void _getLightingStatus(Renderer* renderer, LightStatus* status, Vector3
|
||||||
lightingPushLight(status, &light);
|
lightingPushLight(status, &light);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Vector3 _getCameraLocation(Renderer* renderer, Vector3 location)
|
||||||
|
{
|
||||||
|
UNUSED(renderer);
|
||||||
|
location.x -= 10.0;
|
||||||
|
location.y += 15.0;
|
||||||
|
location.z += 10.0;
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
Renderer* terrainCreatePreviewRenderer()
|
Renderer* terrainCreatePreviewRenderer()
|
||||||
{
|
{
|
||||||
Renderer* result = rendererCreate();
|
Renderer* result = rendererCreate();
|
||||||
|
|
||||||
result->render_quality = 3;
|
result->render_quality = 3;
|
||||||
result->applyTextures = _applyTextures;
|
result->applyTextures = _applyTextures;
|
||||||
|
result->getCameraLocation = _getCameraLocation;
|
||||||
result->atmosphere->getLightingStatus = _getLightingStatus;
|
result->atmosphere->getLightingStatus = _getLightingStatus;
|
||||||
result->camera_location.x = 0.0;
|
|
||||||
result->camera_location.y = 50.0;
|
|
||||||
result->camera_location.z = 0.0;
|
|
||||||
|
|
||||||
if (!_inited)
|
if (!_inited)
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,8 +47,9 @@ static void _renderQuad(TerrainDefinition* definition, Renderer* renderer, doubl
|
||||||
void terrainRenderSurface(Renderer* renderer)
|
void terrainRenderSurface(Renderer* renderer)
|
||||||
{
|
{
|
||||||
int chunk_factor, chunk_count, i;
|
int chunk_factor, chunk_count, i;
|
||||||
double cx = renderer->camera_location.x;
|
Vector3 cam = renderer->getCameraLocation(renderer, VECTOR_ZERO);
|
||||||
double cz = renderer->camera_location.z;
|
double cx = cam.x;
|
||||||
|
double cz = cam.z;
|
||||||
double min_chunk_size, visible_chunk_size;
|
double min_chunk_size, visible_chunk_size;
|
||||||
double radius_int, radius_ext, chunk_size;
|
double radius_int, radius_ext, chunk_size;
|
||||||
double water_height;
|
double water_height;
|
||||||
|
|
|
@ -356,7 +356,7 @@ WaterResult waterGetColorDetail(WaterDefinition* definition, Renderer* renderer,
|
||||||
|
|
||||||
color = renderer->applyLightingToSurface(renderer, location, normal, &material);
|
color = renderer->applyLightingToSurface(renderer, location, normal, &material);
|
||||||
color = renderer->atmosphere->applyAerialPerspective(renderer, location, color);
|
color = renderer->atmosphere->applyAerialPerspective(renderer, location, color);
|
||||||
color = renderer->clouds->getColor(renderer, color, renderer->camera_location, location);
|
color = renderer->clouds->getColor(renderer, color, renderer->getCameraLocation(renderer, location), location);
|
||||||
|
|
||||||
result.base = definition->material.base;
|
result.base = definition->material.base;
|
||||||
result.final = color;
|
result.final = color;
|
||||||
|
@ -371,13 +371,14 @@ Color waterGetColor(WaterDefinition* definition, Renderer* renderer, Vector3 loc
|
||||||
|
|
||||||
static Color _postProcessFragment(Renderer* renderer, Vector3 location, void* data)
|
static Color _postProcessFragment(Renderer* renderer, Vector3 location, void* data)
|
||||||
{
|
{
|
||||||
return waterGetColor((WaterDefinition*)data, renderer, location, v3Sub(location, renderer->camera_location));
|
return waterGetColor((WaterDefinition*)data, renderer, location, v3Sub(location, renderer->getCameraLocation(renderer, location)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vector3 _getFirstPassVertex(WaterDefinition* definition, double x, double z, double precision)
|
static Vector3 _getFirstPassVertex(WaterDefinition* definition, double x, double z, double precision)
|
||||||
{
|
{
|
||||||
Vector3 result;
|
Vector3 result;
|
||||||
|
|
||||||
|
UNUSED(precision);
|
||||||
result.x = x;
|
result.x = x;
|
||||||
result.y = _getHeight(definition, x, z);
|
result.y = _getHeight(definition, x, z);
|
||||||
result.z = z;
|
result.z = z;
|
||||||
|
@ -400,8 +401,9 @@ static void _renderQuad(WaterDefinition* definition, Renderer* renderer, double
|
||||||
void waterRender(WaterDefinition* definition, Renderer* renderer)
|
void waterRender(WaterDefinition* definition, Renderer* renderer)
|
||||||
{
|
{
|
||||||
int chunk_factor, chunk_count, i;
|
int chunk_factor, chunk_count, i;
|
||||||
double cx = renderer->camera_location.x;
|
Vector3 cam = renderer->getCameraLocation(renderer, VECTOR_ZERO);
|
||||||
double cz = renderer->camera_location.z;
|
double cx = cam.x;
|
||||||
|
double cz = cam.z;
|
||||||
double radius_int, radius_ext, base_chunk_size, chunk_size;
|
double radius_int, radius_ext, base_chunk_size, chunk_size;
|
||||||
|
|
||||||
base_chunk_size = 2.0 / (double)renderer->render_quality;
|
base_chunk_size = 2.0 / (double)renderer->render_quality;
|
||||||
|
|
Loading…
Reference in a new issue