2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 #include "TGALoader.h"
29 #include "Quaternions.h"
30 #include "Quaternions.h"
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
41 #define max_decals 1000
44 #define footprintdecal 1
46 #define blooddecalfast 3
47 #define shadowdecalpermanent 4
49 #define blooddecalslow 6
50 #define bodyprintdecal 7
52 #define snowyenvironment 0
53 #define grassyenvironment 1
54 #define desertenvironment 2
64 GLuint footprinttexture;
65 GLuint bodyprinttexture;
67 GLuint terraintexture;
70 int patchobjectnum[subdivision][subdivision];
71 int patchobjects[subdivision][subdivision][300];
75 float heightmap[max_terrain_size+1][max_terrain_size+1];
76 XYZ normals[max_terrain_size][max_terrain_size];
77 XYZ facenormals[max_terrain_size][max_terrain_size];
78 XYZ triangles[(max_terrain_size-1)*(max_terrain_size-1)*2][3];
79 float colors[max_terrain_size][max_terrain_size][4];
80 float opacityother[max_terrain_size][max_terrain_size];
81 float texoffsetx[max_terrain_size][max_terrain_size];
82 float texoffsety[max_terrain_size][max_terrain_size];
83 int numtris[subdivision][subdivision];
84 int textureness[subdivision][subdivision];
86 GLfloat vArray[(max_patch_elements)*subdivision*subdivision];
88 bool visible[subdivision][subdivision];
89 float avgypatch[subdivision][subdivision];
90 float maxypatch[subdivision][subdivision];
91 float minypatch[subdivision][subdivision];
92 float heightypatch[subdivision][subdivision];
96 float decaltexcoords[max_decals][3][2];
97 XYZ decalvertex[max_decals][3];
98 int decaltype[max_decals];
99 float decalopacity[max_decals];
100 float decalrotation[max_decals];
101 float decalalivetime[max_decals];
102 float decalbrightness[max_decals];
103 XYZ decalposition[max_decals];
106 void AddObject(XYZ where, float radius,int id);
107 void DeleteDecal(int which);
108 void MakeDecal(int type, XYZ where, float size, float opacity, float rotation);
109 void MakeDecalLock(int type, XYZ where, int whichx, int whichy, float size, float opacity, float rotation);
110 int lineTerrain(XYZ p1,XYZ p2, XYZ *p);
111 float getHeight(float pointx, float pointz);
112 float getHeightExtrude(float pointx, float pointz,float point2x, float point2z);
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 char *fileName);
121 void CalculateNormals();
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);