Title Fat data
Author zagabar
Link http://thunked.org/p/view/pub/
Created 2012-03-15 19:32:54
Expires never
Filename settings.h
Language C++
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.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.

enum Function{SIMPLEX, GRADIENT};

struct DensityNoise
{
        float xScale, yScale, zScale, extra, magnitude;
        int function;
        int occurrence;
};

struct TypeNoise
{
        float xScale, yScale, zScale, extra, threshold;
        int type;
        int function;
        int occurrence;
};

struct OccurrenceNoise
{
        float xScale, yScale, zScale, extra, magnitude, minCap, maxCap;
        int function;
};

struct BiomeNoise
{
        float xScale, yScale, zScale;
};

struct BiomeRule
{
        int noise;
        float low;
        float high;
};

struct Biome
{      
        Biome()
        {
                occurrenceNoiseAmount = 0;
                densityNoiseAmount = 0;
                typeNoiseAmount = 0;
                ruleAmount = 0;
                r = 0.5f;
                g = 0.5f;
                b = 0.5f;
        }
        void addDensityNoise(float xScale, float yScale, float zScale, float extra, float magnitude, Function function, int occurrence)
        {
                densityNoises[densityNoiseAmount].xScale = xScale;
                densityNoises[densityNoiseAmount].yScale = yScale;
                densityNoises[densityNoiseAmount].zScale = zScale;
                densityNoises[densityNoiseAmount].extra = extra;
                densityNoises[densityNoiseAmount].magnitude = fabs(magnitude);
                densityNoises[densityNoiseAmount].function = function;
                densityNoises[densityNoiseAmount].occurrence = occurrence;
                if(function == GRADIENT)
                {
                        Vector3D vector;
                        vector.setValue(xScale, yScale, zScale);
                        vector = vector.normalise();
                        densityNoises[densityNoiseAmount].xScale = vector.getX();
                        densityNoises[densityNoiseAmount].yScale = vector.getY();
                        densityNoises[densityNoiseAmount].zScale = vector.getZ();
                }
                densityNoiseAmount++;
        }
        void addTypeNoise(float xScale, float yScale, float zScale, float extra, float threshold, int type, Function function, int occurrence)
        {
                typeNoises[typeNoiseAmount].xScale = xScale;
                typeNoises[typeNoiseAmount].yScale = yScale;
                typeNoises[typeNoiseAmount].zScale = zScale;
                typeNoises[typeNoiseAmount].extra = extra;
                typeNoises[typeNoiseAmount].threshold = threshold;
                typeNoises[typeNoiseAmount].type = type;
                typeNoises[typeNoiseAmount].function = function;
                typeNoises[typeNoiseAmount].occurrence = occurrence;
                if(function == GRADIENT)
                {
                        Vector3D vector;
                        vector.setValue(xScale, yScale, zScale);
                        vector = vector.normalise();
                        typeNoises[typeNoiseAmount].xScale = vector.getX();
                        typeNoises[typeNoiseAmount].yScale = vector.getY();
                        typeNoises[typeNoiseAmount].zScale = vector.getZ();
                }
                typeNoiseAmount++;
        }
        void addOccurrenceNoise(float xScale, float yScale, float zScale, float extra, float magnitude, Function function, float minCap, float maxCap)
        {
                occurrenceNoises[occurrenceNoiseAmount].xScale = xScale;
                occurrenceNoises[occurrenceNoiseAmount].yScale = yScale;
                occurrenceNoises[occurrenceNoiseAmount].zScale = zScale;
                occurrenceNoises[occurrenceNoiseAmount].extra = extra;
                occurrenceNoises[occurrenceNoiseAmount].magnitude = fabs(magnitude);
                occurrenceNoises[occurrenceNoiseAmount].function = function;
                occurrenceNoises[occurrenceNoiseAmount].minCap = minCap;
                occurrenceNoises[occurrenceNoiseAmount].maxCap = maxCap;
                if(function == GRADIENT)
                {
                        Vector3D vector;
                        vector.setValue(xScale, yScale, zScale);
                        vector = vector.normalise();
                        occurrenceNoises[occurrenceNoiseAmount].xScale = vector.getX();
                        occurrenceNoises[occurrenceNoiseAmount].yScale = vector.getY();
                        occurrenceNoises[occurrenceNoiseAmount].zScale = vector.getZ();
                }
        }
        void addRule(int noise, float low, float high)
        {
                rules[ruleAmount].noise = noise;
                rules[ruleAmount].low= low;
                rules[ruleAmount].high = high;
                ruleAmount++;
        }
        int defaultType;
        int surfaceLevel;
        int surfaceType;
       
        BiomeRule rules[5];
        int ruleAmount;
        OccurrenceNoise occurrenceNoises[8];
        int occurrenceNoiseAmount;
        DensityNoise densityNoises[8];
        int densityNoiseAmount;
        TypeNoise typeNoises[8];
        int typeNoiseAmount;
        float r, g, b;
};

struct BiomeSettings
{
        BiomeSettings()
        {
                biomeNoiseAmount = 0;
                biomeAmount = 0;
        }
        void addBiome(Biome biome)
        {
                biomes[biomeAmount] = biome;
                biomeAmount++;
        }
        void addBiomeNoise(float xScale, float yScale, float zScale)
        {
                biomeNoises[biomeNoiseAmount].xScale = xScale;
                biomeNoises[biomeNoiseAmount].yScale = yScale;
                biomeNoises[biomeNoiseAmount].zScale = zScale;
                biomeNoiseAmount++;
        }
        Biome biomes[25];
        int biomeAmount;
        BiomeNoise biomeNoises[5];
        int biomeNoiseAmount;
};


struct Landscape
{
        unsigned int seed;
        BiomeSettings biomeSettings;
};