WIP on fluid medium traversal
This commit is contained in:
parent
0edd90c477
commit
4a39eda2dc
12 changed files with 140 additions and 62 deletions
|
@ -161,6 +161,12 @@ else:unix: LIBS += -L$$OUT_PWD/../definition/ -lpaysages_definition
|
||||||
INCLUDEPATH += $$PWD/../definition
|
INCLUDEPATH += $$PWD/../definition
|
||||||
DEPENDPATH += $$PWD/../definition
|
DEPENDPATH += $$PWD/../definition
|
||||||
|
|
||||||
|
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../render/software/release/ -lpaysages_render_software
|
||||||
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../render/software/debug/ -lpaysages_render_software
|
||||||
|
else:unix: LIBS += -L$$OUT_PWD/../render/software/ -lpaysages_render_software
|
||||||
|
INCLUDEPATH += $$PWD/../render/software
|
||||||
|
DEPENDPATH += $$PWD/../render/software
|
||||||
|
|
||||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../render/opengl/release/ -lpaysages_render_opengl
|
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../render/opengl/release/ -lpaysages_render_opengl
|
||||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../render/opengl/debug/ -lpaysages_render_opengl
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../render/opengl/debug/ -lpaysages_render_opengl
|
||||||
else:unix: LIBS += -L$$OUT_PWD/../render/opengl/ -lpaysages_render_opengl
|
else:unix: LIBS += -L$$OUT_PWD/../render/opengl/ -lpaysages_render_opengl
|
||||||
|
|
|
@ -6,11 +6,13 @@ namespace paysages
|
||||||
namespace system {}
|
namespace system {}
|
||||||
namespace basics {}
|
namespace basics {}
|
||||||
namespace definition {}
|
namespace definition {}
|
||||||
|
namespace software {}
|
||||||
namespace opengl {}
|
namespace opengl {}
|
||||||
}
|
}
|
||||||
using namespace paysages::system;
|
using namespace paysages::system;
|
||||||
using namespace paysages::basics;
|
using namespace paysages::basics;
|
||||||
using namespace paysages::definition;
|
using namespace paysages::definition;
|
||||||
|
using namespace paysages::software;
|
||||||
using namespace paysages::opengl;
|
using namespace paysages::opengl;
|
||||||
|
|
||||||
#endif // EDITING_GLOBAL_H
|
#endif // EDITING_GLOBAL_H
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "rendering/water/public.h"
|
#include "rendering/water/public.h"
|
||||||
#include "Scenery.h"
|
#include "Scenery.h"
|
||||||
#include "PackStream.h"
|
#include "PackStream.h"
|
||||||
|
#include "SoftwareRenderer.h"
|
||||||
|
|
||||||
/**************** Previews ****************/
|
/**************** Previews ****************/
|
||||||
class PreviewRenderLandscape : public BasePreview
|
class PreviewRenderLandscape : public BasePreview
|
||||||
|
@ -182,7 +183,7 @@ void FormRender::startQuickRender()
|
||||||
{
|
{
|
||||||
rendererDelete(_renderer);
|
rendererDelete(_renderer);
|
||||||
}
|
}
|
||||||
_renderer = sceneryCreateStandardRenderer();
|
_renderer = new SoftwareRenderer();
|
||||||
_renderer_inited = true;
|
_renderer_inited = true;
|
||||||
|
|
||||||
DialogRender* dialog = new DialogRender(this, _renderer);
|
DialogRender* dialog = new DialogRender(this, _renderer);
|
||||||
|
@ -198,7 +199,7 @@ void FormRender::startRender()
|
||||||
{
|
{
|
||||||
rendererDelete(_renderer);
|
rendererDelete(_renderer);
|
||||||
}
|
}
|
||||||
_renderer = sceneryCreateStandardRenderer();
|
_renderer = new SoftwareRenderer();
|
||||||
_renderer_inited = true;
|
_renderer_inited = true;
|
||||||
|
|
||||||
DialogRender* dialog = new DialogRender(this, _renderer);
|
DialogRender* dialog = new DialogRender(this, _renderer);
|
||||||
|
|
|
@ -4,3 +4,23 @@ FluidMediumTraversal::FluidMediumTraversal(SoftwareRenderer* renderer):
|
||||||
renderer(renderer)
|
renderer(renderer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FluidMediumTraversal::~FluidMediumTraversal()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluidMediumTraversal::setCollector(FluidMediumCollector *collector)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluidMediumTraversal::getTraversedMedia(std::vector<FluidMediumInterface> &media, const SpaceCoordinates &start, const SpaceCoordinates &end)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluidMediumTraversal::collectHalfLine(const SpaceCoordinates &start, const Vector3 &direction)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluidMediumTraversal::collectSegment(const SpaceCoordinates &start, const SpaceCoordinates &end)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
@ -1,14 +1,30 @@
|
||||||
#include "SoftwareRenderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
|
|
||||||
|
#include "Scenery.h"
|
||||||
#include "FluidMediumTraversal.h"
|
#include "FluidMediumTraversal.h"
|
||||||
|
|
||||||
SoftwareRenderer::SoftwareRenderer(Scenery* scenery):
|
SoftwareRenderer::SoftwareRenderer(Scenery* scenery)
|
||||||
scenery(scenery)
|
|
||||||
{
|
{
|
||||||
fluid_medium = new FluidMediumTraversal(this);
|
fluid_medium = new FluidMediumTraversal(this);
|
||||||
|
|
||||||
|
if (scenery)
|
||||||
|
{
|
||||||
|
this->scenery = scenery;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->scenery = Scenery::getCurrent();
|
||||||
|
}
|
||||||
|
this->scenery->bindToRenderer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
SoftwareRenderer::~SoftwareRenderer()
|
SoftwareRenderer::~SoftwareRenderer()
|
||||||
{
|
{
|
||||||
delete fluid_medium;
|
delete fluid_medium;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color SoftwareRenderer::applyMediumTraversal(Vector3 location, Color color)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
|
@ -19,11 +19,13 @@ class SOFTWARESHARED_EXPORT SoftwareRenderer: public Renderer
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SoftwareRenderer(Scenery* scenery);
|
SoftwareRenderer(Scenery* scenery=0);
|
||||||
virtual ~SoftwareRenderer();
|
virtual ~SoftwareRenderer();
|
||||||
|
|
||||||
inline Scenery* getScenery() const {return scenery;}
|
inline Scenery* getScenery() const {return scenery;}
|
||||||
|
|
||||||
|
virtual Color applyMediumTraversal(Vector3 location, Color color);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Scenery* scenery;
|
Scenery* scenery;
|
||||||
FluidMediumTraversal* fluid_medium;
|
FluidMediumTraversal* fluid_medium;
|
||||||
|
|
|
@ -39,6 +39,11 @@ Scenery::~Scenery()
|
||||||
WaterDefinitionClass.destroy(water);
|
WaterDefinitionClass.destroy(water);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Scenery* Scenery::getCurrent()
|
||||||
|
{
|
||||||
|
return _main_scenery;
|
||||||
|
}
|
||||||
|
|
||||||
void Scenery::save(PackStream* stream)
|
void Scenery::save(PackStream* stream)
|
||||||
{
|
{
|
||||||
BaseDefinition::save(stream);
|
BaseDefinition::save(stream);
|
||||||
|
|
|
@ -30,6 +30,8 @@ public:
|
||||||
Scenery();
|
Scenery();
|
||||||
virtual ~Scenery();
|
virtual ~Scenery();
|
||||||
|
|
||||||
|
static Scenery* getCurrent();
|
||||||
|
|
||||||
virtual void save(PackStream* stream);
|
virtual void save(PackStream* stream);
|
||||||
virtual void load(PackStream* stream);
|
virtual void load(PackStream* stream);
|
||||||
|
|
||||||
|
|
|
@ -117,69 +117,89 @@ static Color _applyLightingToSurface(Renderer* renderer, Vector3 location, Vecto
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Color _applyMediumTraversal(Renderer* renderer, Vector3 location, Color color)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Renderer::Renderer()
|
||||||
{
|
{
|
||||||
color = renderer->atmosphere->applyAerialPerspective(renderer, location, color).final;
|
RenderParams params = {1, 1, 1, 5};
|
||||||
color = renderer->clouds->getColor(renderer, color, renderer->getCameraLocation(renderer, location), location);
|
|
||||||
|
render_quality = 5;
|
||||||
|
render_width = 1;
|
||||||
|
render_height = 1;
|
||||||
|
render_interrupt = 0;
|
||||||
|
render_progress = 0.0;
|
||||||
|
is_rendering = 0;
|
||||||
|
render_camera = cameraCreateDefinition();
|
||||||
|
render_area = renderCreateArea(this);
|
||||||
|
|
||||||
|
renderSetParams(render_area, params);
|
||||||
|
|
||||||
|
addRenderProgress = _addRenderProgress;
|
||||||
|
getCameraLocation = _getCameraLocation;
|
||||||
|
getCameraDirection = _getCameraDirection;
|
||||||
|
getPrecision = _getPrecision;
|
||||||
|
projectPoint = _projectPoint;
|
||||||
|
unprojectPoint = _unprojectPoint;
|
||||||
|
pushTriangle = _pushTriangle;
|
||||||
|
pushQuad = _pushQuad;
|
||||||
|
pushDisplacedTriangle = _pushDisplacedTriangle;
|
||||||
|
pushDisplacedQuad = _pushDisplacedQuad;
|
||||||
|
|
||||||
|
rayWalking = _rayWalking;
|
||||||
|
|
||||||
|
applyLightingToSurface = _applyLightingToSurface;
|
||||||
|
|
||||||
|
lighting = lightingManagerCreate();
|
||||||
|
|
||||||
|
atmosphere = (AtmosphereRenderer*)AtmosphereRendererClass.create();
|
||||||
|
clouds = (CloudsRenderer*)CloudsRendererClass.create();
|
||||||
|
terrain = (TerrainRenderer*)TerrainRendererClass.create();
|
||||||
|
textures = (TexturesRenderer*)TexturesRendererClass.create();
|
||||||
|
water = (WaterRenderer*)WaterRendererClass.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
Renderer::~Renderer()
|
||||||
|
{
|
||||||
|
cameraDeleteDefinition(render_camera);
|
||||||
|
lightingManagerDelete(lighting);
|
||||||
|
|
||||||
|
AtmosphereRendererClass.destroy(atmosphere);
|
||||||
|
CloudsRendererClass.destroy(clouds);
|
||||||
|
TerrainRendererClass.destroy(terrain);
|
||||||
|
TexturesRendererClass.destroy(textures);
|
||||||
|
WaterRendererClass.destroy(water);
|
||||||
|
|
||||||
|
renderDeleteArea(render_area);
|
||||||
|
}
|
||||||
|
|
||||||
|
Color Renderer::applyMediumTraversal(Vector3 location, Color color)
|
||||||
|
{
|
||||||
|
color = atmosphere->applyAerialPerspective(this, location, color).final;
|
||||||
|
color = clouds->getColor(this, color, getCameraLocation(this, location), location);
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Old API compat
|
||||||
|
|
||||||
Renderer* rendererCreate()
|
Renderer* rendererCreate()
|
||||||
{
|
{
|
||||||
Renderer* result = new Renderer;
|
return new Renderer();
|
||||||
RenderParams params = {1, 1, 1, 5};
|
|
||||||
|
|
||||||
result->render_quality = 5;
|
|
||||||
result->render_width = 1;
|
|
||||||
result->render_height = 1;
|
|
||||||
result->render_interrupt = 0;
|
|
||||||
result->render_progress = 0.0;
|
|
||||||
result->is_rendering = 0;
|
|
||||||
result->render_camera = cameraCreateDefinition();
|
|
||||||
result->render_area = renderCreateArea(result);
|
|
||||||
|
|
||||||
renderSetParams(result->render_area, params);
|
|
||||||
|
|
||||||
result->addRenderProgress = _addRenderProgress;
|
|
||||||
result->getCameraLocation = _getCameraLocation;
|
|
||||||
result->getCameraDirection = _getCameraDirection;
|
|
||||||
result->getPrecision = _getPrecision;
|
|
||||||
result->projectPoint = _projectPoint;
|
|
||||||
result->unprojectPoint = _unprojectPoint;
|
|
||||||
result->pushTriangle = _pushTriangle;
|
|
||||||
result->pushQuad = _pushQuad;
|
|
||||||
result->pushDisplacedTriangle = _pushDisplacedTriangle;
|
|
||||||
result->pushDisplacedQuad = _pushDisplacedQuad;
|
|
||||||
|
|
||||||
result->rayWalking = _rayWalking;
|
|
||||||
|
|
||||||
result->applyLightingToSurface = _applyLightingToSurface;
|
|
||||||
result->applyMediumTraversal = _applyMediumTraversal;
|
|
||||||
|
|
||||||
result->lighting = lightingManagerCreate();
|
|
||||||
|
|
||||||
result->atmosphere = (AtmosphereRenderer*)AtmosphereRendererClass.create();
|
|
||||||
result->clouds = (CloudsRenderer*)CloudsRendererClass.create();
|
|
||||||
result->terrain = (TerrainRenderer*)TerrainRendererClass.create();
|
|
||||||
result->textures = (TexturesRenderer*)TexturesRendererClass.create();
|
|
||||||
result->water = (WaterRenderer*)WaterRendererClass.create();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rendererDelete(Renderer* renderer)
|
void rendererDelete(Renderer* renderer)
|
||||||
{
|
{
|
||||||
cameraDeleteDefinition(renderer->render_camera);
|
|
||||||
lightingManagerDelete(renderer->lighting);
|
|
||||||
|
|
||||||
AtmosphereRendererClass.destroy(renderer->atmosphere);
|
|
||||||
CloudsRendererClass.destroy(renderer->clouds);
|
|
||||||
TerrainRendererClass.destroy(renderer->terrain);
|
|
||||||
TexturesRendererClass.destroy(renderer->textures);
|
|
||||||
WaterRendererClass.destroy(renderer->water);
|
|
||||||
|
|
||||||
renderDeleteArea(renderer->render_area);
|
|
||||||
|
|
||||||
delete renderer;
|
delete renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,12 @@ class TexturesRenderer;
|
||||||
class CloudsRenderer;
|
class CloudsRenderer;
|
||||||
class WaterRenderer;
|
class WaterRenderer;
|
||||||
|
|
||||||
struct Renderer
|
class Renderer
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
Renderer();
|
||||||
|
virtual ~Renderer();
|
||||||
|
|
||||||
/* Render base configuration */
|
/* Render base configuration */
|
||||||
int render_quality;
|
int render_quality;
|
||||||
int render_width;
|
int render_width;
|
||||||
|
@ -40,7 +44,7 @@ struct Renderer
|
||||||
|
|
||||||
/* Shortcuts */
|
/* Shortcuts */
|
||||||
Color(*applyLightingToSurface)(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial* material);
|
Color(*applyLightingToSurface)(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial* material);
|
||||||
Color(*applyMediumTraversal)(Renderer* renderer, Vector3 location, Color color);
|
virtual Color applyMediumTraversal(Vector3 location, Color color);
|
||||||
|
|
||||||
/* Scenery related */
|
/* Scenery related */
|
||||||
RayCastingResult(*rayWalking)(Renderer* renderer, Vector3 location, Vector3 direction, int terrain, int water, int sky, int clouds);
|
RayCastingResult(*rayWalking)(Renderer* renderer, Vector3 location, Vector3 direction, int terrain, int water, int sky, int clouds);
|
||||||
|
|
|
@ -148,7 +148,7 @@ static Color _realGetFinalColor(Renderer* renderer, Vector3 location, double pre
|
||||||
{
|
{
|
||||||
/* TODO Restore precision control */
|
/* TODO Restore precision control */
|
||||||
TexturesResult textures = renderer->textures->applyToTerrain(renderer, location.x, location.z);
|
TexturesResult textures = renderer->textures->applyToTerrain(renderer, location.x, location.z);
|
||||||
return renderer->applyMediumTraversal(renderer, textures.final_location, textures.final_color);
|
return renderer->applyMediumTraversal(textures.final_location, textures.final_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RayCastingResult _fakeCastRay(Renderer* renderer, Vector3 start, Vector3 direction)
|
static RayCastingResult _fakeCastRay(Renderer* renderer, Vector3 start, Vector3 direction)
|
||||||
|
|
|
@ -290,7 +290,7 @@ static WaterResult _realGetResult(Renderer* renderer, double x, double z)
|
||||||
colorMask(&color, &foam);
|
colorMask(&color, &foam);
|
||||||
|
|
||||||
/* Bring color to the camera */
|
/* Bring color to the camera */
|
||||||
color = renderer->applyMediumTraversal(renderer, location, color);
|
color = renderer->applyMediumTraversal(location, color);
|
||||||
|
|
||||||
result.base = definition->material._rgb;
|
result.base = definition->material._rgb;
|
||||||
result.final = color;
|
result.final = color;
|
||||||
|
|
Loading…
Reference in a new issue