]> git.jsancho.org Git - lugaru.git/blob - Source/Models.h
45ae7a33fbaaf20282fada9cc3aecbcd2e8390a7
[lugaru.git] / Source / Models.h
1 #ifndef _MODELS_H_
2 #define _MODELS_H_
3
4 /**> Model Loading <**/
5 //
6 // Model Maximums
7 //
8 #include "gamegl.h"
9 #include <stdlib.h>
10 #include <stdio.h>
11 #include <string.h>
12 #include <vector>
13
14 #include "Constants.h"
15 #include "Terrain.h"
16 #include "binio.h"
17 #include "Quaternions.h"
18
19 //
20 // Textures List
21 //
22 typedef struct          {
23         long                    xsz,ysz;
24         GLubyte                         *txt;
25 } ModelTexture;
26
27 //
28 // Model Structures
29 //
30
31 class TexturedTriangle{
32 public:
33         short                   vertex[3];
34         float gx[3],gy[3];
35 };
36
37 #define max_model_decals 300
38
39 #define nothing 0
40 #define normaltype 4
41 #define notextype 1
42 #define rawtype 2
43 #define decalstype 3
44
45 class Model{
46 public:
47         short   vertexNum,TriangleNum;
48         bool hastexture;
49
50         int type,oldtype;
51
52         int* possible;
53         int* owner;
54         XYZ* vertex;
55         XYZ* normals;
56         XYZ* facenormals;
57         TexturedTriangle* Triangles;
58         GLfloat* vArray;
59
60         /*int possible[max_model_vertex];
61         int owner[max_textured_triangle];
62         XYZ vertex[max_model_vertex];
63         XYZ normals[max_model_vertex];
64         XYZ facenormals[max_textured_triangle];
65         TexturedTriangle Triangles[max_textured_triangle];
66         GLfloat vArray[max_textured_triangle*24];*/
67
68         GLuint                          textureptr;
69         ModelTexture            Texture;
70         int numpossible;
71         bool color;
72
73         XYZ boundingspherecenter;
74         float boundingsphereradius;
75
76         float*** decaltexcoords;
77         XYZ** decalvertex;
78         int* decaltype;
79         float* decalopacity;
80         float* decalrotation;
81         float* decalalivetime;
82         XYZ* decalposition;
83
84         /*float decaltexcoords[max_model_decals][3][2];
85         XYZ decalvertex[max_model_decals][3];
86         int decaltype[max_model_decals];
87         float decalopacity[max_model_decals];
88         float decalrotation[max_model_decals];
89         float decalalivetime[max_model_decals];
90         XYZ decalposition[max_model_decals];*/
91
92         int numdecals;
93
94         bool flat;
95
96         void DeleteDecal(int which);
97         void MakeDecal(int atype, XYZ *where, float *size, float *opacity, float *rotation);
98         void MakeDecal(int atype, XYZ where, float size, float opacity, float rotation);
99         void drawdecals(GLuint shadowtexture,GLuint bloodtexture,GLuint bloodtexture2,GLuint breaktexture);
100         int SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate);
101         int SphereCheckPossible(XYZ *p1,float radius, XYZ *move, float *rotate);
102         int LineCheck(XYZ *p1,XYZ *p2, XYZ *p, XYZ *move, float *rotate);
103         int LineCheckSlide(XYZ *p1,XYZ *p2, XYZ *p, XYZ *move, float *rotate);
104         int LineCheckPossible(XYZ *p1,XYZ *p2, XYZ *p, XYZ *move, float *rotate);
105         int LineCheckSlidePossible(XYZ *p1,XYZ *p2, XYZ *p, XYZ *move, float *rotate);
106         void UpdateVertexArray();
107         void UpdateVertexArrayNoTex();
108         void UpdateVertexArrayNoTexNoNorm();
109         bool loadnotex(char *filename);
110         bool loadraw(char *filename);
111         bool load(char *filename,bool texture);
112         bool loaddecal(char *filename,bool texture);
113         void Scale(float xscale,float yscale,float zscale);
114         void FlipTexCoords();
115         void UniformTexCoords();
116         void ScaleTexCoords(float howmuch);
117         void ScaleNormals(float xscale,float yscale,float zscale);
118         void Translate(float xtrans,float ytrans,float ztrans);
119         void CalculateNormals(bool facenormalise);
120         void draw();
121         void drawdifftex(GLuint texture);
122         void drawimmediate();
123         void drawdiffteximmediate(GLuint texture);
124         void Rotate(float xang,float yang,float zang);
125         ~Model();
126         void deallocate();
127         Model();
128 };
129
130 #endif