]> git.jsancho.org Git - lugaru.git/blob - Source/Terrain.h
Oops, committed by mistake a temporary commenting of code
[lugaru.git] / Source / Terrain.h
1 /*
2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
4
5 This file is part of Lugaru.
6
7 Lugaru is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 Lugaru is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef _TERRAIN_H_
22 #define _TERRAIN_H_
23
24 #include "gamegl.h"
25 #include "Frustum.h"
26 #include "Lights.h"
27 #include "ImageIO.h"
28 #include "Quaternions.h"
29 #include "Quaternions.h"
30 #include "Texture.h"
31
32 #define max_terrain_size        256
33 #define curr_terrain_size       size
34 #define subdivision             64
35 #define max_patch_elements      (max_terrain_size/subdivision)*(max_terrain_size/subdivision)*54
36
37 #define allfirst 0
38 #define mixed 1
39 #define allsecond 2
40
41 #define max_decals 1000
42
43 #define shadowdecal 0
44 #define footprintdecal 1
45 #define blooddecal 2
46 #define blooddecalfast 3
47 #define shadowdecalpermanent 4
48 #define breakdecal 5
49 #define blooddecalslow 6
50 #define bodyprintdecal 7
51
52 #define snowyenvironment 0
53 #define grassyenvironment 1
54 #define desertenvironment 2
55 //
56 // Model Structures
57 //
58
59 class Terrain
60 {
61 public:
62     Texture bloodtexture;
63     Texture bloodtexture2;
64     Texture shadowtexture;
65     Texture footprinttexture;
66     Texture bodyprinttexture;
67     Texture breaktexture;
68     Texture terraintexture;
69     short size;
70
71     int patchobjectnum[subdivision][subdivision];
72     int patchobjects[subdivision][subdivision][300];
73
74     float scale;
75     int type;
76     float heightmap[max_terrain_size + 1][max_terrain_size + 1];
77     XYZ normals[max_terrain_size][max_terrain_size];
78     XYZ facenormals[max_terrain_size][max_terrain_size];
79     XYZ triangles[(max_terrain_size - 1) * (max_terrain_size - 1) * 2][3];
80     float colors[max_terrain_size][max_terrain_size][4];
81     float opacityother[max_terrain_size][max_terrain_size];
82     float texoffsetx[max_terrain_size][max_terrain_size];
83     float texoffsety[max_terrain_size][max_terrain_size];
84     int numtris[subdivision][subdivision];
85     int textureness[subdivision][subdivision];
86
87     GLfloat vArray[(max_patch_elements)*subdivision*subdivision];
88
89     bool visible[subdivision][subdivision];
90     float avgypatch[subdivision][subdivision];
91     float maxypatch[subdivision][subdivision];
92     float minypatch[subdivision][subdivision];
93     float heightypatch[subdivision][subdivision];
94
95     int patch_elements;
96
97     float decaltexcoords[max_decals][3][2];
98     XYZ decalvertex[max_decals][3];
99     int decaltype[max_decals];
100     float decalopacity[max_decals];
101     float decalrotation[max_decals];
102     float decalalivetime[max_decals];
103     float decalbrightness[max_decals];
104     XYZ decalposition[max_decals];
105     int numdecals;
106
107     void AddObject(XYZ where, float radius, int id);
108     void DeleteDecal(int which);
109     void MakeDecal(int type, XYZ where, float size, float opacity, float rotation);
110     void MakeDecalLock(int type, XYZ where, int whichx, int whichy, float size, float opacity, float rotation);
111     int lineTerrain(XYZ p1, XYZ p2, XYZ *p);
112     float getHeight(float pointx, float pointz);
113     float getOpacity(float pointx, float pointz);
114     XYZ getLighting(float pointx, float pointz);
115     XYZ getNormal(float pointx, float pointz);
116     void UpdateVertexArray(int whichx, int whichy);
117     void UpdateTransparency(int whichx, int whichy);
118     void UpdateTransparencyother(int whichx, int whichy);
119     void UpdateTransparencyotherother(int whichx, int whichy);
120     bool load(const std::string& fileName);
121     void CalculateNormals();
122     void drawdecals();
123     void draw(int layer);
124     void drawpatch(int whichx, int whichy, float opacity);
125     void drawpatchother(int whichx, int whichy, float opacity);
126     void drawpatchotherother(int whichx, int whichy, float opacity);
127     void DoShadows();
128
129     Terrain();
130     ~Terrain();
131 };
132
133 #endif