* Add "less" target to view make output through less.
[matthijs/ABM2.git] / ABM2 / Amaltheia / md2model.h
1 /***************************************************************************
2  *   Copyright (C) 2005 by Dimitris Saougos & Filippos Papadopoulos   *
3  *   <psybases@gmail.com>                                                             *
4  *                                                                                                       *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU Library General Public License as       *
7  *   published by the Free Software Foundation; either version 2 of the    *
8  *   License, or (at your option) any later version.                                    *
9  *                                                                                                           *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU Library General Public     *
16  *   License along with this program; if not, write to the                 *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef _MD2MODEL
22 #define _MD2MODEL
23
24
25 // #include "Texture.h"
26 #include "Graphics.h"
27
28 // using namespace Amaltheia;
29
30 class model;
31 class c_model;
32
33 typedef unsigned char BYTE;
34
35 struct tex
36 {
37         short u, v;
38 };
39
40 struct texturecoord
41 {
42         float u;
43         float v;
44 };
45
46 struct face
47 {
48         short vindex[ 3 ];
49         short tindex[ 3 ];
50 };
51
52 struct triangle
53 {
54         BYTE vertex[ 3 ];
55         BYTE lightNormalIndex;
56 };
57
58 struct frame
59 {
60         float scale[ 3 ];
61         float translate[ 3 ];
62         char name[ 16 ];
63         struct triangle **tr;
64 };
65
66 struct MD2header
67 {
68         int magic;                                      // This is used to identify the file
69         int version;                                    // The version number of the file (Must be 8)
70         int skinWidth;                          // The skin width in pixels
71         int skinHeight;                         // The skin height in pixels
72         int frameSize;                          // The size in bytes the frames are
73         int numSkins;                           // The number of skins associated with the model
74         int numVertices;                                // The number of vertices (constant for each frame)
75         int numTexCoords;                       // The number of texture coordinates
76         int numTriangles;                       // The number of faces (polygons)
77         int numGlCommands;                      // The number of gl commands
78         int numFrames;                          // The number of animation frames
79         int offsetSkins;                                // The offset in the file for the skin data
80         int offsetTexCoords;                    // The offset in the file for the texture data
81         int offsetTriangles;                    // The offset in the file for the face data
82         int offsetFrames;                       // The offset in the file for the frames data
83         int offsetGlCommands;           // The offset in the file for the gl commands data
84         int offsetEnd;                          // The end of the file offset
85 };
86
87 struct fnode
88 {
89         int fnumber;
90         struct fnode *next;
91 };
92 typedef struct fnode flist;
93
94
95
96
97 class model
98 {
99 private:
100         //      void delframelist(void);
101         int framecounter;
102         char *bitmap_filename;
103         Texture *modelTexture;
104         bool change;
105         Graphics *graph;
106 //      GLfloat *v;
107         float *v;
108         //    bool minMax; //ginetai true otan kaleitai h setframeseq. To elegxei h getMin...
109
110 public:
111         bool *mark;
112         float xmin, xmax, ymin, ymax, zmin, zmax;
113         struct MD2header md2h;
114         struct tex *tex1;
115         struct texturecoord *tc;
116         struct face *fc;
117         struct frame **fr;
118         bool ok;
119         float FPS;
120         flist *cpointer;
121
122         model( char *, char *, Graphics *g );
123         ~model();
124
125         void render( float t );
126         int getframecounter( void );
127
128 };
129
130
131
132
133 class c_model
134 {
135 private:
136         model *mod;
137         flist *fhead, *ftail;
138         int nframes;
139         void delFrameSequence( void );
140         int current_offset;
141         float oldt;
142         float gettime( void );
143
144 public:
145         float FPS;
146         float xmin, xmax, ymin, ymax, zmin, zmax;
147         flist *cpointer;
148         char *current_frame_sequence;
149
150         c_model( model *m );
151         ~c_model();
152         void setFrameSequence( char *name );
153         void render( void );
154 };
155
156 #endif