paysages3d/src/render/software/TerrainRasterizer.h

86 lines
2.4 KiB
C
Raw Normal View History

2013-12-05 15:44:18 +00:00
#ifndef TERRAINRASTERIZER_H
#define TERRAINRASTERIZER_H
#include "software_global.h"
#include "Rasterizer.h"
2013-12-05 15:44:18 +00:00
#include "Vector3.h"
namespace paysages {
namespace software {
class SOFTWARESHARED_EXPORT TerrainRasterizer : public Rasterizer {
public:
typedef struct {
2013-12-05 15:44:18 +00:00
Vector3 point_nw;
Vector3 point_sw;
Vector3 point_se;
Vector3 point_ne;
int detail_hint;
} TerrainChunkInfo;
public:
TerrainRasterizer(SoftwareRenderer *renderer, RenderProgress *progress, unsigned short client_id);
2013-12-05 15:44:18 +00:00
2015-09-10 17:33:52 +00:00
/**
* Set the rasterization quality.
*
2016-01-03 18:21:23 +00:00
* base_chunk_size - Size of chunks near the camera
* detail_factor - Precision factor of a chunk's tessellation, depending on screen coverage
* max_chunk_detail - Maximal tessellation of chunks
2015-09-10 17:33:52 +00:00
*/
void setQuality(double base_chunk_size, double detail_factor, int max_chunk_detail);
virtual void setQuality(double factor) override;
virtual int prepareRasterization() override;
virtual void rasterizeToCanvas(CanvasPortion *canvas) override;
virtual Color shadeFragment(const CanvasFragment &fragment, const CanvasFragment *previous) const override;
protected:
2015-10-18 15:26:19 +00:00
/**
* Add a vertical offset to rasterized polygons.
*
* This may be used to rasterize a covering layer on top of ground.
*/
void setYOffset(double offset);
private:
2013-12-05 15:44:18 +00:00
/**
* Method called for each chunk tessellated by performTessellation.
2013-12-05 15:44:18 +00:00
*/
void processChunk(CanvasPortion *canvas, TerrainChunkInfo *chunk);
2013-12-05 15:44:18 +00:00
/**
* Tessellate the terrain, calling processChunk for each chunk.
*
* The terrain will be broken in chunks, most detailed near the camera.
*
* Return the number of quads that has been pushed.
*
2016-01-06 18:55:49 +00:00
* 'canvas' may be NULL to only simulate the tessellation.
2013-12-05 15:44:18 +00:00
*/
2016-01-10 13:27:32 +00:00
int performTessellation(CanvasPortion *canvas);
2013-12-05 15:44:18 +00:00
/**
* Tessellate a terrain chunk, pushing the quads in the render area.
*/
void tessellateChunk(CanvasPortion *canvas, TerrainChunkInfo *chunk, int detail);
void renderQuad(CanvasPortion *canvas, double x, double z, double size, double water_height);
2015-09-10 17:33:52 +00:00
void getChunk(SoftwareRenderer *renderer, TerrainRasterizer::TerrainChunkInfo *chunk, double x, double z,
2016-01-10 13:27:32 +00:00
double size);
2015-09-10 17:33:52 +00:00
private:
2015-10-18 15:26:19 +00:00
double yoffset;
2015-09-10 17:33:52 +00:00
// Quality control
double base_chunk_size;
double detail_factor;
int max_chunk_detail;
2013-12-05 15:44:18 +00:00
};
}
}
#endif // TERRAINRASTERIZER_H