]> git.jsancho.org Git - lugaru.git/blob - Source/Models.h
Replaced all uses of Account::active outside of Account by call to active() method
[lugaru.git] / Source / Models.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 _MODELS_H_
22 #define _MODELS_H_
23
24 /**> Model Loading <**/
25 //
26 // Model Maximums
27 //
28 #include "gamegl.h"
29 #include <stdlib.h>
30 #include <stdio.h>
31 #include <string.h>
32 #include <vector>
33
34 #include "Terrain.h"
35 #include "binio.h"
36 #include "Quaternions.h"
37 #include "Texture.h"
38
39 //
40 // Textures List
41 //
42 typedef struct {
43     long xsz, ysz;
44     GLubyte *txt;
45 } ModelTexture;
46
47 //
48 // Model Structures
49 //
50
51 class TexturedTriangle
52 {
53 public:
54     short vertex[3];
55     float gx[3], gy[3];
56 };
57
58 #define max_model_decals 300
59
60 #define nothing 0
61 #define normaltype 4
62 #define notextype 1
63 #define rawtype 2
64 #define decalstype 3
65
66 class Model
67 {
68 public:
69     short vertexNum, TriangleNum;
70     bool hastexture;
71
72     int type, oldtype;
73
74     int* possible;
75     int* owner;
76     XYZ* vertex;
77     XYZ* normals;
78     XYZ* facenormals;
79     TexturedTriangle* Triangles;
80     GLfloat* vArray;
81
82     /*int possible[max_model_vertex];
83     int owner[max_textured_triangle];
84     XYZ vertex[max_model_vertex];
85     XYZ normals[max_model_vertex];
86     XYZ facenormals[max_textured_triangle];
87     TexturedTriangle Triangles[max_textured_triangle];
88     GLfloat vArray[max_textured_triangle*24];*/
89
90     Texture textureptr;
91     ModelTexture modelTexture;
92     int numpossible;
93     bool color;
94
95     XYZ boundingspherecenter;
96     float boundingsphereradius;
97
98     float*** decaltexcoords;
99     XYZ** decalvertex;
100     int* decaltype;
101     float* decalopacity;
102     float* decalrotation;
103     float* decalalivetime;
104     XYZ* decalposition;
105
106     /*float decaltexcoords[max_model_decals][3][2];
107     XYZ decalvertex[max_model_decals][3];
108     int decaltype[max_model_decals];
109     float decalopacity[max_model_decals];
110     float decalrotation[max_model_decals];
111     float decalalivetime[max_model_decals];
112     XYZ decalposition[max_model_decals];*/
113
114     int numdecals;
115
116     bool flat;
117
118     void DeleteDecal(int which);
119     void MakeDecal(int atype, XYZ *where, float *size, float *opacity, float *rotation);
120     void MakeDecal(int atype, XYZ where, float size, float opacity, float rotation);
121     void drawdecals(Texture shadowtexture, Texture bloodtexture, Texture bloodtexture2, Texture breaktexture);
122     int SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate);
123     int SphereCheckPossible(XYZ *p1, float radius, XYZ *move, float *rotate);
124     int LineCheck(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 std::string& filename);
131     bool loadraw(const std::string& filename);
132     bool load(const std::string& filename, bool texture);
133     bool loaddecal(const std::string& 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 Rotate(float xang, float yang, float zang);
146     ~Model();
147     void deallocate();
148     Model();
149 };
150
151 #endif