summaryrefslogtreecommitdiffstats
path: root/source/HeiGen.h
blob: 869f1c67a2d21f5607f8707b45e70321d9683f09 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

// HeiGen.h

/*
Interfaces to the various height generators:
	- cHeiGenFlat
	- cHeiGenClassic
	- cHeiGenBiomal
*/





#pragma once

#include "cChunkGenerator.h"
#include "cNoise.h"





class cHeiGenFlat :
	public cTerrainHeightGen
{
public:
	cHeiGenFlat(int a_Height) : m_Height(a_Height) {}
	
protected:

	int m_Height;

	// cTerrainHeightGen override:
	virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override;
} ;





class cHeiGenClassic :
	public cTerrainHeightGen
{
public:
	cHeiGenClassic(int a_Seed, float a_HeightFreq1, float a_HeightAmp1, float a_HeightFreq2, float a_HeightAmp2, float a_HeightFreq3, float a_HeightAmp3);
	
protected:

	int m_Seed;
	cNoise m_Noise;
	float m_HeightFreq1, m_HeightAmp1;
	float m_HeightFreq2, m_HeightAmp2;
	float m_HeightFreq3, m_HeightAmp3;
	
	float GetNoise(float x, float y);

	// cTerrainHeightGen override:
	virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override;
} ;





class cHeiGenBiomal :
	public cTerrainHeightGen
{
public:
	cHeiGenBiomal(int a_Seed, cBiomeGen & a_BiomeGen) :
		m_Noise(a_Seed),
		m_BiomeGen(a_BiomeGen)
	{
	}
	
protected:

	typedef cChunkDef::BiomeMap BiomeNeighbors[3][3];

	cNoise      m_Noise;
	cBiomeGen & m_BiomeGen;
	
	// Per-biome terrain generator parameters:
	struct sGenParam
	{
		float m_HeightFreq1, m_HeightAmp1;
		float m_HeightFreq2, m_HeightAmp2;
		float m_HeightFreq3, m_HeightAmp3;
		float m_BaseHeight;
	} ;
	static const sGenParam m_GenParam[biNumBiomes];
	
	// cTerrainHeightGen override:
	virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override;
	
	HEIGHTTYPE GetHeightAt(int a_RelX, int a_RelZ, int a_ChunkX, int a_ChunkZ, const BiomeNeighbors & a_BiomeNeighbors);
} ;