]> git.jsancho.org Git - lugaru.git/blob - Source/Terrain.h
Added .hgignore.
[lugaru.git] / Source / Terrain.h
1 #ifndef _TERRAIN_H_
2 #define _TERRAIN_H_
3
4 #include "gamegl.h"
5 #include "Frustum.h"
6 #include "Lights.h"
7 #include "TGALoader.h"
8 #include "Quaternions.h"
9 #include "Quaternions.h"
10
11 #define max_terrain_size                        256             
12 #define curr_terrain_size                       size
13 #define subdivision                             64
14 #define max_patch_elements                      (max_terrain_size/subdivision)*(max_terrain_size/subdivision)*54
15
16 #define allfirst 0
17 #define mixed 1
18 #define allsecond 2
19
20 #define max_decals 1000
21
22 #define shadowdecal 0
23 #define footprintdecal 1
24 #define blooddecal 2
25 #define blooddecalfast 3
26 #define shadowdecalpermanent 4
27 #define breakdecal 5
28 #define blooddecalslow 6
29 #define bodyprintdecal 7
30
31 #define snowyenvironment 0
32 #define grassyenvironment 1
33 #define desertenvironment 2
34 //
35 // Model Structures
36 //
37
38 class Terrain{
39 public:
40         GLuint bloodtexture;
41         GLuint bloodtexture2;
42         GLuint shadowtexture;
43         GLuint footprinttexture;
44         GLuint bodyprinttexture;
45         GLuint breaktexture;
46         GLuint terraintexture;
47         short   size;
48
49         int patchobjectnum[subdivision][subdivision];
50         int patchobjects[subdivision][subdivision][300];
51
52         float scale;
53         int type;
54         float heightmap[max_terrain_size+1][max_terrain_size+1];
55         XYZ normals[max_terrain_size][max_terrain_size];
56         XYZ facenormals[max_terrain_size][max_terrain_size];
57         XYZ triangles[(max_terrain_size-1)*(max_terrain_size-1)*2][3];
58         float colors[max_terrain_size][max_terrain_size][4];
59         float opacityother[max_terrain_size][max_terrain_size];
60         float texoffsetx[max_terrain_size][max_terrain_size];
61         float texoffsety[max_terrain_size][max_terrain_size];
62         int numtris[subdivision][subdivision];
63         int textureness[subdivision][subdivision];
64
65         GLfloat vArray[(max_patch_elements)*subdivision*subdivision];
66
67         bool visible[subdivision][subdivision];
68         float avgypatch[subdivision][subdivision];
69         float maxypatch[subdivision][subdivision];
70         float minypatch[subdivision][subdivision];
71         float heightypatch[subdivision][subdivision];
72
73         int patch_elements;
74
75         float decaltexcoords[max_decals][3][2];
76         XYZ decalvertex[max_decals][3];
77         int decaltype[max_decals];
78         float decalopacity[max_decals];
79         float decalrotation[max_decals];
80         float decalalivetime[max_decals];
81         float decalbrightness[max_decals];
82         XYZ decalposition[max_decals];
83         int numdecals;
84
85         void AddObject(XYZ where, float radius,int id);
86         void DeleteDecal(int which);
87         void MakeDecal(int type, XYZ where, float size, float opacity, float rotation);
88         void MakeDecalLock(int type, XYZ where, int whichx, int whichy, float size, float opacity, float rotation);
89         int lineTerrain(XYZ p1,XYZ p2, XYZ *p);
90         float getHeight(float pointx, float pointz);
91         float getHeightExtrude(float pointx, float pointz,float point2x, float point2z);
92         float getOpacity(float pointx, float pointz);
93         XYZ getLighting(float pointx, float pointz);
94         XYZ getNormal(float pointx, float pointz);
95         void UpdateVertexArray(int whichx, int whichy);
96         void UpdateTransparency(int whichx, int whichy);
97         void UpdateTransparencyother(int whichx, int whichy);
98         void UpdateTransparencyotherother(int whichx, int whichy);
99         bool load(char *fileName);
100         void CalculateNormals();
101         void drawdecals();
102         void draw(int layer);
103         void drawpatch(int whichx, int whichy, float opacity);
104         void drawpatchother(int whichx, int whichy, float opacity);
105         void drawpatchotherother(int whichx, int whichy, float opacity);
106         void DoLighting();
107         void DoShadows();
108
109         Terrain();
110         ~Terrain();
111 };
112
113 #endif