]> git.jsancho.org Git - lugaru.git/blob - Source/Models.h
Remove Constants.h
[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
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.
10
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.  
14
15 See the GNU General Public License for more details.
16
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.
20 */
21
22 #ifndef _MODELS_H_
23 #define _MODELS_H_
24
25 /**> Model Loading <**/
26 //
27 // Model Maximums
28 //
29 #include "gamegl.h"
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <string.h>
33 #include <vector>
34
35 #include "Terrain.h"
36 #include "binio.h"
37 #include "Quaternions.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 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 public:
67         short   vertexNum,TriangleNum;
68         bool hastexture;
69
70         int type,oldtype;
71
72         int* possible;
73         int* owner;
74         XYZ* vertex;
75         XYZ* normals;
76         XYZ* facenormals;
77         TexturedTriangle* Triangles;
78         GLfloat* vArray;
79
80         /*int possible[max_model_vertex];
81         int owner[max_textured_triangle];
82         XYZ vertex[max_model_vertex];
83         XYZ normals[max_model_vertex];
84         XYZ facenormals[max_textured_triangle];
85         TexturedTriangle Triangles[max_textured_triangle];
86         GLfloat vArray[max_textured_triangle*24];*/
87
88         GLuint                          textureptr;
89         ModelTexture            Texture;
90         int numpossible;
91         bool color;
92
93         XYZ boundingspherecenter;
94         float boundingsphereradius;
95
96         float*** decaltexcoords;
97         XYZ** decalvertex;
98         int* decaltype;
99         float* decalopacity;
100         float* decalrotation;
101         float* decalalivetime;
102         XYZ* decalposition;
103
104         /*float decaltexcoords[max_model_decals][3][2];
105         XYZ decalvertex[max_model_decals][3];
106         int decaltype[max_model_decals];
107         float decalopacity[max_model_decals];
108         float decalrotation[max_model_decals];
109         float decalalivetime[max_model_decals];
110         XYZ decalposition[max_model_decals];*/
111
112         int numdecals;
113
114         bool flat;
115
116         void DeleteDecal(int which);
117         void MakeDecal(int atype, XYZ *where, float *size, float *opacity, float *rotation);
118         void MakeDecal(int atype, XYZ where, float size, float opacity, float rotation);
119         void drawdecals(GLuint shadowtexture,GLuint bloodtexture,GLuint bloodtexture2,GLuint breaktexture);
120         int SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate);
121         int SphereCheckPossible(XYZ *p1,float radius, XYZ *move, float *rotate);
122         int LineCheck(XYZ *p1,XYZ *p2, XYZ *p, XYZ *move, float *rotate);
123         int LineCheckSlide(XYZ *p1,XYZ *p2, XYZ *p, XYZ *move, float *rotate);
124         int LineCheckPossible(XYZ *p1,XYZ *p2, XYZ *p, XYZ *move, float *rotate);
125         int LineCheckSlidePossible(XYZ *p1,XYZ *p2, XYZ *p, XYZ *move, float *rotate);
126         void UpdateVertexArray();
127         void UpdateVertexArrayNoTex();
128         void UpdateVertexArrayNoTexNoNorm();
129         bool loadnotex(const char *filename);
130         bool loadraw(char *filename);
131         bool load(const char *filename,bool texture);
132         bool loaddecal(const char *filename,bool texture);
133         void Scale(float xscale,float yscale,float zscale);
134         void FlipTexCoords();
135         void UniformTexCoords();
136         void ScaleTexCoords(float howmuch);
137         void ScaleNormals(float xscale,float yscale,float zscale);
138         void Translate(float xtrans,float ytrans,float ztrans);
139         void CalculateNormals(bool facenormalise);
140         void draw();
141         void drawdifftex(GLuint texture);
142         void drawimmediate();
143         void drawdiffteximmediate(GLuint texture);
144         void Rotate(float xang,float yang,float zang);
145         ~Model();
146         void deallocate();
147         Model();
148 };
149
150 #endif