2016-07-12 17:40:45 +00:00
|
|
|
#pragma once
|
2013-12-08 19:54:34 +00:00
|
|
|
|
|
|
|
#include "software_global.h"
|
|
|
|
|
2013-12-17 22:45:09 +00:00
|
|
|
#include "LightFilter.h"
|
|
|
|
|
2016-01-10 13:27:32 +00:00
|
|
|
#include <vector>
|
2015-10-15 22:28:07 +00:00
|
|
|
#include "Vector3.h"
|
2013-12-08 19:54:34 +00:00
|
|
|
|
|
|
|
namespace paysages {
|
|
|
|
namespace software {
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
class SOFTWARESHARED_EXPORT TerrainRenderer : public LightFilter {
|
|
|
|
public:
|
|
|
|
typedef struct {
|
2013-12-08 19:54:34 +00:00
|
|
|
Vector3 location;
|
|
|
|
Vector3 normal;
|
|
|
|
} TerrainResult;
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
public:
|
|
|
|
TerrainRenderer(SoftwareRenderer *parent);
|
2013-12-08 19:54:34 +00:00
|
|
|
virtual ~TerrainRenderer();
|
|
|
|
|
2013-12-17 22:45:09 +00:00
|
|
|
virtual void update();
|
2015-09-10 16:16:57 +00:00
|
|
|
void setQuality(bool quad_normals, double ray_precision, double shadow_precision);
|
|
|
|
void setQuality(double factor);
|
2013-12-17 22:45:09 +00:00
|
|
|
|
2013-12-08 19:54:34 +00:00
|
|
|
virtual RayCastingResult castRay(const Vector3 &start, const Vector3 &direction);
|
2015-11-09 21:30:46 +00:00
|
|
|
virtual double getHeight(double x, double z, bool with_painting, bool water_offset = true);
|
2016-01-10 13:27:32 +00:00
|
|
|
virtual TerrainResult getResult(double x, double z, bool with_painting);
|
|
|
|
Vector3 getDisplaced(double x, double z, bool with_painting);
|
2013-12-17 22:45:09 +00:00
|
|
|
virtual bool applyLightFilter(LightComponent &light, const Vector3 &at) override;
|
2013-12-08 19:54:34 +00:00
|
|
|
|
2015-11-02 19:14:35 +00:00
|
|
|
/**
|
|
|
|
* Estimate a probable range of altitudes, given a rectangle area.
|
|
|
|
*/
|
|
|
|
void estimateMinMaxHeight(double x1, double z1, double x2, double z2, double *ymin, double *ymax);
|
|
|
|
|
2016-01-10 13:27:32 +00:00
|
|
|
/**
|
|
|
|
* Get the final color at a given terrain location.
|
|
|
|
*
|
|
|
|
* Textures will be applied (with displacement and detail), and medium traversal will be performed at the location.
|
|
|
|
*/
|
|
|
|
virtual Color getFinalColor(double x, double z, double precision);
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
private:
|
2015-09-10 16:16:57 +00:00
|
|
|
SoftwareRenderer *parent;
|
|
|
|
TerrainRayWalker *walker_ray;
|
|
|
|
TerrainRayWalker *walker_shadows;
|
|
|
|
|
|
|
|
bool quad_normals;
|
2013-12-08 19:54:34 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|