69 lines
2.0 KiB
C++
69 lines
2.0 KiB
C++
#ifndef BLOCK_H
|
|
#define BLOCK_H
|
|
|
|
#include <QVector3D>
|
|
#include <QTime>
|
|
|
|
#include <noise/noise.h>
|
|
|
|
#include "mesh.h"
|
|
#include "types.h"
|
|
|
|
using namespace noise::module;
|
|
|
|
class Block
|
|
{
|
|
private:
|
|
Mesh* m_land;
|
|
Mesh* m_water;
|
|
|
|
int m_x;
|
|
int m_z;
|
|
double m_step;
|
|
uint m_width;
|
|
|
|
GLuint m_vao;
|
|
GLuint m_vbo;
|
|
GLuint m_ebo;
|
|
|
|
bool m_debug;
|
|
|
|
static Perlin m_temperature;
|
|
static Perlin m_height;
|
|
static Perlin m_montainHeight;
|
|
|
|
void createUnitBlock(double x, double z);
|
|
void createWaterSurface();
|
|
|
|
void linkGenericQuad(TypedVertex &v1, TypedVertex &v2, TypedVertex &v3, TypedVertex &v4);
|
|
void linkGenericQuad(TypedVertex &v1, TypedVertex &v2, TypedVertex &v3, TypedVertex &v4, int splitCount);
|
|
void joinBiomeMiddle(TypedVertex &v1, TypedVertex &v2, TypedVertex &v3, TypedVertex &v4);
|
|
void joinBiomeQuad(TypedVertex v1, TypedVertex v2, TypedVertex v3, TypedVertex v4);
|
|
|
|
TypedVertex getVertex(double x, double z);
|
|
void addTriangleOrSplit(TypedVertex &v1, TypedVertex &v2, TypedVertex &v3, int splitCount);
|
|
void getSplitPoints(TypedVertex &v1, TypedVertex &v2, TypedVertex &before, TypedVertex &after);
|
|
void splitTriangle(TypedVertex &v1, TypedVertex &v2, TypedVertex &v3, int splitCount);
|
|
QVector3D faceNormal(TypedVertex *v1, TypedVertex *v2, TypedVertex *v3);
|
|
|
|
double getYGrassLand(double height);
|
|
double getYDesert(double temperature, double height);
|
|
double getYSea(double height);
|
|
double getYCanyon(double temperature, double height);
|
|
double getYMontain(double height, double x, double z);
|
|
|
|
double getYFromPosition(double x, double z);
|
|
double getYFromBiomeParam(Biome biome, double temperature, double height, double x, double z);
|
|
TypedVertex getBiomeIntersection(TypedVertex &start, TypedVertex &end);
|
|
void changeBiome(TypedVertex &v, Biome newBiome);
|
|
public:
|
|
Block(int x, int z, unsigned int width, double step);
|
|
~Block();
|
|
|
|
static Biome getBiome(double x, double z);
|
|
Mesh *land() const;
|
|
Mesh *water() const;
|
|
};
|
|
|
|
#endif // BLOCK_H
|