]> git.jsancho.org Git - lugaru.git/blob - Source/Models.h
License: Update GPLv2+ header to match current FSF recommendation
[lugaru.git] / Source / Models.h
1 /*
2 Copyright (C) 2003, 2010 - Wolfire Games
3
4 This file is part of Lugaru.
5
6 Lugaru is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 Lugaru 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.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef _MODELS_H_
21 #define _MODELS_H_
22
23 /**> Model Loading <**/
24 //
25 // Model Maximums
26 //
27 #include "gamegl.h"
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <string.h>
31 #include <vector>
32
33 #include "Terrain.h"
34 #include "binio.h"
35 #include "Quaternions.h"
36 #include "Texture.h"
37
38 //
39 // Textures List
40 //
41 typedef struct {
42     long xsz, ysz;
43     GLubyte *txt;
44 } ModelTexture;
45
46 //
47 // Model Structures
48 //
49
50 class TexturedTriangle
51 {
52 public:
53     short vertex[3];
54     float gx[3], gy[3];
55 };
56
57 #define max_model_decals 300
58
59 #define nothing 0
60 #define normaltype 4
61 #define notextype 1
62 #define rawtype 2
63 #define decalstype 3
64
65 class Model
66 {
67 public:
68     short vertexNum, TriangleNum;
69     bool hastexture;
70
71     int type, oldtype;
72
73     int* possible;
74     int* owner;
75     XYZ* vertex;
76     XYZ* normals;
77     XYZ* facenormals;
78     TexturedTriangle* Triangles;
79     GLfloat* vArray;
80
81     /*int possible[max_model_vertex];
82     int owner[max_textured_triangle];
83     XYZ vertex[max_model_vertex];
84     XYZ normals[max_model_vertex];
85     XYZ facenormals[max_textured_triangle];
86     TexturedTriangle Triangles[max_textured_triangle];
87     GLfloat vArray[max_textured_triangle*24];*/
88
89     Texture textureptr;
90     ModelTexture modelTexture;
91     int numpossible;
92     bool color;
93
94     XYZ boundingspherecenter;
95     float boundingsphereradius;
96
97     float*** decaltexcoords;
98     XYZ** decalvertex;
99     int* decaltype;
100     float* decalopacity;
101     float* decalrotation;
102     float* decalalivetime;
103     XYZ* decalposition;
104
105     /*float decaltexcoords[max_model_decals][3][2];
106     XYZ decalvertex[max_model_decals][3];
107     int decaltype[max_model_decals];
108     float decalopacity[max_model_decals];
109     float decalrotation[max_model_decals];
110     float decalalivetime[max_model_decals];
111     XYZ decalposition[max_model_decals];*/
112
113     int numdecals;
114
115     bool flat;
116
117     void DeleteDecal(int which);
118     void MakeDecal(int atype, XYZ *where, float *size, float *opacity, float *rotation);
119     void MakeDecal(int atype, XYZ where, float size, float opacity, float rotation);
120     void drawdecals(Texture shadowtexture, Texture bloodtexture, Texture bloodtexture2, Texture breaktexture);
121     int SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate);
122     int SphereCheckPossible(XYZ *p1, float radius, XYZ *move, float *rotate);
123     int LineCheck(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate);
124     int LineCheckSlide(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate);
125     int LineCheckPossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate);
126     int LineCheckSlidePossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate);
127     void UpdateVertexArray();
128     void UpdateVertexArrayNoTex();
129     void UpdateVertexArrayNoTexNoNorm();
130     bool loadnotex(const char *filename);
131     bool loadraw(char *filename);
132     bool load(const char *filename, bool texture);
133     bool loaddecal(const char *filename, bool texture);
134     void Scale(float xscale, float yscale, float zscale);
135     void FlipTexCoords();
136     void UniformTexCoords();
137     void ScaleTexCoords(float howmuch);
138     void ScaleNormals(float xscale, float yscale, float zscale);
139     void Translate(float xtrans, float ytrans, float ztrans);
140     void CalculateNormals(bool facenormalise);
141     void draw();
142     void drawdifftex(GLuint texture);
143     void drawdifftex(Texture texture);
144     void drawimmediate();
145     void drawdiffteximmediate(GLuint texture);
146     void Rotate(float xang, float yang, float zang);
147     ~Model();
148     void deallocate();
149     Model();
150 };
151
152 #endif